From e950c38ba82e5e6bc8b0c50c35e5dbb6a180165a Mon Sep 17 00:00:00 2001 From: 13404089107 <puwei@sinata.cn> Date: 星期二, 20 五月 2025 16:43:06 +0800 Subject: [PATCH] Merge branch 'main' of http://120.76.84.145:10101/gitblit/r/H5/leshan-laboratory --- laboratory/src/views/dataManagement/confirmation-sheet/components/add-test-item.vue | 41 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 39 insertions(+), 2 deletions(-) diff --git a/laboratory/src/views/dataManagement/confirmation-sheet/components/add-test-item.vue b/laboratory/src/views/dataManagement/confirmation-sheet/components/add-test-item.vue index bd4bbc6..a5bd4a2 100644 --- a/laboratory/src/views/dataManagement/confirmation-sheet/components/add-test-item.vue +++ b/laboratory/src/views/dataManagement/confirmation-sheet/components/add-test-item.vue @@ -49,6 +49,10 @@ dialogVisible: { type: Boolean, default: false + }, + editData: { + type: Object, + default: () => null } }, data() { @@ -59,7 +63,9 @@ termType: 1, termMethodCode: '', termMethod: '', - sampleRequire: '' + sampleRequire: '', + status: 1, + testId: '' }, rules: { termCode: [ @@ -83,17 +89,48 @@ } } }, + watch: { + dialogVisible(val) { + if (val && this.editData) { + // 编辑模式,回显数据 + this.$nextTick(() => { + this.form = { + ...this.editData, + termType: Number(this.editData.termType) // 确保termType是数字类型 + } + }) + } else if (!val) { + // 关闭对话框时重置表单 + this.resetForm() + } + } + }, methods: { submitForm() { this.$refs.form.validate((valid) => { if (valid) { - this.$emit('confirm', this.form) + // 提交前确保termType是数字类型 + const submitData = { + ...this.form, + termType: Number(this.form.termType) + } + this.$emit('confirm', submitData) this.resetForm() } }) }, resetForm() { this.$refs.form.resetFields() + this.form = { + termCode: '', + termName: '', + termType: 1, + termMethodCode: '', + termMethod: '', + sampleRequire: '', + status: 1, + testId: '' + } } } } -- Gitblit v1.7.1