fix:修复盘点页面问题
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
fullscreen
|
||||
:visible.sync="dialogVisible"
|
||||
@open="open"
|
||||
@opened="relayout"
|
||||
@close="close"
|
||||
>
|
||||
<el-card class="box-card" shadow="never">
|
||||
@@ -78,6 +79,7 @@
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="dtlLoading"
|
||||
:data="form1.tableData"
|
||||
style="width: 100%;"
|
||||
max-height="300"
|
||||
@@ -144,6 +146,7 @@ export default {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
add_flag: true,
|
||||
dtlLoading: false,
|
||||
nowrow: null,
|
||||
nowindex: '',
|
||||
storlist: [],
|
||||
@@ -173,23 +176,43 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
// 先清空,避免上一张单据的明细残留
|
||||
this.form1.tableData = []
|
||||
// 没有单据标识时不查询,否则后端会返回所有未删除盘点单的明细
|
||||
if (!this.form1.check_id) {
|
||||
return
|
||||
}
|
||||
this.dtlLoading = true
|
||||
// 查询原材料库的仓库
|
||||
crudStorattr.getStor({}).then(res => {
|
||||
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]
|
||||
|
||||
Reference in New Issue
Block a user