|
@@ -0,0 +1,187 @@
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { SearchIcon } from 'tdesign-icons-vue-next';
|
|
|
+import {apiSystemHelpCenter} from '@/api/system'
|
|
|
+import { useTemplateRef } from 'vue';
|
|
|
+import EditClassify from './components/EditClassify.vue'
|
|
|
+import AuthSet from './components/AuthSet.vue'
|
|
|
+
|
|
|
+const tableCol=[
|
|
|
+ { align: 'center', colKey: 'fisrt', title: '一级分类' },
|
|
|
+ { align: 'center', colKey: 'second', title: '二级分类' },
|
|
|
+ { align: 'center', colKey: 'third', title: '三级分类' },
|
|
|
+ {
|
|
|
+ align: 'center',
|
|
|
+ colKey: 'opt',
|
|
|
+ title: '操作',
|
|
|
+ },
|
|
|
+]
|
|
|
+const keyword=ref('')
|
|
|
+const classifyData=ref([])
|
|
|
+const TwoLevelNodes=ref([])
|
|
|
+const tableIns=useTemplateRef('tableIns')
|
|
|
+const defaultExpandedTreeNodes=ref([])
|
|
|
+async function getClassifyData(){
|
|
|
+ classifyData.value=[]
|
|
|
+ defaultExpandedTreeNodes.value=[]
|
|
|
+ const res=await apiSystemHelpCenter.classifyList({
|
|
|
+ KeyWord:keyword.value
|
|
|
+ })
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ classifyData.value=res.Data.AllNodes||[]
|
|
|
+ TwoLevelNodes.value=res.Data.TwoLevelNodes||[]
|
|
|
+
|
|
|
+ classifyData.value.forEach(item => {
|
|
|
+ defaultExpandedTreeNodes.value.push(item.ClassifyId)
|
|
|
+ });
|
|
|
+}
|
|
|
+getClassifyData()
|
|
|
+
|
|
|
+async function handleSort({newData,current,target,targetIndex}){
|
|
|
+ console.log(newData,current,target,targetIndex);
|
|
|
+ const params={
|
|
|
+ ClassifyId:current.ClassifyId,
|
|
|
+ ParentClassifyId:target.ParentId,
|
|
|
+ PrevClassifyId:0,
|
|
|
+ NextClassifyId:0,
|
|
|
+ }
|
|
|
+ if(current.Level===1){
|
|
|
+ let arr=newData.filter(i=>i.Level===1)
|
|
|
+ const index=arr.findIndex(i=>i.ClassifyId===current.ClassifyId)
|
|
|
+ params.NextClassifyId=index<arr.length-1?arr[index+1].ClassifyId:0
|
|
|
+ params.PrevClassifyId=index===0?0:arr[index-1].ClassifyId
|
|
|
+ }else if(current.Level===2){
|
|
|
+ let arr=newData.filter(i=>i.Level===2)
|
|
|
+ const index=arr.findIndex(i=>i.ClassifyId===current.ClassifyId)
|
|
|
+ const preObj=index>0?arr[index-1]:null
|
|
|
+ const nextObj=index<arr.length-1?arr[index+1]:null
|
|
|
+ if(preObj&&preObj.ParentId===params.ParentClassifyId){
|
|
|
+ params.PrevClassifyId=preObj.ClassifyId
|
|
|
+ }
|
|
|
+ if(nextObj&&nextObj.ParentId===params.ParentClassifyId){
|
|
|
+ params.NextClassifyId=nextObj.ClassifyId
|
|
|
+ }
|
|
|
+ }else if(current.Level===3){
|
|
|
+ let arr=newData.filter(i=>i.Level===3)
|
|
|
+ const index=arr.findIndex(i=>i.ClassifyId===current.ClassifyId)
|
|
|
+ const preObj=index>0?arr[index-1]:null
|
|
|
+ const nextObj=index<arr.length-1?arr[index+1]:null
|
|
|
+ if(preObj&&preObj.ParentId===params.ParentClassifyId){
|
|
|
+ params.PrevClassifyId=preObj.ClassifyId
|
|
|
+ }
|
|
|
+ if(nextObj&&nextObj.ParentId===params.ParentClassifyId){
|
|
|
+ params.NextClassifyId=nextObj.ClassifyId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const res=await apiSystemHelpCenter.classifyMove(params)
|
|
|
+ getClassifyData()
|
|
|
+ if(res.Ret===200){
|
|
|
+ MessagePlugin.success('移动分类成功');
|
|
|
+ }
|
|
|
+}
|
|
|
+function handleAbnormalDragSort(e){
|
|
|
+ if (e.code === 1001) {
|
|
|
+ MessagePlugin.warning('不同层级的元素,不允许调整顺序');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+async function handleDel(item){
|
|
|
+ await $confirmDialog({
|
|
|
+ body:'是否确认删除?'
|
|
|
+ })
|
|
|
+ const res=await apiSystemHelpCenter.classifyDelete({
|
|
|
+ ClassifyId:item.ClassifyId
|
|
|
+ })
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ MessagePlugin.success('删除分类成功')
|
|
|
+ getClassifyData()
|
|
|
+}
|
|
|
+
|
|
|
+const editClassifyData=ref(null)
|
|
|
+const showEditClassify=ref(false)
|
|
|
+function handleShowClassify(item){
|
|
|
+ editClassifyData.value=item
|
|
|
+ showEditClassify.value=true
|
|
|
+}
|
|
|
+
|
|
|
+const showAuthSetClassify=ref(false)
|
|
|
+function handleShowAuthSetClassify(item){
|
|
|
+ editClassifyData.value=item
|
|
|
+ showAuthSetClassify.value=true
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="bg-white classify-page">
|
|
|
+ <div class="flex top-box">
|
|
|
+ <t-button theme="primary" @click="handleShowClassify(null)">添加分类</t-button>
|
|
|
+ <t-input
|
|
|
+ style="width: 310px;"
|
|
|
+ placeholder="分类名称"
|
|
|
+ v-model="keyword"
|
|
|
+ clearable
|
|
|
+ @change="getClassifyData"
|
|
|
+ >
|
|
|
+ <template #prefixIcon><SearchIcon /></template>
|
|
|
+ </t-input>
|
|
|
+ </div>
|
|
|
+ <t-enhanced-table
|
|
|
+ ref="tableIns"
|
|
|
+ :defaultExpandedTreeNodes="defaultExpandedTreeNodes"
|
|
|
+ v-model:expandedTreeNodes="defaultExpandedTreeNodes"
|
|
|
+ row-key="ClassifyId"
|
|
|
+ drag-sort="row"
|
|
|
+ :data="classifyData"
|
|
|
+ :columns="tableCol"
|
|
|
+ :tree="{
|
|
|
+ childrenKey:'Children',
|
|
|
+ treeNodeColumnIndex: 0,
|
|
|
+ }"
|
|
|
+ bordered
|
|
|
+ show-header
|
|
|
+ @drag-sort="handleSort"
|
|
|
+ @abnormal-drag-sort="handleAbnormalDragSort"
|
|
|
+ >
|
|
|
+ <template #fisrt="{ row }">
|
|
|
+ <span v-if="row.Level===1">{{row.ClassifyName}}</span>
|
|
|
+ </template>
|
|
|
+ <template #second="{ row }">
|
|
|
+ <span v-if="row.Level===2">{{row.ClassifyName}}</span>
|
|
|
+ </template>
|
|
|
+ <template #third="{ row }">
|
|
|
+ <span v-if="row.Level===3">{{row.ClassifyName}}</span>
|
|
|
+ </template>
|
|
|
+ <template #opt="{ row }">
|
|
|
+ <t-button size="small" variant="text" theme="primary" @click="handleShowAuthSetClassify(row)">权限配置</t-button>
|
|
|
+ <t-button size="small" variant="text" theme="primary" @click="handleShowClassify(row)">编辑</t-button>
|
|
|
+ <t-button size="small" variant="text" theme="danger" @click="handleDel(row)">删除</t-button>
|
|
|
+ </template>
|
|
|
+ </t-enhanced-table>
|
|
|
+ </div>
|
|
|
+ <!-- 新增编辑分类 -->
|
|
|
+ <EditClassify
|
|
|
+ v-model:show="showEditClassify"
|
|
|
+ :options="TwoLevelNodes"
|
|
|
+ :data="editClassifyData"
|
|
|
+ @change="getClassifyData"
|
|
|
+ />
|
|
|
+ <!-- 设置权限 -->
|
|
|
+ <AuthSet
|
|
|
+ v-model:show="showAuthSetClassify"
|
|
|
+ :data="editClassifyData"
|
|
|
+ @change="getClassifyData"
|
|
|
+ />
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.classify-page{
|
|
|
+ padding: 30px;
|
|
|
+ border: 1px solid var(--border-color);
|
|
|
+ min-height: calc(100vh - 160px);
|
|
|
+ .top-box{
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|