diff --git a/src/views/modules/lab/labRecord.vue b/src/views/modules/lab/labRecord.vue index 114ea68..dfb07ed 100644 --- a/src/views/modules/lab/labRecord.vue +++ b/src/views/modules/lab/labRecord.vue @@ -1059,14 +1059,62 @@ export default { mounted () { this.fetchNodeOptions() if (this.authSearch) { - this.getDataList() + this.handleRouteQuery() } this.$nextTick(() => { this.height = window.innerHeight / 2 - 30 this.secondHeight = window.innerHeight / 2 - 186 }) }, + activated () { + this.handleRouteQuery() + }, methods: { + resolveRouteReferenceNo () { + const routeParams = this.$route.params || {} + const routeQuery = this.$route.query || {} + const referenceNo = routeParams.referenceNo || routeParams.labNo || routeParams.docNo || routeParams.documentNo || + routeQuery.referenceNo || routeQuery.labNo || routeQuery.docNo || routeQuery.documentNo || '' + return String(referenceNo || '').trim() + }, + handleRouteQuery () { + if (!this.authSearch) { + return + } + const routeParams = this.$route.params || {} + const isTokenLogin = routeParams.type === 'tokenLogin' + const referenceNo = this.resolveRouteReferenceNo() + if (isTokenLogin) { + if (!referenceNo) { + this.getDataList() + return + } + if (this.modalFlag && String(this.modalData.referenceNo || '').trim() === referenceNo) { + return + } + this.searchData.referenceNo = referenceNo + this.getDataList().then((rows) => { + const rowList = Array.isArray(rows) ? rows : (this.dataList || []) + if (!rowList.length) { + if (this.$refs.labTable) { + this.$refs.labTable.setCurrentRow() + } + return + } + this.$nextTick(() => { + if (this.$refs.labTable) { + this.$refs.labTable.setCurrentRow(rowList[0]) + } + this.addOrUpdateHandle(rowList[0], true) + }) + }) + return + } + if (referenceNo) { + this.searchData.referenceNo = referenceNo + } + this.getDataList() + }, buildDefaultPropertyChooseData () { const currentSite = this.modalData && this.modalData.site ? this.modalData.site : this.$store.state.user.site return { @@ -2153,7 +2201,7 @@ export default { this.currentTestReportFileList = [] this.approvalList = [] this.isFilterSearch = false - return + return Promise.resolve([]) } this.dataListSelections = [] this.dataListLoading = true @@ -2167,7 +2215,8 @@ export default { currentApprover: this.searchData.currentApprover, nodeId: this.searchData.nodeId } - api.getLabList(params).then(({data}) => { + this.isFilterSearch = false + return api.getLabList(params).then(({data}) => { if (data && data.code === 0) { const list = data.page.list || [] this.dataList = list.map(item => ({ @@ -2202,6 +2251,7 @@ export default { this.approvalList = [] } this.dataListLoading = false + return this.dataList }).catch(() => { this.dataListSelections = [] this.currentRow = {} @@ -2213,8 +2263,8 @@ export default { this.currentTestReportFileList = [] this.approvalList = [] this.dataListLoading = false + return [] }) - this.isFilterSearch = false }, sizeChangeHandle (val) { this.pageSize = val @@ -2372,12 +2422,12 @@ export default { this.modalData[field] = value } }, - addOrUpdateHandle (row) { - if (!row && !this.authUpdate) { + addOrUpdateHandle (row, forceOpen = false) { + if (!forceOpen && !row && !this.authUpdate) { this.$message.warning('没有新增权限') return } - if (row && !this.authUpdate && !this.authDataEntry) { + if (!forceOpen && row && !this.authUpdate && !this.authDataEntry) { this.$message.warning('没有编辑权限') return } diff --git a/src/views/modules/rohs/rohsRecord.vue b/src/views/modules/rohs/rohsRecord.vue index 4510819..96596a1 100644 --- a/src/views/modules/rohs/rohsRecord.vue +++ b/src/views/modules/rohs/rohsRecord.vue @@ -2191,7 +2191,7 @@ export default { mounted () { this.fetchNodeOptions() if (this.authSearch) { - this.getDataList() + this.handleRouteQuery() } this.$nextTick(() => { this.height = window.innerHeight / 2 - 30 @@ -2199,6 +2199,9 @@ export default { this.secondHeight = window.innerHeight / 2 - 186 }) }, + activated () { + this.handleRouteQuery() + }, watch: { activeName (val) { if (val === 'attachmentInfo' || val === 'npdInfo') { @@ -2229,6 +2232,51 @@ export default { } }, methods: { + resolveRouteReferenceNo () { + const routeParams = this.$route.params || {} + const routeQuery = this.$route.query || {} + const referenceNo = routeParams.referenceNo || routeParams.rohsNo || routeParams.docNo || routeParams.documentNo || + routeQuery.referenceNo || routeQuery.rohsNo || routeQuery.docNo || routeQuery.documentNo || '' + return String(referenceNo || '').trim() + }, + handleRouteQuery () { + if (!this.authSearch) { + return + } + const routeParams = this.$route.params || {} + const isTokenLogin = routeParams.type === 'tokenLogin' + const referenceNo = this.resolveRouteReferenceNo() + if (isTokenLogin) { + if (!referenceNo) { + this.getDataList() + return + } + if (this.modalFlag && String(this.modalData.referenceNo || '').trim() === referenceNo) { + return + } + this.searchData.referenceNo = referenceNo + this.getDataList().then((rows) => { + const rowList = Array.isArray(rows) ? rows : (this.dataList || []) + if (!rowList.length) { + if (this.$refs.rohsTable) { + this.$refs.rohsTable.setCurrentRow() + } + return + } + this.$nextTick(() => { + if (this.$refs.rohsTable) { + this.$refs.rohsTable.setCurrentRow(rowList[0]) + } + this.addOrUpdateHandle(rowList[0], true) + }) + }) + return + } + if (referenceNo) { + this.searchData.referenceNo = referenceNo + } + this.getDataList() + }, fetchNodeOptions () { if (!this.searchData.site || !this.menuId) { this.nodeOptions = [] @@ -3267,7 +3315,7 @@ export default { this.currentRow = {} this.approvalList = [] this.isFilterSearch = false - return + return Promise.resolve([]) } this.dataListLoading = true let params = { @@ -3283,7 +3331,8 @@ export default { ifsPartNo: this.searchData.ifsPartNo, materialDesc: this.searchData.materialDesc } - api.getRohsList(params).then(({data}) => { + this.isFilterSearch = false + return api.getRohsList(params).then(({data}) => { if (data && data.code === 0) { const list = data.page.list || [] this.dataList = list.map(item => { @@ -3328,13 +3377,14 @@ export default { this.approvalList = [] } this.dataListLoading = false + return this.dataList }).catch(() => { this.dataListSelections = [] this.currentRow = {} this.approvalList = [] this.dataListLoading = false + return [] }) - this.isFilterSearch = false }, // 分页 sizeChangeHandle (val) { @@ -3507,12 +3557,12 @@ export default { } }, // 新增 / 修改 - addOrUpdateHandle (row) { - if (!row && !this.authUpdate) { + addOrUpdateHandle (row, forceOpen = false) { + if (!forceOpen && !row && !this.authUpdate) { this.$message.warning('没有新增权限') return } - if (row && !this.authUpdate && !this.authDataEntry) { + if (!forceOpen && row && !this.authUpdate && !this.authDataEntry) { this.$message.warning('没有编辑权限') return }