Browse Source

feat:[模板管理][update]

lkf
luojie 1 month ago
parent
commit
2b3f56bea5
4 changed files with 97 additions and 10 deletions
  1. +12
    -0
      src/components/Template/BaseInfoFormPackage.vue
  2. +76
    -9
      src/components/Template/HandleFormItem.vue
  3. +8
    -0
      src/components/Template/mixins/formPackageMixins.js
  4. +1
    -1
      src/views/business/comps/template/formConfig/sp/SP0019.js

+ 12
- 0
src/components/Template/BaseInfoFormPackage.vue View File

@ -103,6 +103,12 @@
@resetRecord="resetRecord(key)" @resetRecord="resetRecord(key)"
:item="sItem" :value="formFields[key]" /> :item="sItem" :value="formFields[key]" />
</div> </div>
<div v-else-if="sItem.type === 'checkboxList'" class="flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+key" type="checkboxList" :item="sItem" :value="formFields[key]"
@copy="onCopy(sItem, key)" @change="(e)=>onAttachmentChange(key, e)"
:error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
</div>
<div v-else-if="isRegent(sItem)" class="flex1"> <div v-else-if="isRegent(sItem)" class="flex1">
<HandleFormItem <HandleFormItem
@beforeReagentSubmit="(data, callback)=>onBeforeReagentSubmit(data, callback,key)" @beforeReagentSubmit="(data, callback)=>onBeforeReagentSubmit(data, callback,key)"
@ -217,6 +223,12 @@
@resetRecord="resetRecord(key)" @resetRecord="resetRecord(key)"
:item="sItem" :value="formFields[key]" /> :item="sItem" :value="formFields[key]" />
</div> </div>
<div v-else-if="sItem.type === 'checkboxList'" class="flex flex1">
<HandleFormItem :field-item-label="fieldItemLabel" :field-key="prefixKey+'_'+key" type="checkboxList" :item="sItem" :value="formFields[key]"
@copy="onCopy(sItem, key)" @change="(e)=>onAttachmentChange(key, e)"
:error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
</div>
<div v-else-if="isRegent(sItem)" <div v-else-if="isRegent(sItem)"
class="flex item-center flex1"> class="flex item-center flex1">
<HandleFormItem :field-item-label="fieldItemLabel" <HandleFormItem :field-item-label="fieldItemLabel"

+ 76
- 9
src/components/Template/HandleFormItem.vue View File

@ -31,6 +31,12 @@
<el-checkbox :label="option.value" :disabled="getDisabled()"> <el-checkbox :label="option.value" :disabled="getDisabled()">
{{ option.label }} {{ option.label }}
</el-checkbox> </el-checkbox>
<div v-if="option.otherCode && inputValue.includes(option.value)">
<el-input v-model="otherValues[option.otherCode]"
:placeholder="option.otherPlaceholder || '请输入'"
@blur="onBlur"
@input="onOtherInputChange(option.otherCode, $event)" />
</div>
</div> </div>
</el-checkbox-group> </el-checkbox-group>
</div> </div>
@ -168,7 +174,7 @@ export default {
}, },
// v-model // v-model
value: { value: {
type: [String, Number, Array, Boolean],
type: [String, Number, Array, Boolean, Object],
default: '' default: ''
}, },
// //
@ -200,9 +206,21 @@ export default {
}, },
}, },
data() { data() {
let initialValue = this.value;
let initialOtherValues = {};
// checkboxListvalue
if (this.type === 'checkboxList' && this.value && typeof this.value === 'object') {
initialValue = this.value.checkboxValues || [];
initialOtherValues = this.value.otherValues || {};
} else if (this.type === 'checkboxList' && !Array.isArray(this.value)) {
initialValue = [];
}
return { return {
inputValue: this.type === 'checkboxList' && !Array.isArray(this.value) ? [] : this.value,
oldValue: this.type === 'checkboxList' && !Array.isArray(this.value) ? [] : this.value, //
inputValue: initialValue,
oldValue: initialValue, //
otherValues: initialOtherValues, // checkboxListotherCode
oldOtherValues: {...initialOtherValues}, // otherValues
showModal: false, // showModal: false, //
modificationRecords: [], // modificationRecords: [], //
modalTimer: null, // modalTimer: null, //
@ -226,7 +244,12 @@ export default {
}, },
watch: { watch: {
value(newVal) { value(newVal) {
this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal;
if (this.type === 'checkboxList' && newVal && typeof newVal === 'object') {
this.inputValue = newVal.checkboxValues || [];
this.otherValues = newVal.otherValues || {};
} else {
this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal;
}
} }
}, },
filters: { filters: {
@ -270,7 +293,6 @@ export default {
onInstrumentSubmit(data) { onInstrumentSubmit(data) {
if (data.uuid !== this.uuid) return; if (data.uuid !== this.uuid) return;
this.selectRegentInfo = data; this.selectRegentInfo = data;
console.log(data, "yq")
}, },
// //
@ -500,7 +522,6 @@ export default {
}, },
onDateChange(val, format) { onDateChange(val, format) {
this.inputValue = moment(val).format(format); this.inputValue = moment(val).format(format);
console.log(this.inputValue, "inputValue")
this.onCommonHandleSaveRecord(this.inputValue); this.onCommonHandleSaveRecord(this.inputValue);
}, },
getUserName(record) { getUserName(record) {
@ -690,10 +711,35 @@ export default {
}, },
// //
onInputChange(val) { onInputChange(val) {
const value = val !== undefined ? val : this.inputValue;
let value = val !== undefined ? val : this.inputValue;
// checkboxListcheckboxValuesotherValues
if (this.type === 'checkboxList') {
// checkbox
if (this.oldValue && Array.isArray(this.oldValue)) {
const uncheckedValues = this.oldValue.filter(oldVal => !this.inputValue.includes(oldVal));
// checkboxotherValues
if (uncheckedValues.length > 0) {
this.item.options.forEach(option => {
if (uncheckedValues.includes(option.value) && option.otherCode) {
this.$delete(this.otherValues, option.otherCode);
}
});
}
}
value = {
checkboxValues: this.inputValue,
otherValues: this.otherValues
};
this.onCommonHandleSaveRecord();
}
this.$emit('input', value); this.$emit('input', value);
this.$emit('change', value); this.$emit('change', value);
// //
const isEmpty = this.isValueEmpty(value); const isEmpty = this.isValueEmpty(value);
if (this.error && !isEmpty) { if (this.error && !isEmpty) {
@ -702,6 +748,11 @@ export default {
this.$emit('update:error', true); this.$emit('update:error', true);
} }
}, },
// checkboxListotherCode
onOtherInputChange(code, value) {
this.otherValues[code] = value;
this.onInputChange();
},
// //
onBlur(e) { onBlur(e) {
this.onCommonHandleSaveRecord(e.target.value); this.onCommonHandleSaveRecord(e.target.value);
@ -735,7 +786,6 @@ export default {
} }
}, },
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) {
this.$emit('update:error', false); this.$emit('update:error', false);
@ -780,7 +830,12 @@ export default {
} }
// //
const isSame = this.isEqual(this.oldValue, this.inputValue); const isSame = this.isEqual(this.oldValue, this.inputValue);
if (isSame) {
let isOtherValuesSame = true;
// checkboxListotherValues
if (this.type === 'checkboxList' && this.otherValues) {
isOtherValuesSame = this.isEqual(this.oldOtherValues, this.otherValues);
}
if (isSame && isOtherValuesSame) {
return; return;
} }
if (!this.isValueEmpty(this.oldValue) && !isSame && this.templateFillType === "actFill") { if (!this.isValueEmpty(this.oldValue) && !isSame && this.templateFillType === "actFill") {
@ -825,6 +880,11 @@ export default {
} }
// //
this.oldValue = this.inputValue; // this.oldValue = this.inputValue; //
// oldValueoldOtherValues
if (this.type === 'checkboxList') {
this.oldValue = [...this.inputValue];
this.oldOtherValues = { ...this.otherValues };
}
this.$emit("blur", this.inputValue); this.$emit("blur", this.inputValue);
this.$emit('input', this.inputValue); this.$emit('input', this.inputValue);
this.$emit("change", this.inputValue, data ? "save" : ""); this.$emit("change", this.inputValue, data ? "save" : "");
@ -1391,10 +1451,17 @@ export default {
.checkbox-item { .checkbox-item {
margin-right: 16px; margin-right: 16px;
display: flex;
align-items: center;
&:not(:last-child) { &:not(:last-child) {
margin-bottom: 10px; margin-bottom: 10px;
} }
// display: inline-block; // display: inline-block;
.el-input {
width: 200px;
margin-left: 10px;
}
} }
.el-checkbox { .el-checkbox {

+ 8
- 0
src/components/Template/mixins/formPackageMixins.js View File

@ -409,6 +409,14 @@ export default {
if (this.errors[key]) { if (this.errors[key]) {
this.$set(this.errors, key, false); this.$set(this.errors, key, false);
} }
// 如果是checkboxList类型,需要处理otherValues
if (val && typeof val === 'object' && val.otherValues) {
// 将otherValues中的每个值也保存到formFields中
Object.keys(val.otherValues).forEach(otherCode => {
this.formFields[otherCode] = val.otherValues[otherCode];
});
}
}, },
//复制 //复制
onCopy(config, key) { onCopy(config, key) {

+ 1
- 1
src/views/business/comps/template/formConfig/sp/SP0019.js View File

@ -139,7 +139,7 @@ export const getYqphFormConfig = () => {
options: [ options: [
{ label: '流动相平衡', value: 1 }, { label: '流动相平衡', value: 1 },
{ label: '样品平衡', value: 2 }, { label: '样品平衡', value: 2 },
{ label: '样品', value: 3 },
{ label: '样品', value: 3 ,otherCode:'ypOther'},
{ label: '未平衡', value: 4 } { label: '未平衡', value: 4 }
] ]
}, },

Loading…
Cancel
Save