newAdvice.js 2.6 KB

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