From 3b448d4f61be464324bda86e2d351f59fba4121b Mon Sep 17 00:00:00 2001
From: taozi <1362265981@qq.com>
Date: Wed, 7 Jan 2026 16:29:04 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=BA=93=E5=87=BA=E5=BA=93?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/firstOrder/components/outDialog.vue | 42 +--
.../components/categoryDialog copy.vue | 262 ++++++++++++++++++
.../secondOrder/components/categoryDialog.vue | 135 ++++++---
.../secondOrder/components/outDialog.vue | 43 ++-
4 files changed, 419 insertions(+), 63 deletions(-)
create mode 100644 src/views/secondOrder/components/categoryDialog copy.vue
diff --git a/src/views/firstOrder/components/outDialog.vue b/src/views/firstOrder/components/outDialog.vue
index 67fc123..1abbc56 100644
--- a/src/views/firstOrder/components/outDialog.vue
+++ b/src/views/firstOrder/components/outDialog.vue
@@ -554,22 +554,26 @@ export default {
return department ? department.department : '';
},
//获取单条选择的物资名称列表
- async getMaterialList() {
- this.loading = true
- this.consumableVisible = false;
- try {
- if (this.sizeForm.optionType === "NY" && this.outDialogType !== 'details') {
- this.consumableVisible = true
- } else {
- const res = await getMaterialList({ optionType: this.sizeForm.optionType })
- this.materials = res.data.result
- }
- } catch (error) {
- this.$message.error("获取数据来源失败,请重试");
- } finally {
- this.loading = false;
- }
- },
+ async getMaterialList() {
+ this.loading = true
+ this.consumableVisible = false; // 默认先隐藏
+ try {
+ // 只在单项选择且是耐用品时才显示弹窗
+ if (this.sizeForm.optionType === "NY" &&
+ this.outDialogType !== 'details' &&
+ this.sizeForm.options === 2) {
+ this.consumableVisible = true
+ } else if (this.sizeForm.optionType === "YH" && this.outDialogType !== 'details') {
+ // 易耗品时获取物资列表
+ const res = await getMaterialList({ optionType: this.sizeForm.optionType })
+ this.materials = res.data.result
+ }
+ } catch (error) {
+ this.$message.error("获取数据来源失败,请重试");
+ } finally {
+ this.loading = false;
+ }
+},
// 处理物资选择变化
handleMaterialChange(row, index) {
this.sizeForm.inTableData[index].materialId = row.materialId
@@ -693,16 +697,16 @@ export default {
// 选项选择
radioChange() {
this.sizeForm.inTableData = []
- this.sizeForm.optionType = '';
- this.inBatchDialogVisible = false;
this.consumableVisible = false;
+ this.inBatchDialogVisible = false;
this.batchSelectionVisible = false;
+ this.sizeForm.optionType = '';
this.batchTableData = [];
if (this.sizeForm.options === 1) {
this.getQuarterList()
this.inBatchDialogVisible = true
this.inBatchForm.batchType = '',
- this.inBatchForm.department = ''
+ this.inBatchForm.department = ''
this.inBatchForm.optionType = ''
}
},
diff --git a/src/views/secondOrder/components/categoryDialog copy.vue b/src/views/secondOrder/components/categoryDialog copy.vue
new file mode 100644
index 0000000..a35a87f
--- /dev/null
+++ b/src/views/secondOrder/components/categoryDialog copy.vue
@@ -0,0 +1,262 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/secondOrder/components/categoryDialog.vue b/src/views/secondOrder/components/categoryDialog.vue
index c3d5c03..7857dae 100644
--- a/src/views/secondOrder/components/categoryDialog.vue
+++ b/src/views/secondOrder/components/categoryDialog.vue
@@ -33,12 +33,17 @@ export default {
departmentId: {
type: [String, Number],
default: ''
+ },
+ selectionData: {
+ type: Array,
+ default: () => []
}
},
data() {
return {
form: {},
selectionList: [],
+ newselection: [],
query: {},
loading: true,
page: {
@@ -139,17 +144,18 @@ export default {
},
data: [],
dialogLogVisible: false,
- transactionType: "YH", // 初始值改为YH(易耗品),匹配标签页name
+ transactionType: "YH",
tableData: [],
ckTable: [],
rkTable: [],
currentRow: null,
- allSelectedList: [], //存储所有勾选的数据
- isUpdatingSelection: false, // 修正:将此属性移到 data 中
+ allSelectedList: [],
+ isUpdatingSelection: false,
}
},
mounted() {
- // 页面初始化时调用易耗品接口
+ // 初始化时使用传入的selectionData
+ this.allSelectedList = [...this.selectionData];
this.onLoad(this.page);
},
methods: {
@@ -165,74 +171,141 @@ export default {
done();
},
+ // 更新当前页面的勾选状态
+ updateCurrentPageSelection() {
+ if (!this.$refs.crud || !this.data) return;
+
+ this.isUpdatingSelection = true;
+
+ const currentPageData = this.data || [];
+
+ // 先清除所有选择
+ this.$refs.crud.toggleSelection();
+
+ // 检查当前页面的数据中有哪些在 allSelectedList 中
+ 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);
+ });
+ },
+
//勾选选中
selectionChange(selection) {
- console.log("勾选选中", selection);
+ if (this.isUpdatingSelection) {
+ return;
+ }
+
+ console.log('当前选择:', selection)
+ console.log('当前页面数据:', this.data)
+ console.log('当前全部勾选:', this.allSelectedList)
+
+ // 获取当前页面的数据ID
const currentPageIds = this.data.map(item => item.id);
- this.allSelectedList = this.allSelectedList.filter(item =>
+
+ const otherPageSelected = this.allSelectedList.filter(item =>
!currentPageIds.includes(item.id)
);
- const selectionWithTwoInventoryId = selection.map(item => ({
+
+ const currentSelected = selection.map(item => ({
...item,
- twoInventoryId: item.twoInventoryId || item.id
+ twoInventoryId: item.id
}));
- this.allSelectedList.push(...selectionWithTwoInventoryId);
+
+ // 组合所有勾选数据
+ const combinedSelection = [
+ ...otherPageSelected, // 其他页面的数据
+ ...currentSelected // 当前页面新勾选的数据
+ ];
+
+ // 去重并更新 allSelectedList
+ this.allSelectedList = this.uniqueById(combinedSelection)
+
+ console.log('更新后的allSelectedList:', this.allSelectedList)
+ },
+
+ //去重
+ uniqueById(arr) {
+ const uniqueObj = {};
+ arr.forEach(item => {
+ if (item.id && !uniqueObj[item.id]) {
+ uniqueObj[item.id] = item;
+ }
+ });
+ return Object.values(uniqueObj);
},
+
//点击确定
handleConfirm() {
- this.$emit("confirm", this.allSelectedList);
+ const uniqueList = this.uniqueById(this.allSelectedList)
+ this.$emit("confirm", uniqueList)
},
+
handleCloseDetail() {
this.$emit('handleCloseDetail')
},
+
selectionClear() {
- this.allSelectedList = []; // 清空所有选中的数据
+ this.allSelectedList = []
if (this.$refs.crud) {
- this.$refs.crud.toggleSelection(); // 清空表格选择
+ this.$refs.crud.toggleSelection()
}
},
+
currentChange(currentPage) {
this.page.currentPage = currentPage;
- this.onLoad(this.page, this.query);
+ this.onLoad(this.page, this.query)
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
- this.onLoad(this.page, this.query);
+ this.onLoad(this.page, this.query)
},
-
+
refreshChange() {
- this.onLoad(this.page, this.query);
+ this.onLoad(this.page, this.query)
},
-
- // 切换标签页时触发
+
handleTabClick() {
- // 切换标签后重置页码为第1页,重新加载对应类型数据
- this.page.currentPage = 1;
- this.onLoad(this.page);
- // 清空当前页的勾选状态(可选,根据业务需求)
- this.selectionClear();
+ this.page.currentPage = 1
+ this.onLoad(this.page)
},
-
-
+
onLoad(page, params = {}) {
- this.loading = true;
+ this.loading = true
const requestParams = Object.assign({}, params, this.query, {
num: 0,
departmentId: this.departmentId
});
const apiPromise = this.transactionType === "YH"
? getList(page.currentPage, page.pageSize, requestParams)
- : fetchDurableApi(page.currentPage, page.pageSize, requestParams);
+ : fetchDurableApi(page.currentPage, page.pageSize, requestParams)
apiPromise.then((res) => {
- this.data = res.data.result.list;
- this.page.total = res.data.result.total;
+ this.data = res.data.result.list
+ this.page.total = res.data.result.total
+
+ // 数据加载完成后,更新当前页面的勾选状态
+ this.$nextTick(() => {
+ this.updateCurrentPageSelection()
+ });
}).catch(error => {
- this.$message.error('加载数据失败: ' + error.message);
+ this.$message.error('加载数据失败: ' + error.message)
}).finally(() => {
this.loading = false;
- });
+ })
},
+
handleCancel() {
this.categoryVisible = false
}
diff --git a/src/views/secondOrder/components/outDialog.vue b/src/views/secondOrder/components/outDialog.vue
index 5ed1ba2..bdd1459 100644
--- a/src/views/secondOrder/components/outDialog.vue
+++ b/src/views/secondOrder/components/outDialog.vue
@@ -79,7 +79,7 @@
{{ scope.row.materialName }}
- -->
+ -->
@@ -135,7 +135,7 @@
确 定
-
@@ -201,6 +201,8 @@ export default {
outDialogVisible: false,
categoryVisible: false,
categoryDialogTitle: '出库',
+ allSelectedList:[],
+ selectionData:[],
sizeForm: {
ldTwoOutStorage: {
outDate: "",
@@ -280,17 +282,32 @@ export default {
this.categoryVisible = true
},
confirm(allSelectedList) {
+ console.log('allSelectedList-------',allSelectedList)
+ // this.selectionData = allSelectedList
+ allSelectedList.map(item =>{
+ this.selectionData.push(item)
+ })
this.categoryVisible = false;
- const formattedList = allSelectedList.map(item => ({
- ...item,
- // oldNum: item.num ,
- // newNum: item.num ,
- num: item.type === "NY" ? 1 : item.num // 耐用品默认1,易耗品可选
- }));
- this.sizeForm.ldTwoOutStorageDetailList = formattedList;
- this.sizeForm.inAccountsTableData = JSON.parse(JSON.stringify(formattedList));
+ // 去重:过滤已存在的物资
+ const newItems = allSelectedList.filter(newItem =>
+ !this.sizeForm.ldTwoOutStorageDetailList.some(
+ oldItem => oldItem.id === newItem.id
+ )
+ );
+ // 追加数据
+ this.sizeForm.ldTwoOutStorageDetailList = [
+ ...this.sizeForm.ldTwoOutStorageDetailList,
+ ...newItems
+ ];
+ console.log('ldTwoOutStorageDetailList--------',this.sizeForm.ldTwoOutStorageDetailList)
+ // 同步库存汇总表
+ this.summaryTableData();
},
- // 删除表格行数据
+ categoryHandle() {
+ this.categoryVisible = true;
+
+ },
+ // 删除表格行数据
handleDelete(index, row) {
this.sizeForm.ldTwoOutStorageDetailList.splice(index, 1)
},
@@ -309,7 +326,7 @@ export default {
// this.$set(this.sizeForm.inAccountsTableData, index, currentRow)
// this.sizeForm.inAccountsTableData[index] = currentRow
// },
- handleQuantityChange(newValue, index) {
+ handleQuantityChange(newValue, index) {
const currentRow = this.sizeForm.ldTwoOutStorageDetailList[index];
if (!currentRow) return;
if (currentRow.type === "NY") {
@@ -324,7 +341,7 @@ export default {
currentRow.newNum = stockNum - newValue // 出库后库存
this.$set(this.sizeForm.ldTwoOutStorageDetailList, index, currentRow)
this.$set(this.sizeForm.inAccountsTableData, index, { ...currentRow })
- },
+ },
// 更新全局总计
updateGlobalTotal() {