faet: 分类下表格数据拖拽排序功能实现;重命名分类弹窗绘制;删除分类逻辑判断与提示框

pull/582/head
GoldenZqqq 2024-10-15 15:17:40 +08:00
parent a033706fb4
commit 57820cb3e1
2 changed files with 114 additions and 21 deletions

View File

@ -9,16 +9,24 @@
> >
<Icon icon="ep:arrow-down-bold" color="#999" /> <Icon icon="ep:arrow-down-bold" color="#999" />
</div> </div>
<div class="ml-auto mr-45px"> <div class="ml-auto mr-45px flex items-center">
<template v-if="!isSorting"> <template v-if="!isSorting">
<el-button link type="info" class="mr-10px" @click.stop="handleSort"> <el-button link type="info" class="mr-20px" @click.stop="handleSort">
<Icon icon="fa:sort-amount-desc" class="mr-5px" /> <Icon icon="fa:sort-amount-desc" class="mr-5px" />
排序 排序
</el-button> </el-button>
<el-button link type="info" @click.stop="handleGroup"> <el-dropdown @command="(command) => handleCategoryCommand(command)" placement="bottom">
<Icon icon="ep:setting" class="mr-5px" /> <el-button link type="info" @click.stop="handleGroup">
分组 <Icon icon="ep:setting" class="mr-5px" />
</el-button> 分类
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="handleRename"> 重命名 </el-dropdown-item>
<el-dropdown-item command="handleDeleteGroup"> 删除该类 </el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template> </template>
<template v-else> <template v-else>
<el-button @click.stop="cancelSort"> </el-button> <el-button @click.stop="cancelSort"> </el-button>
@ -32,13 +40,13 @@
<div class="color-gray-600 text-16px"> ({{ dataList?.length || 0 }}) </div> <div class="color-gray-600 text-16px"> ({{ dataList?.length || 0 }}) </div>
</div> </div>
</template> </template>
<el-table <el-table
:class="title" :class="title"
ref="tableRef" ref="tableRef"
:header-cell-style="{ backgroundColor: isDark ? '' : '#edeff0', paddingLeft: '10px' }" :header-cell-style="{ backgroundColor: isDark ? '' : '#edeff0', paddingLeft: '10px' }"
:cell-style="{ paddingLeft: '10px' }" :cell-style="{ paddingLeft: '10px' }"
:data="dataList" :data="tableData"
row-key="id"
> >
<el-table-column label="流程名" prop="name" min-width="150"> <el-table-column label="流程名" prop="name" min-width="150">
<template #default="scope"> <template #default="scope">
@ -183,10 +191,25 @@
</el-table> </el-table>
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
<!-- 弹窗重命名分类 -->
<Dialog :fullscreen="false" class="rename-dialog" v-model="renameVisible" width="400">
<template #title>
<div class="pl-10px font-bold text-18px"> 重命名分类 </div>
</template>
<div class="px-30px">
<el-input v-model="renameVal" />
</div>
<template #footer>
<div class="pr-25px pb-25px">
<el-button @click="renameVisible = false"> </el-button>
<el-button type="primary" @click="handleRenameConfirm"> </el-button>
</div>
</template>
</Dialog>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
//
import Sortable from 'sortablejs' import Sortable from 'sortablejs'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { formatDate } from '@/utils/formatTime' import { formatDate } from '@/utils/formatTime'
@ -201,6 +224,7 @@ import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'BpmModel' }) defineOptions({ name: 'BpmModel' })
const renameVisible = ref(false)
const props = defineProps({ const props = defineProps({
// //
dataList: propTypes.object.def([]), dataList: propTypes.object.def([]),
@ -214,6 +238,8 @@ const { t } = useI18n() // 国际化
const { push } = useRouter() // const { push } = useRouter() //
const userStore = useUserStoreWithOut() // const userStore = useUserStoreWithOut() //
const isSorting = ref(false) // const isSorting = ref(false) //
const tableData: any = ref([])
const originalData: any = ref([]) //
/** '更多'操作按钮 */ /** '更多'操作按钮 */
const handleCommand = (command: string, row: any) => { const handleCommand = (command: string, row: any) => {
@ -232,6 +258,21 @@ const handleCommand = (command: string, row: any) => {
} }
} }
/* '分类'操作按钮 */
const handleCategoryCommand = (command: string) => {
switch (command) {
case 'handleRename':
renameVal.value = props.title
renameVisible.value = true
break
case 'handleDeleteGroup':
handleDeleteGroup()
break
default:
break
}
}
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
@ -340,6 +381,8 @@ const isManagerUser = (row: any) => {
/* 排序 */ /* 排序 */
const handleSort = () => { const handleSort = () => {
//
originalData.value = cloneDeep(props.dataList)
isSorting.value = true isSorting.value = true
initSort() initSort()
} }
@ -347,16 +390,20 @@ const handleSort = () => {
const saveSort = () => { const saveSort = () => {
// //
console.log(tableData.value) console.log(tableData.value)
cancelSort() //
} emit('success')
const cancelSort = () => {
isSorting.value = false isSorting.value = false
} }
/* 分组 */ const cancelSort = () => {
//
tableData.value = cloneDeep(originalData.value)
isSorting.value = false
}
/* 分类 */
const handleGroup = () => { const handleGroup = () => {
console.log('分组') console.log('分')
} }
const tableRef = ref() const tableRef = ref()
// //
@ -379,17 +426,48 @@ const initSort = () => {
} }
}) })
} }
const tableData: any = ref([])
onMounted(() => { //
const updateTableData = () => {
tableData.value = cloneDeep(props.dataList) tableData.value = cloneDeep(props.dataList)
}
const renameVal = ref('')
//
const handleRenameConfirm = () => {
if (!renameVal.value) {
return message.warning('请输入名称')
}
}
//
const handleDeleteGroup = async () => {
if (props.dataList.length > 0) {
return message.warning('该分类下仍有流程定义,不允许删除')
}
await message.confirm('确认删除分类吗?')
//
}
onMounted(() => {
updateTableData()
}) })
defineExpose({ updateTableData })
</script> </script>
<style lang="scss">
.rename-dialog.el-dialog {
padding: 0 !important;
.el-dialog__header {
border-bottom: none;
}
.el-dialog__footer {
border-top: none !important;
}
}
</style>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep() { :deep() {
.el-card {
border-radius: 8px;
}
.el-form--inline .el-form-item { .el-form--inline .el-form-item {
margin-right: 10px; margin-right: 10px;
} }

View File

@ -61,7 +61,12 @@
v-for="(list, title) in categoryGroup" v-for="(list, title) in categoryGroup"
:key="title" :key="title"
> >
<CategoryDraggableModel :dataList="list" :title="title" @success="getList" /> <CategoryDraggableModel
ref="draggableModelRef"
:dataList="list"
:title="title"
@success="getList"
/>
</ContentWrap> </ContentWrap>
</div> </div>
</ContentWrap> </ContentWrap>
@ -84,6 +89,7 @@ import CategoryDraggableModel from './CategoryDraggableModel.vue'
defineOptions({ name: 'BpmModel' }) defineOptions({ name: 'BpmModel' })
const draggableModelRef = ref()
const loading = ref(true) // const loading = ref(true) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
@ -103,6 +109,7 @@ const getList = async () => {
const data = await ModelApi.getModelPage(queryParams) const data = await ModelApi.getModelPage(queryParams)
data.list = mockData data.list = mockData
categoryGroup.value = groupBy(data.list, 'categoryName') categoryGroup.value = groupBy(data.list, 'categoryName')
draggableModelRef.value?.updateTableData()
} finally { } finally {
loading.value = false loading.value = false
} }
@ -131,3 +138,11 @@ onMounted(async () => {
await getList() await getList()
}) })
</script> </script>
<style lang="scss" scoped>
:deep() {
.el-card {
border-radius: 8px;
}
}
</style>