import axios from '@utils/ajax'; import store from '@store'; import { searchList,resetLabel } from '../actions/inspect'; export const getSearchList = (val) => { if(val.trim() == ''){ const data = []; return (dispatch) => dispatch(searchList(data,'')); } let baseList = store.getState(); // console.log(baseList) let type = baseList.inspect.shType; return (dispatch) => { axios.json('/demo/retrieval/index',{ "age": 10, "inputStr": "string", "sex": 1, "type": type }) .then((res)=>{ const data = res.data.data;let curDate=[]; if(type==2){ curDate = data.lisDetailNames }else{ console.log(data,data.lisNames) let arr = data.lisNames,tmp=[]; for (var key in arr) { let obj = {} obj['uniqueName'] = arr[key]; obj['detailName'] = arr[key]; obj['name'] = arr[key]; obj['flg'] = 1; tmp.push(obj) } curDate=tmp } dispatch(searchList(curDate,val.trim())); }) } }; export const getSublableList = (id,idx) => {//getById let baseList = store.getState(); let sex = baseList.patInfo.message.patientSex; return (dispatch) => { axios.json('/questionInfo/getById',{ age:baseList.patInfo.message.patientAge, sexType:sex == '男'?'1' : sex == '女'?'2':'3', id: id }) .then((res)=>{ const data = res.data.data; if (data.controlType == 0) { dispatch(resetLabel(data.questionMapping,data.uniqueName||'')); }else if(data.controlType == 1||data.controlType == 6){ let arr = []; arr[0] = data; dispatch(resetLabel(arr)); } }) } };