diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index 3c4ccaa..769b1fe 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -515,6 +515,7 @@ export default { }, // 根据行索引更新数据 updateDataSourceByRowIndex(rowIndex, data) { + console.log(rowIndex, data, "updateDataSourceByRowIndex") this.localDataSource[rowIndex] = { ...this.localDataSource[rowIndex], ...data }; this.localDataSource = [...this.localDataSource]; }, diff --git a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue index bd71241..0ba532f 100644 --- a/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue +++ b/src/views/business/comps/template/comps/sp/SWYPNBGZYZBB.vue @@ -169,46 +169,45 @@ export default { }, methods: { // 为指定的表单数据数组分配编号 - async assignNumbersToTableData(tableDataArray) { - if (!tableDataArray || tableDataArray.length === 0) { - return; - } + async assignNumbersToTableData(config) { + const configs = this.formData[config] - // 检查表单数据中是否有任何一行的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); + if (configs && configs.length > 0) { + for (let i = 0; i < configs.length; i++) { + const ref = config === "paralleConfigs" ? `paralleStepTableRef_${i}` : `ladderStepTableRef_${i}`; + const {stepTableFormData = []} = configs[i]; + if (stepTableFormData && stepTableFormData.length > 0) { + const tableDataArray = stepTableFormData; + // 检查表单数据中是否有任何一行的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) => { + this.$refs[ref][0]?.updateDataSourceByRowIndex(idx,{subTargetSolutionCode: length==1?snList:snList[idx]}); + }); + } } } } + + }, - // 检查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); + async handleUpdateCode() { + this.assignNumbersToTableData("paralleConfigs"); + this.assignNumbersToTableData("ladderConfigs"); + this.$nextTick(() => { + //通知后端保存数据 + const params = { + type: "fieldChanged", + newRecord: null, + resourceList: null, } - } - } + EventBus.$emit('onModifyRecord', params,) + }) }, //新增平行配制 handleAddParalle() { diff --git a/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js b/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js index 5a9eff9..f4c1166 100644 --- a/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js +++ b/src/views/business/comps/template/formConfig/paralleAndLadderConfig.js @@ -151,8 +151,8 @@ export const getParallelColumnsConfig = ($this) => { prop: 'targetSolutionCode', bodyType: 'select', bodyOptions: $this.getDictOptions('business_sp_nbgzy'), - subType: 'span', - subKey: 'subTargetSolutionCode', + bodySubType: 'span', + bodySubKey: 'subTargetSolutionCode', bodyFillType: 'preFill', width: 280 },