4 天以前 2271982de09628a04da06630c4ab690ef64fbfab
refactor(mdm): 将物料相关字段统一改为品种并优化下拉菜单确认逻辑

- 将物料编码、物料名称、物料分类等字段标签统一修改为品种编码、品种名称、品种分类
- 修改相关占位符文本从物料相关改为品种相关
- 更新组件引用从MdItemSelect改为MdmItemSelect
- 调整表格操作列宽度配置以适应新的显示需求
- 优化下拉菜单中的确认弹窗实现,使用Modal替代Popconfirm解决嵌套问题
- 移除冗余的弹窗确认模板代码,简化组件结构
已修改8个文件
80 ■■■■ 文件已修改
src/components/table-action/table-action.vue 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicData/mdm/components/data.ts 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicData/mdm/components/select-dialog.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicData/mdm/components/select.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mes/pro/bagCode/data.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mes/pro/batch/data.ts 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mes/pro/line/data.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mes/pro/pallet/data.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/table-action/table-action.vue
@@ -15,6 +15,7 @@
  Button,
  Dropdown,
  Menu,
  Modal,
  Popconfirm,
  Space,
  Tooltip,
@@ -122,7 +123,23 @@
/** 处理菜单点击 */
function handleMenuClick(e: any) {
  const action = getDropdownList.value[e.key];
  if (action && action.onClick && isFunction(action.onClick)) {
  if (!action) {
    return;
  }
  const popConfirm = action.popConfirm;
  if (popConfirm) {
    // 下拉菜单项会被 Dropdown 自动关闭销毁,嵌套 Popconfirm 无法弹出,
    // 故改用命令式 Modal.confirm 完成确认
    Modal.confirm({
      title: popConfirm.title,
      okText: popConfirm.okText,
      cancelText: popConfirm.cancelText,
      onOk: popConfirm.confirm ? () => popConfirm.confirm!() : undefined,
      onCancel: popConfirm.cancel ? () => popConfirm.cancel!() : undefined,
    });
    return;
  }
  if (action.onClick && isFunction(action.onClick)) {
    action.onClick();
  }
}
@@ -201,13 +218,8 @@
            v-for="(action, index) in getDropdownList"
            :key="index"
            :disabled="action.disabled"
            @click="!action.popConfirm && handleMenuClick({ key: index })"
            @click="handleMenuClick({ key: index })"
          >
            <template v-if="action.popConfirm">
              <Popconfirm v-bind="getPopConfirmProps(action.popConfirm)">
                <template v-if="action.popConfirm.icon" #icon>
                  <IconifyIcon :icon="action.popConfirm.icon" />
                </template>
                <div
                  :class="
                    action.disabled === true
@@ -220,20 +232,6 @@
                    {{ action.label }}
                  </span>
                </div>
              </Popconfirm>
            </template>
            <template v-else>
              <div
                :class="
                  action.disabled === true
                    ? 'cursor-not-allowed text-gray-300'
                    : ''
                "
              >
                <IconifyIcon v-if="action.icon" :icon="action.icon" />
                {{ action.label }}
              </div>
            </template>
          </Menu.Item>
        </Menu>
      </template>
src/views/basicData/mdm/components/data.ts
@@ -12,28 +12,28 @@
  return [
    {
      fieldName: 'code',
      label: '物料编码',
      label: '品种编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入物料编码',
        placeholder: '请输入品种编码',
      },
    },
    {
      fieldName: 'name',
      label: '物料名称',
      label: '品种名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入物料名称',
        placeholder: '请输入品种名称',
      },
    },
    {
      fieldName: 'categoryId',
      label: '物料分类',
      label: '品种分类',
      component: 'ApiSelect',
      componentProps: {
        placeholder: '请选择物料分类',
        placeholder: '请选择品种分类',
        allowClear: true,
        api: async () => {
          const res = await getItemTypeSimpleList();
@@ -64,12 +64,12 @@
    { type: multiple ? 'checkbox' : 'radio', width: 50 },
    {
      field: 'code',
      title: '物料编码',
      title: '品种编码',
      minWidth: 120,
    },
    {
      field: 'name',
      title: '物料名称',
      title: '品种名称',
      minWidth: 180,
      align: 'left',
    },
@@ -81,7 +81,7 @@
    },
    {
      field: 'categoryId',
      title: '物料分类',
      title: '品种分类',
      minWidth: 120,
      align: 'center',
      slots: { default: 'categoryId' },
src/views/basicData/mdm/components/select-dialog.vue
@@ -209,7 +209,7 @@
function handleConfirm() {
  const rows = multiple.value ? getMultipleSelectedRows() : selectedRows.value;
  if (rows.length === 0) {
    message.warning(multiple.value ? '请至少选择一条数据' : '请选择一条数据');
    message.warning(multiple.value ? '请至少选择一个品种' : '请选择一个品种');
    return;
  }
  emit('selected', multiple.value ? rows : [rows[0]!]);
@@ -222,13 +222,13 @@
<template>
  <Modal
    v-model:open="open"
    title="物料选择"
    title="品种选择"
    width="80%"
    :destroy-on-close="true"
    @ok="handleConfirm"
    @cancel="closeModal"
  >
    <Grid table-title="物料列表">
    <Grid table-title="品种列表">
      <template #categoryId="{ row }">
        <Tag v-if="getCategoryColor(row.categoryId)" :color="getCategoryColor(row.categoryId)">{{ getCategoryName(row.categoryId) }}</Tag>
        <span v-else>{{ getCategoryName(row.categoryId) || '-' }}</span>
src/views/basicData/mdm/components/select.vue
@@ -25,7 +25,7 @@
    allowClear: true,
    disabled: false,
    modelValue: undefined,
    placeholder: '请选择物料',
    placeholder: '请选择品种',
    label: undefined,
  },
);
src/views/mes/pro/bagCode/data.ts
@@ -122,7 +122,7 @@
    },
    {
      title: '操作',
      width: 180,
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
src/views/mes/pro/batch/data.ts
@@ -7,7 +7,7 @@
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { MdItemSelect } from '#/views/mes/md/item/components';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { ProLineSelect } from '#/views/mes/pro/line/components';
import { UserSelect } from '#/views/system/user/components';
import { getRangePickerDefaultProps } from '#/utils';
@@ -56,7 +56,7 @@
    {
      fieldName: 'itemId',
      label: '品种',
      component: markRaw(MdItemSelect),
      component: markRaw(MdmItemSelect),
      componentProps: {
        disabled,
        placeholder: '请选择品种(产品品种)',
@@ -138,7 +138,7 @@
    {
      fieldName: 'itemId',
      label: '品种',
      component: markRaw(MdItemSelect),
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择品种',
      },
@@ -273,7 +273,7 @@
    },
    {
      title: '操作',
      width: 200,
      width: 300,
      fixed: 'right',
      slots: { default: 'actions' },
    },
src/views/mes/pro/line/data.ts
@@ -144,7 +144,7 @@
    },
    {
      title: '操作',
      width: 150,
      width: 180,
      fixed: 'right',
      slots: { default: 'actions' },
    },
src/views/mes/pro/pallet/data.ts
@@ -101,7 +101,7 @@
    },
    {
      title: '操作',
      width: 90,
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },