inspect.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import axios from '@utils/ajax';
  2. import store from '@store';
  3. import { Notify } from '@commonComp';
  4. import { searchList,resetLabel } from '../actions/inspect';
  5. import { formatFormParmas } from '@utils/tools';
  6. export const getSearchList = (val) => {
  7. if(val.trim() == ''){
  8. const data = [];
  9. return (dispatch) => dispatch(searchList(data,''));
  10. }
  11. let baseList = store.getState();
  12. let type = baseList.inspect.shType;
  13. return (dispatch) => {
  14. axios.json('/demo/retrieval/index',{
  15. "age": formatFormParmas('patientAge',baseList.patInfo.patInfoData),
  16. "inputStr": val,
  17. "sex": formatFormParmas('patientSex',baseList.patInfo.patInfoData),
  18. "type": type
  19. })
  20. .then((res)=>{
  21. if(res.data.code==0){
  22. const data = res.data.data;let curDate=[];
  23. if(type==2){
  24. curDate = data && data.lisDetailNames
  25. }else{
  26. let arr = data.lisNames,tmp=[];
  27. for (var key in arr) {
  28. let obj = {}
  29. obj['uniqueName'] = arr[key];
  30. obj['detailName'] = arr[key];
  31. obj['value'] = '';
  32. obj['otherValue']='';
  33. obj['name'] = arr[key];
  34. obj['flg'] = 1;
  35. tmp.push(obj)
  36. }
  37. curDate=tmp
  38. }
  39. dispatch(searchList(curDate,val.trim()));
  40. }else{
  41. Notify.error(res.data.msg)
  42. }
  43. })
  44. }
  45. };
  46. export const getSublableList = (id,idx) => {//getById
  47. let baseList = store.getState();
  48. let sex = baseList.patInfo.message.patientSex;
  49. return (dispatch) => {
  50. axios.json('/questionInfo/getById',{
  51. age:baseList.patInfo.message.patientAge,
  52. sexType:sex == '男'?'1' : sex == '女'?'2':'3',
  53. id: id
  54. })
  55. .then((res)=>{
  56. const data = res.data.data;
  57. if (data.controlType == 0) {
  58. dispatch(resetLabel(data.questionMapping,data.uniqueName||''));
  59. }else if(data.controlType == 1||data.controlType == 6){
  60. let arr = [];
  61. arr[0] = data;
  62. dispatch(resetLabel(arr));
  63. }
  64. })
  65. }
  66. };