inspect.js 2.0 KB

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