From ce431e28be453d478029e904611815e1d4b82e51 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Fri, 11 Apr 2025 10:47:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=20=E6=B5=81=E7=A8=8B=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/bpm/category/index.ts | 44 +++++ apps/web-antd/src/views/bpm/category/data.ts | 163 ++++++++++++++++++ .../web-antd/src/views/bpm/category/index.vue | 117 +++++++++++++ .../src/views/bpm/category/modules/form.vue | 81 +++++++++ 4 files changed, 405 insertions(+) create mode 100644 apps/web-antd/src/api/bpm/category/index.ts create mode 100644 apps/web-antd/src/views/bpm/category/data.ts create mode 100644 apps/web-antd/src/views/bpm/category/index.vue create mode 100644 apps/web-antd/src/views/bpm/category/modules/form.vue diff --git a/apps/web-antd/src/api/bpm/category/index.ts b/apps/web-antd/src/api/bpm/category/index.ts new file mode 100644 index 000000000..27fc9ed50 --- /dev/null +++ b/apps/web-antd/src/api/bpm/category/index.ts @@ -0,0 +1,44 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace CategoryApi { + /** BPM 流程分类 VO */ + export interface CategoryVO { + id: number; + name: string; + code: string; + status: number; + sort: number; // 分类排序 + } +} + +/** 查询流程分类分页 */ +export async function getCategoryPage(params: PageParam) { + return requestClient.get>( + '/bpm/category/page', + { params }, + ); +} + +/** 查询流程分类详情 */ +export async function getCategory(id: number) { + return requestClient.get( + `/bpm/category/get?id=${id}`, + ); +} + +/** 新增流程分类 */ +export async function createCategory(data: CategoryApi.CategoryVO) { + return requestClient.post('/bpm/category/create', data); +} + +/** 修改流程分类 */ +export async function updateCategory(data: CategoryApi.CategoryVO) { + return requestClient.put('/bpm/category/update', data); +} + +/** 删除流程分类 */ +export async function deleteCategory(id: number) { + return requestClient.delete(`/bpm/category/delete?id=${id}`); +} diff --git a/apps/web-antd/src/views/bpm/category/data.ts b/apps/web-antd/src/views/bpm/category/data.ts new file mode 100644 index 000000000..46f2c5e4d --- /dev/null +++ b/apps/web-antd/src/views/bpm/category/data.ts @@ -0,0 +1,163 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { CategoryApi } from '#/api/bpm/category/index'; + +import { z } from '#/adapter/form'; +import { CommonStatusEnum } from '#/utils/constants'; +import { DICT_TYPE, getDictOptions } from '#/utils/dict'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + fieldName: 'name', + label: '分类名', + component: 'Input', + componentProps: { + placeholder: '请输入分类名', + }, + rules: 'required', + }, + { + label: '分类标志', + fieldName: 'code', + component: 'Input', + componentProps: { + placeholder: '请输入分类标志', + }, + rules: 'required', + }, + { + fieldName: 'description', + label: '分类描述', + component: 'Textarea', + componentProps: { + placeholder: '请输入分类描述', + }, + }, + { + fieldName: 'status', + label: '分类状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + { + fieldName: 'sort', + label: '分类排序', + component: 'InputNumber', + componentProps: { + min: 0, + class: 'w-full', + controlsPosition: 'right', + placeholder: '请输入分类排序', + }, + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '分类名', + component: 'Input', + componentProps: { + placeholder: '请输入分类名', + allowClear: true, + }, + }, + // TODO 分类标志 + { + fieldName: 'status', + label: '分类状态', + component: 'Select', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + placeholder: '请选择分类状态', + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '分类编号', + minWidth: 100, + }, + { + field: 'name', + title: '分类名', + minWidth: 200, + }, + { + field: 'code', + title: '分类标志', + minWidth: 200, + }, + { + field: 'description', + title: '分类描述', + minWidth: 200, + }, + { + field: 'status', + title: '分类状态', + minWidth: 100, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'operation', + title: '操作', + minWidth: 180, + align: 'center', + fixed: 'right', + cellRender: { + attrs: { + nameField: 'name', + nameTitle: '流程分类', + onClick: onActionClick, + }, + name: 'CellOperation', + options: [ + { + code: 'edit', + // show: hasAccessByCodes(['bpm:category:update']), TODO 权限 + }, + { + code: 'delete', + // show: hasAccessByCodes(['bpm:category:delete']), + }, + ], + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/bpm/category/index.vue b/apps/web-antd/src/views/bpm/category/index.vue new file mode 100644 index 000000000..ca3062728 --- /dev/null +++ b/apps/web-antd/src/views/bpm/category/index.vue @@ -0,0 +1,117 @@ + + + diff --git a/apps/web-antd/src/views/bpm/category/modules/form.vue b/apps/web-antd/src/views/bpm/category/modules/form.vue new file mode 100644 index 000000000..90f006b80 --- /dev/null +++ b/apps/web-antd/src/views/bpm/category/modules/form.vue @@ -0,0 +1,81 @@ + + + From e82ddeb9159f5a8b5445cd9c705004b814dfac9c Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Fri, 11 Apr 2025 13:38:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=B5=81=E7=A8=8B=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E6=8C=89=E9=92=AE=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/bpm/category/data.ts | 18 +++++++++++++++--- apps/web-antd/src/views/bpm/category/index.vue | 7 +++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/web-antd/src/views/bpm/category/data.ts b/apps/web-antd/src/views/bpm/category/data.ts index 46f2c5e4d..0e2ca35ab 100644 --- a/apps/web-antd/src/views/bpm/category/data.ts +++ b/apps/web-antd/src/views/bpm/category/data.ts @@ -2,10 +2,13 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; import type { CategoryApi } from '#/api/bpm/category/index'; +import { useAccess } from '@vben/access'; + import { z } from '#/adapter/form'; import { CommonStatusEnum } from '#/utils/constants'; import { DICT_TYPE, getDictOptions } from '#/utils/dict'; +const { hasAccessByCodes } = useAccess(); /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { return [ @@ -80,7 +83,15 @@ export function useGridFormSchema(): VbenFormSchema[] { allowClear: true, }, }, - // TODO 分类标志 + { + fieldName: 'code', + label: '分类标志', + component: 'Input', + componentProps: { + placeholder: '请输入分类标志', + allowClear: true, + }, + }, { fieldName: 'status', label: '分类状态', @@ -91,6 +102,7 @@ export function useGridFormSchema(): VbenFormSchema[] { allowClear: true, }, }, + // TODO 创建时间 等通用方法完善后加 ]; } @@ -150,11 +162,11 @@ export function useGridColumns( options: [ { code: 'edit', - // show: hasAccessByCodes(['bpm:category:update']), TODO 权限 + show: hasAccessByCodes(['bpm:category:update']), }, { code: 'delete', - // show: hasAccessByCodes(['bpm:category:delete']), + show: hasAccessByCodes(['bpm:category:delete']), }, ], }, diff --git a/apps/web-antd/src/views/bpm/category/index.vue b/apps/web-antd/src/views/bpm/category/index.vue index ca3062728..80e0ab099 100644 --- a/apps/web-antd/src/views/bpm/category/index.vue +++ b/apps/web-antd/src/views/bpm/category/index.vue @@ -6,7 +6,6 @@ import type { import type { CategoryApi } from '#/api/bpm/category/index'; import { Page, useVbenModal } from '@vben/common-ui'; -import { Plus } from '@vben/icons'; import { Button, message } from 'ant-design-vue'; @@ -107,7 +106,11 @@ async function onDelete(row: CategoryApi.CategoryVO) {