Skip to content

Commit 91ea4b7

Browse files
committed
feat: 流程模型分类排序功能实现、数据获取分组逻辑优化、排序状态下按钮显示逻辑控制
1 parent 2db1f72 commit 91ea4b7

File tree

3 files changed

+135
-296
lines changed

3 files changed

+135
-296
lines changed

src/views/bpm/model/CategoryDraggableModel.vue

Lines changed: 63 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,51 @@
11
<template>
22
<!-- 默认使其全部展开 -->
3-
<el-collapse :modelValue="title">
4-
<el-collapse-item :name="title">
3+
<el-collapse v-model="activeCollapse">
4+
<el-collapse-item :name="categoryInfo.id">
55
<template #icon="{ isActive }">
6-
<div
7-
class="ml-20px flex items-center"
8-
:class="['transition-transform duration-300', isActive ? 'rotate-180' : 'rotate-0']"
9-
>
10-
<Icon icon="ep:arrow-down-bold" color="#999" />
11-
</div>
12-
<div class="ml-auto mr-45px flex items-center">
13-
<template v-if="!isSorting">
14-
<el-button link type="info" class="mr-20px" @click.stop="handleSort">
15-
<Icon icon="fa:sort-amount-desc" class="mr-5px" />
16-
排序
17-
</el-button>
18-
<el-dropdown @command="(command) => handleCategoryCommand(command)" placement="bottom">
19-
<el-button link type="info" @click.stop="handleGroup">
20-
<Icon icon="ep:setting" class="mr-5px" />
21-
分类
6+
<div class="flex-1 flex" v-if="!isCategorySorting">
7+
<div
8+
class="ml-20px flex items-center"
9+
:class="['transition-transform duration-300', isActive ? 'rotate-180' : 'rotate-0']"
10+
>
11+
<Icon icon="ep:arrow-down-bold" color="#999" />
12+
</div>
13+
<div class="ml-auto mr-45px flex items-center">
14+
<template v-if="!isModelSorting">
15+
<el-button
16+
v-if="categoryInfo.modelList.length > 0"
17+
link
18+
type="info"
19+
class="mr-20px"
20+
@click.stop="handleSort"
21+
>
22+
<Icon icon="fa:sort-amount-desc" class="mr-5px" />
23+
排序
2224
</el-button>
23-
<template #dropdown>
24-
<el-dropdown-menu>
25-
<el-dropdown-item command="handleRename"> 重命名 </el-dropdown-item>
26-
<el-dropdown-item command="handleDeleteGroup"> 删除该类 </el-dropdown-item>
27-
</el-dropdown-menu>
28-
</template>
29-
</el-dropdown>
30-
</template>
31-
<template v-else>
32-
<el-button @click.stop="cancelSort"> 取 消 </el-button>
33-
<el-button type="primary" @click.stop="saveSort"> 保存排序 </el-button>
34-
</template>
25+
<el-dropdown
26+
@command="(command) => handleCategoryCommand(command)"
27+
placement="bottom"
28+
>
29+
<el-button link type="info" @click.stop="handleGroup">
30+
<Icon icon="ep:setting" class="mr-5px" />
31+
分类
32+
</el-button>
33+
<template #dropdown>
34+
<el-dropdown-menu>
35+
<el-dropdown-item command="handleRename"> 重命名 </el-dropdown-item>
36+
<el-dropdown-item command="handleDeleteGroup"> 删除该类 </el-dropdown-item>
37+
</el-dropdown-menu>
38+
</template>
39+
</el-dropdown>
40+
</template>
41+
<template v-else>
42+
<el-button @click.stop="cancelSort"> 取 消 </el-button>
43+
<el-button type="primary" @click.stop="saveSort"> 保存排序 </el-button>
44+
</template>
45+
<!-- <el-button v-else type="primary" @click.stop="addModel"> 新建模型 </el-button> -->
46+
</div>
3547
</div>
48+
<div></div>
3649
</template>
3750
<template #title>
3851
<div class="flex items-center">
@@ -43,12 +56,12 @@
4356
class="ml-10px category-drag-icon cursor-move text-#8a909c"
4457
/>
4558
</el-tooltip>
46-
<h3 class="ml-20px mr-8px text-18px">{{ title }}</h3>
47-
<div class="color-gray-600 text-16px"> ({{ dataList?.length || 0 }}) </div>
59+
<h3 class="ml-20px mr-8px text-18px">{{ categoryInfo.name }}</h3>
60+
<div class="color-gray-600 text-16px"> ({{ categoryInfo.modelList?.length || 0 }}) </div>
4861
</div>
4962
</template>
5063
<el-table
51-
:class="title"
64+
:class="categoryInfo.name"
5265
ref="tableRef"
5366
:header-cell-style="{ backgroundColor: isDark ? '' : '#edeff0', paddingLeft: '10px' }"
5467
:cell-style="{ paddingLeft: '10px' }"
@@ -58,7 +71,7 @@
5871
<el-table-column label="流程名" prop="name" min-width="150">
5972
<template #default="scope">
6073
<div class="flex items-center">
61-
<el-tooltip content="拖动排序" v-if="isSorting">
74+
<el-tooltip content="拖动排序" v-if="isModelSorting">
6275
<Icon
6376
icon="ic:round-drag-indicator"
6477
class="drag-icon cursor-move text-#8a909c mr-10px"
@@ -231,11 +244,11 @@ import { cloneDeep } from 'lodash-es'
231244
232245
defineOptions({ name: 'BpmModel' })
233246
247+
const activeCollapse: any = ref([])
234248
const renameVisible = ref(false)
235249
const props = defineProps({
236250
// 分类后的数据
237-
dataList: propTypes.object.def([]),
238-
title: propTypes.string.def(''),
251+
categoryInfo: propTypes.object.def([]),
239252
isCategorySorting: propTypes.bool.def(false)
240253
})
241254
const emit = defineEmits(['success'])
@@ -245,7 +258,7 @@ const isDark = computed(() => appStore.getIsDark)
245258
const { t } = useI18n() // 国际化
246259
const { push } = useRouter() // 路由
247260
const userStore = useUserStoreWithOut() // 用户信息缓存
248-
const isSorting = ref(false) // 是否正处于排序状态
261+
const isModelSorting = ref(false) // 是否正处于排序状态
249262
const tableData: any = ref([])
250263
const originalData: any = ref([]) // 原始数据
251264
@@ -270,7 +283,7 @@ const handleCommand = (command: string, row: any) => {
270283
const handleCategoryCommand = (command: string) => {
271284
switch (command) {
272285
case 'handleRename':
273-
renameVal.value = props.title
286+
renameVal.value = props.categoryInfo.name
274287
renameVisible.value = true
275288
break
276289
case 'handleDeleteGroup':
@@ -390,8 +403,8 @@ const isManagerUser = (row: any) => {
390403
/* 排序 */
391404
const handleSort = () => {
392405
// 保存初始数据
393-
originalData.value = cloneDeep(props.dataList)
394-
isSorting.value = true
406+
originalData.value = cloneDeep(props.categoryInfo.modelList)
407+
isModelSorting.value = true
395408
initSort()
396409
}
397410
@@ -400,13 +413,13 @@ const saveSort = () => {
400413
console.log(tableData.value)
401414
// 刷新列表
402415
emit('success')
403-
isSorting.value = false
416+
isModelSorting.value = false
404417
}
405418
406419
const cancelSort = () => {
407420
// 恢复初始数据
408421
tableData.value = cloneDeep(originalData.value)
409-
isSorting.value = false
422+
isModelSorting.value = false
410423
}
411424
412425
/* 分类 */
@@ -416,7 +429,7 @@ const handleGroup = () => {
416429
const tableRef = ref()
417430
// 创建拖拽实例
418431
const initSort = () => {
419-
const table = document.querySelector(`.${props.title} .el-table__body-wrapper tbody`)
432+
const table = document.querySelector(`.${props.categoryInfo.name} .el-table__body-wrapper tbody`)
420433
Sortable.create(table, {
421434
group: 'shared',
422435
animation: 150,
@@ -437,7 +450,7 @@ const initSort = () => {
437450
438451
// 更新表格数据
439452
const updateTableData = () => {
440-
tableData.value = cloneDeep(props.dataList)
453+
tableData.value = cloneDeep(props.categoryInfo.modelList)
441454
}
442455
443456
const renameVal = ref('')
@@ -450,17 +463,18 @@ const handleRenameConfirm = () => {
450463
451464
// 删除分类
452465
const handleDeleteGroup = async () => {
453-
if (props.dataList.length > 0) {
466+
if (props.categoryInfo.modelList.length > 0) {
454467
return message.warning('该分类下仍有流程定义,不允许删除')
455468
}
456469
await message.confirm('确认删除分类吗?')
457470
// 实际调用接口删除
458471
}
459-
onMounted(() => {
460-
updateTableData()
461-
})
462472
463-
defineExpose({ updateTableData })
473+
watch(() => props.categoryInfo.modelList, updateTableData, { immediate: true })
474+
475+
defineExpose({
476+
activeCollapse
477+
})
464478
</script>
465479

466480
<style lang="scss">
@@ -476,12 +490,6 @@ defineExpose({ updateTableData })
476490
</style>
477491
<style lang="scss" scoped>
478492
:deep() {
479-
.el-form--inline .el-form-item {
480-
margin-right: 10px;
481-
}
482-
.el-divider--horizontal {
483-
margin-top: 6px;
484-
}
485493
.el-collapse,
486494
.el-collapse-item__header,
487495
.el-collapse-item__wrap {

0 commit comments

Comments
 (0)