diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index 60e3b42..9ad7981 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -223,7 +223,6 @@ export default { methods: { //获取其他下拉框的配置 getOtherItem(sItem) { - console.log(sItem, "other sItem") return { label: sItem.otherLabel ? this.$t(sItem.otherLabel) : this.$t("template.common.other"), fillType: sItem.bodyFillType, diff --git a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue index f7fc5ed..bd71241 100644 --- a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue @@ -116,6 +116,14 @@ export default { console.log(v, "fillType") } }, + formData: { + immediate: true, + handler(v) { + if(v &&this.fillType === "actFill"){ + this.handleUpdateCode(); + } + } + } }, computed: { // 存储条件表单配置 @@ -160,6 +168,48 @@ export default { mounted() { }, methods: { + // 为指定的表单数据数组分配编号 + async assignNumbersToTableData(tableDataArray) { + if (!tableDataArray || tableDataArray.length === 0) { + return; + } + + // 检查表单数据中是否有任何一行的subTargetSolutionCode有值 + const hasAnyWithValue = tableDataArray.some(row => + row.subTargetSolutionCode && row.subTargetSolutionCode.trim() !== ''); + + // 如果没有任何一行有值,则为所有行分配编号 + if (!hasAnyWithValue) { + const length = tableDataArray.length; + const snList = await this.getLatestSn(length); + tableDataArray.forEach((row, idx) => { + row.subTargetSolutionCode = snList[idx] || ''; + }); + } + }, + + async handleUpdateCode() { + + // 检查paralleConfigs中的paralleTableFormData数组 + if (this.formData.paralleConfigs && this.formData.paralleConfigs.length > 0) { + for (let i = 0; i < this.formData.paralleConfigs.length; i++) { + const config = this.formData.paralleConfigs[i]; + if (config.stepTableFormData && config.stepTableFormData.length > 0) { + await this.assignNumbersToTableData(config.stepTableFormData); + } + } + } + + // 检查ladderConfigs中的ladderTableFormData数组 + if (this.formData.ladderConfigs && this.formData.ladderConfigs.length > 0) { + for (let i = 0; i < this.formData.ladderConfigs.length; i++) { + const config = this.formData.ladderConfigs[i]; + if (config.stepTableFormData && config.stepTableFormData.length > 0) { + await this.assignNumbersToTableData(config.stepTableFormData); + } + } + } + }, //新增平行配制 handleAddParalle() { // 初始化平行配制配置列表 diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index edd2fe0..48bf329 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -1,4 +1,5 @@ -import moment from 'moment' +import moment from 'moment'; +import { getLatestSn } from '@/api/template'; export default { dicts: [ 'business_pztj', @@ -121,6 +122,13 @@ export default { this.setTemplateData({}) }, methods: { + async getLatestSn(count = 1){ + const res = await getLatestSn({count}) + if(res.code === 200){ + return res.data; + } + return null + }, getResource() { return this.resource },