12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import axios from '@utils/ajax';
- import store from '@store';
- import { searchList,resetLabel } from '../actions/newAdvice';
- import { Notify } from '@commonComp';
- import { formatFormParmas } from '@utils/tools';
- export const getSearchList = (val) => {
- if(val.trim() == ''){
- const data = [];
- return (dispatch) => dispatch(searchList(data,''));
- }
- let baseList = store.getState();
- let type = baseList.newAdvice.shType;
- return (dispatch) => {
- axios.json('/demo/retrieval/index',{
- "inputStr": val,
- "hospitalId": 2,
- "age": formatFormParmas('patientAge',baseList.patInfo.patInfoData),
- "sex": formatFormParmas('patientSex',baseList.patInfo.patInfoData),
- "type": type
- })
- .then((res)=>{
- if(res.data.code==0){
- const data = res.data.data;let curDate=[];
- //药:阿替乐尔;手术:髂动脉造影
- let arr = type==5?(data.drugNames||[]):type==6?(data.operationNames||[]):(data.transfusionNames||[]),tmp=[];
- for(let i = 0;i < arr.length;i++){
- let obj = {}
- if(type==8){
- obj['uniqueName'] = arr[i];
- obj['name'] = arr[i];
- obj['detailName'] = arr[i];
- obj['flg'] = type;
- }else{
- obj['uniqueName'] = arr[i].name;
- obj['detailName'] = arr[i].name;
- obj['name'] = arr[i].name;
- obj['flg'] = type;
- }
- tmp.push(obj)
- }
- curDate=tmp
- dispatch(searchList(curDate,val.trim()));
- }else{
- Notify.success(res.data.msg)
- }
- })
- }
- };
- 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));
- }
- })
- }
- };
|