review:流程分类
parent
0ccc6e0b80
commit
471f403a73
|
@ -2,7 +2,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
|||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace CategoryApi {
|
||||
export namespace BpmCategoryApi {
|
||||
/** BPM 流程分类 VO */
|
||||
export interface CategoryVO {
|
||||
id: number;
|
||||
|
@ -15,26 +15,21 @@ export namespace CategoryApi {
|
|||
|
||||
/** 查询流程分类分页 */
|
||||
export async function getCategoryPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<CategoryApi.CategoryVO>>(
|
||||
'/bpm/category/page',
|
||||
{ params },
|
||||
);
|
||||
return requestClient.get<PageResult<BpmCategoryApi.CategoryVO>>('/bpm/category/page', { params });
|
||||
}
|
||||
|
||||
/** 查询流程分类详情 */
|
||||
export async function getCategory(id: number) {
|
||||
return requestClient.get<CategoryApi.CategoryVO>(
|
||||
`/bpm/category/get?id=${id}`,
|
||||
);
|
||||
return requestClient.get<BpmCategoryApi.CategoryVO>(`/bpm/category/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增流程分类 */
|
||||
export async function createCategory(data: CategoryApi.CategoryVO) {
|
||||
export async function createCategory(data: BpmCategoryApi.CategoryVO) {
|
||||
return requestClient.post('/bpm/category/create', data);
|
||||
}
|
||||
|
||||
/** 修改流程分类 */
|
||||
export async function updateCategory(data: CategoryApi.CategoryVO) {
|
||||
export async function updateCategory(data: BpmCategoryApi.CategoryVO) {
|
||||
return requestClient.put('/bpm/category/update', data);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { CategoryApi } from '#/api/bpm/category/index';
|
||||
import type { BpmCategoryApi } from '#/api/bpm/category';
|
||||
|
||||
import { useAccess } from '@vben/access';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { CommonStatusEnum } from '#/utils/constants';
|
||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||
|
@ -107,7 +106,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns<T = CategoryApi.CategoryVO>(
|
||||
export function useGridColumns<T = BpmCategoryApi.CategoryVO>(
|
||||
onActionClick: OnActionClickFn<T>,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
<script lang="ts" setup>
|
||||
import type {
|
||||
OnActionClickParams,
|
||||
VxeTableGridOptions,
|
||||
} from '#/adapter/vxe-table';
|
||||
import type { CategoryApi } from '#/api/bpm/category/index';
|
||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { BpmCategoryApi } from '#/api/bpm/category';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteCategory, getCategoryPage } from '#/api/bpm/category/index';
|
||||
import { deleteCategory, getCategoryPage } from '#/api/bpm/category';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
|
@ -46,14 +42,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
refresh: { code: 'query' },
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<CategoryApi.CategoryVO>,
|
||||
} as VxeTableGridOptions<BpmCategoryApi.CategoryVO>,
|
||||
});
|
||||
|
||||
/** 表格操作按钮的回调函数 */
|
||||
function onActionClick({
|
||||
code,
|
||||
row,
|
||||
}: OnActionClickParams<CategoryApi.CategoryVO>) {
|
||||
}: OnActionClickParams<BpmCategoryApi.CategoryVO>) {
|
||||
switch (code) {
|
||||
case 'delete': {
|
||||
onDelete(row);
|
||||
|
@ -77,12 +73,12 @@ function onCreate() {
|
|||
}
|
||||
|
||||
/** 编辑流程分类 */
|
||||
function onEdit(row: CategoryApi.CategoryVO) {
|
||||
function onEdit(row: BpmCategoryApi.CategoryVO) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除流程分类 */
|
||||
async function onDelete(row: CategoryApi.CategoryVO) {
|
||||
async function onDelete(row: BpmCategoryApi.CategoryVO) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
<script lang="ts" setup>
|
||||
import type { CategoryApi } from '#/api/bpm/category/index';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import type { BpmCategoryApi } from '#/api/bpm/category';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createCategory,
|
||||
getCategory,
|
||||
updateCategory,
|
||||
} from '#/api/bpm/category/index';
|
||||
import {createCategory, getCategory, updateCategory } from '#/api/bpm/category';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<CategoryApi.CategoryVO>();
|
||||
const formData = ref<BpmCategoryApi.CategoryVO>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.id
|
||||
? $t('ui.actionTitle.edit', ['流程分类'])
|
||||
|
@ -39,7 +33,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as CategoryApi.CategoryVO;
|
||||
const data = (await formApi.getValues()) as BpmCategoryApi.CategoryVO;
|
||||
try {
|
||||
await (formData.value?.id ? updateCategory(data) : createCategory(data));
|
||||
// 关闭并提示
|
||||
|
@ -58,7 +52,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<CategoryApi.CategoryVO>();
|
||||
const data = modalApi.getData<BpmCategoryApi.CategoryVO>();
|
||||
if (!data || !data.id) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue