【功能实现】工作流:流程模型的分类、模型读取 list 接口

【功能实现】工作流:流程模型的分类名的修改实现
pull/582/head
YunaiV 2024-11-02 16:36:54 +08:00
parent fec7af453f
commit 1bb6a23ff8
5 changed files with 421 additions and 332 deletions

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,8 @@ export type ModelVO = {
bpmnXml: string bpmnXml: string
} }
export const getModelPage = async (params) => { export const getModelList = async (name: string | undefined) => {
return await request.get({ url: '/bpm/model/page', params }) return await request.get({ url: '/bpm/model/list', params: { name } })
} }
export const getModel = async (id: string) => { export const getModel = async (id: string) => {

View File

@ -39,7 +39,10 @@
<Icon icon="fa:plus" class="mr-5px" /> <Icon icon="fa:plus" class="mr-5px" />
新建 新建
</el-button> </el-button>
<el-dropdown @command="(command) => handleCategoryCommand(command)" placement="bottom"> <el-dropdown
@command="(command) => handleCategoryCommand(command, categoryInfo)"
placement="bottom"
>
<el-button link type="info"> <el-button link type="info">
<Icon icon="ep:setting" class="mr-5px" /> <Icon icon="ep:setting" class="mr-5px" />
分类 分类
@ -47,7 +50,7 @@
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item command="handleRename"> 重命名 </el-dropdown-item> <el-dropdown-item command="handleRename"> 重命名 </el-dropdown-item>
<el-dropdown-item command="handleDeleteGroup"> 删除该类 </el-dropdown-item> <el-dropdown-item command="handleDeleteCategory"> 删除该类 </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
@ -178,7 +181,7 @@
</el-button> </el-button>
<el-dropdown <el-dropdown
class="!align-middle ml-5px" class="!align-middle ml-5px"
@command="(command) => handleCommand(command, scope.row)" @command="(command) => handleModelCommand(command, scope.row)"
v-hasPermi="['bpm:process-definition:query', 'bpm:model:update', 'bpm:model:delete']" v-hasPermi="['bpm:process-definition:query', 'bpm:model:update', 'bpm:model:delete']"
> >
<el-button type="primary" link>更多</el-button> <el-button type="primary" link>更多</el-button>
@ -215,27 +218,28 @@
</el-collapse-transition> </el-collapse-transition>
<!-- 弹窗重命名分类 --> <!-- 弹窗重命名分类 -->
<Dialog :fullscreen="false" class="rename-dialog" v-model="renameVisible" width="400"> <Dialog :fullscreen="false" class="rename-dialog" v-model="renameCategoryVisible" width="400">
<template #title> <template #title>
<div class="pl-10px font-bold text-18px"> 重命名分类 </div> <div class="pl-10px font-bold text-18px"> 重命名分类 </div>
</template> </template>
<div class="px-30px"> <div class="px-30px">
<el-input v-model="renameVal" /> <el-input v-model="renameCategoryForm.name" />
</div> </div>
<template #footer> <template #footer>
<div class="pr-25px pb-25px"> <div class="pr-25px pb-25px">
<el-button @click="renameVisible = false"> </el-button> <el-button @click="renameCategoryVisible = false"> </el-button>
<el-button type="primary" @click="handleRenameConfirm"> </el-button> <el-button type="primary" @click="handleRenameConfirm"> </el-button>
</div> </div>
</template> </template>
</Dialog> </Dialog>
<!-- 表单弹窗添加流程模型 --> <!-- 表单弹窗添加流程模型 -->
<ModelForm :categoryId="categoryInfo.code" ref="modelFormRef" @success="emit('success')" /> <ModelForm :categoryId="categoryInfo.code" ref="modelFormRef" @success="emit('success')" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import ModelForm from './ModelForm.vue' import ModelForm from './ModelForm.vue'
import { CategoryApi } from '@/api/bpm/category' import { CategoryApi, CategoryVO } from '@/api/bpm/category'
import Sortable from 'sortablejs' import Sortable from 'sortablejs'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
@ -250,7 +254,6 @@ import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'BpmModel' }) defineOptions({ name: 'BpmModel' })
const renameVisible = ref(false)
const props = defineProps({ const props = defineProps({
// //
categoryInfo: propTypes.object.def([]), categoryInfo: propTypes.object.def([]),
@ -267,8 +270,9 @@ const isModelSorting = ref(false) // 是否正处于排序状态
const tableData: any = ref([]) const tableData: any = ref([])
const originalData: any = ref([]) // const originalData: any = ref([]) //
const isExpand = ref(false) // const isExpand = ref(false) //
/** '更多'操作按钮 */ /** '更多'操作按钮 */
const handleCommand = (command: string, row: any) => { const handleModelCommand = (command: string, row: any) => {
switch (command) { switch (command) {
case 'handleDefinitionList': case 'handleDefinitionList':
handleDefinitionList(row) handleDefinitionList(row)
@ -284,15 +288,15 @@ const handleCommand = (command: string, row: any) => {
} }
} }
/* '分类'操作按钮 */ /** '分类'操作按钮 */
const handleCategoryCommand = (command: string) => { const handleCategoryCommand = async (command: string, row: any) => {
switch (command) { switch (command) {
case 'handleRename': case 'handleRename':
renameVal.value = props.categoryInfo.name renameCategoryForm.value = await CategoryApi.getCategory(row.id)
renameVisible.value = true renameCategoryVisible.value = true
break break
case 'handleDeleteGroup': case 'handleDeleteCategory':
handleDeleteGroup() await handleDeleteCategory()
break break
default: default:
break break
@ -364,7 +368,7 @@ const handleDeploy = async (row: any) => {
} }
/** 跳转到指定流程定义列表 */ /** 跳转到指定流程定义列表 */
const handleDefinitionList = (row) => { const handleDefinitionList = (row: any) => {
push({ push({
name: 'BpmProcessDefinition', name: 'BpmProcessDefinition',
query: { query: {
@ -450,16 +454,25 @@ const updateTableData = () => {
} }
} }
const renameVal = ref('') /** 重命名弹窗确定 */
// const renameCategoryVisible = ref(false)
const handleRenameConfirm = () => { const renameCategoryForm = ref({
if (!renameVal.value) { name: ''
})
const handleRenameConfirm = async () => {
if (renameCategoryForm.value?.name.length === 0) {
return message.warning('请输入名称') return message.warning('请输入名称')
} }
//
await CategoryApi.updateCategory(renameCategoryForm.value as CategoryVO)
message.success('修改成功')
//
renameCategoryVisible.value = false
emit('success')
} }
// //
const handleDeleteGroup = async () => { const handleDeleteCategory = async () => {
try { try {
if (props.categoryInfo.modelList.length > 0) { if (props.categoryInfo.modelList.length > 0) {
return message.warning('该分类下仍有流程定义,不允许删除') return message.warning('该分类下仍有流程定义,不允许删除')

View File

@ -12,9 +12,9 @@
label-width="68px" label-width="68px"
@submit.prevent @submit.prevent
> >
<el-form-item align="right" prop="key" class="ml-auto"> <el-form-item prop="name" class="ml-auto">
<el-input <el-input
v-model="queryParams.key" v-model="queryParams.name"
placeholder="搜索流程" placeholder="搜索流程"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
@ -25,12 +25,12 @@
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item>
<!-- 右上角新建模型更多操作 -->
<el-form-item> <el-form-item>
<el-button type="primary" @click="openForm('create')" v-hasPermi="['bpm:model:create']"> <el-button type="primary" @click="openForm('create')" v-hasPermi="['bpm:model:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新建模型 <Icon icon="ep:plus" class="mr-5px" /> 新建模型
</el-button> </el-button>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-dropdown @command="(command) => handleCommand(command)" placement="bottom-end"> <el-dropdown @command="(command) => handleCommand(command)" placement="bottom-end">
<el-button class="w-30px" plain> <el-button class="w-30px" plain>
@ -59,7 +59,7 @@
<el-divider /> <el-divider />
<!-- 分类卡片组 --> <!-- 按照分类展示其所属的模型列表 -->
<div class="px-15px"> <div class="px-15px">
<draggable <draggable
:disabled="!isCategorySorting" :disabled="!isCategorySorting"
@ -75,7 +75,6 @@
:key="element.id" :key="element.id"
> >
<CategoryDraggableModel <CategoryDraggableModel
ref="categoryDraggableModelRef"
:isCategorySorting="isCategorySorting" :isCategorySorting="isCategorySorting"
:categoryInfo="element" :categoryInfo="element"
@success="getList" @success="getList"
@ -88,7 +87,7 @@
<!-- 表单弹窗添加/修改流程 --> <!-- 表单弹窗添加/修改流程 -->
<ModelForm ref="formRef" @success="getList" /> <ModelForm ref="formRef" @success="getList" />
<!-- 表单弹窗添加/修改分类 --> <!-- 表单弹窗添加分类 -->
<CategoryForm ref="categoryFormRef" @success="getList" /> <CategoryForm ref="categoryFormRef" @success="getList" />
<!-- 弹窗表单详情 --> <!-- 弹窗表单详情 -->
<Dialog title="表单详情" v-model="formDetailVisible" width="800"> <Dialog title="表单详情" v-model="formDetailVisible" width="800">
@ -107,34 +106,30 @@ import CategoryDraggableModel from './CategoryDraggableModel.vue'
defineOptions({ name: 'BpmModel' }) defineOptions({ name: 'BpmModel' })
const categoryDraggableModelRef = ref()
const categoryFormRef = ref() const categoryFormRef = ref()
const loading = ref(true) // const loading = ref(true) //
const isCategorySorting = ref(false) // const isCategorySorting = ref(false) // category
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, name: undefined
pageSize: 10,
key: undefined,
name: undefined,
category: undefined
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const categoryGroup: any = ref([]) // category const categoryGroup: any = ref([]) // category
const originalData: any = ref([]) const originalData: any = ref([]) //
//
/** 查询所有分类 */
const getAllCategory = async () => { const getAllCategory = async () => {
// TODO const list = await CategoryApi.getCategorySimpleList()
const data = await CategoryApi.getCategoryPage(queryParams) categoryGroup.value = list.map((item: any) => ({ ...item, modelList: [] }))
categoryGroup.value = data.list.map((item) => ({ ...item, modelList: [] }))
} }
/** 查询所有流程模型接口 */ /** 查询所有流程模型接口 */
const getAllModel = async () => { const getAllModel = async () => {
// TODO //
const data = await ModelApi.getModelPage(queryParams) const list = await ModelApi.getModelList(queryParams.name)
const groupedData = groupBy(data.list, 'categoryName') // categoryName
const groupedData = groupBy(list, 'categoryName')
Object.keys(groupedData).forEach((key) => { Object.keys(groupedData).forEach((key) => {
const category = categoryGroup.value.find((item) => item.name === key) const category = categoryGroup.value.find((item: any) => item.name === key)
if (category) { if (category) {
category.modelList = groupedData[key] category.modelList = groupedData[key]
} }
@ -143,7 +138,6 @@ const getAllModel = async () => {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.pageNo = 1
getList() getList()
} }
@ -152,6 +146,7 @@ const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
/** 流程表单的详情按钮操作 */ /** 流程表单的详情按钮操作 */
const formDetailVisible = ref(false) const formDetailVisible = ref(false)
const formDetailPreview = ref({ const formDetailPreview = ref({
@ -173,27 +168,33 @@ const handleCommand = (command: string) => {
} }
} }
// /** 新建分类 */
const handleAddCategory = () => { const handleAddCategory = () => {
categoryFormRef.value.open('create') categoryFormRef.value.open('create')
} }
//
// TODO
/** 分类排序 */
const handleSort = () => { const handleSort = () => {
// //
originalData.value = cloneDeep(categoryGroup.value) originalData.value = cloneDeep(categoryGroup.value)
isCategorySorting.value = true isCategorySorting.value = true
} }
//
// TODO
/** 取消排序 */
const cancelSort = () => { const cancelSort = () => {
// //
categoryGroup.value = cloneDeep(originalData.value) categoryGroup.value = cloneDeep(originalData.value)
isCategorySorting.value = false isCategorySorting.value = false
} }
//
/** 保存排序 */
const saveSort = () => { const saveSort = () => {
// TODO // TODO
} }
/** 加载数据 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
@ -205,7 +206,7 @@ const getList = async () => {
} }
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(() => {
getList() getList()
}) })
</script> </script>

View File

@ -252,7 +252,7 @@ const categoryList = ref([]) // 流程分类列表
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await ModelApi.getModelPage(queryParams) const data = await ModelApi.getModelList(queryParams)
list.value = data.list list.value = data.list
total.value = data.total total.value = data.total
} finally { } finally {