2023-02-11 00:44:00 +08:00
|
|
|
|
<template>
|
2023-03-26 00:16:28 +08:00
|
|
|
|
<ContentWrap>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
<div class="flex justify-between pl-20px items-center">
|
|
|
|
|
<h3 class="font-extrabold">流程模型</h3>
|
|
|
|
|
<!-- 搜索工作栏 -->
|
|
|
|
|
<el-form
|
|
|
|
|
v-if="!isCategorySorting"
|
|
|
|
|
class="-mb-15px flex mr-10px"
|
|
|
|
|
:model="queryParams"
|
|
|
|
|
ref="queryFormRef"
|
|
|
|
|
:inline="true"
|
|
|
|
|
label-width="68px"
|
|
|
|
|
@submit.prevent
|
|
|
|
|
>
|
|
|
|
|
<el-form-item align="right" prop="key" class="ml-auto">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="queryParams.key"
|
|
|
|
|
placeholder="搜索流程"
|
|
|
|
|
clearable
|
|
|
|
|
@keyup.enter="handleQuery"
|
|
|
|
|
class="!w-240px"
|
2024-10-03 17:13:13 +08:00
|
|
|
|
>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
<template #prefix>
|
|
|
|
|
<Icon icon="ep:search" class="mx-10px" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" @click="openForm('create')" v-hasPermi="['bpm:model:create']">
|
|
|
|
|
<Icon icon="ep:plus" class="mr-5px" /> 新建模型
|
2023-03-26 00:46:32 +08:00
|
|
|
|
</el-button>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-dropdown @command="(command) => handleCommand(command)" placement="bottom-end">
|
|
|
|
|
<el-button class="w-30px" plain>
|
|
|
|
|
<Icon icon="ep:setting" />
|
|
|
|
|
</el-button>
|
2024-10-03 17:13:13 +08:00
|
|
|
|
<template #dropdown>
|
|
|
|
|
<el-dropdown-menu>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
<el-dropdown-item command="handleAddCategory">
|
|
|
|
|
<Icon icon="ep:circle-plus" :size="13" class="mr-5px" />
|
|
|
|
|
新建分类
|
2024-10-03 17:13:13 +08:00
|
|
|
|
</el-dropdown-item>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
<el-dropdown-item command="handleSort">
|
|
|
|
|
<Icon icon="fa:sort-amount-desc" :size="13" class="mr-5px" />
|
|
|
|
|
分类排序
|
2024-10-03 17:13:13 +08:00
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dropdown>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div class="mr-20px" v-else>
|
|
|
|
|
<el-button @click="cancelSort"> 取 消 </el-button>
|
|
|
|
|
<el-button type="primary" @click="saveSort"> 保存排序 </el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<el-divider />
|
|
|
|
|
|
|
|
|
|
<!-- 分类卡片组 -->
|
|
|
|
|
<div class="px-15px">
|
|
|
|
|
<draggable
|
|
|
|
|
:disabled="!isCategorySorting"
|
|
|
|
|
v-model="categoryGroup"
|
|
|
|
|
item-key="id"
|
|
|
|
|
:animation="400"
|
|
|
|
|
>
|
|
|
|
|
<template #item="{ element }">
|
|
|
|
|
<ContentWrap
|
|
|
|
|
class="rounded-lg transition-all duration-300 ease-in-out hover:shadow-xl"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
:body-style="{ padding: 0 }"
|
|
|
|
|
:key="element.id"
|
|
|
|
|
>
|
|
|
|
|
<CategoryDraggableModel
|
|
|
|
|
ref="categoryDraggableModelRef"
|
|
|
|
|
:isCategorySorting="isCategorySorting"
|
|
|
|
|
:categoryInfo="element"
|
|
|
|
|
@success="getList"
|
|
|
|
|
/>
|
|
|
|
|
</ContentWrap>
|
2023-03-26 00:16:28 +08:00
|
|
|
|
</template>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
</draggable>
|
|
|
|
|
</div>
|
2023-03-26 00:16:28 +08:00
|
|
|
|
</ContentWrap>
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2023-03-26 01:36:27 +08:00
|
|
|
|
<!-- 表单弹窗:添加/修改流程 -->
|
2023-03-26 00:16:28 +08:00
|
|
|
|
<ModelForm ref="formRef" @success="getList" />
|
2024-10-19 21:53:05 +08:00
|
|
|
|
<!-- 表单弹窗:添加/修改分类 -->
|
|
|
|
|
<CategoryForm ref="categoryFormRef" @success="getList" />
|
2023-03-26 00:46:32 +08:00
|
|
|
|
<!-- 弹窗:表单详情 -->
|
|
|
|
|
<Dialog title="表单详情" v-model="formDetailVisible" width="800">
|
|
|
|
|
<form-create :rule="formDetailPreview.rule" :option="formDetailPreview.option" />
|
|
|
|
|
</Dialog>
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
2023-06-21 19:35:11 +08:00
|
|
|
|
<script lang="ts" setup>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
import { CategoryApi } from '@/api/bpm/category'
|
2023-02-11 00:44:00 +08:00
|
|
|
|
import * as ModelApi from '@/api/bpm/model'
|
2023-03-26 00:16:28 +08:00
|
|
|
|
import ModelForm from './ModelForm.vue'
|
2024-10-19 21:53:05 +08:00
|
|
|
|
import CategoryForm from '../category/CategoryForm.vue'
|
|
|
|
|
import { groupBy, cloneDeep } from 'lodash-es'
|
|
|
|
|
import CategoryDraggableModel from './CategoryDraggableModel.vue'
|
2023-06-21 19:14:34 +08:00
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'BpmModel' })
|
|
|
|
|
|
2024-10-19 21:53:05 +08:00
|
|
|
|
const categoryDraggableModelRef = ref()
|
|
|
|
|
const categoryFormRef = ref()
|
2023-03-26 00:16:28 +08:00
|
|
|
|
const loading = ref(true) // 列表的加载中
|
2024-10-19 21:53:05 +08:00
|
|
|
|
const isCategorySorting = ref(false) // 是否正处于排序状态
|
2023-03-26 00:16:28 +08:00
|
|
|
|
const queryParams = reactive({
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
key: undefined,
|
|
|
|
|
name: undefined,
|
|
|
|
|
category: undefined
|
2023-02-11 00:44:00 +08:00
|
|
|
|
})
|
2023-03-26 00:16:28 +08:00
|
|
|
|
const queryFormRef = ref() // 搜索的表单
|
2024-10-19 21:53:05 +08:00
|
|
|
|
const categoryGroup: any = ref([]) // 按照category分组的数据
|
|
|
|
|
const originalData: any = ref([])
|
|
|
|
|
// 查询所有分类数据
|
|
|
|
|
const getAllCategory = async () => {
|
|
|
|
|
// TODO 芋艿:这里需要一个不分页查全部的流程分类接口
|
|
|
|
|
const data = await CategoryApi.getCategoryPage(queryParams)
|
|
|
|
|
categoryGroup.value = data.list.map((item) => ({ ...item, modelList: [] }))
|
|
|
|
|
}
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2024-10-19 21:53:05 +08:00
|
|
|
|
/** 查询所有流程模型接口 */
|
|
|
|
|
const getAllModel = async () => {
|
|
|
|
|
// TODO 芋艿:这里需要一个不分页查全部的流程模型接口
|
|
|
|
|
const data = await ModelApi.getModelPage(queryParams)
|
|
|
|
|
const groupedData = groupBy(data.list, 'categoryName')
|
|
|
|
|
Object.keys(groupedData).forEach((key) => {
|
|
|
|
|
const category = categoryGroup.value.find((item) => item.name === key)
|
|
|
|
|
if (category) {
|
|
|
|
|
category.modelList = groupedData[key]
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-26 00:16:28 +08:00
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
|
queryParams.pageNo = 1
|
|
|
|
|
getList()
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-19 21:53:05 +08:00
|
|
|
|
/** 添加/修改操作 */
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
const openForm = (type: string, id?: number) => {
|
|
|
|
|
formRef.value.open(type, id)
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
2024-10-19 21:53:05 +08:00
|
|
|
|
/** 流程表单的详情按钮操作 */
|
|
|
|
|
const formDetailVisible = ref(false)
|
|
|
|
|
const formDetailPreview = ref({
|
|
|
|
|
rule: [],
|
|
|
|
|
option: {}
|
|
|
|
|
})
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2024-10-19 21:53:05 +08:00
|
|
|
|
/** 右上角设置按钮 */
|
|
|
|
|
const handleCommand = (command: string) => {
|
2024-10-03 17:13:13 +08:00
|
|
|
|
switch (command) {
|
2024-10-19 21:53:05 +08:00
|
|
|
|
case 'handleAddCategory':
|
|
|
|
|
handleAddCategory()
|
2024-10-03 17:13:13 +08:00
|
|
|
|
break
|
2024-10-19 21:53:05 +08:00
|
|
|
|
case 'handleSort':
|
|
|
|
|
handleSort()
|
2024-10-03 17:13:13 +08:00
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-19 21:53:05 +08:00
|
|
|
|
// 新建分类
|
|
|
|
|
const handleAddCategory = () => {
|
|
|
|
|
categoryFormRef.value.open('create')
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
2024-10-19 21:53:05 +08:00
|
|
|
|
// 分类排序
|
|
|
|
|
const handleSort = () => {
|
|
|
|
|
// 保存初始数据
|
|
|
|
|
originalData.value = cloneDeep(categoryGroup.value)
|
|
|
|
|
isCategorySorting.value = true
|
2023-03-26 00:46:32 +08:00
|
|
|
|
}
|
2024-10-19 21:53:05 +08:00
|
|
|
|
// 取消排序
|
|
|
|
|
const cancelSort = () => {
|
|
|
|
|
// 恢复初始数据
|
|
|
|
|
categoryGroup.value = cloneDeep(originalData.value)
|
|
|
|
|
isCategorySorting.value = false
|
2023-03-26 00:46:32 +08:00
|
|
|
|
}
|
2024-10-19 21:53:05 +08:00
|
|
|
|
// 保存排序
|
|
|
|
|
const saveSort = () => {
|
|
|
|
|
// TODO 芋艿:这里需要一个保存分类排序接口
|
2024-03-20 22:25:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-19 21:53:05 +08:00
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
2023-03-26 00:46:32 +08:00
|
|
|
|
try {
|
2024-10-19 21:53:05 +08:00
|
|
|
|
await getAllCategory()
|
|
|
|
|
await getAllModel()
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
2023-03-26 00:46:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-26 00:16:28 +08:00
|
|
|
|
/** 初始化 **/
|
2024-03-19 19:49:52 +08:00
|
|
|
|
onMounted(async () => {
|
2024-10-19 21:53:05 +08:00
|
|
|
|
getList()
|
2023-02-11 00:44:00 +08:00
|
|
|
|
})
|
|
|
|
|
</script>
|
2024-10-19 21:53:05 +08:00
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
:deep() {
|
|
|
|
|
.el-table--fit .el-table__inner-wrapper:before {
|
|
|
|
|
height: 0;
|
|
|
|
|
}
|
|
|
|
|
.el-card {
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
}
|
|
|
|
|
.el-form--inline .el-form-item {
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
}
|
|
|
|
|
.el-divider--horizontal {
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|