|
@@ -51,150 +51,6 @@ export const confirm = (state,action) =>{
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-//单选下拉选中
|
|
|
-export function setRadioValue(state,action){
|
|
|
- let res = Object.assign({},state);
|
|
|
- const {ikey,id,text} = action;
|
|
|
- let labelInx = getLabelIndex(ikey);
|
|
|
- const subInx = ikey.substr(ikey.length-1);
|
|
|
- let item = res.data[labelInx];
|
|
|
- if(typeof text != 'string'){ //需要展开项--有无治疗类型
|
|
|
- const len = +item.copyType === 0?1:0;
|
|
|
- res.data.splice(labelInx,len,text);
|
|
|
- return res;
|
|
|
- }
|
|
|
- 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;
|
|
|
- }else{
|
|
|
- its.selected = false;
|
|
|
- }
|
|
|
- });
|
|
|
- }else{
|
|
|
- item.questionMapping[subInx].value = text;
|
|
|
- let hasValue = false;
|
|
|
- const sub = item.questionMapping.map((it)=>{
|
|
|
- //添加选中状态
|
|
|
- it.questionDetailList.map((its)=>{
|
|
|
- if(its.id === id){
|
|
|
- its.selected = true;
|
|
|
- }else{
|
|
|
- its.selected = false;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if(it.value){ //至少有一个子值才黑显
|
|
|
- hasValue = true;
|
|
|
- }
|
|
|
- return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
|
|
|
- });
|
|
|
- res.saveText[labelInx] = hasValue?sub.join(''):'';
|
|
|
- }
|
|
|
- res.update = Math.random();
|
|
|
- return res;
|
|
|
-}
|
|
|
-
|
|
|
-//单选带输入值保存
|
|
|
-export const setRadioInputValue = (state,action)=>{
|
|
|
- const res = Object.assign({},state);
|
|
|
- const {ikey,values,id} = action.data;
|
|
|
- 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;
|
|
|
- });
|
|
|
- sld?sld.selected=false:'';
|
|
|
- item.vals = null;
|
|
|
- item.value = '';
|
|
|
- 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;
|
|
|
- }
|
|
|
- for(let i in values){
|
|
|
- temp = values[i];
|
|
|
- if(typeof temp=='object'){
|
|
|
- str+=temp.value;
|
|
|
- }else{
|
|
|
- str+=temp;
|
|
|
- }
|
|
|
- }
|
|
|
- //选中状态
|
|
|
- if(id){
|
|
|
- obj.map((its)=>{
|
|
|
- if(its.id === id){
|
|
|
- its.selected = true;
|
|
|
- }else{
|
|
|
- its.selected = false;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- item.vals = values;
|
|
|
- item.value = 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;
|
|
|
-}
|
|
|
-//数字键盘选中事件
|
|
|
-export function setNumberValue(state,action){
|
|
|
- let res = Object.assign({},state);
|
|
|
- const param = action.params;
|
|
|
- const ikey = param.ikey;
|
|
|
- const code = param.formulaCode;
|
|
|
- let labelInx = getLabelIndex(ikey);
|
|
|
- const subInx = ikey.substr(ikey.length-1);
|
|
|
- let item = res.data[labelInx];
|
|
|
- if(+item.tagType===1){
|
|
|
- item.value = param.text;
|
|
|
- res.saveText[labelInx] = param.text?item.labelPrefix+param.text+item.labelSuffix:'';
|
|
|
- }else{
|
|
|
- item.questionMapping[subInx].value = param.text;
|
|
|
- let hasValue = false;
|
|
|
- const sub = item.questionMapping.map((it)=>{
|
|
|
- if(it.value){ //至少有一个子值才黑显
|
|
|
- hasValue = true;
|
|
|
- }
|
|
|
- return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
|
|
|
- });
|
|
|
- res.saveText[labelInx] = hasValue?sub.join(''):'';
|
|
|
- }
|
|
|
- res[code] = param.text;
|
|
|
- res.update = Math.random();
|
|
|
- return res;
|
|
|
-}
|
|
|
-
|
|
|
//自由文本
|
|
|
export function setCheckText(state,action) {
|
|
|
let res = Object.assign({},state);
|
|
@@ -208,33 +64,6 @@ export function setCheckText(state,action) {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
-//文本输入标签
|
|
|
-export function setOtherInput(state,action){
|
|
|
- let res = Object.assign({}, state);//console.log(state,action)
|
|
|
- const {i, text, prefix, suffix, subIndex} = action;
|
|
|
- const item = res.data[i];
|
|
|
- if (+item.tagType === 3 || +item.tagType === 4) { //multSpred标签
|
|
|
- item.questionMapping[subIndex].value = text;
|
|
|
- let texts = item.questionMapping.map((it) => {
|
|
|
- return (it.labelPrefix || '') + (it.value || '') + (it.labelSuffix || '');
|
|
|
- });
|
|
|
- res.saveText[i] = texts.join('');
|
|
|
- res.update = Math.random();
|
|
|
- return res;
|
|
|
- } else {
|
|
|
- if (item) {
|
|
|
- item.value = text;
|
|
|
- }
|
|
|
- }
|
|
|
- if(text){
|
|
|
- res.saveText[i] = prefix+text+suffix;
|
|
|
- }else{//删除完要清空
|
|
|
- res.saveText[i] = "";
|
|
|
- }
|
|
|
- res.update = Math.random();
|
|
|
- return res;
|
|
|
-}
|
|
|
-
|
|
|
//多选文字,如杂音
|
|
|
export function setCheckBoxValue(state,action) {
|
|
|
const res = Object.assign({},state);
|
|
@@ -370,42 +199,6 @@ function hasNoSame(arr,text){
|
|
|
return arr.findIndex((it)=>text==it.name)==-1;
|
|
|
}
|
|
|
|
|
|
-// 数字键盘较特殊,有直接输入
|
|
|
-export const changeNumLabelVal = (state,action)=>{
|
|
|
- const res = Object.assign({},state);
|
|
|
- const {changeVal,totalVal,ikey,prefix,suffix} = action.data;
|
|
|
- const index = ikey;
|
|
|
- const newVal = changeVal;
|
|
|
- let item = res.data[index];
|
|
|
- const next = res.data[+index+1];
|
|
|
- const next2 = res.data[+index + 2];
|
|
|
- const nextVal = next.value||next.name;
|
|
|
- //下一个非文本标签是数字组件
|
|
|
- const next2IsNum = +next2.tagType === 1 && +next2.controlType === 7;
|
|
|
- //标签后是不是标点符号标签,是的话删除本标签时一起删除
|
|
|
- let nextIsDot = +next.tagType===8&&!nextVal.match(config.punctuationReg);
|
|
|
- let labText = totalVal?totalVal:newVal; //如单选没有前后缀
|
|
|
- if(labText.trim()){
|
|
|
- if(item){
|
|
|
- item.value = newVal;
|
|
|
- item.labelPrefix = prefix||'';
|
|
|
- item.labelSuffix = suffix||'';
|
|
|
- }
|
|
|
- res.saveText[index] = labText;
|
|
|
- }else{//删除完标签内容则删除该标签
|
|
|
- let num = nextIsDot ? 2 : 1;
|
|
|
- if (nextIsDot && next2IsNum) { //解决连续2个相同的数字组件删除第一个,第二个显示异常bug--临时方案
|
|
|
- next.value = '';
|
|
|
- num = 1;
|
|
|
- }
|
|
|
- res.data.splice(index,num);
|
|
|
- res.selecteds.splice(index,num);//杂音类样式选中状态对应
|
|
|
- res.saveText = fullfillText(res.data).saveText;
|
|
|
- };
|
|
|
- res.update = Math.random();
|
|
|
- return res;
|
|
|
-}
|
|
|
-
|
|
|
export function clearOtherHistory(state,action){ //清空数据
|
|
|
let res = Object.assign({},state);
|
|
|
for(let it in action){
|
|
@@ -427,6 +220,42 @@ export const setTextModeValue = (state,action)=>{
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
+//数字键盘选中事件
|
|
|
+export function setNumberValue(state,action){
|
|
|
+ let res = Object.assign({},state);
|
|
|
+ const param = action.params;
|
|
|
+ const ikey = param.ikey;
|
|
|
+ const code = param.formulaCode;
|
|
|
+ let labelInx = getLabelIndex(ikey);
|
|
|
+ const subInx = ikey.substr(ikey.length-1);
|
|
|
+ let item = res.data[labelInx];
|
|
|
+ if(+item.tagType===1){
|
|
|
+ item.value = param.text;
|
|
|
+ res.saveText[labelInx] = param.text?item.labelPrefix+param.text+item.labelSuffix:'';
|
|
|
+ }else{
|
|
|
+ item.questionMapping[subInx].value = param.text;
|
|
|
+ let hasValue = false;
|
|
|
+ const sub = item.questionMapping.map((it)=>{
|
|
|
+ if(it.value){ //至少有一个子值才黑显
|
|
|
+ hasValue = true;
|
|
|
+ }
|
|
|
+ if(it.tagType===8){ //维护时的连接词无value
|
|
|
+ return it.name;
|
|
|
+ }else{
|
|
|
+ //组合中未填值的子标签预览中不显示
|
|
|
+ if(!it.value){
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return (it.labelPrefix||'')+(it.value||'')+(it.labelSuffix||'');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ res.saveText[labelInx] = hasValue?sub.join(''):'';
|
|
|
+ }
|
|
|
+ res[code] = param.text;
|
|
|
+ res.update = Math.random();
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
//复制标签(如血压)事件
|
|
|
export function addLabelItem(state,action){
|
|
|
let res = Object.assign({},state);
|