|
@@ -4,8 +4,10 @@ import {getLabelIndex,fullfillText} from '@common/js/func.js';
|
|
|
export function set(state,action){
|
|
|
let res = Object.assign({},state);
|
|
|
const {data} = action;
|
|
|
- res.data = [...data];
|
|
|
- res.saveText = fullfillText(res.data).saveText;//存逗号
|
|
|
+ const obj = fullfillText(data,false,false,false);
|
|
|
+ res.data = obj.newArr;
|
|
|
+ res.saveText = obj.saveText;//存逗号
|
|
|
+ res.showAll = obj.checkHiddenDefault;
|
|
|
res.update = Math.random();
|
|
|
res.isEmpty = action.isEmpty;
|
|
|
return res;
|
|
@@ -103,7 +105,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;
|
|
@@ -111,6 +117,7 @@ export function setRadioValue(state,action){
|
|
|
its.selected = false;
|
|
|
}
|
|
|
});
|
|
|
+ res.saveText[labelInx] = item.labelPrefix+text+item.labelSuffix;
|
|
|
}else{ //组合组件中的单选组件
|
|
|
item.questionMapping[subInx].value = text;
|
|
|
let hasValue = false;
|
|
@@ -138,8 +145,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==3){ //在组合项中
|
|
|
+ item = res.data[index].questionMapping[innerInx];
|
|
|
+ }
|
|
|
+ let str='',temp='',obj=item.questionDetailList;
|
|
|
if(!values){ //清空
|
|
|
let sld=obj.find((item)=>{
|
|
|
return item.selected==true;
|
|
@@ -147,7 +159,18 @@ export const setRadioInputValue = (state,action)=>{
|
|
|
sld?sld.selected=false:'';
|
|
|
item.vals = null;
|
|
|
item.value = '';
|
|
|
- res.saveText[ikey] = '';
|
|
|
+ if(res.data[index].tagType==3){
|
|
|
+ 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;
|
|
|
}
|
|
@@ -171,7 +194,15 @@ export const setRadioInputValue = (state,action)=>{
|
|
|
}
|
|
|
item.vals = values;
|
|
|
item.value = str;
|
|
|
- res.saveText[ikey] = str;
|
|
|
+ if(res.data[index].tagType==3){
|
|
|
+ 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;
|
|
|
}
|
|
@@ -179,7 +210,7 @@ export const setRadioInputValue = (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+2,0,JSON.parse(data),textLabel);
|
|
@@ -230,11 +261,17 @@ export function setSearchData(state,action){
|
|
|
//插入标签数据-搜索
|
|
|
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,searchInEnd}=action;console.log("查体",data);
|
|
|
+ const {index,data,isReplace,span,searchInEnd}=action;
|
|
|
const showText = res.saveText[index];
|
|
|
- const spreadLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
|
|
|
+ let tempLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
|
|
|
+ //查体中,默认显示区域搜索出来的标签要默认显示,隐藏区域搜索出的默认隐藏
|
|
|
+ let hideAreaIndex = [...res.data].reverse().findIndex((it)=>it.showInCheck);
|
|
|
+ hideAreaIndex = res.data.length-hideAreaIndex-1; //默认显示的最后一个标签的位置
|
|
|
+ const text = Object.assign({},JSON.parse(config._textLabel),{showInCheck:index>hideAreaIndex?false:true});
|
|
|
+ let spreadLabels =tempLabels.map((it)=>{
|
|
|
+ return Object.assign({},it,{showInCheck:index>hideAreaIndex?false:true});
|
|
|
+ });
|
|
|
let reg = searchInEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
|
|
|
const newText=showText.replace(reg,'')||'';
|
|
|
if(!isReplace){
|
|
@@ -284,6 +321,33 @@ export const changeLabelVal = (state,action)=>{//双击标签输入改变值
|
|
|
if(labText && 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] = totalVal;
|
|
@@ -299,6 +363,10 @@ 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);
|
|
@@ -384,8 +452,23 @@ export function backspaceText(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;
|