newAdvice.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import axios from '@utils/ajax';
  2. import store from '@store';
  3. import { searchList,resetLabel } from '../actions/newAdvice';
  4. import { Notify } from '@commonComp';
  5. export const getSearchList = (val) => {
  6. if(val.trim() == ''){
  7. const data = [];
  8. return (dispatch) => dispatch(searchList(data,''));
  9. }
  10. let baseList = store.getState();
  11. let type = baseList.newAdvice.shType;
  12. return (dispatch) => {
  13. axios.json('/demo/retrieval/index',{
  14. "age": 10,
  15. "inputStr": val,
  16. "sex": 1,
  17. "type": type
  18. })
  19. .then((res)=>{
  20. if(res.data.code==0){
  21. const data = res.data.data;let curDate=[];
  22. //药:阿替乐尔;手术:髂动脉造影
  23. let arr = type==5?data.drugNames:data.operationNames,tmp=[];
  24. for(let i = 0;i < arr.length;i++){
  25. let obj = {}
  26. obj['uniqueName'] = arr[i].name;
  27. obj['name'] = arr[i].name;
  28. obj['flg'] = type;
  29. tmp.push(obj)
  30. }
  31. curDate=tmp
  32. dispatch(searchList(curDate,val.trim()));
  33. }else{
  34. Notify.success(res.data.msg)
  35. }
  36. })
  37. }
  38. };
  39. export const getSublableList = (id,idx) => {//getById
  40. let baseList = store.getState();
  41. let sex = baseList.patInfo.message.patientSex;
  42. return (dispatch) => {
  43. axios.json('/questionInfo/getById',{
  44. age:baseList.patInfo.message.patientAge,
  45. sexType:sex == '男'?'1' : sex == '女'?'2':'3',
  46. id: id
  47. })
  48. .then((res)=>{
  49. const data = res.data.data;
  50. if (data.controlType == 0) {
  51. dispatch(resetLabel(data.questionMapping,data.uniqueName||''));
  52. }else if(data.controlType == 1||data.controlType == 6){
  53. let arr = [];
  54. arr[0] = data;
  55. dispatch(resetLabel(arr));
  56. }
  57. })
  58. }
  59. };