From 2cd4bc127daf3ff240495ae7741b294351ba6b03 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 20 Oct 2025 19:59:32 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd=E3=80=91bpm=20catego?= =?UTF-8?q?ry=20=E7=9A=84=E4=BB=A3=E7=A0=81=E9=A3=8E=E6=A0=BC=E7=BB=9F?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/bpm/category/index.ts | 2 +- apps/web-antd/src/views/bpm/category/data.ts | 20 +++++++ .../web-antd/src/views/bpm/category/index.vue | 9 ++-- .../src/views/bpm/category/modules/form.vue | 9 +++- .../bpm/category/modules/rename-form.vue | 54 ++++++------------- .../modules/category-draggable-model.vue | 2 +- 6 files changed, 50 insertions(+), 46 deletions(-) diff --git a/apps/web-antd/src/api/bpm/category/index.ts b/apps/web-antd/src/api/bpm/category/index.ts index d8b5a9b3d..64cf36cb4 100644 --- a/apps/web-antd/src/api/bpm/category/index.ts +++ b/apps/web-antd/src/api/bpm/category/index.ts @@ -10,7 +10,7 @@ export namespace BpmCategoryApi { code: string; status: number; description?: string; - sort: number; // 分类排序 + sort: number; } } diff --git a/apps/web-antd/src/views/bpm/category/data.ts b/apps/web-antd/src/views/bpm/category/data.ts index 0667efbc3..3ee0bd9a7 100644 --- a/apps/web-antd/src/views/bpm/category/data.ts +++ b/apps/web-antd/src/views/bpm/category/data.ts @@ -68,6 +68,21 @@ export function useFormSchema(): VbenFormSchema[] { ]; } +/** 重命名的表单 */ +export function useRenameFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '分类名', + component: 'Input', + componentProps: { + placeholder: '请输入分类名', + }, + rules: 'required', + }, + ]; +} + /** 列表的搜索表单 */ export function useGridFormSchema(): VbenFormSchema[] { return [ @@ -143,6 +158,11 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { props: { type: DICT_TYPE.COMMON_STATUS }, }, }, + { + field: 'sort', + title: '分类排序', + minWidth: 100, + }, { field: 'createTime', title: '创建时间', diff --git a/apps/web-antd/src/views/bpm/category/index.vue b/apps/web-antd/src/views/bpm/category/index.vue index 475851616..46172f4ce 100644 --- a/apps/web-antd/src/views/bpm/category/index.vue +++ b/apps/web-antd/src/views/bpm/category/index.vue @@ -36,16 +36,14 @@ function handleEdit(row: BpmCategoryApi.Category) { /** 删除流程分类 */ async function handleDelete(row: BpmCategoryApi.Category) { const hideLoading = message.loading({ - content: $t('ui.actionMessage.deleting', [row.code]), + content: $t('ui.actionMessage.deleting', [row.name]), duration: 0, }); try { await deleteCategory(row.id as number); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.code]), - }); + message.success($t('ui.actionMessage.deleteSuccess', [row.name])); handleRefresh(); - } catch { + } finally { hideLoading(); } } @@ -71,6 +69,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: true, diff --git a/apps/web-antd/src/views/bpm/category/modules/form.vue b/apps/web-antd/src/views/bpm/category/modules/form.vue index 24c81b706..7402f6a6e 100644 --- a/apps/web-antd/src/views/bpm/category/modules/form.vue +++ b/apps/web-antd/src/views/bpm/category/modules/form.vue @@ -26,6 +26,13 @@ const getTitle = computed(() => { }); const [Form, formApi] = useVbenForm({ + commonConfig: { + componentProps: { + class: 'w-full', + }, + formItemClass: 'col-span-2', + labelWidth: 80, + }, layout: 'horizontal', schema: useFormSchema(), showDefaultActions: false, @@ -73,7 +80,7 @@ const [Modal, modalApi] = useVbenModal({ diff --git a/apps/web-antd/src/views/bpm/category/modules/rename-form.vue b/apps/web-antd/src/views/bpm/category/modules/rename-form.vue index 9dfe3c46e..e9bc301a8 100644 --- a/apps/web-antd/src/views/bpm/category/modules/rename-form.vue +++ b/apps/web-antd/src/views/bpm/category/modules/rename-form.vue @@ -11,50 +11,36 @@ import { useVbenForm } from '#/adapter/form'; import { getCategory, updateCategory } from '#/api/bpm/category'; import { $t } from '#/locales'; +import { useRenameFormSchema } from '../data'; + const emit = defineEmits(['success']); const formData = ref(); -// 定义表单结构 -const formSchema = [ - { - fieldName: 'name', - label: '分类名', - component: 'Input', - componentProps: { - placeholder: '请输入分类名', - }, - rules: 'required', - }, -]; - -// 创建表单 const [Form, formApi] = useVbenForm({ + commonConfig: { + componentProps: { + class: 'w-full', + }, + formItemClass: 'col-span-2', + labelWidth: 80, + }, layout: 'horizontal', - schema: formSchema, + schema: useRenameFormSchema(), showDefaultActions: false, }); -// 创建模态窗 const [Modal, modalApi] = useVbenModal({ - // 保存按钮回调 async onConfirm() { const { valid } = await formApi.validate(); if (!valid) { return; } modalApi.lock(); - - // 提交表单,只更新流程分类名 - const formValues = await formApi.getValues(); + // 提交表单 const data = { - id: formData.value?.id, - name: formValues.name, // 只更新流程分类名 - code: formData.value?.code, - status: formData.value?.status, - description: formData.value?.description, - sort: formData.value?.sort, + ...formData.value, + ...(await formApi.getValues()), } as BpmCategoryApi.Category; - try { await updateCategory(data); // 关闭并提示 @@ -65,29 +51,21 @@ const [Modal, modalApi] = useVbenModal({ modalApi.unlock(); } }, - - // 打开/关闭弹窗回调 async onOpenChange(isOpen: boolean) { if (!isOpen) { formData.value = undefined; return; } - // 加载数据 const data = modalApi.getData(); - if (!data || !data.id) { return; } - modalApi.lock(); try { - // 获取流程分类数据 formData.value = await getCategory(data.id); - // 仅设置 name 字段 - await formApi.setValues({ - name: formData.value.name, - }); + // 设置到 values + await formApi.setValues(formData.value); } finally { modalApi.unlock(); } @@ -96,7 +74,7 @@ const [Modal, modalApi] = useVbenModal({ diff --git a/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue b/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue index 00d224764..57bf88b57 100644 --- a/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue +++ b/apps/web-antd/src/views/bpm/model/modules/category-draggable-model.vue @@ -70,7 +70,7 @@ const isModelSorting = ref(false); const originalData = ref([]); const modelList = ref([]); // 根据是否为第一个分类, 来设置初始展开状态 -const isExpand = ref(!!props.isFirst); +const isExpand = ref(props.isFirst); const [Grid, gridApi] = useVbenVxeGrid({ gridOptions: {