newAdvice.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. "inputStr": val,
  16. "hospitalId": 2,
  17. "age": formatFormParmas('patientAge',baseList.patInfo.patInfoData),
  18. "sex": formatFormParmas('patientSex',baseList.patInfo.patInfoData),
  19. "type": type
  20. })
  21. .then((res)=>{
  22. if(res.data.code==0){
  23. const data = res.data.data;let curDate=[];
  24. //药:阿替乐尔;手术:髂动脉造影
  25. let arr = type==5?(data.drugNames||[]):type==6?(data.operationNames||[]):(data.transfusionNames||[]),tmp=[];
  26. for(let i = 0;i < arr.length;i++){
  27. let obj = {}
  28. if(type==8){
  29. obj['uniqueName'] = arr[i];
  30. obj['name'] = arr[i];
  31. obj['detailName'] = arr[i];
  32. obj['flg'] = type;
  33. }else{
  34. obj['uniqueName'] = arr[i].name;
  35. obj['detailName'] = arr[i].name;
  36. obj['name'] = arr[i].name;
  37. obj['flg'] = type;
  38. }
  39. tmp.push(obj)
  40. }
  41. curDate=tmp
  42. dispatch(searchList(curDate,val.trim()));
  43. }else{
  44. Notify.success(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. };