Browse Source

feat:[模板管理][yp003]

ouqian
luojie 1 month ago
parent
commit
20ee6d90af
2 changed files with 142 additions and 43 deletions
  1. +83
    -15
      src/components/Template/HandleFormItem.vue
  2. +59
    -28
      src/components/Template/mixins/formPackageMixins.js

+ 83
- 15
src/components/Template/HandleFormItem.vue View File

@ -110,12 +110,13 @@
</div> </div>
</div> </div>
<div v-else-if="type === 'fqyq'" :class="getFillTypeStyle()"> <div v-else-if="type === 'fqyq'" :class="getFillTypeStyle()">
<el-radio-group>
<div class="item-center">
<el-radio-group v-model="fqyqValue.mainRadio" :disabled="getDisabled()" @input="onFqyqRadioChange($event,'mainRadio')">
<div class="item-center mb-10">
<el-radio label="是"></el-radio> <el-radio label="是"></el-radio>
<div class="item-center">
<el-input class="fqyq-input" maxlength="100" v-model="inputValue" :disabled="getDisabled()" placeholder="请输入"></el-input>
<el-radio-group v-model="inputValue">
<div class="item-center" v-if="fqyqValue.mainRadio === '是'">
<el-input class="fqyq-input" maxlength="100" v-model="fqyqValue.inputValue" :disabled="getDisabled()" placeholder="请输入" @blur="onFqyqInputBlur" ></el-input>
<div class="fs-14 mr-10">是否在规定时间完成</div>
<el-radio-group v-model="fqyqValue.subRadio" :disabled="getDisabled()" @input="onFqyqRadioChange($event,'subRadio')">
<el-radio label="是"></el-radio> <el-radio label="是"></el-radio>
<el-radio label="否"></el-radio> <el-radio label="否"></el-radio>
</el-radio-group> </el-radio-group>
@ -253,7 +254,7 @@ export default {
}, },
data() { data() {
let initialValue = this.value; let initialValue = this.value;
let initialOtherValues = {}, checkboxTagList = [];
let initialOtherValues = {}, checkboxTagList = [], fqyqValue = {};
// checkboxListvalue // checkboxListvalue
if (this.type === 'checkboxList' && this.value && typeof this.value === 'object') { if (this.type === 'checkboxList' && this.value && typeof this.value === 'object') {
@ -267,7 +268,9 @@ export default {
checked: tag.checked, checked: tag.checked,
tagValue: tag.tagValue || '' tagValue: tag.tagValue || ''
})); }));
}
} else if (this.type === 'fqyq' && !this.value) {
initialValue = {mainRadio: '', subRadio: '',inputValue:""};
}
return { return {
inputValue: initialValue, inputValue: initialValue,
oldValue: initialValue, // oldValue: initialValue, //
@ -284,6 +287,8 @@ export default {
checkboxValue: this.getChecked(),// checkboxValue: this.getChecked(),//
checkboxTagList: checkboxTagList, // checkboxTag checkboxTagList: checkboxTagList, // checkboxTag
oldCheckboxTagList: JSON.parse(JSON.stringify(checkboxTagList)), // checkboxTagList oldCheckboxTagList: JSON.parse(JSON.stringify(checkboxTagList)), // checkboxTagList
fqyqValue: initialValue, // fqyq
oldFqyqValue: {...initialValue}, // fqyq
uuid: getuuid(), // EventBus uuid: getuuid(), // EventBus
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], //// regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], ////
selectRegentInfo: {},//// selectRegentInfo: {},////
@ -295,6 +300,7 @@ export default {
pendingUploadFile: null, // pendingUploadFile: null, //
pendingRemoveFile: null, // pendingRemoveFile: null, //
currentTagIndex:-1,//checkboxTag currentTagIndex:-1,//checkboxTag
currentFqyqType:'',//fqyq
} }
}, },
watch: { watch: {
@ -309,7 +315,14 @@ export default {
checked: tag.checked, checked: tag.checked,
tagValue: tag.tagValue || '' tagValue: tag.tagValue || ''
})); }));
} else {
} else if (this.type === 'fqyq' && newVal && typeof newVal === 'object') {
// fqyq
this.fqyqValue = {
mainRadio: newVal.mainRadio || '',
inputValue: newVal.inputValue || '',
subRadio: newVal.subRadio || ''
};
} else {
this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal; this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal;
} }
} }
@ -346,7 +359,7 @@ export default {
}, },
methods: { methods: {
getFlexClass() { getFlexClass() {
const noFlexArr = ["radio", "checkboxTag"]
const noFlexArr = ["radio", "checkboxTag","fqyq"]
return noFlexArr.includes(this.type) ? '' : 'flex1' return noFlexArr.includes(this.type) ? '' : 'flex1'
}, },
getDecimalDigits() { getDecimalDigits() {
@ -665,13 +678,14 @@ export default {
}, },
getFillTypeStyle(type) { getFillTypeStyle(type) {
const { fillType } = this.item; const { fillType } = this.item;
const filterType = ["attachment","checkboxTag","fqyq"]
const typeObj = { const typeObj = {
actFill: "orange-border",// actFill: "orange-border",//
green: "green-border", green: "green-border",
preFill: "blue-border",// preFill: "blue-border",//
} }
// //
if (this.error && this.type !== "attachment" && this.type !== "checkboxTag") {
if (this.error && !filterType.includes(this.type)) {
return "error-border"; return "error-border";
} }
return typeObj[fillType] || "" return typeObj[fillType] || ""
@ -857,6 +871,21 @@ export default {
this.$emit('input', [...this.checkboxTagList]); this.$emit('input', [...this.checkboxTagList]);
this.$emit('change', [...this.checkboxTagList]); this.$emit('change', [...this.checkboxTagList]);
}, },
// fqyq radio
onFqyqRadioChange(val, radioType) {
this.fqyqValue[radioType] = val;
this.currentFqyqType = radioType;
this.onCommonHandleSaveRecord();
},
// fqyq
onFqyqInputBlur(e) {
this.fqyqValue.inputValue = e.target.value;
this.currentFqyqType = 'inputValue';
this.onCommonHandleSaveRecord(this.fqyqValue.inputValue);
},
// //
onBlur(e) { onBlur(e) {
this.onCommonHandleSaveRecord(e.target.value); this.onCommonHandleSaveRecord(e.target.value);
@ -889,6 +918,16 @@ export default {
this.visible = true; this.visible = true;
} }
}, },
getFqyqInfo(){
const { mainRadio,inputValue,subRadio } = this.fqyqValue;
const { mainRadio: oldMainRadio,inputValue: oldInputValue,subRadio: oldSubRadio } = this.oldFqyqValue;
const o ={
"mainRadio":{oldValue:oldMainRadio,newValue:mainRadio,des:""},
"inputValue":{oldValue:oldInputValue,newValue:inputValue,des:""},
"subRadio":{oldValue:oldSubRadio,newValue:subRadio,des:"是否在规定时间完成:"}
}
return o[this.currentFqyqType];
},
async onCommonHandleSaveRecord(val) { async onCommonHandleSaveRecord(val) {
const isEmpty = this.isValueEmpty(this.inputValue); const isEmpty = this.isValueEmpty(this.inputValue);
if (this.error && !isEmpty) { if (this.error && !isEmpty) {
@ -945,11 +984,15 @@ export default {
const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {}; const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {};
isSame = this.isEqual(oldTag.checked, currentTag.checked); isSame = this.isEqual(oldTag.checked, currentTag.checked);
isOldValueEmpty = this.isValueEmpty(oldTag.checked); isOldValueEmpty = this.isValueEmpty(oldTag.checked);
}else{
} else if (this.type === "fqyq") {
const current = this.getFqyqInfo();
isSame = this.isEqual(current.oldValue,current.newValue);
isOldValueEmpty = this.isValueEmpty(current.oldValue);
} else {
isSame = this.isEqual(this.oldValue, this.inputValue) isSame = this.isEqual(this.oldValue, this.inputValue)
isOldValueEmpty = this.isValueEmpty(this.oldValue); isOldValueEmpty = this.isValueEmpty(this.oldValue);
} }
console.log(isSame,isOldValueEmpty,this.fqyqValue,this.oldFqyqValue,"isSame")
if (isSame) { if (isSame) {
return; return;
} }
@ -981,6 +1024,10 @@ export default {
this.checkboxTagList = JSON.parse(JSON.stringify(this.oldCheckboxTagList)); this.checkboxTagList = JSON.parse(JSON.stringify(this.oldCheckboxTagList));
oldValue = [...this.checkboxTagList]; oldValue = [...this.checkboxTagList];
} }
} else if (this.type === "fqyq") {
// 退
this.fqyqValue = JSON.parse(JSON.stringify(this.oldFqyqValue));
oldValue = { ...this.fqyqValue };
} }
this.inputValue = this.oldValue; this.inputValue = this.oldValue;
this.$emit('input', oldValue); // v-model this.$emit('input', oldValue); // v-model
@ -1008,8 +1055,12 @@ export default {
const currentTag = this.checkboxTagList[this.currentTagIndex] || {}; const currentTag = this.checkboxTagList[this.currentTagIndex] || {};
recordOldVlaue = `${oldTag.tagValue || ''}:${oldTag.checked ? '勾选' : '未勾选'}`; recordOldVlaue = `${oldTag.tagValue || ''}:${oldTag.checked ? '勾选' : '未勾选'}`;
recordValue = `${currentTag.tagValue || ''}:${currentTag.checked ? '勾选' : '未勾选'}`; recordValue = `${currentTag.tagValue || ''}:${currentTag.checked ? '勾选' : '未勾选'}`;
isModify = oldTag.checked !== undefined
isModify = oldTag.checked !== undefined;
} else if (this.type === "fqyq") {
const current = this.getFqyqInfo();
recordOldVlaue = `${current.des+current.oldValue}`;
recordValue = `${current.des+current.newValue}`;
isModify = !!this.oldFqyqValue.mainRadio
} }
const record = { const record = {
...baseInfo, ...baseInfo,
@ -1040,6 +1091,9 @@ export default {
// tagIndex // tagIndex
this.oldCheckboxTagList = JSON.parse(JSON.stringify(this.checkboxTagList)); this.oldCheckboxTagList = JSON.parse(JSON.stringify(this.checkboxTagList));
} }
} else if (this.type === "fqyq") {
//
this.oldFqyqValue = JSON.parse(JSON.stringify(this.fqyqValue));
} }
let value = this.inputValue; let value = this.inputValue;
if (this.type === 'checkboxList') { if (this.type === 'checkboxList') {
@ -1049,6 +1103,8 @@ export default {
}; };
} else if (this.type === "checkboxTag") { } else if (this.type === "checkboxTag") {
value = [...this.checkboxTagList]; value = [...this.checkboxTagList];
} else if (this.type === "fqyq") {
value = { ...this.fqyqValue };
} }
if (this.type === "button") { if (this.type === "button") {
this.$emit('clickButton', this.item, this.inputValue, data); this.$emit('clickButton', this.item, this.inputValue, data);
@ -1692,6 +1748,9 @@ export default {
border-color: #f9c588; border-color: #f9c588;
} }
} }
.el-radio__inner {
border-color: #f9c588;
}
} }
} }
@ -1748,6 +1807,15 @@ export default {
} }
.fqyq-input{ .fqyq-input{
width: 500px; width: 500px;
margin-left: 10px;
margin-right:10px;
}
.mb-10{
margin-bottom: 10px;
}
.fs-14{
font-size: 14px;
}
.mr-10{
margin-right: 10px;
} }
</style> </style>

+ 59
- 28
src/components/Template/mixins/formPackageMixins.js View File

@ -54,7 +54,7 @@ export default {
} }
this.onValueChangeCompareTo(key, val); this.onValueChangeCompareTo(key, val);
this.formFields[key] = val; this.formFields[key] = val;
this.$emit("select", { key, value: val, type,...this.formFields });
this.$emit("select", { key, value: val, type, ...this.formFields });
// 清除该表单项的错误状态 // 清除该表单项的错误状态
if (this.errors[key]) { if (this.errors[key]) {
this.$set(this.errors, key, false); this.$set(this.errors, key, false);
@ -62,22 +62,22 @@ export default {
}, },
//试剂/仪器等弹窗提交 //试剂/仪器等弹窗提交
onRegentSubmit(data,inputValue,key,item){
this.updateFormData(key,inputValue);
this.$emit("onRegentSubmit", {selectInfo:data,inputValue,key,config:item});
onRegentSubmit(data, inputValue, key, item) {
this.updateFormData(key, inputValue);
this.$emit("onRegentSubmit", { selectInfo: data, inputValue, key, config: item });
}, },
getRegentItem(item,fieldCode="type"){
const type = item[fieldCode] ;
console.log(item,"type")
getRegentItem(item, fieldCode = "type") {
const type = item[fieldCode];
console.log(item, "type")
return { return {
label: "", label: "",
type, type,
fillType: item.subFillType || item.fillType, fillType: item.subFillType || item.fillType,
parentLabel: item.label, parentLabel: item.label,
filledCodes:item.filledCodes,
filledCodes: item.filledCodes,
} }
}, },
handleClickButton(key) { handleClickButton(key) {
this.$emit("clickButton", key) this.$emit("clickButton", key)
}, },
@ -96,7 +96,7 @@ export default {
this.$set(this.errors, key, false); this.$set(this.errors, key, false);
} }
}, },
//批量更新表单数据
//批量更新表单数据
batchUpdateFormData(data) { batchUpdateFormData(data) {
const cloneFormFields = JSON.parse(JSON.stringify(this.formFields)); const cloneFormFields = JSON.parse(JSON.stringify(this.formFields));
Object.keys(data).forEach(key => { Object.keys(data).forEach(key => {
@ -107,29 +107,29 @@ export default {
this.$set(this.errors, key, false); this.$set(this.errors, key, false);
} }
}) })
}, },
//更新表单数据 //更新表单数据
updateFormData(key, value,data) {
const {isUpdateRecord,signData} = data || {};
updateFormData(key, value, data) {
const { isUpdateRecord, signData } = data || {};
// 深拷贝当前表单数据,避免直接修改原数据 // 深拷贝当前表单数据,避免直接修改原数据
const cloneFormFields = JSON.parse(JSON.stringify(this.formFields)); const cloneFormFields = JSON.parse(JSON.stringify(this.formFields));
this.oldFormFields[key] = cloneFormFields[key]; this.oldFormFields[key] = cloneFormFields[key];
this.formFields[key] = value; this.formFields[key] = value;
// 清除该表单项的错误状态 // 清除该表单项的错误状态
if (this.errors[key]) { if (this.errors[key]) {
this.$set(this.errors, key, false); this.$set(this.errors, key, false);
} }
if(isUpdateRecord){
if (isUpdateRecord) {
setTimeout(() => { setTimeout(() => {
this.$refs[key][0].handleUpdateRecord(signData,{oldValue:this.oldFormFields[key],inputValue:value});
this.$refs[key][0].handleUpdateRecord(signData, { oldValue: this.oldFormFields[key], inputValue: value });
}, 10); }, 10);
} }
}, },
handleClickable(sItem, key) { handleClickable(sItem, key) {
if (this.templateFillType !== 'actFill') { if (this.templateFillType !== 'actFill') {
return return
@ -177,7 +177,7 @@ export default {
fillType: sItem.subFillType || sItem.fillType, fillType: sItem.subFillType || sItem.fillType,
parentLabel: sItem.label, parentLabel: sItem.label,
} }
if(sItem.subDisabled){
if (sItem.subDisabled) {
config.disabled = sItem.subDisabled; config.disabled = sItem.subDisabled;
} }
return config; return config;
@ -215,14 +215,14 @@ export default {
// 处理特殊字段 - "其他"字段 // 处理特殊字段 - "其他"字段
if (currentConfig.otherCode) { if (currentConfig.otherCode) {
const { otherCode,type } = currentConfig;
const { otherCode, type } = currentConfig;
//如果是更新的话,优先使用formFields中的值 //如果是更新的话,优先使用formFields中的值
if (update) { if (update) {
result[otherCode] = formFields[otherCode] || formData[otherCode] || ''; result[otherCode] = formFields[otherCode] || formData[otherCode] || '';
} else { } else {
result[otherCode] = formData[otherCode] || formFields[otherCode] || ''; result[otherCode] = formData[otherCode] || formFields[otherCode] || '';
} }
config[otherCode] = { label: "template.common.other",parentType:type, parentKey: key, type: "input", fillType: currentConfig.fillType }
config[otherCode] = { label: "template.common.other", parentType: type, parentKey: key, type: "input", fillType: currentConfig.fillType }
} }
if (currentConfig.subKey) { if (currentConfig.subKey) {
const { subKey } = currentConfig; const { subKey } = currentConfig;
@ -311,17 +311,17 @@ export default {
if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段 if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段
formFields[o.otherCode] = ""; formFields[o.otherCode] = "";
} }
}else if(o.type === "radioAndOther"){
const isSelectedOther = this.isShowOtherByRadioAndOther(formFields[key]);
} else if (o.type === "radioAndOther") {
const isSelectedOther = this.isShowOtherByRadioAndOther(formFields[key]);
if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段 if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段
formFields[o.otherCode] = ""; formFields[o.otherCode] = "";
} }
} }
} }
if(o.type === "attachment"){
if (o.type === "attachment") {
const attValue = formFields[key]; const attValue = formFields[key];
if(!attValue || attValue == "[]"){
if (!attValue || attValue == "[]") {
errors.push({ errors.push({
field: key, field: key,
label: o.label, label: o.label,
@ -329,13 +329,44 @@ export default {
}); });
this.$set(this.errors, key, true); this.$set(this.errors, key, true);
} }
} else if (o.type === "fqyq") {
const fqyqValue = formFields[key];
const {mainRadio, subRadio,inputValue} = fqyqValue;
if (!mainRadio) {
errors.push({
field: key,
label: o.label,
error: "请选择是否在规定时间完成"
});
this.$set(this.errors, key, true);
} else {
if (mainRadio==="是") {
if (!subRadio) {
errors.push({
field: key,
label: o.label,
error: "请选择是否在规定时间完成"
});
this.$set(this.errors, key, true);
}else if(!inputValue){
errors.push({
field: key,
label: o.label,
error: "请输入信息"
});
this.$set(this.errors, key, true);
}
}
}
continue
} }
if (this.isValueEmpty(formFields[key])) { if (this.isValueEmpty(formFields[key])) {
// 其他字段需要判断是否显示再校验 // 其他字段需要判断是否显示再校验
if (o.label === "template.common.other" && !this.isShowOther(formFields[o.parentKey]) && o.parentType !== "radioAndOther") { if (o.label === "template.common.other" && !this.isShowOther(formFields[o.parentKey]) && o.parentType !== "radioAndOther") {
continue continue
} }
if (o.type === "radioAndOther" &&o.label === "template.common.other" && !this.isShowOtherByRadioAndOther(formFields[o.parentKey])) {
if (o.type === "radioAndOther" && o.label === "template.common.other" && !this.isShowOtherByRadioAndOther(formFields[o.parentKey])) {
continue continue
} }
//span的字段不校验 //span的字段不校验
@ -432,7 +463,7 @@ export default {
if (this.errors[key]) { if (this.errors[key]) {
this.$set(this.errors, key, false); this.$set(this.errors, key, false);
} }
// 如果是checkboxList类型,需要处理otherValues // 如果是checkboxList类型,需要处理otherValues
if (val && typeof val === 'object' && val.otherValues) { if (val && typeof val === 'object' && val.otherValues) {
// 将otherValues中的每个值也保存到formFields中 // 将otherValues中的每个值也保存到formFields中

Loading…
Cancel
Save