|
@@ -1,6 +1,7 @@
|
|
|
import {getLabelIndex,fullfillText,getIds} from '@common/js/func.js';
|
|
|
import config from '@config/index.js';
|
|
|
import {getInitModules} from '@store/async-actions/homePage.js';
|
|
|
+import {formatContinueDots} from '@utils/tools';
|
|
|
|
|
|
//插入病程变化模板
|
|
|
function insertPro(data,processModule){
|
|
@@ -20,8 +21,29 @@ function insertPro(data,processModule){
|
|
|
//设置模板
|
|
|
export const setModule = (state,action)=>{
|
|
|
const res = Object.assign({},state);
|
|
|
- res.moduleData = action.data;
|
|
|
- res.processModule = action.processModule;//病程变化模板
|
|
|
+ // 处理tagType=4的类型
|
|
|
+ const originalData = action.data;
|
|
|
+ const originalSonData = action.processModule;
|
|
|
+ let spreadLabels=[];
|
|
|
+ let sonSpreadLabels=[];//子模板
|
|
|
+ for(let i=0; i<originalData.length;i++){
|
|
|
+ if(originalData[i].tagType==4){
|
|
|
+ spreadLabels.push(...originalData[i].questionMapping);
|
|
|
+ }else{
|
|
|
+ spreadLabels.push(originalData[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(let j=0; j<originalSonData.length;j++){
|
|
|
+ if(originalSonData[j].tagType==4){
|
|
|
+ sonSpreadLabels.push(...originalSonData[j].questionMapping);
|
|
|
+ }else{
|
|
|
+ sonSpreadLabels.push(originalSonData[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // res.moduleData = action.data;
|
|
|
+ // res.processModule = action.processModule;//病程变化模板
|
|
|
+ res.moduleData = spreadLabels;
|
|
|
+ res.processModule = sonSpreadLabels;//病程变化模板
|
|
|
res.processModuleName = action.processModuleName;//模板名称
|
|
|
res.emptyData = action.emptyData;//空模板
|
|
|
let data = action.data;
|
|
@@ -83,7 +105,7 @@ export const setData = (state,action) =>{
|
|
|
let newMain = [];
|
|
|
let mainLabelModule = res.mainLabelModule;//主诉选中的症状id获取到的模板
|
|
|
let objToArr = [];
|
|
|
- let keyArr = Object.keys(mainLabelModule);
|
|
|
+ let keyArr = Object.keys(mainLabelModule);
|
|
|
for(let i=0; i<keyArr.length; i++){
|
|
|
objToArr.push(mainLabelModule[JSON.parse(keyArr[i])]);
|
|
|
}
|
|
@@ -256,7 +278,7 @@ export const setData = (state,action) =>{
|
|
|
}
|
|
|
|
|
|
let symptomArr = newMainCopy.concat(manInput,newWiths,manWithInput);
|
|
|
- let newSymptomArr = JSON.parse(JSON.stringify(symptomArr));
|
|
|
+ let newSymptomArr = formatContinueDots(JSON.parse(JSON.stringify(symptomArr))); //过来连续标点
|
|
|
//组装好的主症状和伴随症状插入现病史模板(flag=4前)
|
|
|
let insertIdx = null;
|
|
|
for(let j=0; j<current.length; j++){
|
|
@@ -488,8 +510,13 @@ export function setRadioValue(state,action){
|
|
|
export const setRadioInputValue = (state,action)=>{
|
|
|
const res = Object.assign({},state);
|
|
|
const {ikey,values,id} = action.data;
|
|
|
- const item = res.data[ikey];
|
|
|
- let str='',temp='',obj=res.data[ikey].questionDetailList;
|
|
|
+ let index = getLabelIndex(ikey);
|
|
|
+ let innerInx = ikey.substr(ikey.length-1);
|
|
|
+ let item = res.data[index];
|
|
|
+ if(item.tagType!=1){ //在组合项中
|
|
|
+ item = res.data[index].questionMapping[innerInx];
|
|
|
+ }
|
|
|
+ let str='',temp='',obj=item.questionDetailList;
|
|
|
if(!values){ //清空
|
|
|
let sld=obj.find((item)=>{
|
|
|
return item.selected==true;
|
|
@@ -497,7 +524,18 @@ export const setRadioInputValue = (state,action)=>{
|
|
|
sld?sld.selected=false:'';
|
|
|
item.vals = null;
|
|
|
item.value = '';
|
|
|
- res.saveText[ikey] = '';
|
|
|
+ if(res.data[index].tagType!=1){
|
|
|
+ let hasValue = false;
|
|
|
+ const sub = res.data[index].questionMapping.map((it)=>{
|
|
|
+ if(it.value){ //至少有一个子值才黑显
|
|
|
+ hasValue = true;
|
|
|
+ }
|
|
|
+ return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
|
|
|
+ });
|
|
|
+ res.saveText[index] = hasValue?sub.join(''):'';
|
|
|
+ }else{
|
|
|
+ res.saveText[index] = '';
|
|
|
+ }
|
|
|
res.update = Math.random();
|
|
|
return res;
|
|
|
}
|
|
@@ -521,7 +559,15 @@ export const setRadioInputValue = (state,action)=>{
|
|
|
}
|
|
|
item.vals = values;
|
|
|
item.value = str;
|
|
|
- res.saveText[ikey] = str;
|
|
|
+ if(res.data[index].tagType!=1){
|
|
|
+ let hasValue = false;
|
|
|
+ const sub = res.data[index].questionMapping.map((it)=>{
|
|
|
+ return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
|
|
|
+ });
|
|
|
+ res.saveText[index] = sub.join('');
|
|
|
+ }else {
|
|
|
+ res.saveText[ikey] = str;
|
|
|
+ }
|
|
|
res.update = Math.random();
|
|
|
return res;
|
|
|
}
|
|
@@ -685,15 +731,21 @@ export function insertLabelData(state,action){
|
|
|
let focusIndex = res.focusIndex;
|
|
|
let saveText = res.saveText;
|
|
|
let banIdx = saveText.indexOf("伴");
|
|
|
-
|
|
|
+ //伴随展开数据-过滤了连续标点
|
|
|
+ const FilteredDotMapping2=formatContinueDots(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==2;
|
|
|
+ }));
|
|
|
+ //主症状展开数据-过滤连续了标点
|
|
|
+ const FilteredDotMapping1=formatContinueDots(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
+ }));
|
|
|
if(isReplace){
|
|
|
span.current.innerText?(span.current.innerText = ''):(span.current.innerHTML = '');
|
|
|
// res.data.splice(focusIndex,1,text,data);
|
|
|
// 搜索结果展开伴随symptomType==2的尾巴
|
|
|
+
|
|
|
let resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData.splice(focusIndex,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==2;
|
|
|
- })));
|
|
|
+ resData.splice(focusIndex,1,text,...(FilteredDotMapping2));
|
|
|
res.data = fullfillText(resData).newArr;
|
|
|
res.saveText[focusIndex] = searchData;
|
|
|
}else{
|
|
@@ -707,55 +759,45 @@ export function insertLabelData(state,action){
|
|
|
res.symptomIds.push(id);
|
|
|
// 没有伴展开主诉symptomType=0/1的尾巴,有伴一>第一个点选上去的伴为依据,伴前展开主诉,伴后展开伴随;多余的伴以及手动输入的伴不做处理(2-25)
|
|
|
if(banIdx==-1){
|
|
|
+
|
|
|
// if(strIndex <= 1){//前
|
|
|
if(strIndex < 1){//前
|
|
|
- res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })),pText);
|
|
|
+ res.data.splice(index,1,text,...(FilteredDotMapping1),pText);
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(FilteredDotMapping1.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,pText,text,...(FilteredDotMapping1));
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(FilteredDotMapping1.length).fill(null));
|
|
|
}
|
|
|
}else{
|
|
|
if(focusIndex > banIdx){//伴后
|
|
|
if(strIndex < 1){//前
|
|
|
- res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==2;
|
|
|
- })),pText);
|
|
|
+ res.data.splice(index,1,text,...(FilteredDotMapping2),pText);
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(FilteredDotMapping2.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==2;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,pText,text,...(FilteredDotMapping2));
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(FilteredDotMapping2.length).fill(null));
|
|
|
}
|
|
|
}else{//伴前
|
|
|
if(strIndex < 1){//前
|
|
|
- res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })),pText);
|
|
|
+ res.data.splice(index,1,text,...(FilteredDotMapping1),pText);
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(FilteredDotMapping1.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,pText,text,...(FilteredDotMapping1));
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
- res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(FilteredDotMapping1.length).fill(null));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
res.data = fullfillText(res.data).newArr;
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
|
}else{//标签
|
|
|
- const spreadLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
|
|
|
+ const arr=fullfillText(data.questionMapping).newArr; //过滤连续标点
|
|
|
+ const spreadLabels = data.tagType==4?formatContinueDots(arr):[data];
|
|
|
if(strIndex < 1){//前
|
|
|
// 判断前一个是否为文本标签,是直接插入标签,不是则在前面插入一个空文本标签
|
|
|
const preItem = res.data[index-1];
|
|
@@ -799,10 +841,12 @@ export const clearCurrentEdit = (state,action)=>{
|
|
|
export function addLabelItem(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
const {data,i} = action;
|
|
|
- const textLabel = JSON.parse(config.textLabel);
|
|
|
+ const textLabel = Object.assign({},JSON.parse(config._textLabel),{showInCheck:JSON.parse(data).showInCheck});
|
|
|
//使用Object.assign({},data)拷贝操作时复制项和原项会同步修改
|
|
|
if(!data) return res;
|
|
|
- res.data.splice(i+1,0,JSON.parse(data),textLabel);
|
|
|
+ res.data.splice(+i+2,0,JSON.parse(data),textLabel);
|
|
|
+ res.saveText.splice(+i+2,0,'','');
|
|
|
+ res.selecteds.splice(+i+2,0,null,null);
|
|
|
res.update = Math.random();
|
|
|
return res;
|
|
|
}
|
|
@@ -841,10 +885,12 @@ export function backspaceText(state,action){
|
|
|
// data[delIndex].value = text;
|
|
|
}else if(data[delIndex-1].tagType==8){
|
|
|
data.splice(delIndex,1);
|
|
|
+ res.selecteds.splice(delIndex,1); //杂音类样式选中状态对应
|
|
|
res.saveText.splice(delIndex,1);
|
|
|
}
|
|
|
else{
|
|
|
data.splice(delIndex-1,2);
|
|
|
+ res.selecteds.splice(delIndex-1,2); //杂音类样式选中状态对应
|
|
|
res.saveText.splice(delIndex-1,2);
|
|
|
}
|
|
|
// res.saveText = fullfillText(data).saveText;
|