fix: code review 修改

pull/142/head
jason 2025-06-14 22:02:16 +08:00
parent 96ea1f98c0
commit 1dd0588a39
12 changed files with 62 additions and 66 deletions

View File

@ -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<PageResult<BpmCategoryApi.CategoryVO>>(
return requestClient.get<PageResult<BpmCategoryApi.Category>>(
'/bpm/category/page',
{ params },
);
@ -25,18 +24,18 @@ export async function getCategoryPage(params: PageParam) {
/** 查询流程分类详情 */
export async function getCategory(id: number) {
return requestClient.get<BpmCategoryApi.CategoryVO>(
return requestClient.get<BpmCategoryApi.Category>(
`/bpm/category/get?id=${id}`,
);
}
/** 新增流程分类 */
export async function createCategory(data: BpmCategoryApi.CategoryVO) {
export async function createCategory(data: BpmCategoryApi.Category) {
return requestClient.post<number>('/bpm/category/create', data);
}
/** 修改流程分类 */
export async function updateCategory(data: BpmCategoryApi.CategoryVO) {
export async function updateCategory(data: BpmCategoryApi.Category) {
return requestClient.put<boolean>('/bpm/category/update', data);
}
@ -47,7 +46,7 @@ export async function deleteCategory(id: number) {
/** 查询流程分类列表 */
export async function getCategorySimpleList() {
return requestClient.get<BpmCategoryApi.CategoryVO[]>(
return requestClient.get<BpmCategoryApi.Category[]>(
`/bpm/category/simple-list`,
);
}

View File

@ -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;

View File

@ -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<BpmModelApi.ModelVO[]>('/bpm/model/list', {
return requestClient.get<BpmModelApi.Model[]>('/bpm/model/list', {
params: { name },
});
}
/** 获取流程模型详情 */
export async function getModel(id: string) {
return requestClient.get<BpmModelApi.ModelVO>(`/bpm/model/get?id=${id}`);
return requestClient.get<BpmModelApi.Model>(`/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);
}

View File

@ -53,7 +53,7 @@ export namespace BpmProcessInstanceApi {
formVariables: Record<string, any>;
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;

View File

@ -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<BpmCategoryApi.CategoryVO>,
} as VxeTableGridOptions<BpmCategoryApi.Category>,
});
</script>

View File

@ -18,7 +18,7 @@ import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<BpmCategoryApi.CategoryVO>();
const formData = ref<BpmCategoryApi.Category>();
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<BpmCategoryApi.CategoryVO>();
const data = modalApi.getData<BpmCategoryApi.Category>();
if (!data || !data.id) {
return;
}

View File

@ -12,7 +12,7 @@ import { getCategory, updateCategory } from '#/api/bpm/category';
import { $t } from '#/locales';
const emit = defineEmits(['success']);
const formData = ref<BpmCategoryApi.CategoryVO>();
const formData = ref<BpmCategoryApi.Category>();
//
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<BpmCategoryApi.CategoryVO>();
const data = modalApi.getData<BpmCategoryApi.Category>();
if (!data || !data.id) {
return;

View File

@ -133,7 +133,7 @@ provide('modelData', formData);
//
const formList = ref<BpmFormApi.FormVO[]>([]);
const categoryList = ref<BpmCategoryApi.CategoryVO[]>([]);
const categoryList = ref<BpmCategoryApi.Category[]>([]);
const userList = ref<SystemUserApi.User[]>([]);
const deptList = ref<SystemDeptApi.Dept[]>([]);

View File

@ -29,7 +29,7 @@ import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '#/utils';
const props = defineProps({
categoryList: {
type: Array as PropType<BpmCategoryApi.CategoryVO[]>,
type: Array as PropType<BpmCategoryApi.Category[]>,
required: true,
},
userList: {

View File

@ -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<BpmModelApi.ModelVO[]>([]);
const modelList = ref<BpmModelApi.ModelVO[]>([]);
const originalData = ref<BpmModelApi.Model[]>([]);
const modelList = ref<BpmModelApi.Model[]>([]);
const isExpand = ref(false);
const [Grid, gridApi] = useVbenVxeGrid({
@ -90,6 +91,18 @@ const sortableInstance = ref<any>(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="图标"
/>
<div class="min-w-0">
<EllipsisText :max-width="100" :tooltip-when-ellipsis="true">
{{ row.name }}
</EllipsisText>
</div>
<EllipsisText :max-width="160" :tooltip-when-ellipsis="true">
{{ row.name }}
</EllipsisText>
</div>
</template>
<template #startUserIds="{ row }">
@ -598,13 +597,12 @@ const handleRenameSuccess = () => {
</template>
<template #actions="{ row }">
<div class="flex items-center space-x-0">
<!-- TODO 权限校验-->
<Button
type="link"
size="small"
class="px-1"
@click="modelOperation('update', row.id)"
:disabled="!isManagerUser(row)"
:disabled="!isManagerUser(row) || !hasPermiUpdate"
>
修改
</Button>
@ -613,7 +611,7 @@ const handleRenameSuccess = () => {
size="small"
class="px-1"
@click="handleDeploy(row)"
:disabled="!isManagerUser(row)"
:disabled="!isManagerUser(row) || !hasPermiDeploy"
>
发布
</Button>
@ -654,7 +652,7 @@ const handleRenameSuccess = () => {
<Menu.Item
danger
key="handleDelete"
:disabled="!isManagerUser(row)"
:disabled="!isManagerUser(row) || !hasPermiDelete"
>
删除
</Menu.Item>

View File

@ -4,12 +4,12 @@ import type { BpmModelApi } from '#/api/bpm/model';
import { DICT_TYPE } from '#/utils';
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BpmModelApi.ModelVO>['columns'] {
export function useGridColumns(): VxeTableGridOptions<BpmModelApi.Model>['columns'] {
return [
{
field: 'name',
title: '流程名称',
minWidth: 250,
minWidth: 200,
slots: { default: 'name' },
},
{
@ -21,7 +21,7 @@ export function useGridColumns(): VxeTableGridOptions<BpmModelApi.ModelVO>['colu
{
field: 'type',
title: '流程类型',
minWidth: 150,
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.BPM_MODEL_TYPE },
@ -36,12 +36,12 @@ export function useGridColumns(): VxeTableGridOptions<BpmModelApi.ModelVO>['colu
{
field: 'deploymentTime',
title: '最后发布',
minWidth: 260,
minWidth: 280,
slots: { default: 'deploymentTime' },
},
{
title: '操作',
width: 200,
width: 150,
fixed: 'right',
slots: { default: 'actions' },
},

View File

@ -161,7 +161,7 @@ const processDefinitionGroup = computed(() => {
string,
BpmProcessDefinitionApi.ProcessDefinitionVO[]
> = {};
categoryList.value.forEach((category: BpmCategoryApi.CategoryVO) => {
categoryList.value.forEach((category: BpmCategoryApi.Category) => {
if (grouped[category.code]) {
orderedGroup[category.code] = grouped[
category.code
@ -203,7 +203,7 @@ const availableCategories = computed(() => {
const availableCategoryCodes = Object.keys(processDefinitionGroup.value);
//
return categoryList.value.filter((category: BpmCategoryApi.CategoryVO) =>
return categoryList.value.filter((category: BpmCategoryApi.Category) =>
availableCategoryCodes.includes(category.code),
);
});