|
@@ -933,35 +933,111 @@ function notTextLabel(label){
|
|
|
* 入参:arr源数组,
|
|
|
* noPre是否不添加前置文本标签,默认false即添加
|
|
|
* noEnd是否不添加后置文本标签,默认false即添加
|
|
|
-* ifEmpty是否添加空标签,默认true即添加,传false添加逗号,如查体,
|
|
|
-* showInCheck是否默认在查体中展开
|
|
|
+* 出参:newArr添加自由文本标签后的数据Array,
|
|
|
+* saveText添加自由文本后对应的预览数据Array,
|
|
|
* */
|
|
|
-function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
|
|
|
+function fullfillText(arr,noPre=false,noEnd=false){
|
|
|
let newArr =[],
|
|
|
pre={},
|
|
|
textLabel={},
|
|
|
- _textLabel={},
|
|
|
notText = true,
|
|
|
saveText=[],
|
|
|
tempText = '',
|
|
|
value = '',
|
|
|
- item={},
|
|
|
- cNum = 0,
|
|
|
- checkHiddenDefault=false;//console.log(arr)
|
|
|
+ cNum = 0;
|
|
|
arr&&arr.map((it,i)=>{
|
|
|
notText = notTextLabel(it);
|
|
|
cNum = i;
|
|
|
value = it.value||'';
|
|
|
- textLabel = !ifEmpty&&i==0?Object.assign({},JSON.parse(config.textLabel),{showInCheck:true}):JSON.parse(config.textLabel);
|
|
|
+ textLabel = JSON.parse(config.textLabel);
|
|
|
+ //n个显示的标签最后一个标签后面要落关标,所以+1
|
|
|
+ if(i===0){
|
|
|
+ //第一个标签不是文本标签时在前面添加文本标签
|
|
|
+ if(!noPre&¬Text){
|
|
|
+ newArr.push(textLabel);
|
|
|
+ saveText.push('');
|
|
|
+ }
|
|
|
+ newArr.push(it);
|
|
|
+ if(it.tagType != 3){ //非血压类组合标签
|
|
|
+ tempText = value?it.labelPrefix+value+it.labelSuffix:'';
|
|
|
+ tempText = notText?tempText:it.value||it.name;
|
|
|
+ }else{
|
|
|
+ tempText = getSaveText(it);
|
|
|
+ }
|
|
|
+ saveText.push(tempText);
|
|
|
+ // 模板只有一个标签时第一项后面也要加空标签
|
|
|
+ if(arr.length==1&¬Text){
|
|
|
+ newArr.push(JSON.parse(config.textLabel));
|
|
|
+ saveText.push('');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ pre = arr[i-1];
|
|
|
+ //如果本身不是文本标签且前面一个也不是文本标签,该标签前面添加文本标签
|
|
|
+ if(notTextLabel(pre)&¬Text){
|
|
|
+ newArr.push(textLabel,it);
|
|
|
+ if(it.tagType != 3) {
|
|
|
+ tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
|
|
|
+ }else{
|
|
|
+ tempText = getSaveText(it);
|
|
|
+ }
|
|
|
+ saveText.push("",tempText);
|
|
|
+ }else{ //本身是或者前面是文本标签时,前面不添加文本标签
|
|
|
+ newArr.push(it);
|
|
|
+ if(it.tagType != 3) {
|
|
|
+ tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
|
|
|
+ tempText = notText ? tempText : (it.value || it.value == "" ? it.value : it.name);
|
|
|
+ }else{
|
|
|
+ tempText = getSaveText(it);
|
|
|
+ }
|
|
|
+ saveText.push(tempText);
|
|
|
+ }
|
|
|
+ if(notText&&!noEnd&&i===arr.length-1){//最后一个非文本标签,后面添加一个文本标签
|
|
|
+ //不能用上面的变量textLabel,因为上一个if可能也进了,这样就是同一个对象,值改变时会同步
|
|
|
+ newArr.push(JSON.parse(config.textLabel));
|
|
|
+ saveText.push("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return {newArr,saveText};
|
|
|
+};
|
|
|
+
|
|
|
+/*
|
|
|
+ * 查体添加自由文本标签函数
|
|
|
+ * 默认标签直接添加,
|
|
|
+ * 前config.showCheckNum个源数据标签默认显示,剩余隐藏收起
|
|
|
+ * 入参:arr源数组,
|
|
|
+ * noPre是否不添加前置文本标签,默认false即添加
|
|
|
+ * noEnd是否不添加后置文本标签,默认false即添加
|
|
|
+ * showInCheck是否默认在查体中展开
|
|
|
+ * 出参:newArr添加自由文本标签后的数据Array,
|
|
|
+ * saveText添加自由文本后对应的预览数据Array,
|
|
|
+ * checkHiddenDefault查体是否全部标签展开
|
|
|
+ *
|
|
|
+ * */
|
|
|
+function checkFullfillText(arr,noPre=false,noEnd=false){
|
|
|
+ let newArr =[],
|
|
|
+ pre={},
|
|
|
+ textLabel={},
|
|
|
+ notText = true,
|
|
|
+ saveText=[],
|
|
|
+ tempText = '',
|
|
|
+ value = '',
|
|
|
+ item={},
|
|
|
+ checkHiddenDefault=false;
|
|
|
+ arr&&arr.map((it,i)=>{
|
|
|
+ notText = notTextLabel(it);
|
|
|
+ value = it.value||'';
|
|
|
+ //textLabel = i==0?JSON.parse(config.textLabel):Object.assign({},JSON.parse(config.textLabel),{showInCheck:true});
|
|
|
//n个显示的标签最后一个标签后面要落关标,所以+1
|
|
|
- _textLabel = !ifEmpty&&cNum<config.showCheckNum+1?Object.assign({},JSON.parse(config._textLabel),{showInCheck:true}):JSON.parse(config._textLabel);
|
|
|
+ //_textLabel = !ifEmpty&&cNum<config.showCheckNum+1?Object.assign({},JSON.parse(config._textLabel),{showInCheck:true}):JSON.parse(config._textLabel);
|
|
|
if(i===0){
|
|
|
+ textLabel = Object.assign({},JSON.parse(config.textLabel),{showInCheck:true});
|
|
|
//第一个标签不是文本标签时在前面添加文本标签
|
|
|
if(!noPre&¬Text){
|
|
|
newArr.push(textLabel);
|
|
|
saveText.push('');
|
|
|
}
|
|
|
- item = ifEmpty?it:Object.assign({},it,{showInCheck:true});
|
|
|
+ item = Object.assign({},it,{showInCheck:true});
|
|
|
newArr.push(item);
|
|
|
if(it.tagType != 3){
|
|
|
tempText = value?it.labelPrefix+value+it.labelSuffix:'';
|
|
@@ -977,17 +1053,18 @@ function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
|
|
|
}
|
|
|
}else{
|
|
|
pre = arr[i-1];
|
|
|
- item = !ifEmpty&&cNum<config.showCheckNum?Object.assign({},it,{showInCheck:true}):it;
|
|
|
+ item = i<config.showCheckNum?Object.assign({},it,{showInCheck:true}):it;
|
|
|
//判断单选项是否有默认选中,位置在隐藏区域时,查体所有标签展示
|
|
|
- if(!ifEmpty&&!checkHiddenDefault&&cNum>config.showCheckNum&&+it.tagType===1&&(+it.controlType===0||+it.controlType===1)){
|
|
|
+ if(!checkHiddenDefault&&i>config.showCheckNum&&+it.tagType===1&&(+it.controlType===0||+it.controlType===1)){
|
|
|
if(it.questionDetailList.find((it)=>it.defaultSelect=='1')){
|
|
|
checkHiddenDefault=true;
|
|
|
}
|
|
|
}
|
|
|
//如果本身不是文本标签且前面一个也不是文本标签,该标签前面添加文本标签
|
|
|
if(notTextLabel(pre)&¬Text){
|
|
|
- // newArr.push(textLabel,it);
|
|
|
- ifEmpty?newArr.push(textLabel,it):newArr.push(_textLabel,item);
|
|
|
+ textLabel = Object.assign(JSON.parse(config._textLabel),{showInCheck:i-1<config.showCheckNum?true:false});
|
|
|
+ newArr.push(textLabel,item);
|
|
|
+
|
|
|
if(it.tagType != 3) {
|
|
|
tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
|
|
|
}else{
|
|
@@ -998,7 +1075,6 @@ function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
|
|
|
newArr.push(item);
|
|
|
if(it.tagType != 3) {
|
|
|
tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
|
|
|
- // tempText = notText?tempText:it.value||it.name;
|
|
|
tempText = notText ? tempText : (it.value || it.value == "" ? it.value : it.name);
|
|
|
}else{
|
|
|
tempText = getSaveText(it);
|
|
@@ -1006,15 +1082,14 @@ function fullfillText(arr,noPre=false,noEnd=false,ifEmpty=true){
|
|
|
saveText.push(tempText);
|
|
|
}
|
|
|
if(notText&&!noEnd&&i===arr.length-1){//最后一个非文本标签,后面添加一个文本标签
|
|
|
- //不能用上面的变量textLabel,因为上一个if可能也进了,这样就是同一个对象,值改变时会同步
|
|
|
- const _text = arr.length>config.showCheckNum?JSON.parse(config._textLabel):_textLabel;
|
|
|
- newArr.push(ifEmpty?textLabel:_text);
|
|
|
+ const _text = Object.assign(JSON.parse(config.textLabel),{showInCheck:arr.length>config.showCheckNum?false:true});
|
|
|
+ newArr.push(_text);
|
|
|
saveText.push("");
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return {newArr,saveText,checkHiddenDefault};
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
|
|
|
//获取标签index,入参:病例项index+标签index+标签内index
|
|
@@ -1074,6 +1149,7 @@ module.exports = {
|
|
|
getWindowInnerHeight,
|
|
|
getLabelIndex,
|
|
|
fullfillText,
|
|
|
+ checkFullfillText,
|
|
|
parseUrl,
|
|
|
getAge,
|
|
|
dateParser,
|