inspect.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. for (let i = 0;i < curDate.length;i++) {
  26. curDate[i]['detailName'] = curDate[i]['uniqueName']
  27. curDate[i]['flg'] = 0;
  28. }
  29. }else{
  30. let arr = data.lisNames||[],tmp=[];
  31. for (var key in arr) {
  32. let obj = {}
  33. obj['uniqueName'] = arr[key];
  34. obj['value'] = '';
  35. obj['otherValue']='';
  36. obj['name'] = arr[key];
  37. obj['flg'] = 1;
  38. tmp.push(obj)
  39. }
  40. curDate=tmp
  41. }
  42. dispatch(searchList(curDate,val.trim()));
  43. }else{
  44. Notify.error(res.data.msg)
  45. }
  46. })
  47. }
  48. };
  49. export const getSublableList = (id,idx) => {//getById
  50. let baseList = store.getState();
  51. let sex = baseList.patInfo.message.patientSex;
  52. return (dispatch) => {
  53. axios.json('/questionInfo/getById',{
  54. age:baseList.patInfo.message.patientAge,
  55. sexType:sex == '男'?'1' : sex == '女'?'2':'3',
  56. id: id
  57. })
  58. .then((res)=>{
  59. const data = res.data.data;
  60. if (data.controlType == 0) {
  61. dispatch(resetLabel(data.questionMapping,data.uniqueName||''));
  62. }else if(data.controlType == 1||data.controlType == 6){
  63. let arr = [];
  64. arr[0] = data;
  65. dispatch(resetLabel(arr));
  66. }
  67. })
  68. }
  69. };