refactor(mdm): 将物料相关字段统一改为品种并优化下拉菜单确认逻辑
- 将物料编码、物料名称、物料分类等字段标签统一修改为品种编码、品种名称、品种分类
- 修改相关占位符文本从物料相关改为品种相关
- 更新组件引用从MdItemSelect改为MdmItemSelect
- 调整表格操作列宽度配置以适应新的显示需求
- 优化下拉菜单中的确认弹窗实现,使用Modal替代Popconfirm解决嵌套问题
- 移除冗余的弹窗确认模板代码,简化组件结构
| | |
| | | Button, |
| | | Dropdown, |
| | | Menu, |
| | | Modal, |
| | | Popconfirm, |
| | | Space, |
| | | Tooltip, |
| | |
| | | /** 处理菜单点击 */ |
| | | 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(); |
| | | } |
| | | } |
| | |
| | | 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 |
| | |
| | | {{ 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> |
| | |
| | | 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(); |
| | |
| | | { type: multiple ? 'checkbox' : 'radio', width: 50 }, |
| | | { |
| | | field: 'code', |
| | | title: '物料编码', |
| | | title: '品种编码', |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'name', |
| | | title: '物料名称', |
| | | title: '品种名称', |
| | | minWidth: 180, |
| | | align: 'left', |
| | | }, |
| | |
| | | }, |
| | | { |
| | | field: 'categoryId', |
| | | title: '物料分类', |
| | | title: '品种分类', |
| | | minWidth: 120, |
| | | align: 'center', |
| | | slots: { default: 'categoryId' }, |
| | |
| | | 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]!]); |
| | |
| | | <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> |
| | |
| | | allowClear: true, |
| | | disabled: false, |
| | | modelValue: undefined, |
| | | placeholder: '请选择物料', |
| | | placeholder: '请选择品种', |
| | | label: undefined, |
| | | }, |
| | | ); |
| | |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 180, |
| | | width: 200, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |
| | |
| | | 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'; |
| | |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '品种', |
| | | component: markRaw(MdItemSelect), |
| | | component: markRaw(MdmItemSelect), |
| | | componentProps: { |
| | | disabled, |
| | | placeholder: '请选择品种(产品品种)', |
| | |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '品种', |
| | | component: markRaw(MdItemSelect), |
| | | component: markRaw(MdmItemSelect), |
| | | componentProps: { |
| | | placeholder: '请选择品种', |
| | | }, |
| | |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 200, |
| | | width: 300, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |
| | |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 150, |
| | | width: 180, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |
| | |
| | | }, |
| | | { |
| | | title: '操作', |
| | | width: 90, |
| | | width: 200, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |