liu
2026-10-26 7763f23f3224a0f609c4c483351edd656b0dfb26
src/views/basicData/mdm/index.vue
@@ -5,6 +5,8 @@
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';
@@ -23,6 +25,7 @@
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';
@@ -35,6 +38,11 @@
const [ImportModal, importModalApi] = useVbenModal({
  connectedComponent: ImportForm,
  destroyOnClose: true,
});
const [AgentImportModal, agentImportModalApi] = useVbenModal({
  connectedComponent: AgentImport,
  destroyOnClose: true,
});
@@ -96,6 +104,56 @@
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) {
@@ -223,42 +281,10 @@
  <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.import', ['物料']),
              type: 'primary',
              icon: ACTION_ICON.UPLOAD,
              auth: ['mdm:item:import'],
              onClick: handleImport,
            },
            {
              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>