|
@@ -607,106 +607,88 @@ export function insertLabelData(state,action){
|
|
|
let innerText = span.current.innerText || span.current.innerHTML;
|
|
|
let strIndex = innerText.indexOf(searchStr);
|
|
|
const value = innerText.replace(searchStr,"");
|
|
|
+ const pText = Object.assign({},textEmpty,{value:value});
|
|
|
if(data.itemType==0){//症状
|
|
|
res.symptomIds.push(id);
|
|
|
// 没有伴展开主诉symptomType=0/1的尾巴,有伴一>第一个点选上去的伴为依据,伴前展开主诉,伴后展开伴随;多余的伴以及手动输入的伴不做处理(2-25)
|
|
|
if(banIdx==-1){
|
|
|
// if(strIndex <= 1){//前
|
|
|
if(strIndex < 1){//前
|
|
|
- res.data.splice(focusIndex,0,text);
|
|
|
- res.saveText.splice(focusIndex,0,searchData);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
+ })),pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(focusIndex+1,0,text);
|
|
|
- res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- res.saveText[focusIndex] = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- // +2是因为插入一个文本标签
|
|
|
- resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
+ res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
})));
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
}
|
|
|
}else{
|
|
|
if(focusIndex > banIdx){//伴后
|
|
|
if(strIndex < 1){//前
|
|
|
- res.data.splice(focusIndex,0,text);
|
|
|
- res.saveText.splice(focusIndex,0,searchData);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==2;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==2;
|
|
|
+ })),pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(focusIndex+1,0,text);
|
|
|
- res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- // +2是因为插入一个文本标签
|
|
|
- resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==2;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==2;
|
|
|
+ })));
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
}
|
|
|
}else{//伴前
|
|
|
if(strIndex < 1){//前
|
|
|
- res.data.splice(focusIndex,0,text);
|
|
|
- res.saveText.splice(focusIndex,0,searchData);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
+ })),pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(focusIndex+1,0,text);
|
|
|
- res.saveText.splice(focusIndex+1,0,searchData);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- // +2是因为插入一个文本标签
|
|
|
- resData.splice(focusIndex+2,0,...(data.questionMapping.filter((item)=>{
|
|
|
- return item.symptomType==0||item.symptomType==1;
|
|
|
- })));
|
|
|
+ res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
|
|
|
+ return item.symptomType==0||item.symptomType==1;
|
|
|
+ })));
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- res.data = fullfillText(resData).newArr;
|
|
|
- res.saveText = fullfillText(resData).saveText;
|
|
|
+ res.data = fullfillText(res.data).newArr;
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
}else{//标签
|
|
|
+ const spreadLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
|
|
|
if(strIndex < 1){//前
|
|
|
// 判断前一个是否为文本标签,是直接插入标签,不是则在前面插入一个空文本标签
|
|
|
- const preItem = res.data[focusIndex-1];
|
|
|
+ const preItem = res.data[index-1];
|
|
|
if(preItem&&preItem.tagType==8){
|
|
|
- res.data.splice(focusIndex,0,data);
|
|
|
- res.saveText.splice(focusIndex,0,'','');
|
|
|
- res.selecteds.splice(focusIndex,0,null,null);
|
|
|
- res.data[focusIndex+1].value = value;
|
|
|
- res.saveText[focusIndex+1] = value;
|
|
|
+ res.data.splice(index,1,...spreadLabels,pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,...new Array(spreadLabels.length).fill(null),null);
|
|
|
}else{
|
|
|
- res.data.splice(focusIndex,0,textEmpty,data);
|
|
|
- res.saveText.splice(focusIndex,0,'','');
|
|
|
- res.selecteds.splice(focusIndex,0,null,null);
|
|
|
- res.data[focusIndex+2].value = value;
|
|
|
- res.saveText[focusIndex+2] = value;
|
|
|
+ res.data.splice(index,1,textEmpty,...spreadLabels,pText);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
|
|
|
}
|
|
|
// res.data.splice(focusIndex,0,data,textEmpty);
|
|
|
|
|
|
}else{
|
|
|
- res.data.splice(focusIndex+1,0,data,textEmpty);
|
|
|
- res.saveText.splice(focusIndex+1,0,'','');
|
|
|
- res.selecteds.splice(focusIndex+1,0,null,null);
|
|
|
- res.data[focusIndex].value = value;
|
|
|
- res.saveText[focusIndex] = value;
|
|
|
+ // 后面插入 :判断后一个标签是否为文本标签,不是则插入一个空标签
|
|
|
+ const afterItem = res.data[index+1];
|
|
|
+ if(afterItem&&afterItem.tagType==8){
|
|
|
+ res.data.splice(index,1,pText,...spreadLabels);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null));
|
|
|
+ }else{
|
|
|
+ res.data.splice(index,1,pText,...spreadLabels,textEmpty);
|
|
|
+ res.saveText = fullfillText(res.data).saveText;
|
|
|
+ res.selecteds.splice(index,1,null,...new Array(spreadLabels.length).fill(null),null);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- // span.current.innerText?(span.current.innerText = value):(span.current.innerHTML = value);
|
|
|
- // res.data = fullfillText(resData).newArr;
|
|
|
- // res.saveText = fullfillText(resData).saveText;
|
|
|
}
|
|
|
res.searchData = []; //选中清空搜索内容(即关闭搜索弹窗)
|
|
|
res.update = Math.random();//console.log('现病史',res);
|