From 1dd0588a39349d4efa2878fa1970b457b36e39e8 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Sat, 14 Jun 2025 22:02:16 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20code=20review=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/bpm/category/index.ts | 15 +++--- apps/web-antd/src/api/bpm/form/index.ts | 2 +- apps/web-antd/src/api/bpm/model/index.ts | 23 +++++---- .../src/api/bpm/processInstance/index.ts | 4 +- .../web-antd/src/views/bpm/category/index.vue | 6 +-- .../src/views/bpm/category/modules/form.vue | 6 +-- .../bpm/category/modules/rename-form.vue | 6 +-- .../src/views/bpm/model/form/index.vue | 2 +- .../bpm/model/form/modules/basic-info.vue | 2 +- .../modules/category-draggable-model.vue | 48 +++++++++---------- .../src/views/bpm/model/modules/data.ts | 10 ++-- .../bpm/processInstance/create/index.vue | 4 +- 12 files changed, 62 insertions(+), 66 deletions(-) diff --git a/apps/web-antd/src/api/bpm/category/index.ts b/apps/web-antd/src/api/bpm/category/index.ts index d622183f0..d8b5a9b3d 100644 --- a/apps/web-antd/src/api/bpm/category/index.ts +++ b/apps/web-antd/src/api/bpm/category/index.ts @@ -3,9 +3,8 @@ import type { PageParam, PageResult } from '@vben/request'; import { requestClient } from '#/api/request'; export namespace BpmCategoryApi { - /** 流程分类 VO */ - // TODO @jason:不用 VO 后缀哈 - export interface CategoryVO { + /** 流程分类 */ + export interface Category { id: number; name: string; code: string; @@ -17,7 +16,7 @@ export namespace BpmCategoryApi { /** 查询流程分类分页 */ export async function getCategoryPage(params: PageParam) { - return requestClient.get>( + return requestClient.get>( '/bpm/category/page', { params }, ); @@ -25,18 +24,18 @@ export async function getCategoryPage(params: PageParam) { /** 查询流程分类详情 */ export async function getCategory(id: number) { - return requestClient.get( + return requestClient.get( `/bpm/category/get?id=${id}`, ); } /** 新增流程分类 */ -export async function createCategory(data: BpmCategoryApi.CategoryVO) { +export async function createCategory(data: BpmCategoryApi.Category) { return requestClient.post('/bpm/category/create', data); } /** 修改流程分类 */ -export async function updateCategory(data: BpmCategoryApi.CategoryVO) { +export async function updateCategory(data: BpmCategoryApi.Category) { return requestClient.put('/bpm/category/update', data); } @@ -47,7 +46,7 @@ export async function deleteCategory(id: number) { /** 查询流程分类列表 */ export async function getCategorySimpleList() { - return requestClient.get( + return requestClient.get( `/bpm/category/simple-list`, ); } diff --git a/apps/web-antd/src/api/bpm/form/index.ts b/apps/web-antd/src/api/bpm/form/index.ts index 1c14a67e8..252d4d420 100644 --- a/apps/web-antd/src/api/bpm/form/index.ts +++ b/apps/web-antd/src/api/bpm/form/index.ts @@ -4,7 +4,7 @@ import { requestClient } from '#/api/request'; export namespace BpmFormApi { /** 流程表单 */ - // TODO @jason:不用 VO 后缀哈 + // TODO @ziye:不用 VO 后缀哈 export interface FormVO { id?: number | undefined; name: string; diff --git a/apps/web-antd/src/api/bpm/model/index.ts b/apps/web-antd/src/api/bpm/model/index.ts index 655cfb034..443b85c5e 100644 --- a/apps/web-antd/src/api/bpm/model/index.ts +++ b/apps/web-antd/src/api/bpm/model/index.ts @@ -11,9 +11,8 @@ export namespace BpmModelApi { deptName?: string; } - /** 流程定义 VO */ - // TODO @jason:不用 VO 后缀哈 - export interface ProcessDefinitionVO { + /** 流程定义 */ + export interface ProcessDefinition { id: string; key?: string; version: number; @@ -23,8 +22,8 @@ export namespace BpmModelApi { formCustomViewPath?: string; } - /** 流程模型 VO */ - export interface ModelVO { + /** 流程模型 */ + export interface Model { id: number; key: string; name: string; @@ -36,7 +35,7 @@ export namespace BpmModelApi { formId: number; formCustomCreatePath: string; formCustomViewPath: string; - processDefinition: ProcessDefinitionVO; + processDefinition: ProcessDefinition; status: number; remark: string; createTime: string; @@ -49,23 +48,23 @@ export namespace BpmModelApi { export interface ModelCategoryInfo { id: number; name: string; - modelList: BpmModelApi.ModelVO[]; + modelList: BpmModelApi.Model[]; } /** 获取流程模型列表 */ export async function getModelList(name: string | undefined) { - return requestClient.get('/bpm/model/list', { + return requestClient.get('/bpm/model/list', { params: { name }, }); } /** 获取流程模型详情 */ export async function getModel(id: string) { - return requestClient.get(`/bpm/model/get?id=${id}`); + return requestClient.get(`/bpm/model/get?id=${id}`); } /** 更新流程模型 */ -export async function updateModel(data: BpmModelApi.ModelVO) { +export async function updateModel(data: BpmModelApi.Model) { return requestClient.put('/bpm/model/update', data); } @@ -78,7 +77,7 @@ export async function updateModelSortBatch(ids: number[]) { } /** 更新流程模型的 BPMN XML */ -export async function updateModelBpmn(data: BpmModelApi.ModelVO) { +export async function updateModelBpmn(data: BpmModelApi.Model) { return requestClient.put('/bpm/model/update-bpmn', data); } @@ -92,7 +91,7 @@ export async function updateModelState(id: number, state: number) { } /** 创建流程模型 */ -export async function createModel(data: BpmModelApi.ModelVO) { +export async function createModel(data: BpmModelApi.Model) { return requestClient.post('/bpm/model/create', data); } diff --git a/apps/web-antd/src/api/bpm/processInstance/index.ts b/apps/web-antd/src/api/bpm/processInstance/index.ts index 67a6d9cf6..80ede2b76 100644 --- a/apps/web-antd/src/api/bpm/processInstance/index.ts +++ b/apps/web-antd/src/api/bpm/processInstance/index.ts @@ -53,7 +53,7 @@ export namespace BpmProcessInstanceApi { formVariables: Record; id: number; name: string; - processDefinition?: BpmModelApi.ProcessDefinitionVO; + processDefinition?: BpmModelApi.ProcessDefinition; processDefinitionId: string; remark: string; result: number; @@ -67,7 +67,7 @@ export namespace BpmProcessInstanceApi { export type ApprovalDetail = { activityNodes: BpmProcessInstanceApi.ApprovalNodeInfo[]; formFieldsPermission: any; - processDefinition: BpmModelApi.ProcessDefinitionVO; + processDefinition: BpmModelApi.ProcessDefinition; processInstance: BpmProcessInstanceApi.ProcessInstanceVO; status: number; todoTask: BpmTaskApi.TaskVO; diff --git a/apps/web-antd/src/views/bpm/category/index.vue b/apps/web-antd/src/views/bpm/category/index.vue index e1f762e7e..7d840c215 100644 --- a/apps/web-antd/src/views/bpm/category/index.vue +++ b/apps/web-antd/src/views/bpm/category/index.vue @@ -29,12 +29,12 @@ function handleCreate() { } /** 编辑流程分类 */ -function handleEdit(row: BpmCategoryApi.CategoryVO) { +function handleEdit(row: BpmCategoryApi.Category) { formModalApi.setData(row).open(); } /** 删除流程分类 */ -async function handleDelete(row: BpmCategoryApi.CategoryVO) { +async function handleDelete(row: BpmCategoryApi.Category) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', [row.code]), key: 'action_key_msg', @@ -77,7 +77,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ refresh: { code: 'query' }, search: true, }, - } as VxeTableGridOptions, + } as VxeTableGridOptions, }); 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 9705a1fb9..0c8c3e1a1 100644 --- a/apps/web-antd/src/views/bpm/category/modules/form.vue +++ b/apps/web-antd/src/views/bpm/category/modules/form.vue @@ -18,7 +18,7 @@ import { $t } from '#/locales'; import { useFormSchema } from '../data'; const emit = defineEmits(['success']); -const formData = ref(); +const formData = ref(); const getTitle = computed(() => { return formData.value?.id ? $t('ui.actionTitle.edit', ['流程分类']) @@ -39,7 +39,7 @@ const [Modal, modalApi] = useVbenModal({ } modalApi.lock(); // 提交表单 - const data = (await formApi.getValues()) as BpmCategoryApi.CategoryVO; + const data = (await formApi.getValues()) as BpmCategoryApi.Category; try { await (formData.value?.id ? updateCategory(data) : createCategory(data)); // 关闭并提示 @@ -56,7 +56,7 @@ const [Modal, modalApi] = useVbenModal({ return; } // 加载数据 - const data = modalApi.getData(); + const data = modalApi.getData(); if (!data || !data.id) { return; } 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 ba68a44ef..acabd37f7 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 @@ -12,7 +12,7 @@ import { getCategory, updateCategory } from '#/api/bpm/category'; import { $t } from '#/locales'; const emit = defineEmits(['success']); -const formData = ref(); +const formData = ref(); // 定义表单结构 const formSchema = [ @@ -53,7 +53,7 @@ const [Modal, modalApi] = useVbenModal({ status: formData.value?.status, description: formData.value?.description, sort: formData.value?.sort, - } as BpmCategoryApi.CategoryVO; + } as BpmCategoryApi.Category; try { await updateCategory(data); @@ -74,7 +74,7 @@ const [Modal, modalApi] = useVbenModal({ } // 加载数据 - const data = modalApi.getData(); + const data = modalApi.getData(); if (!data || !data.id) { return; diff --git a/apps/web-antd/src/views/bpm/model/form/index.vue b/apps/web-antd/src/views/bpm/model/form/index.vue index 8f9f79b3b..4f655bbe6 100644 --- a/apps/web-antd/src/views/bpm/model/form/index.vue +++ b/apps/web-antd/src/views/bpm/model/form/index.vue @@ -133,7 +133,7 @@ provide('modelData', formData); // 数据列表 const formList = ref([]); -const categoryList = ref([]); +const categoryList = ref([]); const userList = ref([]); const deptList = ref([]); diff --git a/apps/web-antd/src/views/bpm/model/form/modules/basic-info.vue b/apps/web-antd/src/views/bpm/model/form/modules/basic-info.vue index 83c164618..5c4a6caf2 100644 --- a/apps/web-antd/src/views/bpm/model/form/modules/basic-info.vue +++ b/apps/web-antd/src/views/bpm/model/form/modules/basic-info.vue @@ -29,7 +29,7 @@ import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '#/utils'; const props = defineProps({ categoryList: { - type: Array as PropType, + type: Array as PropType, required: true, }, userList: { 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 837d07152..fed9ecf6a 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 @@ -5,7 +5,8 @@ import type { BpmModelApi, ModelCategoryInfo } from '#/api/bpm/model'; import { computed, ref, watchEffect } from 'vue'; import { useRouter } from 'vue-router'; -import { confirm, useVbenModal } from '@vben/common-ui'; +import { useAccess } from '@vben/access'; +import { confirm, EllipsisText, useVbenModal } from '@vben/common-ui'; import { IconifyIcon } from '@vben/icons'; import { useUserStore } from '@vben/stores'; import { cloneDeep, formatDateTime, isEqual } from '@vben/utils'; @@ -65,8 +66,8 @@ const router = useRouter(); const userStore = useUserStore(); const userId = userStore.userInfo?.id; const isModelSorting = ref(false); -const originalData = ref([]); -const modelList = ref([]); +const originalData = ref([]); +const modelList = ref([]); const isExpand = ref(false); const [Grid, gridApi] = useVbenVxeGrid({ @@ -90,6 +91,18 @@ const sortableInstance = ref(null); /** 解决 v-model 问题,使用计算属性 */ const expandKeys = computed(() => (isExpand.value ? ['1'] : [])); +const { hasAccessByCodes } = useAccess(); +/** 权限校验:通过 computed 解决列表的卡顿问题 */ +const hasPermiUpdate = computed(() => { + return hasAccessByCodes(['bpm:model:update']); +}); +const hasPermiDelete = computed(() => { + return hasAccessByCodes(['bpm:model:delete']); +}); +const hasPermiDeploy = computed(() => { + return hasAccessByCodes(['bpm:model:deploy']); +}); + /** 处理模型的排序 */ function handleModelSort() { // 保存初始数据并确保数据完整 @@ -145,21 +158,9 @@ async function handleModelSortSubmit() { message.error('排序数据异常,请重试'); return; } - // 保存排序 const ids = modelList.value.map((item) => item.id); - - // 检查是否有所有必要的ID - if (ids.length === props.categoryInfo.modelList.length) { - // 使用排序后的数据 - await updateModelSortBatch(ids); - } else { - console.warn('排序数据不完整,尝试使用原始数据'); - // 如果数据不完整,使用原始数据 - const originalIds = props.categoryInfo.modelList.map((item) => item.id); - await updateModelSortBatch(originalIds); - } - + await updateModelSortBatch(ids); // 刷新列表 isModelSorting.value = false; message.success('排序模型成功'); @@ -520,11 +521,9 @@ const handleRenameSuccess = () => { class="mr-2.5 h-9 w-9 flex-shrink-0 rounded" alt="图标" /> -
- - {{ row.name }} - -
+ + {{ row.name }} +