Skip to content

Commit 708e12b

Browse files
committed
feat: 优化交互细节、删除流程分类接口联调
1 parent 91ea4b7 commit 708e12b

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

src/views/bpm/model/CategoryDraggableModel.vue

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<template>
22
<!-- 默认使其全部展开 -->
33
<el-collapse v-model="activeCollapse">
4-
<el-collapse-item :name="categoryInfo.id">
4+
<el-collapse-item :name="categoryInfo.id" :disabled="categoryInfo.modelList.length === 0">
55
<template #icon="{ isActive }">
66
<div class="flex-1 flex" v-if="!isCategorySorting">
77
<div
8+
v-if="categoryInfo.modelList.length > 0"
89
class="ml-20px flex items-center"
910
:class="['transition-transform duration-300', isActive ? 'rotate-180' : 'rotate-0']"
1011
>
@@ -230,6 +231,7 @@
230231
</template>
231232

232233
<script lang="ts" setup>
234+
import { CategoryApi } from '@/api/bpm/category'
233235
import Sortable from 'sortablejs'
234236
import { propTypes } from '@/utils/propTypes'
235237
import { formatDate } from '@/utils/formatTime'
@@ -409,8 +411,7 @@ const handleSort = () => {
409411
}
410412
411413
const saveSort = () => {
412-
// 接口调用
413-
console.log(tableData.value)
414+
// TODO 芋艿:这里需要一个保存分类下模型排序接口
414415
// 刷新列表
415416
emit('success')
416417
isModelSorting.value = false
@@ -451,6 +452,9 @@ const initSort = () => {
451452
// 更新表格数据
452453
const updateTableData = () => {
453454
tableData.value = cloneDeep(props.categoryInfo.modelList)
455+
if (props.categoryInfo.modelList.length > 0) {
456+
activeCollapse.value = [props.categoryInfo.id]
457+
}
454458
}
455459
456460
const renameVal = ref('')
@@ -463,15 +467,27 @@ const handleRenameConfirm = () => {
463467
464468
// 删除分类
465469
const handleDeleteGroup = async () => {
466-
if (props.categoryInfo.modelList.length > 0) {
467-
return message.warning('该分类下仍有流程定义,不允许删除')
468-
}
469-
await message.confirm('确认删除分类吗?')
470-
// 实际调用接口删除
470+
try {
471+
if (props.categoryInfo.modelList.length > 0) {
472+
return message.warning('该分类下仍有流程定义,不允许删除')
473+
}
474+
await message.confirm('确认删除分类吗?')
475+
// 发起删除
476+
await CategoryApi.deleteCategory(props.categoryInfo.id)
477+
message.success(t('common.delSuccess'))
478+
// 刷新列表
479+
emit('success')
480+
} catch {}
471481
}
472482
473483
watch(() => props.categoryInfo.modelList, updateTableData, { immediate: true })
474-
484+
watch(
485+
() => props.isCategorySorting,
486+
(val) => {
487+
if (val) activeCollapse.value = []
488+
},
489+
{ immediate: true }
490+
)
475491
defineExpose({
476492
activeCollapse
477493
})

src/views/bpm/model/index_new.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
ref="categoryDraggableModelRef"
6868
:isCategorySorting="isCategorySorting"
6969
:categoryInfo="element"
70-
@success="getAllModel"
70+
@success="getList"
7171
/>
7272
</ContentWrap>
7373
</template>
@@ -76,7 +76,7 @@
7676
</ContentWrap>
7777

7878
<!-- 表单弹窗:添加/修改流程 -->
79-
<ModelForm ref="formRef" @success="getAllModel" />
79+
<ModelForm ref="formRef" @success="getList" />
8080
<!-- 表单弹窗:添加/修改分类 -->
8181
<CategoryForm ref="categoryFormRef" @success="getList" />
8282
<!-- 弹窗:表单详情 -->
@@ -133,7 +133,7 @@ const getAllModel = async () => {
133133
/** 搜索按钮操作 */
134134
const handleQuery = () => {
135135
queryParams.pageNo = 1
136-
getAllModel()
136+
getList()
137137
}
138138
139139
/** 添加/修改操作 */
@@ -171,9 +171,6 @@ const handleSort = () => {
171171
// 保存初始数据
172172
originalData.value = cloneDeep(categoryGroup.value)
173173
isCategorySorting.value = true
174-
categoryDraggableModelRef.value?.forEach((element) => {
175-
element.activeCollapse = []
176-
})
177174
}
178175
// 取消排序
179176
const cancelSort = () => {
@@ -182,7 +179,9 @@ const cancelSort = () => {
182179
isCategorySorting.value = false
183180
}
184181
// 保存排序
185-
const saveSort = () => {}
182+
const saveSort = () => {
183+
// TODO 芋艿:这里需要一个保存分类排序接口
184+
}
186185
187186
const getList = async () => {
188187
loading.value = true

0 commit comments

Comments
 (0)