From 7ca3a710d5f8bab88efee23b971427f4c4c3c66b Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 29 一月 2026 10:54:14 +0800
Subject: [PATCH] 危险物料管控
---
src/api/safeProduction/hazardousMaterialsControl.js | 33 ++
src/views/safeProduction/hazardousMaterialsControl/index.vue | 889 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/views/safeProduction/dangerInvestigation/index.vue | 25 -
3 files changed, 931 insertions(+), 16 deletions(-)
diff --git a/src/api/safeProduction/hazardousMaterialsControl.js b/src/api/safeProduction/hazardousMaterialsControl.js
new file mode 100644
index 0000000..0f5557f
--- /dev/null
+++ b/src/api/safeProduction/hazardousMaterialsControl.js
@@ -0,0 +1,33 @@
+import request from "@/utils/request";
+
+export function safeHazardRecordListPage(query) {
+ return request({
+ url: "/safeHazardRecord/page",
+ method: "get",
+ params: query,
+ });
+}
+
+export function safeHazardRecordDel(ids) {
+ return request({
+ url: '/safeHazardRecord/' + ids,
+ method: 'delete',
+ data: ids
+ })
+}
+// 鏂板鍗遍櫓婧愬彴璐�
+export function safeHazardRecordAdd(query) {
+ return request({
+ url: '/safeHazardRecord/borrow',
+ method: 'post',
+ data: query
+ })
+}
+
+export function safeHazardRecordUpdate(query) {
+ return request({
+ url: '/safeHazardRecord/return',
+ method: 'put',
+ data: query
+ })
+}
\ No newline at end of file
diff --git a/src/views/safeProduction/dangerInvestigation/index.vue b/src/views/safeProduction/dangerInvestigation/index.vue
index eaa12bb..1878370 100644
--- a/src/views/safeProduction/dangerInvestigation/index.vue
+++ b/src/views/safeProduction/dangerInvestigation/index.vue
@@ -215,7 +215,7 @@
prop="createUser">
<el-select v-model="form.createUser"
placeholder="璇烽�夋嫨"
- @change="handleChange"
+ disabled
clearable>
<el-option v-for="item in userList"
:key="item.userId"
@@ -228,14 +228,13 @@
<el-form-item label="涓婃姤鏃堕棿锛�"
prop="createTime">
<el-date-picker style="width: 100%"
- readonly
+ disabled
v-model="form.createTime"
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
type="date"
placeholder="璇烽�夋嫨"
- clearable
- :disabled="operationType === 'view'" />
+ clearable />
</el-form-item>
</el-col>
</el-row>
@@ -263,8 +262,7 @@
format="YYYY-MM-DD"
type="date"
placeholder="璇烽�夋嫨"
- clearable
- :disabled="operationType === 'view'" />
+ clearable />
</el-form-item>
</el-col>
</el-row>
@@ -345,8 +343,7 @@
format="YYYY-MM-DD"
type="date"
placeholder="璇烽�夋嫨"
- clearable
- :disabled="operationType === 'view'" />
+ clearable />
</el-form-item>
</el-col>
</el-row>
@@ -586,12 +583,6 @@
customer: "",
});
- const handleChange = userId => {
- const selectedUser = userList.value.find(user => user.userId === userId);
- if (selectedUser) {
- form.value.createUserName = selectedUser.nickName;
- }
- };
const handleChange2 = userId => {
const selectedUser = userList.value.find(user => user.userId === userId);
if (selectedUser) {
@@ -722,8 +713,8 @@
hiddenCode: "", // 闅愭偅缂栧彿
location: "", // 闅愭偅浣嶇疆
hiddenDesc: "", // 闅愭偅鎻忚堪
- createUser: "", // 涓婃姤浜�
- createUserName: "",
+ createUser: Number(currentUserId.value), // 涓婃姤浜�
+ createUserName: currentUserName.value,
createTime: dayjs().format("YYYY-MM-DD HH:mm:ss"), // 涓婃姤鏃堕棿
rectifyUserId: "", // 鏁存敼璐d换浜�
rectifyUserName: "",
@@ -952,9 +943,11 @@
});
};
const currentUserId = ref("");
+ const currentUserName = ref("");
const getCurrentFactoryName = async () => {
let res = await userStore.getInfo();
currentUserId.value = res.user.userId;
+ currentUserName.value = res.user.nickName;
};
/**
diff --git a/src/views/safeProduction/hazardousMaterialsControl/index.vue b/src/views/safeProduction/hazardousMaterialsControl/index.vue
new file mode 100644
index 0000000..63d9a5b
--- /dev/null
+++ b/src/views/safeProduction/hazardousMaterialsControl/index.vue
@@ -0,0 +1,889 @@
+<template>
+ <div class="app-container">
+ <div class="search_form">
+ <div>
+ <span class="search_title">鍗遍櫓婧愬悕绉帮細</span>
+ <el-input v-model="searchForm.name"
+ style="width: 240px"
+ placeholder="璇疯緭鍏ュ嵄闄╂簮鍚嶇О鎼滅储"
+ @change="handleQuery"
+ clearable
+ :prefix-icon="Search" />
+ <span class="search_title ml10">鍗遍櫓婧愮被鍨嬶細</span>
+ <el-select v-model="searchForm.type"
+ clearable
+ @change="handleQuery"
+ style="width: 240px">
+ <el-option v-for="item in knowledgeTypeOptions"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value" />
+ </el-select>
+ <el-button type="primary"
+ @click="handleQuery"
+ style="margin-left: 10px">
+ 鎼滅储
+ </el-button>
+ </div>
+ <div>
+ <el-button type="primary"
+ @click="openForm('add')">鍘婚鐢�</el-button>
+ <el-button type="danger"
+ plain
+ @click="handleDelete">鍒犻櫎</el-button>
+ </div>
+ </div>
+ <div class="table_list">
+ <PIMTable rowKey="id"
+ :column="tableColumn"
+ :tableData="tableData"
+ :page="page"
+ :isSelection="true"
+ @selection-change="handleSelectionChange"
+ :tableLoading="tableLoading"
+ @pagination="pagination1"
+ :total="page.total"></PIMTable>
+ </div>
+ <!-- 鏂板/缂栬緫鐭ヨ瘑寮圭獥 -->
+ <el-dialog v-model="dialogVisible"
+ :title="dialogTitle"
+ width="800px"
+ :close-on-click-modal="false">
+ <el-form ref="formRef"
+ v-if="dialogType === 'add'"
+ :model="form"
+ :rules="rules"
+ label-width="120px">
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="鍗遍櫓婧�"
+ prop="safeHazardId">
+ <el-input v-model="valueItem.name"
+ readonly
+ @click="openSafeHazardSelect"
+ placeholder="璇烽�夋嫨鍗遍櫓婧�" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鎵�鍦ㄤ綅缃�"
+ prop="location">
+ <el-input v-model="valueItem.location"
+ disabled
+ placeholder="鑷姩甯﹀嚭" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="鍗遍櫓婧愮被鍨�"
+ prop="type">
+ <el-input v-model="valueItem.type"
+ disabled
+ placeholder="鑷姩甯﹀嚭" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="椋庨櫓绛夌骇"
+ prop="riskLevel">
+ <el-input v-model="valueItem.riskLevel"
+ disabled
+ placeholder="鑷姩甯﹀嚭" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="搴撳瓨鏁伴噺"
+ prop="stockQty">
+ <el-input v-model="valueItem.stockQty"
+ disabled
+ placeholder="鑷姩甯﹀嚭" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="棰嗙敤鐢ㄩ��"
+ prop="applyPurpose">
+ <el-input v-model="form.applyPurpose"
+ placeholder="璇疯緭鍏ラ鐢ㄧ敤閫�" />
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="棰嗙敤鏁伴噺"
+ prop="applyQty">
+ <el-input v-model="form.applyQty"
+ type="number"
+ min="0"
+ @input="handleApplyQtyChange"
+ placeholder="璇疯緭鍏ラ鐢ㄦ暟閲�" />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="棰嗙敤浜�"
+ prop="applyUserId">
+ <el-select v-model="form.applyUserId"
+ disabled
+ placeholder="璇烽�夋嫨"
+ clearable>
+ <el-option v-for="item in userList"
+ :key="item.userId"
+ :label="item.nickName"
+ :value="item.userId" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="棰嗙敤鏃堕棿"
+ prop="applyTime">
+ <el-date-picker style="width: 100%"
+ disabled
+ v-model="form.applyTime"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ type="date"
+ placeholder="璇烽�夋嫨"
+ clearable />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <el-descriptions :column="2"
+ style="margin-bottom: 20px"
+ v-if="dialogType === 'edit' || dialogType === 'view'"
+ border>
+ <el-descriptions-item label="鍗遍櫓婧愮紪鐮�">
+ <span>{{ form.code }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item label="鍗遍櫓婧愬悕绉�">
+ <span>{{ form.name }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item label="鍗遍櫓婧愮被鍨�">
+ <span>{{ getTypeLabel(form.type) }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item label="鎵�鍦ㄤ綅缃�">
+ <span>{{ form.location }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item label="椋庨櫓绛夌骇">
+ <el-tag :type="getTypeTagType(form.riskLevel)">
+ {{ form.riskLevel }}
+ </el-tag>
+ </el-descriptions-item>
+ <el-descriptions-item label="棰嗙敤鐢ㄩ��">
+ <span>{{ form.applyPurpose }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item label="棰嗙敤鏃堕棿">
+ <span>{{ form.applyTime }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item label="棰嗙敤鏁伴噺">
+ <span>{{ form.applyQty }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item label="棰嗙敤浜�">
+ <span>{{ form.applyUserName }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item v-if="dialogType === 'view' && form.returnUserId"
+ label="褰掕繕浜�">
+ <span>{{ form.returnUserName }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item v-if="dialogType === 'view' && form.returnTime"
+ label="褰掕繕鏃堕棿">
+ <span>{{ form.returnTime }}</span>
+ </el-descriptions-item>
+ <el-descriptions-item v-if="dialogType === 'view' && form.returnUserId"
+ label="褰掕繕鎯呭喌璇存槑">
+ <span>{{ form.returnRemark }}</span>
+ </el-descriptions-item>
+ </el-descriptions>
+ <el-form ref="formRef1"
+ v-if="dialogType === 'edit'"
+ :model="form"
+ :rules="rules1"
+ label-width="120px">
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="褰掕繕浜�"
+ prop="returnUserId">
+ <el-select v-model="form.returnUserId"
+ disabled
+ placeholder="璇烽�夋嫨"
+ clearable>
+ <el-option v-for="item in userList"
+ :key="item.userId"
+ :label="item.nickName"
+ :value="item.userId" />
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="褰掕繕鏃堕棿"
+ prop="returnTime">
+ <el-date-picker style="width: 100%"
+ disabled
+ v-model="form.returnTime"
+ value-format="YYYY-MM-DD"
+ format="YYYY-MM-DD"
+ type="date"
+ placeholder="璇烽�夋嫨"
+ clearable />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-form-item label="褰掕繕鎯呭喌璇存槑"
+ prop="applyPurpose">
+ <el-input v-model="form.returnRemark"
+ type="textarea"
+ :rows="4"
+ placeholder="璇疯緭鍏ュ綊杩樻儏鍐佃鏄�" />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button @click="dialogVisible = false">鍙栨秷</el-button>
+ <el-button type="primary"
+ @click="submitForm">纭畾</el-button>
+ </span>
+ </template>
+ </el-dialog>
+ <!-- 鍗遍櫓婧愰�夋嫨寮圭獥 -->
+ <el-dialog v-model="safeHazardSelectVisible"
+ title="閫夋嫨鍗遍櫓婧�"
+ width="800px"
+ :close-on-click-modal="false">
+ <div>
+ <el-table :data="safeHazardList"
+ border
+ v-loading="safeHazardLoading"
+ style="width: 100%"
+ @row-click="handleSafeHazardSelect">
+ <el-table-column prop="code"
+ label="鍗遍櫓婧愮紪鐮�"
+ width="180"
+ show-overflow-tooltip />
+ <el-table-column prop="name"
+ label="鍗遍櫓婧愬悕绉�"
+ show-overflow-tooltip />
+ <el-table-column prop="type"
+ label="鍗遍櫓婧愮被鍨�"
+ width="120"
+ show-overflow-tooltip>
+ <template #default="scope">
+ {{ getTypeLabel(scope.row.type) }}
+ </template>
+ </el-table-column>
+ <el-table-column prop="location"
+ label="鎵�鍦ㄤ綅缃�"
+ width="180"
+ show-overflow-tooltip />
+ <el-table-column prop="riskLevel"
+ label="椋庨櫓绛夌骇"
+ width="100">
+ <template #default="scope">
+ <el-tag :type="getTypeTagType(scope.row.riskLevel)">
+ {{ scope.row.riskLevel }}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="stockQty"
+ label="搴撳瓨鏁伴噺"
+ width="100" />
+ </el-table>
+ <pagination :total="safeHazardPage.total"
+ style="margin-top: 20px"
+ layout="total, sizes, prev, pager, next, jumper"
+ :page="safeHazardPage.current"
+ :limit="safeHazardPage.size"
+ @pagination="safeHazardPagination" />
+ </div>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button @click="safeHazardSelectVisible = false">鍙栨秷</el-button>
+ </span>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script setup>
+ import { Search } from "@element-plus/icons-vue";
+ import {
+ onMounted,
+ ref,
+ reactive,
+ toRefs,
+ getCurrentInstance,
+ computed,
+ } from "vue";
+ import { ElMessage, ElMessageBox } from "element-plus";
+ import PIMTable from "@/components/PIMTable/PIMTable.vue";
+ import pagination from "@/components/PIMTable/Pagination.vue";
+ import { userListNoPage } from "@/api/system/user.js";
+ import { safeHazardListPage } from "@/api/safeProduction/hazardSourceLedger.js";
+ import {
+ safeHazardRecordListPage,
+ safeHazardRecordDel,
+ safeHazardRecordAdd,
+ safeHazardRecordUpdate,
+ } from "@/api/safeProduction/hazardousMaterialsControl.js";
+ import dayjs from "dayjs";
+ import useUserStore from "@/store/modules/user";
+ const userStore = useUserStore();
+ // 琛ㄥ崟楠岃瘉瑙勫垯
+ const rules = {
+ applyPurpose: [
+ { required: true, message: "璇疯緭鍏ラ鐢ㄧ敤閫�", trigger: "blur" },
+ ],
+ applyQty: [{ required: true, message: "璇疯緭鍏ラ鐢ㄦ暟閲�", trigger: "blur" }],
+ safeHazardId: [
+ { required: true, message: "璇烽�夋嫨鍗遍櫓婧�", trigger: "change" },
+ ],
+ };
+ const rules1 = {
+ returnRemark: [
+ { required: true, message: "璇疯緭鍏ュ綊杩樻儏鍐佃鏄�", trigger: "blur" },
+ ],
+ };
+ // 鍝嶅簲寮忔暟鎹�
+ const data = reactive({
+ searchForm: {
+ name: "",
+ type: "",
+ },
+ tableLoading: false,
+ page: {
+ current: 1,
+ size: 20,
+ total: 0,
+ },
+ tableData: [],
+ selectedIds: [],
+ form: {
+ applyPurpose: "", // 棰嗙敤鐢ㄩ��
+ applyTime: "", // 棰嗙敤鏃堕棿
+ applyQty: "", // 棰嗙敤鏁伴噺
+ applyUserId: "", // 棰嗙敤浜篒D
+ safeHazardId: "", // 鍗遍櫓婧怚D
+ },
+ dialogVisible: false,
+ dialogTitle: "",
+ dialogType: "add",
+ viewDialogVisible: false,
+ currentKnowledge: {},
+ safeHazardSelectVisible: false,
+ safeHazardList: [],
+ safeHazardLoading: false,
+ safeHazardPage: {
+ current: 1,
+ size: 10,
+ total: 0,
+ },
+ });
+
+ const {
+ searchForm,
+ tableLoading,
+ page,
+ tableData,
+ selectedIds,
+ form,
+ dialogVisible,
+ dialogTitle,
+ dialogType,
+ viewDialogVisible,
+ currentKnowledge,
+ safeHazardSelectVisible,
+ safeHazardList,
+ safeHazardLoading,
+ safeHazardPage,
+ } = toRefs(data);
+ const valueItem = ref({});
+
+ // 琛ㄥ崟寮曠敤
+ const formRef = ref();
+ const formRef1 = ref();
+ const riskLevelOptions = ref([
+ { value: "浣庨闄�", label: "浣庨闄�" },
+ { value: "涓�鑸闄�", label: "涓�鑸闄�" },
+ { value: "杈冨ぇ椋庨櫓", label: "杈冨ぇ椋庨櫓" },
+ { value: "閲嶅ぇ椋庨櫓", label: "閲嶅ぇ椋庨櫓" },
+ ]);
+
+ // 琛ㄦ牸鍒楅厤缃�
+ const tableColumn = ref([
+ {
+ label: "鍗遍櫓婧愮紪鐮�",
+ prop: "code",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "鍗遍櫓婧愬悕绉�",
+ prop: "name",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "鍗遍櫓婧愮被鍨�",
+ prop: "type",
+ showOverflowTooltip: true,
+ formatData: params => {
+ return getTypeLabel(params);
+ },
+ },
+ {
+ label: "椋庨櫓绛夌骇",
+ prop: "riskLevel",
+ showOverflowTooltip: true,
+ dataType: "tag",
+ formatType: params => {
+ const typeMap = {
+ 浣庨闄�: "info",
+ 涓�鑸闄�: "info",
+ 杈冨ぇ椋庨櫓: "warning",
+ 閲嶅ぇ椋庨櫓: "danger",
+ };
+ return typeMap[params] || "info";
+ },
+ },
+ {
+ label: "棰嗙敤鐢ㄩ��",
+ prop: "applyPurpose",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "棰嗙敤鏃堕棿",
+ prop: "applyTime",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "棰嗙敤鏁伴噺",
+ prop: "applyQty",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "褰掕繕鏃堕棿",
+ prop: "returnTime",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "褰掕繕浜�",
+ prop: "returnUserName",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "褰掕繕鎯呭喌璇存槑",
+ prop: "returnRemark",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "鎵�鍦ㄤ綅缃�",
+ prop: "location",
+ showOverflowTooltip: true,
+ },
+ {
+ label: "鍗曞彿",
+ prop: "materialRecordCode",
+ showOverflowTooltip: true,
+ },
+ {
+ dataType: "action",
+ label: "鎿嶄綔",
+ align: "center",
+ fixed: "right",
+ width: 200,
+ operation: [
+ {
+ name: "褰掕繕",
+ type: "text",
+ clickFun: row => {
+ openForm("edit", row);
+ },
+ disabled: row => row.returnUserId,
+ },
+ {
+ name: "鏌ョ湅",
+ type: "text",
+ clickFun: row => {
+ openForm("view", row);
+ },
+ },
+ ],
+ },
+ ]);
+ const userList = ref([]);
+ // 鐢熷懡鍛ㄦ湡
+ onMounted(() => {
+ getCurrentFactoryName();
+ getList();
+ startAutoRefresh();
+ userListNoPage().then(res => {
+ userList.value = res.data;
+ });
+ });
+ const currentUserId = ref("");
+ const currentUserName = ref("");
+ const getCurrentFactoryName = async () => {
+ let res = await userStore.getInfo();
+ currentUserId.value = res.user.userId;
+ currentUserName.value = res.user.nickName;
+ };
+
+ // 澶勭悊鐢ㄦ埛閫夋嫨鍙樺寲
+ const handleUserChange = userId => {
+ const selectedUser = userList.value.find(user => user.userId === userId);
+ if (selectedUser) {
+ form.value.principalUser = selectedUser.nickName;
+ form.value.principalMobile = selectedUser.phonenumber;
+ }
+ };
+ const handleApplyQtyChange = () => {
+ if (form.value.applyQty > valueItem.value.stockQty) {
+ ElMessage.error("棰嗙敤鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺");
+ form.value.applyQty = "";
+ }
+ };
+
+ // 寮�濮嬭嚜鍔ㄥ埛鏂�
+ const startAutoRefresh = () => {
+ setInterval(() => {
+ getList();
+ }, 600000); // 10鍒嗛挓鍒锋柊涓�娆� (10 * 60 * 1000 = 600000ms)
+ };
+
+ // 鏌ヨ鏁版嵁
+ const handleQuery = () => {
+ page.value.current = 1;
+ getList();
+ };
+
+ const getList = () => {
+ tableLoading.value = true;
+ safeHazardRecordListPage({ ...page.value, ...searchForm.value })
+ .then(res => {
+ tableLoading.value = false;
+ tableData.value = res.data.records;
+ page.value.total = res.data.total;
+ })
+ .catch(err => {
+ tableLoading.value = false;
+ });
+ };
+ const openSafeHazardSelect = async () => {
+ await fetchSafeHazardList();
+ safeHazardSelectVisible.value = true;
+ };
+
+ const fetchSafeHazardList = () => {
+ safeHazardLoading.value = true;
+ return safeHazardListPage({
+ page: safeHazardPage.value.current,
+ size: safeHazardPage.value.size,
+ })
+ .then(res => {
+ safeHazardList.value = res.data.records;
+ safeHazardPage.value.total = res.data.total;
+ })
+ .finally(() => {
+ safeHazardLoading.value = false;
+ });
+ };
+
+ const handleSafeHazardSelect = item => {
+ valueItem.value = {
+ ...item,
+ };
+ valueItem.value.type = getTypeLabel(valueItem.value.type);
+ form.value.safeHazardId = item.id;
+ safeHazardSelectVisible.value = false;
+ };
+
+ const safeHazardPagination = obj => {
+ safeHazardPage.value.current = obj.page;
+ safeHazardPage.value.size = obj.limit;
+ fetchSafeHazardList();
+ };
+
+ // 鍒嗛〉澶勭悊
+ const pagination1 = obj => {
+ page.value.current = obj.page;
+ page.value.size = obj.limit;
+ handleQuery();
+ };
+
+ // 閫夋嫨鍙樺寲澶勭悊
+ const handleSelectionChange = selection => {
+ selectedIds.value = selection.map(item => item.id);
+ };
+
+ // 鎵撳紑琛ㄥ崟
+ const openForm = (type, row = null) => {
+ dialogType.value = type;
+ if (type === "add") {
+ dialogTitle.value = "棰嗙敤鍗遍櫓婧�";
+ // 閲嶇疆琛ㄥ崟
+ form.value = {};
+ Object.assign(form.value, {
+ applyPurpose: "", // 棰嗙敤鐢ㄩ��
+ applyTime: dayjs().format("YYYY-MM-DD"), // 棰嗙敤鏃堕棿
+ applyQty: "", // 棰嗙敤鏁伴噺
+ applyUserId: currentUserId.value, // 棰嗙敤浜篒D
+ safeHazardId: "", // 鍗遍櫓婧怚D
+ });
+ valueItem.value = {};
+ } else if (type === "edit" && row) {
+ dialogTitle.value = "褰掕繕";
+ Object.assign(form.value, {
+ id: row.id, // 涓婚敭ID
+ materialRecordCode: row.materialRecordCode, // 鍗曞彿
+ applyPurpose: row.applyPurpose, // 棰嗙敤鐢ㄩ��
+ applyTime: row.applyTime, // 棰嗙敤鏃堕棿
+ applyQty: row.applyQty, // 棰嗙敤鏁伴噺
+ applyUserId: row.applyUserId, // 棰嗙敤浜篒D
+ safeHazardId: row.safeHazardId, // 鍗遍櫓婧怚D
+ applyUserName: row.applyUserName, // 棰嗙敤浜哄鍚�
+ code: row.code, // 鍗遍櫓婧愮紪鐮�
+ name: row.name, // 鍗遍櫓婧愬悕绉�
+ type: row.type, // 鍗遍櫓婧愮被鍨�
+ location: row.location, // 鎵�鍦ㄤ綅缃�
+ riskLevel: row.riskLevel, // 椋庨櫓绛夌骇
+ type: row.type, // 鍗遍櫓婧愮被鍨�
+ returnTime: dayjs().format("YYYY-MM-DD"), // 褰掕繕鏃堕棿
+ returnUserName: "", // 褰掕繕浜哄鍚�
+ returnUserId: currentUserId.value, // 褰掕繕浜篒D
+ returnRemark: "", // 褰掕繕鎯呭喌璇存槑
+ });
+ } else if (type === "view") {
+ dialogTitle.value = "鏌ョ湅";
+ form.value = { ...row };
+ }
+ dialogVisible.value = true;
+ };
+
+ // 鏌ョ湅鍗遍櫓婧愯鎯�
+ const viewKnowledge = row => {
+ currentKnowledge.value = { ...row };
+ viewDialogVisible.value = true;
+ };
+
+ // 鑾峰彇绫诲瀷鏍囩绫诲瀷
+ const getTypeTagType = type => {
+ const typeMap = {
+ 杈冨ぇ椋庨櫓: "warning",
+ 浣庨闄�: "info",
+ 涓�鑸闄�: "info",
+ 閲嶅ぇ椋庨櫓: "danger",
+ };
+ return typeMap[type] || "info";
+ };
+
+ // 鑾峰彇绫诲瀷鏍囩鏂囨湰
+ const getTypeLabel = type => {
+ return getKnowledgeTypeLabel(type);
+ };
+
+ // 鑾峰彇鏁堢巼鏍囩绫诲瀷
+ const getEfficiencyTagType = efficiency => {
+ const typeMap = {
+ high: "success",
+ medium: "warning",
+ low: "info",
+ };
+ return typeMap[efficiency] || "info";
+ };
+
+ // 鑾峰彇鏁堢巼鏍囩鏂囨湰
+ const getEfficiencyLabel = efficiency => {
+ const efficiencyMap = {
+ high: "鏄捐憲鎻愬崌",
+ medium: "涓�鑸彁鍗�",
+ low: "杞诲井鎻愬崌",
+ };
+ return efficiencyMap[efficiency] || efficiency;
+ };
+
+ // 鑾峰彇鏁堢巼鎻愬崌鐧惧垎姣�
+ const getEfficiencyScore = efficiency => {
+ const scoreMap = {
+ high: 40,
+ medium: 25,
+ low: 15,
+ };
+ return scoreMap[efficiency] || 0;
+ };
+
+ // 鑾峰彇骞冲潎鑺傜渷鏃堕棿
+ const getTimeSaved = efficiency => {
+ const timeMap = {
+ high: "2-3澶�",
+ medium: "1-2澶�",
+ low: "0.5-1澶�",
+ };
+ return timeMap[efficiency] || "鏈煡";
+ };
+
+ // 鎻愪氦鍗遍櫓婧愯〃鍗�
+ const submitForm = async () => {
+ try {
+ if (dialogType.value === "add") {
+ await formRef.value.validate();
+ safeHazardRecordAdd({ ...form.value })
+ .then(res => {
+ if (res.code == 200) {
+ ElMessage.success("娣诲姞鎴愬姛");
+ dialogVisible.value = false;
+ getList();
+ }
+ })
+ .catch(err => {
+ ElMessage.error(err.msg);
+ });
+ } else {
+ await formRef1.value.validate();
+ safeHazardRecordUpdate({ ...form.value })
+ .then(res => {
+ if (res.code == 200) {
+ ElMessage.success("鏇存柊鎴愬姛");
+ dialogVisible.value = false;
+ getList();
+ }
+ })
+ .catch(err => {
+ ElMessage.error(err.msg);
+ });
+ }
+ } catch (error) {
+ console.error("琛ㄥ崟楠岃瘉澶辫触:", error);
+ }
+ };
+
+ // 鍒犻櫎鍗遍櫓婧愯褰�
+ const handleDelete = () => {
+ if (selectedIds.value.length === 0) {
+ ElMessage.warning("璇烽�夋嫨瑕佸垹闄ょ殑璁板綍");
+ return;
+ }
+
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ // console.log(selectedIds.value);
+ safeHazardRecordDel(selectedIds.value).then(res => {
+ if (res.code == 200) {
+ ElMessage.success("鍒犻櫎鎴愬姛");
+ selectedIds.value = [];
+ getList();
+ }
+ });
+ })
+ .catch(() => {
+ // 鐢ㄦ埛鍙栨秷
+ });
+ };
+
+ // 瀵煎嚭
+ const { proxy } = getCurrentInstance();
+ const { hazard_source_type } = proxy.useDict("hazard_source_type");
+
+ // 瀛楀吀宸ュ叿
+ const knowledgeTypeOptions = computed(() => hazard_source_type?.value || []);
+ const getKnowledgeTypeLabel = val => {
+ const item = knowledgeTypeOptions.value.find(
+ i => String(i.value) === String(val)
+ );
+ return item ? item.label : val;
+ };
+ const getKnowledgeTypeTagType = val => {
+ const item = knowledgeTypeOptions.value.find(
+ i => String(i.value) === String(val)
+ );
+ return item?.elTagType || "info";
+ };
+ const handleExport = () => {
+ proxy.download(
+ "/knowledgeBase/export",
+ { ...searchForm.value },
+ "鐭ヨ瘑搴�.xlsx"
+ );
+ };
+</script>
+
+<style scoped>
+ .auto-refresh-info {
+ margin-bottom: 15px;
+ }
+
+ .auto-refresh-info .el-alert {
+ border-radius: 8px;
+ }
+
+ .dialog-footer {
+ text-align: right;
+ }
+
+ .knowledge-detail {
+ padding: 20px 0;
+ }
+
+ .detail-title {
+ font-size: 18px;
+ font-weight: bold;
+ color: #303133;
+ }
+
+ .detail-section {
+ margin-top: 24px;
+ }
+
+ .detail-section h4 {
+ margin: 0 0 12px 0;
+ font-size: 16px;
+ font-weight: 600;
+ color: #303133;
+ border-left: 4px solid #409eff;
+ padding-left: 12px;
+ }
+
+ .detail-content {
+ background: #f8f9fa;
+ padding: 16px;
+ border-radius: 6px;
+ line-height: 1.6;
+ color: #606266;
+ white-space: pre-wrap;
+ }
+
+ .key-points {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+ }
+
+ .usage-stats {
+ margin-top: 16px;
+ }
+
+ .stat-item {
+ text-align: center;
+ padding: 20px;
+ background: #f8f9fa;
+ border-radius: 8px;
+ }
+
+ .stat-number {
+ font-size: 24px;
+ font-weight: bold;
+ color: #409eff;
+ margin-bottom: 8px;
+ }
+
+ .stat-label {
+ font-size: 14px;
+ color: #909399;
+ }
+
+ :deep(.danger-row td) {
+ color: #e95a66 !important;
+ }
+</style>
--
Gitblit v1.9.3