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