|
@@ -7,6 +7,7 @@ export function set(state,action){
|
|
|
res.data = [...data];
|
|
|
res.saveText = fullfillText(res.data).saveText;//存逗号
|
|
|
res.update = Math.random();
|
|
|
+ res.isEmpty = false;
|
|
|
return res;
|
|
|
}
|
|
|
//查体中数字键盘选中事件
|
|
@@ -130,31 +131,44 @@ export function setSearchData(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
res.searchData = action.data;
|
|
|
res.searchStr = action.inpStr;
|
|
|
+ res.searchInEnd = action.isEnd;
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
-//插入标签数据
|
|
|
+//插入标签数据-搜索
|
|
|
export function insertLabelData(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
const text = Object.assign({},JSON.parse(config.textLabel));
|
|
|
const searchStr = res.searchStr;
|
|
|
- const {index,data,isReplace,span}=action;
|
|
|
+ const {index,data,isReplace,span,searchInEnd}=action;
|
|
|
const showText = res.saveText[index];
|
|
|
const spreadLabels = data;
|
|
|
- const toEnd = showText.indexOf(searchStr)>0; //替换前或后的搜索词(中间不可搜)
|
|
|
- let reg = toEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
|
|
|
+ let reg = searchInEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
|
|
|
const newText=showText.replace(reg,'')||'';
|
|
|
if(!isReplace){
|
|
|
span.current.innerText = newText;
|
|
|
const pText = Object.assign({},text,{value:newText});
|
|
|
- res.data.splice(index,1,pText,spreadLabels,text);
|
|
|
- res.saveText.splice(index,1,newText,'','');
|
|
|
- res.selecteds.splice(index,1,null,null,null);
|
|
|
+ if(searchInEnd){
|
|
|
+ res.data.splice(index,1,pText,spreadLabels,text);
|
|
|
+ res.saveText.splice(index,1,newText,'','');
|
|
|
+ res.selecteds.splice(index,1,null,null,null);
|
|
|
+ }else{
|
|
|
+ res.data.splice(index,1,text,spreadLabels,pText);
|
|
|
+ res.saveText.splice(index,1,'','',newText);
|
|
|
+ res.selecteds.splice(index,1,null,null,null);
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
span.current.innerText = ' ';
|
|
|
- res.data.splice(index+1,0,spreadLabels,text);
|
|
|
- res.saveText.splice(index+1,0,'','');
|
|
|
- res.selecteds.splice(index+1,0,null,null);
|
|
|
+ if(searchInEnd){
|
|
|
+ res.data.splice(index+1,0,spreadLabels,text);
|
|
|
+ res.saveText.splice(index+1,0,'','');
|
|
|
+ res.selecteds.splice(index+1,0,null,null);
|
|
|
+ }else{
|
|
|
+ res.data.splice(index,0,text,spreadLabels);
|
|
|
+ res.saveText.splice(index,0,'','');
|
|
|
+ res.selecteds.splice(index,0,null,null);
|
|
|
+ }
|
|
|
}
|
|
|
res.searchData = []; //选中清空搜索内容(即关闭搜索弹窗)
|
|
|
res.update = Math.random();
|
|
@@ -193,8 +207,8 @@ export const changeNumLabelVal = (state,action)=>{
|
|
|
if(newVal.trim()){
|
|
|
if(item){
|
|
|
item.value = newVal;
|
|
|
- res.saveText[index] = totalVal;
|
|
|
}
|
|
|
+ res.saveText[index] = newVal;
|
|
|
}else{//删除完标签内容则删除该标签
|
|
|
res.data.splice(index,1);
|
|
|
res.saveText = fullfillText(res.data).saveText;
|
|
@@ -208,6 +222,7 @@ export function clearCheckBody(state,action){ //清空
|
|
|
let res = Object.assign({},state);
|
|
|
res.data = action.data;
|
|
|
res.saveText = action.saveText;
|
|
|
+ res.isEmpty = action.isEmpty;
|
|
|
res.selecteds = action.selecteds?action.selecteds:[];
|
|
|
return res;
|
|
|
}
|