From 8d541eed8bb02d5a9b32b706cde9665df9a83aec Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 29 十月 2026 11:47:49 +0800
Subject: [PATCH] refactor(safety): 人员与车间字段改用员工选择器与车间下拉

---
 src/views/safety/accident/index.vue |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/views/safety/accident/index.vue b/src/views/safety/accident/index.vue
index dc7c838..daa69d2 100644
--- a/src/views/safety/accident/index.vue
+++ b/src/views/safety/accident/index.vue
@@ -25,6 +25,7 @@
 } from 'ant-design-vue';
 import dayjs from 'dayjs';
 
+import { getWorkshopSimpleList } from '#/api/mes/md/workstation/workshop';
 import {
   createAccident,
   deleteAccident,
@@ -46,6 +47,8 @@
 const loading = ref(false);
 const pagination = reactive({ current: 1, pageSize: 10, total: 0, showSizeChanger: true });
 
+const workshopOptions = ref<{ label: string; value: number }[]>([]);
+
 const open = ref(false);
 const saving = ref(false);
 const formRef = ref<FormInstance>();
@@ -56,14 +59,13 @@
   level: 'GENERAL',
   occurTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
   location: '',
-  workshopName: '',
+  workshopId: undefined,
   casualtyDesc: '',
   economicLoss: 0,
   involvedPersons: '',
   description: '',
   causeAnalysis: '',
   measures: '',
-  reporter: '',
   status: 'REPORTED',
   attachment: '',
   remark: '',
@@ -84,6 +86,7 @@
   { title: '绛夌骇', dataIndex: 'level', width: 110, align: 'center' as const },
   { title: '鍙戠敓鏃堕棿', dataIndex: 'occurTime', width: 165 },
   { title: '鍙戠敓鍦扮偣', dataIndex: 'location', width: 160, ellipsis: true },
+  { title: '杞﹂棿', dataIndex: 'workshopName', width: 130, ellipsis: true },
   { title: '浼や骸鎯呭喌', dataIndex: 'casualtyDesc', width: 160, ellipsis: true },
   { title: '鐘舵��', dataIndex: 'status', width: 110, align: 'center' as const },
   { title: '鎿嶄綔', key: 'action', width: 150, fixed: 'right' as const },
@@ -109,6 +112,15 @@
   }
 }
 
+async function loadWorkshops() {
+  try {
+    const list = await getWorkshopSimpleList();
+    workshopOptions.value = (list || []).map((w) => ({ label: w.name!, value: w.id! }));
+  } catch {
+    workshopOptions.value = [];
+  }
+}
+
 function resetFilters() {
   Object.keys(filters).forEach((k) => delete filters[k]);
   void load(true);
@@ -131,6 +143,9 @@
   saving.value = true;
   try {
     const data = { ...model, title: model.title.trim() };
+    // 鎵�灞炶溅闂村悕绉� / 鐧昏浜哄鍚嶄负鍚庣鍥炲~鐨勫揩鐓у瓧娈碉紝涓嶅弬涓庢彁浜�
+    delete data.workshopName;
+    delete data.reporter;
     await (data.id ? updateAccident(data) : createAccident(data));
     message.success('浜嬫晠璁板綍宸蹭繚瀛�');
     open.value = false;
@@ -146,7 +161,10 @@
   await load();
 }
 
-onMounted(() => load());
+onMounted(() => {
+  void load();
+  void loadWorkshops();
+});
 </script>
 
 <template>
@@ -191,7 +209,7 @@
         row-key="id"
         :loading="loading"
         :pagination="pagination"
-        :scroll="{ x: 1400 }"
+        :scroll="{ x: 1530 }"
         size="middle"
         :cell-style="{ padding: '12px 16px' }"
         @change="tableChange"
@@ -211,6 +229,9 @@
           </template>
           <template v-else-if="column.dataIndex === 'status'">
             <Tag>{{ record.statusName }}</Tag>
+          </template>
+          <template v-else-if="column.dataIndex === 'workshopName'">
+            {{ record.workshopName || '-' }}
           </template>
           <template v-else-if="column.key === 'action'">
             <Space :size="0">
@@ -249,8 +270,14 @@
         <FormItem label="鍙戠敓鍦扮偣" name="location">
           <Input v-model:value="model.location" :maxlength="200" placeholder="濡� 2#楂樺帇閰嶇數瀹�" />
         </FormItem>
-        <FormItem label="鎵�灞炶溅闂�/鍖哄煙" name="workshopName">
-          <Input v-model:value="model.workshopName" :maxlength="100" placeholder="濡� 鐢垫皵杞﹂棿" />
+        <FormItem label="鎵�灞炶溅闂�/鍖哄煙" name="workshopId">
+          <Select
+            v-model:value="model.workshopId"
+            :options="workshopOptions"
+            show-search
+            :filter-option="(i: string, o: any) => String(o.label).includes(i)"
+            placeholder="璇烽�夋嫨杞﹂棿"
+          />
         </FormItem>
         <FormItem label="浼や骸鎯呭喌" name="casualtyDesc">
           <Input v-model:value="model.casualtyDesc" :maxlength="500" placeholder="濡� 1 浜鸿交浼�" />

--
Gitblit v1.9.3