9
9
>
10
10
<Icon icon =" ep:arrow-down-bold" color =" #999" />
11
11
</div >
12
- <div class =" ml-auto mr-45px" >
12
+ <div class =" ml-auto mr-45px flex items-center " >
13
13
<template v-if =" ! isSorting " >
14
- <el-button link type =" info" class =" mr-10px " @click.stop =" handleSort" >
14
+ <el-button link type =" info" class =" mr-20px " @click.stop =" handleSort" >
15
15
<Icon icon =" fa:sort-amount-desc" class =" mr-5px" />
16
16
排序
17
17
</el-button >
18
- <el-button link type =" info" @click.stop =" handleGroup" >
19
- <Icon icon =" ep:setting" class =" mr-5px" />
20
- 分组
21
- </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
+ 分类
22
+ </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 >
22
30
</template >
23
31
<template v-else >
24
32
<el-button @click.stop =" cancelSort" > 取 消 </el-button >
32
40
<div class =" color-gray-600 text-16px" > ({{ dataList?.length || 0 }}) </div >
33
41
</div >
34
42
</template >
35
-
36
43
<el-table
37
44
:class =" title"
38
45
ref =" tableRef"
39
46
:header-cell-style =" { backgroundColor: isDark ? '' : '#edeff0', paddingLeft: '10px' }"
40
47
:cell-style =" { paddingLeft: '10px' }"
41
- :data =" dataList"
48
+ :data =" tableData"
49
+ row-key =" id"
42
50
>
43
51
<el-table-column label =" 流程名" prop =" name" min-width =" 150" >
44
52
<template #default =" scope " >
183
191
</el-table >
184
192
</el-collapse-item >
185
193
</el-collapse >
194
+
195
+ <!-- 弹窗:重命名分类 -->
196
+ <Dialog :fullscreen =" false" class =" rename-dialog" v-model =" renameVisible" width =" 400" >
197
+ <template #title >
198
+ <div class =" pl-10px font-bold text-18px" > 重命名分类 </div >
199
+ </template >
200
+ <div class =" px-30px" >
201
+ <el-input v-model =" renameVal" />
202
+ </div >
203
+ <template #footer >
204
+ <div class =" pr-25px pb-25px" >
205
+ <el-button @click =" renameVisible = false" >取 消</el-button >
206
+ <el-button type =" primary" @click =" handleRenameConfirm" >确 定</el-button >
207
+ </div >
208
+ </template >
209
+ </Dialog >
186
210
</template >
187
211
188
212
<script lang="ts" setup>
189
- // 拖拽组件
190
213
import Sortable from ' sortablejs'
191
214
import { propTypes } from ' @/utils/propTypes'
192
215
import { formatDate } from ' @/utils/formatTime'
@@ -201,6 +224,7 @@ import { cloneDeep } from 'lodash-es'
201
224
202
225
defineOptions ({ name: ' BpmModel' })
203
226
227
+ const renameVisible = ref (false )
204
228
const props = defineProps ({
205
229
// 分类后的数据
206
230
dataList: propTypes .object .def ([]),
@@ -214,6 +238,8 @@ const { t } = useI18n() // 国际化
214
238
const { push } = useRouter () // 路由
215
239
const userStore = useUserStoreWithOut () // 用户信息缓存
216
240
const isSorting = ref (false ) // 是否正处于排序状态
241
+ const tableData: any = ref ([])
242
+ const originalData: any = ref ([]) // 原始数据
217
243
218
244
/** '更多'操作按钮 */
219
245
const handleCommand = (command : string , row : any ) => {
@@ -232,6 +258,21 @@ const handleCommand = (command: string, row: any) => {
232
258
}
233
259
}
234
260
261
+ /* '分类'操作按钮 */
262
+ const handleCategoryCommand = (command : string ) => {
263
+ switch (command ) {
264
+ case ' handleRename' :
265
+ renameVal .value = props .title
266
+ renameVisible .value = true
267
+ break
268
+ case ' handleDeleteGroup' :
269
+ handleDeleteGroup ()
270
+ break
271
+ default :
272
+ break
273
+ }
274
+ }
275
+
235
276
/** 添加/修改操作 */
236
277
const formRef = ref ()
237
278
const openForm = (type : string , id ? : number ) => {
@@ -340,23 +381,29 @@ const isManagerUser = (row: any) => {
340
381
341
382
/* 排序 */
342
383
const handleSort = () => {
384
+ // 保存初始数据
385
+ originalData .value = cloneDeep (props .dataList )
343
386
isSorting .value = true
344
387
initSort ()
345
388
}
346
389
347
390
const saveSort = () => {
348
391
// 接口调用
349
392
console .log (tableData .value )
350
- cancelSort ()
393
+ // 刷新列表
394
+ emit (' success' )
395
+ isSorting .value = false
351
396
}
352
397
353
398
const cancelSort = () => {
399
+ // 恢复初始数据
400
+ tableData .value = cloneDeep (originalData .value )
354
401
isSorting .value = false
355
402
}
356
403
357
- /* 分组 */
404
+ /* 分类 */
358
405
const handleGroup = () => {
359
- console .log (' 分组 ' )
406
+ console .log (' 分类 ' )
360
407
}
361
408
const tableRef = ref ()
362
409
// 创建拖拽实例
@@ -379,17 +426,48 @@ const initSort = () => {
379
426
}
380
427
})
381
428
}
382
- const tableData: any = ref ([])
383
- onMounted (() => {
429
+
430
+ // 更新表格数据
431
+ const updateTableData = () => {
384
432
tableData .value = cloneDeep (props .dataList )
433
+ }
434
+
435
+ const renameVal = ref (' ' )
436
+ // 重命名弹窗确定
437
+ const handleRenameConfirm = () => {
438
+ if (! renameVal .value ) {
439
+ return message .warning (' 请输入名称' )
440
+ }
441
+ }
442
+
443
+ // 删除分类
444
+ const handleDeleteGroup = async () => {
445
+ if (props .dataList .length > 0 ) {
446
+ return message .warning (' 该分类下仍有流程定义,不允许删除' )
447
+ }
448
+ await message .confirm (' 确认删除分类吗?' )
449
+ // 实际调用接口删除
450
+ }
451
+ onMounted (() => {
452
+ updateTableData ()
385
453
})
454
+
455
+ defineExpose ({ updateTableData })
386
456
</script >
387
457
458
+ <style lang="scss">
459
+ .rename-dialog.el-dialog {
460
+ padding : 0 !important ;
461
+ .el-dialog__header {
462
+ border-bottom : none ;
463
+ }
464
+ .el-dialog__footer {
465
+ border-top : none !important ;
466
+ }
467
+ }
468
+ </style >
388
469
<style lang="scss" scoped>
389
470
:deep() {
390
- .el-card {
391
- border-radius : 8px ;
392
- }
393
471
.el-form--inline .el-form-item {
394
472
margin-right : 10px ;
395
473
}
0 commit comments