1
1
<template >
2
2
<!-- 默认使其全部展开 -->
3
- <el-collapse :modelValue = " title " >
4
- <el-collapse-item :name =" title " >
3
+ <el-collapse v-model = " activeCollapse " >
4
+ <el-collapse-item :name =" categoryInfo.id " >
5
5
<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
+ 排序
22
24
</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 >
35
47
</div >
48
+ <div ></div >
36
49
</template >
37
50
<template #title >
38
51
<div class =" flex items-center" >
43
56
class =" ml-10px category-drag-icon cursor-move text-#8a909c"
44
57
/>
45
58
</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 >
48
61
</div >
49
62
</template >
50
63
<el-table
51
- :class =" title "
64
+ :class =" categoryInfo.name "
52
65
ref =" tableRef"
53
66
:header-cell-style =" { backgroundColor: isDark ? '' : '#edeff0', paddingLeft: '10px' }"
54
67
:cell-style =" { paddingLeft: '10px' }"
58
71
<el-table-column label =" 流程名" prop =" name" min-width =" 150" >
59
72
<template #default =" scope " >
60
73
<div class =" flex items-center" >
61
- <el-tooltip content =" 拖动排序" v-if =" isSorting " >
74
+ <el-tooltip content =" 拖动排序" v-if =" isModelSorting " >
62
75
<Icon
63
76
icon =" ic:round-drag-indicator"
64
77
class =" drag-icon cursor-move text-#8a909c mr-10px"
@@ -231,11 +244,11 @@ import { cloneDeep } from 'lodash-es'
231
244
232
245
defineOptions ({ name: ' BpmModel' })
233
246
247
+ const activeCollapse: any = ref ([])
234
248
const renameVisible = ref (false )
235
249
const props = defineProps ({
236
250
// 分类后的数据
237
- dataList: propTypes .object .def ([]),
238
- title: propTypes .string .def (' ' ),
251
+ categoryInfo: propTypes .object .def ([]),
239
252
isCategorySorting: propTypes .bool .def (false )
240
253
})
241
254
const emit = defineEmits ([' success' ])
@@ -245,7 +258,7 @@ const isDark = computed(() => appStore.getIsDark)
245
258
const { t } = useI18n () // 国际化
246
259
const { push } = useRouter () // 路由
247
260
const userStore = useUserStoreWithOut () // 用户信息缓存
248
- const isSorting = ref (false ) // 是否正处于排序状态
261
+ const isModelSorting = ref (false ) // 是否正处于排序状态
249
262
const tableData: any = ref ([])
250
263
const originalData: any = ref ([]) // 原始数据
251
264
@@ -270,7 +283,7 @@ const handleCommand = (command: string, row: any) => {
270
283
const handleCategoryCommand = (command : string ) => {
271
284
switch (command ) {
272
285
case ' handleRename' :
273
- renameVal .value = props .title
286
+ renameVal .value = props .categoryInfo . name
274
287
renameVisible .value = true
275
288
break
276
289
case ' handleDeleteGroup' :
@@ -390,8 +403,8 @@ const isManagerUser = (row: any) => {
390
403
/* 排序 */
391
404
const handleSort = () => {
392
405
// 保存初始数据
393
- originalData .value = cloneDeep (props .dataList )
394
- isSorting .value = true
406
+ originalData .value = cloneDeep (props .categoryInfo . modelList )
407
+ isModelSorting .value = true
395
408
initSort ()
396
409
}
397
410
@@ -400,13 +413,13 @@ const saveSort = () => {
400
413
console .log (tableData .value )
401
414
// 刷新列表
402
415
emit (' success' )
403
- isSorting .value = false
416
+ isModelSorting .value = false
404
417
}
405
418
406
419
const cancelSort = () => {
407
420
// 恢复初始数据
408
421
tableData .value = cloneDeep (originalData .value )
409
- isSorting .value = false
422
+ isModelSorting .value = false
410
423
}
411
424
412
425
/* 分类 */
@@ -416,7 +429,7 @@ const handleGroup = () => {
416
429
const tableRef = ref ()
417
430
// 创建拖拽实例
418
431
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 ` )
420
433
Sortable .create (table , {
421
434
group: ' shared' ,
422
435
animation: 150 ,
@@ -437,7 +450,7 @@ const initSort = () => {
437
450
438
451
// 更新表格数据
439
452
const updateTableData = () => {
440
- tableData .value = cloneDeep (props .dataList )
453
+ tableData .value = cloneDeep (props .categoryInfo . modelList )
441
454
}
442
455
443
456
const renameVal = ref (' ' )
@@ -450,17 +463,18 @@ const handleRenameConfirm = () => {
450
463
451
464
// 删除分类
452
465
const handleDeleteGroup = async () => {
453
- if (props .dataList .length > 0 ) {
466
+ if (props .categoryInfo . modelList .length > 0 ) {
454
467
return message .warning (' 该分类下仍有流程定义,不允许删除' )
455
468
}
456
469
await message .confirm (' 确认删除分类吗?' )
457
470
// 实际调用接口删除
458
471
}
459
- onMounted (() => {
460
- updateTableData ()
461
- })
462
472
463
- defineExpose ({ updateTableData })
473
+ watch (() => props .categoryInfo .modelList , updateTableData , { immediate: true })
474
+
475
+ defineExpose ({
476
+ activeCollapse
477
+ })
464
478
</script >
465
479
466
480
<style lang="scss">
@@ -476,12 +490,6 @@ defineExpose({ updateTableData })
476
490
</style >
477
491
<style lang="scss" scoped>
478
492
:deep() {
479
- .el-form--inline .el-form-item {
480
- margin-right : 10px ;
481
- }
482
- .el-divider--horizontal {
483
- margin-top : 6px ;
484
- }
485
493
.el-collapse ,
486
494
.el-collapse-item__header ,
487
495
.el-collapse-item__wrap {
0 commit comments