diagnosticSearch.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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['uniqueName'] = arr[key];
  45. obj['conceptId'] = '';
  46. curDate.push(obj)
  47. }
  48. if(flag){
  49. dispatch({
  50. type: GET_SEARCH,
  51. searchResult: curDate
  52. })
  53. }else{
  54. dispatch({
  55. type: GET_SEARCH_RESULT,
  56. searchResult: curDate
  57. })
  58. // 是否进行过搜索
  59. dispatch({
  60. type: SHOWNODATATEXT,
  61. isShowNoDataInfo: true
  62. });
  63. }
  64. }else{
  65. Notify.error(res.data.msg)
  66. }
  67. })
  68. }
  69. };