From 70b7935fc261cd5e8eaaf1cfbc8078b04db576d2 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期六, 07 十一月 2026 14:51:06 +0800
Subject: [PATCH] fix(mes): 自动回填销售订单生产信息

---
 src/views/basicData/mdm/index.vue |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/src/views/basicData/mdm/index.vue b/src/views/basicData/mdm/index.vue
index e59b39f..67b8678 100644
--- a/src/views/basicData/mdm/index.vue
+++ b/src/views/basicData/mdm/index.vue
@@ -8,7 +8,7 @@
 import { confirm, Page, useVbenModal } from '#/packages/effects/common-ui/src';
 import { downloadFileFromBlobPart, isEmpty } from '#/packages/utils/src';
 
-import { message, Tag } from 'ant-design-vue';
+import { message, Switch, Tag } from 'ant-design-vue';
 
 import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
 import {
@@ -16,18 +16,27 @@
   deleteItemList,
   // exportItem,
   getItemPage,
+  importItem,
+  importItemTemplate,
   updateItemStatus,
+  updateItemSync,
 } from '#/api/mdm/item';
 import { getItemTypeSimpleList } from '#/api/mes/md/item/type';
 import { $t } from '#/locales';
 
 import { useGridColumns, useGridFormSchema } from './data';
 import Form from './modules/form.vue';
+import ImportModalComponent from '#/components/import-modal';
 
 defineOptions({ name: 'MdmItem' });
 
 const [FormModal, formModalApi] = useVbenModal({
   connectedComponent: Form,
+  destroyOnClose: true,
+});
+
+const [ImportModal, importModalApi] = useVbenModal({
+  connectedComponent: ImportModalComponent,
   destroyOnClose: true,
 });
 
@@ -85,6 +94,19 @@
   formModalApi.setData(null).open();
 }
 
+/** 瀵煎叆鐗╂枡 */
+function handleImport() {
+  importModalApi
+    .setData({
+      title: $t('ui.actionTitle.import', ['鐗╂枡']),
+      fileName: '鐗╂枡瀵煎叆妯℃澘.xls',
+      importFn: importItem,
+      templateFn: importItemTemplate,
+      uploadHint: '绾㈣壊琛ㄥご涓哄繀濉�傚垎绫诲拰鍗曚綅椤诲凡瀛樺湪锛涙柊澧炵墿鏂欏悓姝� MES锛岃鐩栨椂淇濈暀鍘熷悓姝ョ姸鎬併��',
+    })
+    .open();
+}
+
 /** 缂栬緫鐗╂枡 */
 function handleEdit(row: MdmItemApi.Item) {
   formModalApi.setData(row).open();
@@ -135,6 +157,23 @@
     handleRefresh();
   } finally {
     hideLoading();
+  }
+}
+
+const syncingId = ref<number | null>(null);
+
+/** 鍒囨崲鍚屾鐘舵�侊細鍏抽棴寮�鍏充細浠� MES 鍒犻櫎鐗╂枡锛岄渶纭 */
+async function handleSyncChange(row: MdmItemApi.Item, checked: boolean) {
+  if (!checked) {
+    await confirm('鍏抽棴鍚屾灏嗕粠 MES 鍒犻櫎璇ョ墿鏂欏強鍏宠仈閰嶇疆锛圔OM/SOP/SIP/鎵规閰嶇疆锛夛紝纭缁х画锛�');
+  }
+  syncingId.value = row.id!;
+  try {
+    await updateItemSync(row.id!, checked);
+    message.success(checked ? '宸插悓姝ュ埌 MES' : '宸插彇娑堝悓姝�');
+    handleRefresh();
+  } finally {
+    syncingId.value = null;
   }
 }
 
@@ -193,6 +232,7 @@
 <template>
   <Page auto-content-height>
     <FormModal @success="handleRefresh" />
+    <ImportModal @success="handleRefresh" />
     <Grid table-title="鐗╂枡鍒楄〃">
       <template #toolbar-tools>
         <TableAction
@@ -203,6 +243,13 @@
               icon: ACTION_ICON.ADD,
               auth: ['mdm:item:create'],
               onClick: handleCreate,
+            },
+            {
+              label: $t('ui.actionTitle.import', ['鐗╂枡']),
+              type: 'primary',
+              icon: ACTION_ICON.UPLOAD,
+              auth: ['mdm:item:import'],
+              onClick: handleImport,
             },
             // {
             //   label: $t('ui.actionTitle.export'),
@@ -232,8 +279,13 @@
         <Tag v-else>鍚�</Tag>
       </template>
       <template #syncedMes="{ row }">
-        <Tag v-if="row.syncedMes" color="success">宸插悓姝�</Tag>
-        <Tag v-else color="default">鏈悓姝�</Tag>
+        <Switch
+          :checked="row.syncedMes"
+          :loading="syncingId === row.id"
+          checkedChildren="宸插悓姝�"
+          unCheckedChildren="鏈悓姝�"
+          @change="handleSyncChange(row, $event)"
+        />
       </template>
       <template #actions="{ row }">
         <TableAction

--
Gitblit v1.9.3