diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue index ae84268..d383577 100644 --- a/src/views/modules/rohs/rohsRecord.vue +++ b/src/views/modules/rohs/rohsRecord.vue @@ -420,6 +420,7 @@ 上传附件 + + 保存 - 关闭 + 关闭 同意 驳回 @@ -844,6 +861,7 @@ { + if (val === 'attachmentInfo') { + this.refreshOssRef('modalAttachmentOss') + } + if (val === 'npdInfo') { + this.refreshOssRef('modalTdsOss') + } + }) + } + }, + uploadDialog (val, oldVal) { + if (oldVal && !val) { + this.$nextTick(() => { + this.refreshAttachmentPanels() + this.refreshCurrentRowFromServer(this.modalData.site, this.modalData.referenceNo) + }) + } + } + }, methods: { fetchNodeOptions () { if (!this.searchData.site || !this.menuId) { @@ -1797,39 +1838,94 @@ export default { }) }, changeClickRow (row, column, event) { - // 通过接口或直接赋值,让底部的页签显示当前选中行的数据 - api.getRohsDetail(row.site, row.referenceNo).then(({data}) => { - if (data && data.code === 0) { - this.currentRow = data.data || {} - } else { - this.currentRow = row || {} - } - if (!Array.isArray(this.currentRow.materialList)) { - this.$set(this.currentRow, 'materialList', []) - } - this.fillDisplayFields(this.currentRow, row || {}) - this.refreshCurrentTabTable() - }).catch(() => { - this.currentRow = row || {} - if (!Array.isArray(this.currentRow.materialList)) { - this.$set(this.currentRow, 'materialList', []) - } - this.fillDisplayFields(this.currentRow) - this.refreshCurrentTabTable() - }) + this.loadCurrentRowFromServer(row, row || {}) }, currentChange (val) { - this.currentRow = val || {} if (val) { - if (!Array.isArray(this.currentRow.materialList)) { - this.$set(this.currentRow, 'materialList', []) - } - this.fillDisplayFields(this.currentRow) - this.refreshCurrentTabTable() + this.loadCurrentRowFromServer(val, val || {}) } else { + this.currentRow = {} this.approvalList = [] } }, + applyCurrentRowData (detailData, fallbackData = {}) { + this.currentRow = detailData || {} + if (!Array.isArray(this.currentRow.materialList)) { + this.$set(this.currentRow, 'materialList', []) + } + this.fillDisplayFields(this.currentRow, fallbackData || {}) + this.syncDataListRow(this.currentRow) + this.refreshCurrentTabTable() + }, + syncDataListRow (rowData) { + if (!rowData || !rowData.site || !rowData.referenceNo || !Array.isArray(this.dataList)) { + return + } + const targetIndex = this.dataList.findIndex(item => item.site === rowData.site && item.referenceNo === rowData.referenceNo) + if (targetIndex < 0) { + return + } + const mergedRow = { + ...this.dataList[targetIndex], + ...rowData + } + this.fillDisplayFields(mergedRow, this.dataList[targetIndex] || {}) + this.$set(this.dataList, targetIndex, mergedRow) + }, + loadCurrentRowFromServer (row, fallbackData = {}) { + if (!row || !row.site || !row.referenceNo) { + this.applyCurrentRowData(row || {}, fallbackData || {}) + return Promise.resolve() + } + return api.getRohsDetail(row.site, row.referenceNo).then(({data}) => { + if (data && data.code === 0 && data.data) { + this.applyCurrentRowData(data.data, fallbackData || row) + } else { + this.applyCurrentRowData(row || {}, fallbackData || {}) + } + }).catch(() => { + this.applyCurrentRowData(row || {}, fallbackData || {}) + }) + }, + refreshCurrentRowFromServer (site, referenceNo) { + const querySite = site || (this.currentRow && this.currentRow.site) + const queryReferenceNo = referenceNo || (this.currentRow && this.currentRow.referenceNo) + if (!querySite || !queryReferenceNo || String(queryReferenceNo).startsWith('TEMP-')) { + return Promise.resolve() + } + return this.loadCurrentRowFromServer({ + site: querySite, + referenceNo: queryReferenceNo + }, this.currentRow || {}) + }, + refreshOssRef (refName) { + const ref = this.$refs[refName] + if (!ref) { + return + } + const refList = Array.isArray(ref) ? ref : [ref] + refList.forEach(item => { + if (item && typeof item.handleQuery === 'function') { + item.handleQuery() + } + }) + }, + refreshAttachmentPanels () { + this.refreshOssRef('modalAttachmentOss') + this.refreshOssRef('modalTdsOss') + this.refreshOssRef('bottomAttachmentOss') + this.refreshOssRef('bottomTdsOss') + }, + handleModalClose () { + const site = this.modalData.site + const referenceNo = this.modalData.referenceNo + this.modalFlag = false + this.uploadDialog = false + this.$nextTick(() => { + this.refreshAttachmentPanels() + }) + this.refreshCurrentRowFromServer(site, referenceNo) + }, fillDisplayFields (target, fallbackData = {}) { if (!target) { return @@ -1853,6 +1949,14 @@ export default { refreshCurrentTabTable () { if (this.activeTable === 'approvalInformation') { this.getApprovalList() + return + } + if (this.activeTable === 'attachment') { + this.refreshOssRef('bottomAttachmentOss') + return + } + if (this.activeTable === 'npdInfo') { + this.refreshOssRef('bottomTdsOss') } }, getApprovalList () {