From 3dc2d1a0dc94aeb2f056197f4f3f5cc2a78a98df Mon Sep 17 00:00:00 2001 From: taozi <1362265981@qq.com> Date: Tue, 6 Jan 2026 14:46:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/firstOrder/outbound.js | 13 ++ .../components/batchSelectionDialog.vue | 4 +- .../components/consumableDialog.vue | 200 ++++++++++-------- .../firstOrder/components/needDialog.vue | 124 +++++++---- src/views/firstOrder/components/outDialog.vue | 26 ++- src/views/firstOrder/inbound.vue | 3 +- src/views/firstOrder/outbound.vue | 21 +- src/views/materials/index.vue | 5 +- .../secondOrder/components/outDialog.vue | 11 +- 9 files changed, 245 insertions(+), 162 deletions(-) diff --git a/src/api/firstOrder/outbound.js b/src/api/firstOrder/outbound.js index 9ada133..1938af4 100644 --- a/src/api/firstOrder/outbound.js +++ b/src/api/firstOrder/outbound.js @@ -85,4 +85,17 @@ export const editList = (oneOutStorageId) => { cryptoToken: false, cryptoData: false }) +} +export const getPutPurchaseList = (current, size, params) => { + return request({ + url: '/smartpark/oneOutStorageDetail/getOneOutStorageDetailList', + method: 'get', + params: { + ...params, + pageSize: size, + pageNum: current, + }, + cryptoToken: false, + cryptoData: false + }) } \ No newline at end of file diff --git a/src/views/firstOrder/components/batchSelectionDialog.vue b/src/views/firstOrder/components/batchSelectionDialog.vue index d1a9b74..375ca3a 100644 --- a/src/views/firstOrder/components/batchSelectionDialog.vue +++ b/src/views/firstOrder/components/batchSelectionDialog.vue @@ -38,8 +38,8 @@ - - + + diff --git a/src/views/firstOrder/components/consumableDialog.vue b/src/views/firstOrder/components/consumableDialog.vue index 2071594..4c4b9e4 100644 --- a/src/views/firstOrder/components/consumableDialog.vue +++ b/src/views/firstOrder/components/consumableDialog.vue @@ -35,7 +35,7 @@ export default { query: { type: "NY" }, loading: true, page: { - pageSize: 5, + pageSize: 10, currentPage: 1, total: 0, }, @@ -152,6 +152,7 @@ export default { rkTable: [], currentRow: null, allSelectedList: [], //存储所有勾选的数据 + isUpdatingSelection: false, // 修正:将此属性移到 data 中 } }, computed: { @@ -194,8 +195,8 @@ export default { handleTabClick() { this.loadTransactionData(); - }, + async loadTransactionData() { if (!this.currentRow) return; const params = { @@ -223,142 +224,155 @@ export default { this.loading = false; } }, + searchReset() { this.query = {}; this.onLoad(this.page); }, + searchChange(params, done) { this.query = params; this.page.currentPage = 1; this.onLoad(this.page, params); done(); }, + //勾选选中 - selectionChange(list) { - console.log("勾选选中", list) - const currentPageIds = this.data.map(item => item.id) - console.log(currentPageIds, "currentPageIds") - this.allSelectedList = this.allSelectedList.filter(item => !currentPageIds.includes(item.id)) - console.log(this.allSelectedList, '1') - this.allSelectedList.push(...list) - console.log('所有勾选数据:', this.allSelectedList) + selectionChange(selection) { + // 如果是程序自动更新选择状态,则不执行清理逻辑 + if (this.isUpdatingSelection) { + return; + } + + console.log("勾选选中", selection); + const currentPageIds = this.data.map(item => item.id); + console.log(currentPageIds, "currentPageIds"); + + // 从allSelectedList中移除当前页面的数据(因为当前页面的数据状态以selection为准) + this.allSelectedList = this.allSelectedList.filter(item => + !currentPageIds.includes(item.id) + ); + console.log(this.allSelectedList, '1'); + + // 将当前页面选中的数据添加到allSelectedList + this.allSelectedList.push(...selection); + console.log('所有勾选数据:', this.allSelectedList); }, + //点击确定 handleConfirm() { - console.log(6) - console.log(this.allSelectedList, 'chuan') - this.$emit("confirm", this.allSelectedList) + console.log(6); + console.log(this.allSelectedList, 'chuan'); + this.$emit("confirm", this.allSelectedList); }, + selectionClear() { - this.selectionList = []; - this.$refs.crud.toggleSelection(); + this.allSelectedList = []; // 清空所有选中的数据 + if (this.$refs.crud) { + this.$refs.crud.toggleSelection(); // 清空表格选择 + } }, + handleRowChange(row, index, data) { - // 切换页面保持勾选状态(仅保留有效行) + // 这个方法应该只处理行变化,分页勾选保持应该在 onLoad 中处理 + // 但为了保持当前页面勾选状态,我们保留此逻辑 this.$nextTick(() => { - const currentPageData = this.data - console.log(this.data,0) - this.$refs.crud.toggleAllSelection(false); + // 设置标志,表示正在程序化更新选择状态 + this.isUpdatingSelection = true; + + const currentPageData = this.data || []; + // 清除当前页面的选中状态 + this.$refs.crud.toggleSelection(); + + // 遍历当前页面的数据,检查是否在 allSelectedList 中 currentPageData.forEach((item) => { - // 仅勾选数量非0的行 - const isSelected = this.allSelectedList.some(selectedItem => - selectedItem.id === item.id && !(item.num === 0 || item.num === null || item.num === undefined || item.num === '') + const isSelected = this.allSelectedList.some(selectedItem => + selectedItem.id === item.id ); + // 如果该项已经被选中,则勾选它 if (isSelected) { this.$refs.crud.toggleRowSelection(item, true); } }); + + // 延迟重置标志 + setTimeout(() => { + this.isUpdatingSelection = false; + }, 100); }); }, - // handleRowChange(row, index, data) { - // // 切换页面要判断当前页面数据是否在已勾选的数据中,如果在则勾选,否则不勾选 - // this.$nextTick(() => { - // // 获取当前页面的所有数据 - // const currentPageData = this.data || []; - // // 清除当前页面的选中状态 - // this.$refs.crud.toggleAllSelection(false); - - // // 遍历当前页面的数据,检查是否在 allSelectedList 中 - // currentPageData.forEach((item, index) => { - // const isSelected = this.allSelectedList.some(selectedItem => - // selectedItem.id === item.id - // ); - // // 如果该项已经被选中,则勾选它 - // if (isSelected) { - // this.$refs.crud.toggleRowSelection(item, true); - // } - // }); - // }); - // }, - // currentChange(currentPage) { - // console.log(currentPage, 1); - // this.page.currentPage = currentPage; - // // 切换页面时重新加载数据,会触发 onLoad,从而调用 handleRowChange - // this.onLoad(this.page, this.query); - // }, - // onLoad(page, params = {}) { - // this.loading = true; - // console.log(this.query, 2); - // getList( - // page.currentPage, - // page.pageSize, - // Object.assign(params, this.query) - - // ).then((res) => { - // this.data = res.data.result.list; - // this.loading = false; - // this.page.total = res.data.result.total; - - // // 数据加载完成后,更新当前页面的勾选状态 - // this.$nextTick(() => { - // this.updateCurrentPageSelection(); - // }); - // }); - // this.loading = false; - // }, - // // 添加一个新方法来更新当前页面的选中状态 - // updateCurrentPageSelection() { - // if (!this.$refs.crud) return; - - // const currentPageData = this.data || []; - - // currentPageData.forEach((item) => { - // const isSelected = this.allSelectedList.some(selectedItem => - // selectedItem.id === item.id - // ); - - // if (isSelected) { - // this.$refs.crud.toggleRowSelection(item, true); - // } - // }); - // }, - + currentChange(currentPage) { - console.log(currentPage, 1) - this.handleRowChange() + console.log(currentPage, 1); this.page.currentPage = currentPage; + // 切换页面时重新加载数据,会触发 onLoad + this.onLoad(this.page, this.query); }, + sizeChange(pageSize) { this.page.pageSize = pageSize; + this.onLoad(this.page, this.query); }, + refreshChange() { this.onLoad(this.page, this.query); }, + onLoad(page, params = {}) { this.loading = true; - console.log(this.query, 2) + console.log(this.query, 2); getList( page.currentPage, page.pageSize, Object.assign(params, this.query) - ).then((res) => { - this.data = res.data.result.list + this.data = res.data.result.list; this.loading = false; this.page.total = res.data.result.total; - }) - this.loading = false; + + // 数据加载完成后,更新当前页面的勾选状态 + this.$nextTick(() => { + this.updateCurrentPageSelection(); + }); + }).catch(error => { + this.loading = false; + this.$message.error('加载数据失败: ' + error.message); + }); }, + + // 添加一个新方法来更新当前页面的选中状态 + updateCurrentPageSelection() { + if (!this.$refs.crud) return; + + // 设置标志,表示正在程序化更新选择状态 + this.isUpdatingSelection = true; + + const currentPageData = this.data || []; + + // 先清除所有选择 + this.$refs.crud.toggleSelection(); + + currentPageData.forEach((item) => { + const isSelected = this.allSelectedList.some(selectedItem => + selectedItem.id === item.id + ); + + if (isSelected) { + this.$refs.crud.toggleRowSelection(item, true); + } + }); + + // 延迟重置标志,确保选择状态已完全更新 + this.$nextTick(() => { + setTimeout(() => { + this.isUpdatingSelection = false; + }, 100); + }); + }, + + handleCancel() { + this.$emit('handleCloseDetail'); + } }, } @@ -375,4 +389,4 @@ export default { padding-right: 10px; overflow-x: hidden; } - + \ No newline at end of file diff --git a/src/views/firstOrder/components/needDialog.vue b/src/views/firstOrder/components/needDialog.vue index 4efd40e..9a9a2e1 100644 --- a/src/views/firstOrder/components/needDialog.vue +++ b/src/views/firstOrder/components/needDialog.vue @@ -1,59 +1,91 @@ diff --git a/src/views/firstOrder/components/outDialog.vue b/src/views/firstOrder/components/outDialog.vue index ca00c9d..ee6a4fb 100644 --- a/src/views/firstOrder/components/outDialog.vue +++ b/src/views/firstOrder/components/outDialog.vue @@ -88,7 +88,7 @@ - + - + -