diff --git a/src/views/modules/lab/labRecord.vue b/src/views/modules/lab/labRecord.vue index 9ea54a6..ad12d56 100644 --- a/src/views/modules/lab/labRecord.vue +++ b/src/views/modules/lab/labRecord.vue @@ -344,7 +344,7 @@
- + @@ -589,19 +589,99 @@ - + - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + + + + + +
+
+ +
+ + + + + +
+
+ +
+ + + + + + + + + + +
@@ -672,6 +752,9 @@ export default { height: 400, secondHeight: 200, currentRow: {}, + currentDetail: this.buildDefaultModalData(), + currentDetailLoading: false, + currentDetailRequestId: 0, nodeOptions: [], approvalList: [], plmLabAuthorityArr: [], @@ -1556,13 +1639,79 @@ export default { return { cursor: 'pointer' } }, changeClickRow (row) { - this.currentRow = row || {} - this.refreshCurrentTabTable() + this.handleCurrentRowChange(row) }, currentChange (row) { - this.currentRow = row || {} + this.handleCurrentRowChange(row) + }, + handleCurrentRowChange (row) { + const nextRow = row || {} + const prevSite = (this.currentRow && this.currentRow.site) || '' + const prevReferenceNo = (this.currentRow && this.currentRow.referenceNo) || '' + const nextSite = nextRow.site || '' + const nextReferenceNo = nextRow.referenceNo || '' + this.currentRow = nextRow + if (!nextSite || !nextReferenceNo) { + this.currentDetailRequestId += 1 + this.currentDetailLoading = false + this.currentDetail = this.buildDefaultModalData() + this.refreshCurrentTabTable() + return + } + if (prevSite !== nextSite || prevReferenceNo !== nextReferenceNo) { + this.loadCurrentDetail(nextRow) + } this.refreshCurrentTabTable() }, + loadCurrentDetail (row) { + if (!row || !row.site || !row.referenceNo) { + this.currentDetailRequestId += 1 + this.currentDetailLoading = false + this.currentDetail = this.buildDefaultModalData() + return + } + const requestId = this.currentDetailRequestId + 1 + this.currentDetailRequestId = requestId + this.currentDetailLoading = true + api.getLabDetail(row.site, row.referenceNo).then(({data}) => { + if (requestId !== this.currentDetailRequestId) { + return + } + if (data && data.code === 0) { + const detail = data.data || {} + const mergedDetail = { + ...this.buildDefaultModalData(), + ...row, + ...detail + } + this.fillDisplayFields(mergedDetail, row || {}) + this.$set(mergedDetail, 'propertyItemList', (detail.propertyItemList || []).map(item => this.normalizePropertyItem(item))) + this.$set(mergedDetail, 'testerList', this.normalizeTesterList(mergedDetail.tester)) + this.currentDetail = mergedDetail + } else { + const fallbackDetail = { + ...this.buildDefaultModalData(), + ...row + } + this.fillDisplayFields(fallbackDetail, row || {}) + this.currentDetail = fallbackDetail + } + }).catch(() => { + if (requestId !== this.currentDetailRequestId) { + return + } + const fallbackDetail = { + ...this.buildDefaultModalData(), + ...row + } + this.fillDisplayFields(fallbackDetail, row || {}) + this.currentDetail = fallbackDetail + }).finally(() => { + if (requestId === this.currentDetailRequestId) { + this.currentDetailLoading = false + } + }) + }, tabClick () { this.refreshCurrentTabTable() }, @@ -1596,6 +1745,9 @@ export default { this.dataList = [] this.totalPage = 0 this.currentRow = {} + this.currentDetailRequestId += 1 + this.currentDetail = this.buildDefaultModalData() + this.currentDetailLoading = false this.approvalList = [] return } @@ -1635,11 +1787,17 @@ export default { this.dataList = [] this.totalPage = 0 this.currentRow = {} + this.currentDetailRequestId += 1 + this.currentDetail = this.buildDefaultModalData() + this.currentDetailLoading = false this.approvalList = [] } this.dataListLoading = false }).catch(() => { this.currentRow = {} + this.currentDetailRequestId += 1 + this.currentDetail = this.buildDefaultModalData() + this.currentDetailLoading = false this.approvalList = [] this.dataListLoading = false }) @@ -2137,6 +2295,10 @@ export default {