diff --git a/src/components/Template/BaseInfoFormPcakge.vue b/src/components/Template/BaseInfoFormPcakge.vue index 1c90393..7a362cf 100644 --- a/src/components/Template/BaseInfoFormPcakge.vue +++ b/src/components/Template/BaseInfoFormPcakge.vue @@ -8,7 +8,7 @@ :key="key"> @@ -30,7 +30,7 @@
其他
-
@@ -56,11 +56,11 @@ @copy="onCopy(sItem, key)" @change="onSelectChange(key, $event)" />
-
-
@@ -83,13 +83,21 @@
其他
-
- + +
{{ formFields[sItem.subKey] }}
+
{{ formFields[sItem.subKey] }}
+
+
+ @@ -136,6 +144,15 @@ export default { immediate: true, deep: true, // 深度监听,以便检测嵌套对象变化 handler(v) { + if(v){ + this.handleFormField(); + } + } + }, + formConfig: { + immediate: true, + deep: true, // 深度监听,以便检测嵌套对象变化 + handler(v) { this.handleFormField(); } } @@ -146,6 +163,21 @@ export default { }, methods: { + onInputNumberChange(key, val){ + if(val === 0){ + this.formFields[key] = null; + return; + } + this.formFields[key] = val; + }, + updateFormField(key, value){ + this.formFields[key] = value; + }, + batchUpdateFormFields(data){ + Object.keys(data).forEach(key => { + this.formFields[key] = data[key]; + }) + }, handleClickable(sItem){ console.log(sItem) this.$emit("clickable",sItem) @@ -163,11 +195,12 @@ export default { return { label:"其他", fillType: sItem.fillType, + maxlength: sItem.otherMaxlength || 50, } }, getSubItem(sItem){ return { - label: sItem.label, + label: "", options: sItem.subOptions || [], fillType: sItem.subFillType || sItem.fillType, } @@ -182,7 +215,6 @@ export default { const result = {}; let config = {}; const { formConfig, formData, formFields } = this; - // 遍历配置 formConfig.forEach((item) => { if (item.config) { @@ -194,30 +226,13 @@ export default { const currentConfig = item.config[key]; let value = formData[key]; - // 处理多选下拉框的默认值,确保数组类型 - // if (currentConfig.type === 'select' && currentConfig.multiple) { - // if (!Array.isArray(value)) { - // // 转换为数组格式,确保兼容性 - // value = value ? [value] : []; - // } - // } - - // // 处理null/undefined值,保持一致性 - // if (value === null || value === undefined) { - // // 根据类型设置默认值 - // if (currentConfig.type === 'select' && currentConfig.multiple) { - // value = []; - // } else { - // value = ''; - // } - // } - // 如果formFields中已经有值,保持原值(用户输入或之前设置的值) if (formFields[key] !== null && formFields[key] !== undefined && formFields[key] !== ''&& typeof formFields[key] !== 'object' ) { + console.log(key,formData,formFields[key],"kkk") // 保留原值,不使用formData中的值 result[key] = formFields[key]; } else { @@ -276,9 +291,8 @@ export default { }) }, - onInput(key, val) { - this.formFields[key] = val; - this.$emit("input", { key, value: val }); + onBlur(key, val) { + this.$emit("blur", { key, value: val ,...this.formFields}); }, onSelectChange(key, val) { // 获取对应的配置 @@ -292,7 +306,6 @@ export default { // 单选情况 this.formFields[key] = val; // } - this.$emit("select", { key, value: val }); }, //复制 diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index a768751..9f14ea8 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -3,6 +3,7 @@
+ v-model="inputValue" @input="onInputChange" @change="onInputChange" /> - +
@@ -115,6 +119,12 @@ export default { this.$emit('input', value); this.$emit('change', value); }, + //判断是否显示复制按钮 + getIsShowCopyIcon(){ + const {copyFrom} = this.item; + const {templateStatus} = this.$store.state.template; + return copyFrom && templateStatus=== "actFill"; + }, //判断是否显示操作按钮 isShowHandle(){ const {fillType} = this.item; diff --git a/src/components/Template/Step.vue b/src/components/Template/Step.vue index 421571d..cd60912 100644 --- a/src/components/Template/Step.vue +++ b/src/components/Template/Step.vue @@ -11,19 +11,14 @@
步骤{{ index + 1 }} - - - + /> [] - } - }, - data() { - return { - stepTypes: [ +const stepTypes = [ { label: '容器选择', value: 'container' }, // { label: '离心', value: 'centrifuge' }, // { label: '自动称量', value: 'autoWeigh' }, @@ -89,7 +75,23 @@ export default { // { label: '静置开始', value: 'staticStart' }, // { label: '静置结束', value: 'staticEnd' }, // { label: '取板', value: 'takePlate' } - ], + ]; + +export default { + name: 'Step', + props: { + formData: { + type: Object, + default: () => ({stepData:[]}) + } + }, + data() { + return { + stepSelectConfig:{ + options: stepTypes, + fillType:"preFill", + placeholder:"请选择步骤类型" + }, steps: [], stepId: 1, componentMap: null @@ -121,6 +123,7 @@ export default { } }, components: { + HandleFormItem, ContainerStep, CentrifugeStep, AutoWeighStep, @@ -139,17 +142,17 @@ export default { TakePlateStep }, created() { - // 初始化步骤数据 - if (this.value && this.value.length > 0) { - this.steps = this.value.map((step) => ({ - id: this.stepId++, - type: step.type || '', - formData: step.formData || {} - })) - } else { - // 默认添加一个步骤 - this.addStep() - } + // // 初始化步骤数据 + // if (this.value && this.value.length > 0) { + // this.steps = this.value.map((step) => ({ + // id: this.stepId++, + // type: step.type || '', + // formData: step.formData || {} + // })) + // } else { + // // 默认添加一个步骤 + // this.addStep() + // } }, watch: { steps: { @@ -160,6 +163,18 @@ export default { }))) }, deep: true + }, + 'formData.stepData': { + handler(newVal) { + console.log('newVal', newVal) + if(!newVal || newVal.length === 0) return + this.steps = newVal.map((step) => ({ + id: this.stepId++, + type: step.type || '', + formData: step.formData || {} + })) + }, + deep: true } }, methods: { @@ -218,7 +233,7 @@ export default { type: step.type, ...step.formData })) - resolve(stepData) + resolve({stepData}) }) }, @@ -323,7 +338,7 @@ export default { .step-list { .step-item { - margin-bottom: 20px; + margin-top: 20px; border-radius: 6px; overflow: hidden; @@ -347,7 +362,6 @@ export default { } .step-content { - padding: 20px; display: flex; align-items: center; } diff --git a/src/components/Template/Table.vue b/src/components/Template/Table.vue index 3a0102f..0d678d4 100644 --- a/src/components/Template/Table.vue +++ b/src/components/Template/Table.vue @@ -1,33 +1,39 @@ \ No newline at end of file diff --git a/src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue b/src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue new file mode 100644 index 0000000..1f10457 --- /dev/null +++ b/src/views/business/comps/template/comps/sp/SWYPFXCBYPZB.vue @@ -0,0 +1,288 @@ + + + + + \ No newline at end of file diff --git a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue index 094f877..014c764 100644 --- a/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPFXRYPZB.vue @@ -2,30 +2,32 @@ - + \ No newline at end of file diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index 24f3ce9..77b6906 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -1,17 +1,56 @@ export default { + props: { + templateData: { + type: Object, + default: () => {}, + }, + }, + watch: { + templateData: { + immediate: true, + handler(v) { + if(v){ + let n = {...v}; + if(v.bdnr){ + n = {...n,...JSON.parse(v.bdnr)}; + } + this.formData = n; + this.setTemplateData(n); + } + } + } + }, data() { }, mounted() { - - this.setTemplateStatus("preFill") + + setTimeout(() => { + this.setConditionOptions( + [ + { label: "条件5", value: "1" }, + { label: "条件6", value: "2" }, + { label: "条件7", value: "3" }, + { label: "其他", value: "-1" }, + ] + ) + }, 1000); + this.setTemplateStatus("preFill"); // this.setTemplateStatus(this.fillType) }, + unmounted() { + this.setTemplateStatus(""); + this.setTemplateData({}); + }, methods: { setTemplateStatus(status) { this.$store.commit('template/SET_TEMPLATE_STATUS', status) - } + }, + setConditionOptions(options) { + this.$store.commit('template/SET_CONDITION_OPTIONS', options) + }, + }, } diff --git a/src/views/business/study/comp/tbbd/Xq.vue b/src/views/business/study/comp/tbbd/Xq.vue index 43e888d..29bde39 100644 --- a/src/views/business/study/comp/tbbd/Xq.vue +++ b/src/views/business/study/comp/tbbd/Xq.vue @@ -28,7 +28,7 @@ G