From f3f855be1fd86d28485fceb02c30b6c6b2853aef Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 04 十一月 2026 18:15:40 +0800
Subject: [PATCH] feat(mes): 质检附件与来源关联界面,新增工单技术文件、废料登记与领料单打印
---
src/views/basicData/mdm/index.vue | 140 +++++++++++++++++++++++++++++++++++-----------
1 files changed, 106 insertions(+), 34 deletions(-)
diff --git a/src/views/basicData/mdm/index.vue b/src/views/basicData/mdm/index.vue
index 4cc1c42..b31f503 100644
--- a/src/views/basicData/mdm/index.vue
+++ b/src/views/basicData/mdm/index.vue
@@ -5,29 +5,44 @@
import { computed, ref } from 'vue';
+import { isAiEnable } from '@vben/hooks';
+
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 {
deleteItem,
deleteItemList,
- // exportItem,
+ exportItem,
getItemPage,
updateItemStatus,
+ updateItemSync,
} from '#/api/mdm/item';
import { getItemTypeSimpleList } from '#/api/mes/md/item/type';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
+import AgentImport from './modules/agent-import.vue';
import Form from './modules/form.vue';
+import ImportForm from './modules/import-form.vue';
defineOptions({ name: 'MdmItem' });
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
+ destroyOnClose: true,
+});
+
+const [ImportModal, importModalApi] = useVbenModal({
+ connectedComponent: ImportForm,
+ destroyOnClose: true,
+});
+
+const [AgentImportModal, agentImportModalApi] = useVbenModal({
+ connectedComponent: AgentImport,
destroyOnClose: true,
});
@@ -74,16 +89,71 @@
gridApi.query();
}
-/** 瀵煎嚭琛ㄦ牸 */
-// async function handleExport() {
-// const data = await exportItem(await gridApi.formApi.getValues());
-// downloadFileFromBlobPart({ fileName: '鐗╂枡.xls', source: data });
-// }
+/** 瀵煎嚭琛ㄦ牸锛堟寜褰撳墠鍒楄〃鏌ヨ鏉′欢瀵煎嚭鍏ㄩ儴鍛戒腑鏁版嵁锛� */
+async function handleExport() {
+ const data = await exportItem(await gridApi.formApi.getValues());
+ downloadFileFromBlobPart({ fileName: '鐗╂枡鏁版嵁.xls', source: data });
+}
/** 鍒涘缓鐗╂枡 */
function handleCreate() {
formModalApi.setData(null).open();
}
+
+/** 瀵煎叆鐗╂枡 */
+function handleImport() {
+ importModalApi.open();
+}
+
+/** 鏅鸿兘浣撳鍏ョ墿鏂� */
+function handleAgentImport() {
+ agentImportModalApi.open();
+}
+
+/** 宸ュ叿鏍忔寜閽細鏅鸿兘浣撳鍏ュ彈 AI 鎬诲紑鍏虫帶鍒� */
+const toolbarActions = computed(() => [
+ {
+ label: $t('ui.actionTitle.create', ['鐗╂枡']),
+ type: 'primary' as const,
+ icon: ACTION_ICON.ADD,
+ auth: ['mdm:item:create'],
+ onClick: handleCreate,
+ },
+ {
+ label: $t('ui.actionTitle.import', ['鐗╂枡']),
+ type: 'primary' as const,
+ icon: ACTION_ICON.UPLOAD,
+ auth: ['mdm:item:import'],
+ onClick: handleImport,
+ },
+ ...(isAiEnable()
+ ? [
+ {
+ label: '鏅鸿兘浣撳鍏�',
+ type: 'primary' as const,
+ icon: ACTION_ICON.UPLOAD,
+ auth: ['mdm:item:import'],
+ onClick: handleAgentImport,
+ },
+ ]
+ : []),
+ {
+ label: $t('ui.actionTitle.export'),
+ type: 'primary' as const,
+ icon: ACTION_ICON.DOWNLOAD,
+ auth: ['mdm:item:export'],
+ onClick: handleExport,
+ },
+ {
+ label: $t('ui.actionTitle.deleteBatch'),
+ type: 'primary' as const,
+ danger: true,
+ icon: ACTION_ICON.DELETE,
+ auth: ['mdm:item:delete'],
+ disabled: isEmpty(checkedIds),
+ onClick: handleDeleteBatch,
+ },
+]);
/** 缂栬緫鐗╂枡 */
function handleEdit(row: MdmItemApi.Item) {
@@ -135,6 +205,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,35 +280,11 @@
<template>
<Page auto-content-height>
<FormModal @success="handleRefresh" />
+ <ImportModal @success="handleRefresh" />
+ <AgentImportModal @success="handleRefresh" />
<Grid table-title="鐗╂枡鍒楄〃">
<template #toolbar-tools>
- <TableAction
- :actions="[
- {
- label: $t('ui.actionTitle.create', ['鐗╂枡']),
- type: 'primary',
- icon: ACTION_ICON.ADD,
- auth: ['mdm:item:create'],
- onClick: handleCreate,
- },
- // {
- // label: $t('ui.actionTitle.export'),
- // type: 'primary',
- // icon: ACTION_ICON.DOWNLOAD,
- // auth: ['mdm:item:export'],
- // onClick: handleExport,
- // },
- {
- label: $t('ui.actionTitle.deleteBatch'),
- type: 'primary',
- danger: true,
- icon: ACTION_ICON.DELETE,
- auth: ['mdm:item:delete'],
- disabled: isEmpty(checkedIds),
- onClick: handleDeleteBatch,
- },
- ]"
- />
+ <TableAction :actions="toolbarActions" />
</template>
<template #categoryName="{ row }">
<Tag v-if="getCategoryColor(row.categoryId)" :color="getCategoryColor(row.categoryId)">{{ getCategoryName(row.categoryId) }}</Tag>
@@ -231,6 +294,15 @@
<Tag v-if="row.isBatchManaged" color="success">鏄�</Tag>
<Tag v-else>鍚�</Tag>
</template>
+ <template #syncedMes="{ row }">
+ <Switch
+ :checked="row.syncedMes"
+ :loading="syncingId === row.id"
+ checkedChildren="宸插悓姝�"
+ unCheckedChildren="鏈悓姝�"
+ @change="handleSyncChange(row, $event)"
+ />
+ </template>
<template #actions="{ row }">
<TableAction
:actions="[
--
Gitblit v1.9.3