update 重构流程分类表

This commit is contained in:
疯狂的狮子Li 2024-12-16 17:22:36 +08:00
parent f832a6b3be
commit aa1bceeafb
5 changed files with 102 additions and 55 deletions

View File

@ -1,13 +1,16 @@
export interface CategoryTreeVO {
id: number | string;
label: string;
parentId: number | string;
weight: number;
children: CategoryTreeVO[];
}
export interface CategoryVO {
/**
*
*/
id: string;
/**
*
*/
categoryName: string;
categoryId: string | number;
/**
* id
@ -15,33 +18,60 @@ export interface CategoryVO {
parentId: string | number;
/**
*
*
*/
sortNum: number;
parentName: string;
/**
*
*/
ancestors: string;
/**
*
*/
categoryName: string;
/**
*
*/
orderNum: number;
/**
* 0 1
*/
status: number;
children: CategoryVO[];
children?: CategoryVO[];
}
export interface CategoryForm extends BaseEntity {
/**
*
*/
id?: string | number;
categoryId?: string | number;
/**
* id
*/
parentId: string | number;
/**
*
*/
categoryName?: string;
/**
* id
*/
parentId?: string | number;
/**
*
*/
sortNum?: number;
orderNum?: number;
/**
* 0 1
*/
status: number;
}
export interface CategoryQuery extends PageQuery {

View File

@ -1,19 +1,39 @@
import request from '@/utils/request';
import { FlowDefinitionQuery, definitionXmlVO, FlowDefinitionForm } from '@/api/workflow/definition/types';
import {
FlowDefinitionQuery,
definitionXmlVO,
FlowDefinitionForm,
FlowDefinitionVo
} from '@/api/workflow/definition/types';
import { AxiosPromise } from 'axios';
import {CategoryForm, CategoryTreeVO} from "@/api/workflow/category/types";
/**
*
* @param query id
* @returns
*/
export const listDefinition = (query: FlowDefinitionQuery): AxiosPromise<FlowDefinitionQuery[]> => {
export const listDefinition = (query: FlowDefinitionQuery): AxiosPromise<FlowDefinitionVo[]> => {
return request({
url: `/workflow/definition/list`,
method: 'get',
params: query
});
};
/**
*
* @param query id
* @returns
*/
export const categoryTree = (query?: CategoryForm): AxiosPromise<CategoryTreeVO[]> => {
return request({
url: `/workflow/definition/categoryTree`,
method: 'get',
params: query
});
};
/**
* key获取流程定义
* @param flowCode

View File

@ -1,7 +1,7 @@
export interface FlowDefinitionQuery extends PageQuery {
flowCode?: string;
flowName?: string;
category: string;
category: string | number;
isPublish?: number;
}

View File

@ -30,7 +30,7 @@
ref="categoryTableRef"
v-loading="loading"
:data="categoryList"
row-key="id"
row-key="categoryId"
:default-expand-all="isExpandAll"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
@ -58,8 +58,8 @@
<el-tree-select
v-model="form.parentId"
:data="categoryOptions"
:props="{ value: 'id', label: 'categoryName', children: 'children' }"
value-key="id"
:props="{ value: 'categoryId', label: 'categoryName', children: 'children' }"
value-key="categoryId"
placeholder="请选择父级id"
check-strictly
/>
@ -67,8 +67,8 @@
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model="form.categoryName" placeholder="请输入分类名称" />
</el-form-item>
<el-form-item label="排序" prop="sortNum">
<el-input-number v-model="form.sortNum" placeholder="请输入排序" controls-position="right" :min="0" />
<el-form-item label="排序" prop="orderNum">
<el-input-number v-model="form.orderNum" placeholder="请输入排序" controls-position="right" :min="0" />
</el-form-item>
</el-form>
<template #footer>
@ -86,8 +86,9 @@ import { listCategory, getCategory, delCategory, addCategory, updateCategory } f
import { CategoryVO, CategoryQuery, CategoryForm } from '@/api/workflow/category/types';
type CategoryOption = {
id: number;
categoryId: string | number;
categoryName: string;
parentId: string | number;
children?: CategoryOption[];
};
@ -110,10 +111,11 @@ const dialog = reactive<DialogOption>({
});
const initFormData: CategoryForm = {
id: undefined,
categoryId: undefined,
categoryName: undefined,
parentId: undefined,
sortNum: 0
orderNum: 0,
status: 0
};
const data = reactive<PageData<CategoryForm, CategoryQuery>>({
@ -136,7 +138,7 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listCategory(queryParams.value);
const data = proxy?.handleTree<CategoryVO>(res.data, 'id', 'parentId');
const data = proxy?.handleTree<CategoryVO>(res.data, 'categoryId', 'parentId');
if (data) {
categoryList.value = data;
loading.value = false;
@ -147,9 +149,10 @@ const getList = async () => {
const getTreeselect = async () => {
const res = await listCategory();
categoryOptions.value = [];
const data: CategoryOption = { id: 0, categoryName: '顶级节点', children: [] };
data.children = proxy?.handleTree<CategoryOption>(res.data, 'id', 'parentId');
const data: CategoryOption = { categoryId: 0, categoryName: '顶级节点', parentId: 0, children: [] };
data.children = proxy?.handleTree<CategoryOption>(res.data, 'categoryId', 'parentId');
categoryOptions.value.push(data);
console.log(categoryOptions.value)
};
//
@ -182,8 +185,8 @@ const handleAdd = (row?: CategoryVO) => {
nextTick(() => {
reset();
getTreeselect();
if (row != null && row.id) {
form.value.parentId = row.id;
if (row != null && row.categoryId) {
form.value.parentId = row.categoryId;
} else {
form.value.parentId = 0;
}
@ -213,9 +216,9 @@ const handleUpdate = (row: CategoryVO) => {
reset();
await getTreeselect();
if (row != null) {
form.value.parentId = row.id;
form.value.parentId = row.categoryId;
}
const res = await getCategory(row.id);
const res = await getCategory(row.categoryId);
loading.value = false;
Object.assign(form.value, res.data);
});
@ -226,7 +229,7 @@ const submitForm = () => {
categoryFormRef.value.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
if (form.value.categoryId) {
await updateCategory(form.value).finally(() => (buttonLoading.value = false));
} else {
await addCategory(form.value).finally(() => (buttonLoading.value = false));
@ -240,9 +243,9 @@ const submitForm = () => {
/** 删除按钮操作 */
const handleDelete = async (row: CategoryVO) => {
await proxy?.$modal.confirm('是否确认删除流程分类编号为"' + row.id + '"的数据项?');
await proxy?.$modal.confirm('是否确认删除流程分类编号为"' + row.categoryId + '"的数据项?');
loading.value = true;
await delCategory(row.id).finally(() => (loading.value = false));
await delCategory(row.categoryId).finally(() => (loading.value = false));
await getList();
proxy?.$modal.msgSuccess('删除成功');
};

View File

@ -10,7 +10,7 @@
class="mt-2"
node-key="id"
:data="categoryOptions"
:props="{ label: 'categoryName', children: 'children' }"
:props="{ value: 'id', label: 'label', children: 'children' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
highlight-current
@ -62,7 +62,7 @@
<el-table v-loading="loading" border :data="processDefinitionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column align="center" prop="id" label="主键" v-if="true" ></el-table-column>
<el-table-column align="center" prop="id" label="主键" v-if="false" ></el-table-column>
<el-table-column align="center" prop="flowName" label="流程定义名称" :show-overflow-tooltip="true"></el-table-column>
<el-table-column align="center" prop="flowCode" label="标识KEY" :show-overflow-tooltip="true"></el-table-column>
<el-table-column align="center" prop="version" label="版本号" width="80">
@ -146,7 +146,7 @@
<el-tree-select
v-model="selectCategory"
:data="categoryOptions"
:props="{ value: 'id', label: 'categoryName', children: 'children' }"
:props="{ value: 'id', label: 'label', children: 'children' }"
filterable
value-key="id"
:render-after-expand="false"
@ -234,7 +234,7 @@
<el-tree-select
v-model="form.category"
:data="categoryOptions"
:props="{ value: 'id', label: 'categoryName', children: 'children' }"
:props="{ value: 'id', label: 'label', children: 'children' }"
filterable
value-key="id"
:render-after-expand="false"
@ -262,9 +262,9 @@
</template>
<script lang="ts" setup name="processDefinition">
import { listDefinition, deleteDefinition, active, importDef, getHisListByKey, publish, add, edit, getInfo, copy } from '@/api/workflow/definition';
import { listCategory } from '@/api/workflow/category';
import { CategoryVO } from '@/api/workflow/category/types';
import { listDefinition, deleteDefinition, active, importDef,
getHisListByKey, publish, add, edit, getInfo, copy, categoryTree } from '@/api/workflow/definition';
import { CategoryTreeVO } from '@/api/workflow/category/types';
import { FlowDefinitionQuery, FlowDefinitionVo, FlowDefinitionForm } from '@/api/workflow/definition/types';
import { UploadRequestOptions } from 'element-plus';
@ -273,12 +273,6 @@ const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const queryFormRef = ref<ElFormInstance>();
const categoryTreeRef = ref<ElTreeInstance>();
type CategoryOption = {
id: string;
categoryName: string;
children?: CategoryOption[];
};
const loading = ref(true);
const ids = ref<Array<any>>([]);
const flowCodeList = ref<Array<any>>([]);
@ -289,7 +283,7 @@ const total = ref(0);
const uploadDialogLoading = ref(false);
const processDefinitionList = ref<FlowDefinitionVo[]>([]);
const processDefinitionHistoryList = ref<FlowDefinitionVo[]>([]);
const categoryOptions = ref<CategoryOption[]>([]);
const categoryOptions = ref<CategoryTreeVO[]>([]);
const categoryName = ref('');
/** 部署文件分类选择 */
const selectCategory = ref();
@ -344,7 +338,7 @@ onMounted(() => {
});
/** 节点单击事件 */
const handleNodeClick = (data: CategoryVO) => {
const handleNodeClick = (data: CategoryTreeVO) => {
queryParams.value.category = data.id;
if (data.id === '0') {
queryParams.value.category = '';
@ -368,10 +362,10 @@ watchEffect(
/** 查询流程分类下拉树结构 */
const getTreeselect = async () => {
const res = await listCategory();
const res = await categoryTree();
categoryOptions.value = [];
const data: CategoryOption = { id: '0', categoryName: '顶级节点', children: [] };
data.children = proxy?.handleTree<CategoryOption>(res.data, 'id', 'parentId');
const data: CategoryTreeVO = { id: '0', parentId: '0', label: '顶级节点', weight: 0, children: [] };
data.children = res.data
categoryOptions.value.push(data);
};