From 6382ce232afa4d60c305b3f16d04782c683fc7be Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 02 二月 2026 11:21:29 +0800
Subject: [PATCH] bug修改
---
src/views/safeProduction/hazardousMaterialsControl/index.vue | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/src/views/safeProduction/hazardousMaterialsControl/index.vue b/src/views/safeProduction/hazardousMaterialsControl/index.vue
index afc79b8..f4f30aa 100644
--- a/src/views/safeProduction/hazardousMaterialsControl/index.vue
+++ b/src/views/safeProduction/hazardousMaterialsControl/index.vue
@@ -244,9 +244,9 @@
</el-form>
<template #footer>
<span class="dialog-footer">
- <el-button @click="dialogVisible = false">鍙栨秷</el-button>
<el-button type="primary"
@click="submitForm">纭畾</el-button>
+ <el-button @click="dialogVisible = false">鍙栨秷</el-button>
</span>
</template>
</el-dialog>
@@ -258,9 +258,13 @@
<div>
<el-table :data="safeHazardList"
border
+ ref="safeHazardTableRef"
v-loading="safeHazardLoading"
- style="width: 100%"
- @row-click="handleSafeHazardSelect">
+ :selection="selectedSafeHazardIds"
+ @selection-change="handleSafeHazardSelectionChange"
+ style="width: 100%">
+ <el-table-column type="selection"
+ width="55" />
<el-table-column prop="code"
label="鍗遍櫓婧愮紪鐮�"
width="180"
@@ -302,6 +306,8 @@
</div>
<template #footer>
<span class="dialog-footer">
+ <el-button type="primary"
+ @click="handleSafeHazardSelect">纭畾</el-button>
<el-button @click="safeHazardSelectVisible = false">鍙栨秷</el-button>
</span>
</template>
@@ -541,11 +547,17 @@
}
};
const handleApplyQtyChange = () => {
+ if (Number(form.value.applyQty) < 0) {
+ ElMessage.error("棰嗙敤鏁伴噺涓嶈兘灏忎簬0");
+ form.value.applyQty = 0;
+ return;
+ }
if (form.value.applyQty > valueItem.value.stockQty) {
ElMessage.error("棰嗙敤鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺");
form.value.applyQty = "";
}
};
+ const selectedSafeHazardIds = ref([]);
// 寮�濮嬭嚜鍔ㄥ埛鏂�
const startAutoRefresh = () => {
@@ -580,7 +592,7 @@
const fetchSafeHazardList = () => {
safeHazardLoading.value = true;
return safeHazardListPage({
- page: safeHazardPage.value.current,
+ current: safeHazardPage.value.current,
size: safeHazardPage.value.size,
})
.then(res => {
@@ -592,12 +604,31 @@
});
};
- const handleSafeHazardSelect = item => {
+ const handleSafeHazardSelectionChange = selection => {
+ // 鍙繚鐣欐渶鍚庝竴涓�変腑鐨勯」
+ if (selection.length > 1) {
+ const lastSelected = selection[selection.length - 1];
+ selectedSafeHazardIds.value = [lastSelected];
+ proxy.$refs.safeHazardTableRef.clearSelection();
+ proxy.$refs.safeHazardTableRef.toggleRowSelection(lastSelected, true);
+ } else if (selection.length === 1) {
+ selectedSafeHazardIds.value = [selection[0]];
+ } else {
+ selectedSafeHazardIds.value = [];
+ }
+ };
+
+ const handleSafeHazardSelect = () => {
+ if (!selectedSafeHazardIds.value.length) {
+ ElMessage.error("璇烽�夋嫨涓�涓嵄闄╂簮");
+ return;
+ }
+
valueItem.value = {
- ...item,
+ ...selectedSafeHazardIds.value[0],
};
valueItem.value.type = getTypeLabel(valueItem.value.type);
- form.value.safeHazardId = item.id;
+ form.value.safeHazardId = selectedSafeHazardIds.value[0].id;
safeHazardSelectVisible.value = false;
};
@@ -616,7 +647,15 @@
// 閫夋嫨鍙樺寲澶勭悊
const handleSelectionChange = selection => {
- selectedIds.value = selection.map(item => item.id);
+ // 涓昏〃鏍间篃鍙繚鐣欐渶鍚庝竴涓�変腑鐨勯」
+ if (selection.length > 1) {
+ const lastSelected = selection[selection.length - 1];
+ selectedIds.value = [lastSelected.id];
+ } else if (selection.length === 1) {
+ selectedIds.value = [selection[0].id];
+ } else {
+ selectedIds.value = [];
+ }
};
// 鎵撳紑琛ㄥ崟
@@ -741,7 +780,7 @@
.catch(err => {
ElMessage.error(err.msg);
});
- } else {
+ } else if (dialogType.value === "edit") {
await formRef1.value.validate();
safeHazardRecordUpdate({ ...form.value })
.then(res => {
@@ -754,6 +793,9 @@
.catch(err => {
ElMessage.error(err.msg);
});
+ } else if (dialogType.value === "view") {
+ // 鏌ョ湅妯″紡涓嬩笉鎻愪氦琛ㄥ崟
+ dialogVisible.value = false;
}
} catch (error) {
console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
--
Gitblit v1.9.3