newAdvice.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import axios from '@utils/ajax';
  2. import store from '@store';
  3. import { searchList,resetLabel } from '../actions/newAdvice';
  4. import { Notify } from '@commonComp';
  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.newAdvice.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. //药:阿替乐尔;手术:髂动脉造影
  24. let arr = type==5?(data.drugNames||[]):type==6?(data.operationNames||[]):(data.transfusionNames||[]),tmp=[];
  25. for(let i = 0;i < arr.length;i++){
  26. let obj = {}
  27. if(type==8){
  28. obj['uniqueName'] = arr[i];
  29. obj['name'] = arr[i];
  30. obj['flg'] = type;
  31. }else{
  32. obj['uniqueName'] = arr[i].name;
  33. obj['name'] = arr[i].name;
  34. obj['flg'] = type;
  35. }
  36. tmp.push(obj)
  37. }
  38. curDate=tmp
  39. dispatch(searchList(curDate,val.trim()));
  40. }else{
  41. Notify.success(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. };