newAdvice.js 2.1 KB

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