diff --git a/src/views/modules/project/projectInfo/com_project_info_part.vue b/src/views/modules/project/projectInfo/com_project_info_part.vue index 7da5344..a6bf9f6 100644 --- a/src/views/modules/project/projectInfo/com_project_info_part.vue +++ b/src/views/modules/project/projectInfo/com_project_info_part.vue @@ -2917,8 +2917,8 @@ import CodeGeneration from "../../code/generation.vue"; this.modalData.partItemInfoFlag = this.partItemInfoFlag partInformationEdit2(this.modalData).then(({data}) => { if (data && data.code === 0) { - this.searchTable() this.modalFlag = false + this.onProjectPartAdded(false) this.$message({ message: '操作成功', type: 'success', diff --git a/src/views/modules/project/projectInfo/projectInfo.vue b/src/views/modules/project/projectInfo/projectInfo.vue index 6543845..5767cd9 100644 --- a/src/views/modules/project/projectInfo/projectInfo.vue +++ b/src/views/modules/project/projectInfo/projectInfo.vue @@ -249,7 +249,7 @@ - + @@ -1652,11 +1652,19 @@ // 导出 end // 获取数据列表 search2 (projectId) { - this.searchData.projectId = projectId - this.search() + this.refreshDataListKeepFilter(projectId) }, - search () { + refreshDataListKeepFilter (projectId) { + const keepProjectId = projectId || (this.currentRow && this.currentRow.projectId) + if (this.isFilterSearch) { + this.projectInfoSearchByAnyField(this.filterSearchData, keepProjectId) + return + } + this.search(keepProjectId, true) + }, + + search (keepProjectId, keepFilter) { this.searchData.limit = this.pageSize this.searchData.page = this.pageIndex this.searchData.userId = this.$store.state.user.id @@ -1667,13 +1675,59 @@ this.pageIndex = data.page.currPage this.pageSize = data.page.pageSize this.totalPage = data.page.totalCount - if(this.dataList1.length>0){ - this.$refs.mainTable.setCurrentRow(this.dataList1[0]); - this.changeData(this.dataList1[0]) - } + this.applyCurrentListRow(keepProjectId) } this.dataListLoading = false - this.isFilterSearch = false + if (!keepFilter) { + this.isFilterSearch = false + } + }) + }, + applyCurrentListRow (projectId) { + if (!this.dataList1 || !this.dataList1.length) { + return + } + const matched = projectId + ? this.dataList1.find(item => item.projectId === projectId) + : null + const row = matched || this.dataList1[0] + this.$nextTick(() => { + if (this.$refs.mainTable) { + this.$refs.mainTable.setCurrentRow(row) + } + this.changeData(row) + }) + }, + refreshProjectProductCategory () { + const current = this.currentRow || this.projectData + if (!current || !current.projectId) { + return + } + const query = { + site: current.site, + projectId: current.projectId, + page: 1, + limit: 1, + menuId: this.menuId, + userName: this.$store.state.user.name, + userId: this.$store.state.user.id + } + projectInfoSearch(query).then(({data}) => { + if (data.code !== 0 || !data.page || !Array.isArray(data.page.list) || data.page.list.length === 0) { + return + } + const latest = data.page.list.find(item => item.projectId === current.projectId && item.site === current.site) || data.page.list[0] + const productCategory = latest.productCategory + const target = (this.dataList1 || []).find(item => item.projectId === current.projectId && item.site === current.site) + if (target) { + this.$set(target, 'productCategory', productCategory) + } + if (this.currentRow && this.currentRow.projectId === current.projectId) { + this.$set(this.currentRow, 'productCategory', productCategory) + } + if (this.projectData && this.projectData.projectId === current.projectId) { + this.$set(this.projectData, 'productCategory', productCategory) + } }) }, //单击切换订单 @@ -2456,7 +2510,7 @@ }).catch(() => {}) }, - projectInfoSearchByAnyField(params){ + projectInfoSearchByAnyField(params, keepProjectId){ params.no = this.pageIndex params.size = this.pageSize params.site = this.$store.state.user.site @@ -2466,6 +2520,9 @@ if (data && data.code === 0){ this.dataList1 = data.page.list this.totalPage = data.page.totalCount + if (keepProjectId) { + this.applyCurrentListRow(keepProjectId) + } }else { this.$message.warning(data.msg) } diff --git a/src/views/modules/project/projectInfo/projectInfoQuery.vue b/src/views/modules/project/projectInfo/projectInfoQuery.vue index 6c8eaf2..9c57e8b 100644 --- a/src/views/modules/project/projectInfo/projectInfoQuery.vue +++ b/src/views/modules/project/projectInfo/projectInfoQuery.vue @@ -231,7 +231,7 @@ :save-visible="false" :remove-visible="false"> - + @@ -938,6 +938,37 @@ this.isFilterSearch = false }) }, + refreshProjectProductCategory () { + const current = this.currentRow || this.projectData + if (!current || !current.projectId) { + return + } + const query = { + site: current.site, + projectId: current.projectId, + page: 1, + limit: 1, + userName: this.$store.state.user.name, + userId: this.$store.state.user.id + } + projectInfoSearchForQuery(query).then(({data}) => { + if (data.code !== 0 || !data.page || !Array.isArray(data.page.list) || data.page.list.length === 0) { + return + } + const latest = data.page.list.find(item => item.projectId === current.projectId && item.site === current.site) || data.page.list[0] + const productCategory = latest.productCategory + const target = (this.dataList1 || []).find(item => item.projectId === current.projectId && item.site === current.site) + if (target) { + this.$set(target, 'productCategory', productCategory) + } + if (this.currentRow && this.currentRow.projectId === current.projectId) { + this.$set(this.currentRow, 'productCategory', productCategory) + } + if (this.projectData && this.projectData.projectId === current.projectId) { + this.$set(this.projectData, 'productCategory', productCategory) + } + }) + }, //单击切换订单 changeData(row) { this.currentRow = JSON.parse(JSON.stringify(row));