diff --git a/nladmin-ui/src/views/wms/st/checkbill/CheckDialog.vue b/nladmin-ui/src/views/wms/st/checkbill/CheckDialog.vue index 3eb2c2d3..9b6bbef0 100644 --- a/nladmin-ui/src/views/wms/st/checkbill/CheckDialog.vue +++ b/nladmin-ui/src/views/wms/st/checkbill/CheckDialog.vue @@ -5,6 +5,7 @@ fullscreen :visible.sync="dialogVisible" @open="open" + @opened="relayout" @close="close" > @@ -78,6 +79,7 @@ { this.storlist = res.data }) check.getDtl({ 'check_id': this.form1.check_id }).then(res => { - this.form1.tableData = res.data + const dtlList = res.data || [] // 将明细变成不可编辑 - for (let i = 0; i < this.form1.tableData.length; i++) { - const row = this.form1.tableData[i] + dtlList.forEach(row => { row.edit = false if (row.status > '20') { row.edit = true } - this.$set(this.form1.tableData, i, row) + }) + // $set 保证 tableData 变化能触发表格重渲染 + this.$set(this.form1, 'tableData', dtlList) + this.dtlLoading = false + // 弹框内表格在过渡动画中算高度会得到 0,数据到了再重算一次布局 + this.$nextTick(this.relayout) + }).catch(() => { + this.dtlLoading = false + }) + }, + relayout() { + // el-table 在弹框/全屏弹框里首次渲染时列宽和高度可能算错,强制重算 + this.$nextTick(() => { + const table = this.$refs.table + if (table && table.doLayout) { + table.doLayout() } }) - this.$forceUpdate() }, close() { this.$emit('AddChanged') @@ -277,8 +300,24 @@ export default { } }, setForm(row) { + // 不能直接 this.form1 = row:列表行对象上没有 tableData 属性, + // 整体替换后 open() 里再给 tableData 赋值属于“新增属性”,Vue2 侦听不到, + // 明细接口返回时不会触发重渲染,表现为弹框打开了但明细空白。 + // 这里逐字段拷贝,保证 tableData 始终是 data 中已声明的响应式属性。 + this.form1 = { + check_id: row.check_id, + check_code: row.check_code, + stor_id: row.stor_id, + stor_code: row.stor_code || '', + stor_name: row.stor_name || '', + status: row.status, + dtl_num: row.dtl_num, + check_type: row.check_type, + remark: row.remark || '', + create_mode: row.create_mode, + tableData: [] + } this.dialogVisible = true - this.form1 = row }, bill_statusFormat(row, column) { return this.dict.label.CHECK_DTL_STATUS[row.status]