diagnosticSearch.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { json } from "@utils/ajax";
  2. import { GET_SEARCH_RESULT, SHOWNODATATEXT } from '@store/types/diagnosticSearch';
  3. import { GET_SEARCH } from '@store/types/emergencyHis';
  4. import { Notify } from '@commonComp';
  5. import { formatFormParmas } from '@utils/tools';
  6. import store from '@store';
  7. export const getSearchList = (val,flag) => {
  8. if(val.trim() == ''){
  9. // const data = [];
  10. if(flag){
  11. return (dispatch) => dispatch({
  12. type: GET_SEARCH,
  13. searchResult: []
  14. })
  15. }
  16. return (dispatch) => dispatch({
  17. type: GET_SEARCH_RESULT,
  18. searchResult: []
  19. })
  20. }
  21. return (dispatch, getState) => {
  22. const state = getState();
  23. let baseList = state;
  24. const diagnosticList = flag?state.emergencyHis.searchData:state.diagnosticList.diagnosticList;
  25. let noIds = []
  26. for(let i = 0; i < diagnosticList.length; i++) {
  27. if(diagnosticList[i].conceptId) {
  28. noIds.push(diagnosticList[i].conceptId)
  29. }
  30. }
  31. json('/demo/retrieval/index',{
  32. "type":'4',
  33. "age": formatFormParmas('patientAge',state.patInfo.patInfoData),
  34. "inputStr": val,
  35. "sex": formatFormParmas('patientSex',state.patInfo.patInfoData),
  36. })
  37. .then((res)=>{
  38. if(res.data.code==0){
  39. const data = res.data.data;let curDate=[];
  40. let arr = data.diseaseNames;
  41. for (var key in arr) {
  42. let obj = {}
  43. obj['name'] = arr[key];
  44. obj['conceptId'] = '';
  45. curDate.push(obj)
  46. }
  47. if(flag){
  48. dispatch({
  49. type: GET_SEARCH,
  50. searchResult: curDate
  51. })
  52. }else{
  53. dispatch({
  54. type: GET_SEARCH_RESULT,
  55. searchResult: curDate
  56. })
  57. // 是否进行过搜索
  58. dispatch({
  59. type: SHOWNODATATEXT,
  60. isShowNoDataInfo: true
  61. });
  62. }
  63. }else{
  64. Notify.error(res.data.msg)
  65. }
  66. })
  67. }
  68. };