|
@@ -457,11 +457,12 @@ export function setCheckText(state,action) {
|
|
|
|
|
|
//搜索 插入标签数据
|
|
|
export function insertLabelData(state,action){
|
|
|
- let res = Object.assign({},state);//console.log(789,res,action);
|
|
|
- const text = Object.assign(JSON.parse(config.textLabel),{name:action.name});
|
|
|
+ let res = Object.assign({},state);
|
|
|
const {index,data,isReplace,span}=action;
|
|
|
let id = data.id;
|
|
|
+ let searchData = action.name;
|
|
|
res.symptomIds.push(id);
|
|
|
+ const text = Object.assign(JSON.parse(config.textLabel),{name:searchData},{id:id});
|
|
|
let focusIndex = res.focusIndex;
|
|
|
|
|
|
if(isReplace){
|
|
@@ -473,26 +474,36 @@ export function insertLabelData(state,action){
|
|
|
return item.symptomType==0||item.symptomType==2;
|
|
|
})));
|
|
|
res.data = fullfillText(resData).newArr;
|
|
|
- res.saveText[focusIndex] = action.name;
|
|
|
+ res.saveText[focusIndex] = searchData;
|
|
|
}else{
|
|
|
+ let resData;
|
|
|
// res.data.splice(index,0,data);
|
|
|
const searchStr = res.searchStr;
|
|
|
let innerText = span.current.innerText;
|
|
|
let strIndex = innerText.indexOf(searchStr);
|
|
|
- let value;
|
|
|
- if(strIndex <= 1){//前
|
|
|
- value = innerText.replace(searchStr,action.name);
|
|
|
+ const value = innerText.replace(searchStr,"");
|
|
|
+ // let value;
|
|
|
+ // 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==2;
|
|
|
+ })));
|
|
|
}else{
|
|
|
- let temp = innerText.substring(0,innerText.lastIndexOf(searchStr));
|
|
|
- value = temp + action.name;
|
|
|
- }
|
|
|
- span.current.innerText = value;
|
|
|
- let resData = JSON.parse(JSON.stringify(res.data));
|
|
|
- resData[focusIndex].value = value;
|
|
|
- // resData[focusIndex].id = id;
|
|
|
- resData.splice(focusIndex+1,0,...(data.questionMapping.filter((item)=>{
|
|
|
+ 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));
|
|
|
+ // +3是因为插入一个文本标签加一个符号标签
|
|
|
+ resData.splice(focusIndex+3,0,...(data.questionMapping.filter((item)=>{
|
|
|
return item.symptomType==0||item.symptomType==2;
|
|
|
})));
|
|
|
+ }
|
|
|
+ span.current.innerText = value;
|
|
|
res.data = fullfillText(resData).newArr;
|
|
|
res.saveText = fullfillText(resData).saveText;
|
|
|
}
|
|
@@ -546,10 +557,14 @@ export function backspaceText(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
const {delIndex,text} = action;
|
|
|
const data = res.data;
|
|
|
- if(data[delIndex-1].tagType==8 ||data[delIndex-1].flag&&data[delIndex-1].flag==3){
|
|
|
- // 前一个是文本标签或者子模板,只改变值
|
|
|
+ // if(data[delIndex-1].tagType==8 ||data[delIndex-1].flag&&data[delIndex-1].flag==3){
|
|
|
+ // 前一个是文本标签或者子模板,只改变值
|
|
|
+ if(data[delIndex-1].flag&&data[delIndex-1].flag==3){//子模板不删
|
|
|
// data[delIndex].value = text;
|
|
|
- }else{
|
|
|
+ }else if(data[delIndex-1].tagType==8){
|
|
|
+ data.splice(delIndex,1);
|
|
|
+ }
|
|
|
+ else{
|
|
|
data.splice(delIndex-1,2);
|
|
|
}
|
|
|
res.saveText = fullfillText(data).saveText;
|