|
@@ -1,5 +1,6 @@
|
|
|
import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
|
|
|
import config from '@config/index.js';
|
|
|
+import {getInitModules} from '@store/async-actions/homePage.js';
|
|
|
|
|
|
//插入病程变化模板
|
|
|
function insertPro(data,processModule){
|
|
@@ -38,12 +39,23 @@ export const setModule = (state,action)=>{
|
|
|
//插入病程变化
|
|
|
export const insertProcess = (state,action)=>{
|
|
|
const res = Object.assign({},state);
|
|
|
- const processModule = JSON.parse(JSON.stringify(res.processModule));
|
|
|
+ const sonId = action.id;//子模板id
|
|
|
+ // const processModule = JSON.parse(JSON.stringify(res.processModule));
|
|
|
+ let addSmoduleData;
|
|
|
+ // let allModules = JSON.parse(localStorage.getItem('modules'));
|
|
|
+ let allModules = action.allModules;
|
|
|
+ for(let k=0; k<allModules.length; k++){
|
|
|
+ if(allModules[k].id==sonId){
|
|
|
+ addSmoduleData = JSON.parse(JSON.stringify(allModules[k].moduleDetailDTOList));
|
|
|
+ }
|
|
|
+ }
|
|
|
let data = res.data;
|
|
|
- res.data = insertPro(data,processModule);
|
|
|
+ let newData = insertPro(data,addSmoduleData);
|
|
|
+ res.data = fullfillText(newData).newArr;
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
res.update=Math.random();
|
|
|
return res;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -63,12 +75,10 @@ export const setData = (state,action) =>{
|
|
|
res.symptomIds = JSON.parse(JSON.stringify(mainIds));
|
|
|
const num = action.info.num;//点击了几次添加病情变化
|
|
|
const symptomFeature = action.info.symptomFeature;//分词
|
|
|
- // const useEmpty = action.info.useEmpty;
|
|
|
let useEmpty,mainData;
|
|
|
- // let mainData = JSON.parse(JSON.stringify(action.info.mainData));//主诉模板数据
|
|
|
let mainModleData = JSON.parse(JSON.stringify(action.info.mainData));//主诉模板数据
|
|
|
let moduleData = JSON.parse(JSON.stringify(res.moduleData));//现病史模板
|
|
|
- let addModule = JSON.parse(JSON.stringify(res.addModule));//拷贝的模板
|
|
|
+ // let addModule = JSON.parse(JSON.stringify(res.addModule));//拷贝的模板
|
|
|
let current = JSON.parse(JSON.stringify(moduleData));
|
|
|
let newMain = [];
|
|
|
let mainLabelModule = res.mainLabelModule;//主诉选中的症状id获取到的模板
|
|
@@ -102,7 +112,7 @@ export const setData = (state,action) =>{
|
|
|
})
|
|
|
useEmpty = existData&&existData.length>0?false:true;
|
|
|
}
|
|
|
- // console.log(888,useEmpty);
|
|
|
+
|
|
|
if (useEmpty) {
|
|
|
// res.data = res.emptyData;
|
|
|
res.data = JSON.parse(JSON.stringify(res.emptyData));
|
|
@@ -137,12 +147,8 @@ export const setData = (state,action) =>{
|
|
|
// 主症状添加tongYong标签选中文字
|
|
|
let tongYText = tongYong?{name:tongYong,value:tongYong,tagType:config.tagType}:'';
|
|
|
let mainCopy = JSON.parse(JSON.stringify(main));
|
|
|
- /*if(tongYText){
|
|
|
- for(let j=0; j<mainCopy.length; j++){
|
|
|
- mainCopy[j].name = tongYong + (mainCopy[j].name).replace('、',"");
|
|
|
- mainCopy[j].value = tongYong + (mainCopy[j].value).replace('、',"");
|
|
|
- }
|
|
|
- }*/
|
|
|
+ let manInput = [];
|
|
|
+ // 去掉主诉添加的顿号
|
|
|
for(let j=0; j<mainCopy.length; j++){
|
|
|
if(tongYText){
|
|
|
mainCopy[j].name = tongYong + (mainCopy[j].name).replace('、',"");
|
|
@@ -150,11 +156,18 @@ export const setData = (state,action) =>{
|
|
|
}else{
|
|
|
mainCopy[j].name = (mainCopy[j].name).replace('、',"");
|
|
|
mainCopy[j].value = (mainCopy[j].value).replace('、',"");
|
|
|
+ }
|
|
|
+ //查询是否有手动输入--输入的内容放到最后(3-27)
|
|
|
+ if(mainCopy[j].name != mainCopy[j].value){
|
|
|
+ const inputText = mainCopy[j].value.replace(mainCopy[j].name,"");
|
|
|
+ const textObj = Object.assign({},JSON.parse(config.textLabel),{name:inputText});
|
|
|
+ if(config.textReg.test(inputText)){//包含中英文或数字->即不全是标点符号才插入
|
|
|
+ manInput.push(textObj);
|
|
|
+ }
|
|
|
+ mainCopy[j].value = mainCopy[j].name;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 将ids接口获取到的模板匹配到对应主症状后面
|
|
|
// 主症状
|
|
|
let newMainCopy = JSON.parse(JSON.stringify(mainCopy));
|
|
@@ -193,15 +206,20 @@ export const setData = (state,action) =>{
|
|
|
}
|
|
|
// 伴随
|
|
|
// 去掉顿号
|
|
|
- /* for(let b=0; b<withs.length; b++){
|
|
|
- withs[b].name = withs[b].name.replace('、',"");
|
|
|
- }*/
|
|
|
- // let newWiths = JSON.parse(JSON.stringify(withs));
|
|
|
let newWiths = [];
|
|
|
+ let manWithInput = [];
|
|
|
if(withs.length>0){
|
|
|
for(let b=0; b<withs.length; b++){
|
|
|
withs[b].name = withs[b].name.replace('、',"");
|
|
|
withs[b].value = withs[b].value.replace('、',"");
|
|
|
+ if(withs[b].name != withs[b].value){
|
|
|
+ const inputText = withs[b].value.replace(withs[b].name,"");
|
|
|
+ const textObj = Object.assign({},JSON.parse(config.textLabel),{name:inputText});
|
|
|
+ if(config.textReg.test(inputText)){//包含中英文或数字->即不全是标点符号才插入
|
|
|
+ manWithInput.push(textObj);
|
|
|
+ }
|
|
|
+ withs[b].value = withs[b].name;
|
|
|
+ }
|
|
|
}
|
|
|
newWiths = JSON.parse(JSON.stringify(withs));
|
|
|
let withInd = 0;
|
|
@@ -237,7 +255,7 @@ export const setData = (state,action) =>{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- let symptomArr = newMainCopy.concat(newWiths);
|
|
|
+ let symptomArr = newMainCopy.concat(manInput,newWiths,manWithInput);
|
|
|
let newSymptomArr = JSON.parse(JSON.stringify(symptomArr));
|
|
|
//组装好的主症状和伴随症状插入现病史模板(flag=4前)
|
|
|
let insertIdx = null;
|
|
@@ -363,16 +381,15 @@ export const confirm = (state,action) =>{
|
|
|
//普通多选确定事件-主诉通用特征、初为后为等
|
|
|
export const setCheckBox = (state,action)=>{
|
|
|
const res = Object.assign({},state);
|
|
|
- const {exists,labelInx,existsName} = action.data;
|
|
|
+ const {labelInx,excluName,existsName,nones,withsName,ban} = action.data;
|
|
|
// 若每个选项都有符号,去掉最后一个,因与标签间的符号有冲突
|
|
|
- let names=existsName;
|
|
|
+ let showText = (excluName||'')+(existsName||'')+(ban.name||'')+(withsName||'')+(nones&&nones.replace('、','')||'');
|
|
|
let pattern = new RegExp(/\,+$|\,+$|\.+$|\。+$|\、+$/);//+ 一次或多次
|
|
|
- if(pattern.test(existsName)){
|
|
|
- names = existsName.substr(0,existsName.length-1);
|
|
|
+ if(pattern.test(showText)){
|
|
|
+ showText = showText.substr(0,showText.length-1);
|
|
|
}
|
|
|
- let arr = res.data;
|
|
|
- arr[labelInx].value = names;
|
|
|
- res.saveText[labelInx] = names;
|
|
|
+ res.data[labelInx].value = showText;
|
|
|
+ res.saveText[labelInx] = showText;
|
|
|
res.selecteds[labelInx] = action.data;
|
|
|
res.update=Math.random();
|
|
|
return res;
|
|
@@ -427,6 +444,11 @@ export function setRadioValue(state,action){
|
|
|
if(+item.tagType===1){
|
|
|
item.value = text;
|
|
|
res.saveText[labelInx] = item.labelPrefix+text+item.labelSuffix;
|
|
|
+ const exist = JSON.parse(localStorage.getItem('radio'+item.id)||null);
|
|
|
+ if(exist){ //选中状态处理
|
|
|
+ exist[0].selected=exist[0].id==id;
|
|
|
+ localStorage.setItem('radio'+item.id,JSON.stringify(exist));
|
|
|
+ }
|
|
|
item.questionDetailList.map((its)=>{
|
|
|
if(its.id === id){
|
|
|
its.selected = true;
|
|
@@ -519,6 +541,33 @@ export const changeLabelVal = (state,action)=>{
|
|
|
if(labText.trim()){
|
|
|
if(item){
|
|
|
item.value = newVal;
|
|
|
+ const canAdd=hasNoSame(item.questionDetailList,labText);
|
|
|
+ //单选双击编辑的内容自动加到下拉选项中,双击编辑但未修改不添加
|
|
|
+ if(canAdd&&+item.tagType===1&&(+item.controlType===1||+item.controlType===0)){
|
|
|
+ const li = {
|
|
|
+ id:-Math.floor(Math.random()*1000),
|
|
|
+ name:labText,
|
|
|
+ questionId:item.id,
|
|
|
+ orderNo:0,
|
|
|
+ code:0,
|
|
|
+ defaultSelect:"0",
|
|
|
+ remark:null,
|
|
|
+ abnormal:0,
|
|
|
+ selected:true
|
|
|
+ };
|
|
|
+
|
|
|
+ const exist = JSON.parse(localStorage.getItem('radio'+item.id)||null);
|
|
|
+ //console.log(exist)
|
|
|
+ if(exist&&typeof exist=='object'){ //已添加过编辑的数据
|
|
|
+ //exist.push(li);
|
|
|
+ exist[0]=li; //暂限添1条
|
|
|
+ localStorage.setItem('radio'+item.id,JSON.stringify(exist));
|
|
|
+ }else{
|
|
|
+ localStorage.setItem('radio'+item.id,JSON.stringify([li]));
|
|
|
+ }
|
|
|
+ //取消原选中状态
|
|
|
+ item.questionDetailList.find((it)=>it.selected==true).selected=false;
|
|
|
+ }
|
|
|
item.labelPrefix = prefix||'';
|
|
|
item.labelSuffix = suffix||'';
|
|
|
res.saveText[index] = labText;
|
|
@@ -532,6 +581,9 @@ export const changeLabelVal = (state,action)=>{
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+function hasNoSame(arr,text){
|
|
|
+ return arr.findIndex((it)=>text==it.name)==-1;
|
|
|
+}
|
|
|
// 数字键盘较特殊,有直接输入
|
|
|
export const changeNumLabelVal = (state,action)=>{
|
|
|
const res = Object.assign({},state);
|
|
@@ -826,12 +878,26 @@ export function removeId(state,action){
|
|
|
// 单列多选
|
|
|
export function multipleComfirn(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
- const {ikey,seleData} = action.data;
|
|
|
- let data = res.data;
|
|
|
+ const {ikey,seleData,fullIkey} = action.data;
|
|
|
+ let data = res.data;//console.log(action,data[ikey])
|
|
|
+ let index = fullIkey.substr(fullIkey.length-1,1);
|
|
|
+ if(data[ikey].tagType==3){ //在组合项中
|
|
|
+ let item = data[ikey].questionMapping;
|
|
|
+ let arr=[];
|
|
|
+ item[index].value = seleData;
|
|
|
+ item.map((it)=>{
|
|
|
+ if(it.value){
|
|
|
+ arr.push(it.labelPrefix+it.value+it.labelSuffix);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ res.saveText[ikey] = arr.join("");
|
|
|
+ res.update = Math.random();
|
|
|
+ res.selecteds[ikey] = {[index]:action.data};
|
|
|
+ return res;
|
|
|
+ }
|
|
|
data[ikey].value = seleData;
|
|
|
res.saveText[ikey] = seleData;
|
|
|
res.selecteds[ikey] = action.data;
|
|
|
- res.update = Math.random();
|
|
|
return res;
|
|
|
}
|
|
|
|