123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import { json } from "@utils/ajax";
- import { GET_SEARCH_RESULT, SET_SEARCH_VALUE } from '@store/types/diagnosticSearch';
- export const getSearchResult = (value) =>{
-
- return (dispatch, getState) => {
- const state = getState();
- const url = '/api/icss/retrieval/getTagInfos'
- const param={
- type: 7,
- age: state.patInfo.message.patientAge,
- inputStr: value,
- sexType: state.patInfo.message.sex
- }
- if(value === state.diagnosticSearch.searchValue) {
- return
- } else {
- dispatch({
- type: SET_SEARCH_VALUE,
- searchValue: value
- })
- //如果搜索值为空,则直接将搜索结果设为空
- if(value === '') {
- dispatch({
- type: GET_SEARCH_RESULT,
- searchResult: []
- })
- return
- }
- json(url, param).then((data)=>{
- const searchRes = data.data.data;
- const diagList = state.diagnosticList.diagnosticList;
- let searchResult = [];
- if(searchRes) {
- for(let i = 0; i < searchRes.length; i++) {
- let repeat = false;
- for (let j = 0; j < diagList.length; j++) {
- if(searchRes[i].questionId === diagList[j].id) {
- repeat = true;
- }
- }
- if(!repeat) {
- searchResult.push(searchRes[i])
- }
- }
- dispatch({
- type: GET_SEARCH_RESULT,
- searchResult: searchResult
- })
- } else {
- dispatch({
- type: GET_SEARCH_RESULT,
- searchResult: []
- })
- }
-
- }).catch((e)=>{
- console.log(e)
- })
- }
-
- }
- }
|