inspect.js 2.7 KB

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