|
@@ -1,9 +1,27 @@
|
|
-<script setup lang='jsx'>
|
|
|
|
-import { useTemplateRef } from "vue";
|
|
|
|
|
|
+<script setup>
|
|
|
|
+import {apiETAChartUser} from '@/api/etaChart'
|
|
|
|
+import { useTemplateRef, watch } from "vue";
|
|
import EditClassify from './EditClassify.vue'
|
|
import EditClassify from './EditClassify.vue'
|
|
|
|
+import MoveChart from './MoveChart.vue'
|
|
import {confirmDialog} from '@/plugin/dialog.jsx'
|
|
import {confirmDialog} from '@/plugin/dialog.jsx'
|
|
|
|
+import { MessagePlugin } from 'tdesign-vue-next';
|
|
|
|
|
|
-const classifyOpts=[
|
|
|
|
|
|
+const emits=defineEmits(['change'])
|
|
|
|
+
|
|
|
|
+const selecClassify=ref(0)
|
|
|
|
+function handleClassifyItemClick({node}){
|
|
|
|
+ selecClassify.value=node.value
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+watch(
|
|
|
|
+ ()=>selecClassify.value,
|
|
|
|
+ ()=>{
|
|
|
|
+ console.log("分类改变");
|
|
|
|
+ emits('change',selecClassify.value)
|
|
|
|
+ }
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+const classifyActions=[
|
|
{
|
|
{
|
|
content:'重命名',
|
|
content:'重命名',
|
|
value:'rename',
|
|
value:'rename',
|
|
@@ -18,32 +36,40 @@ const classifyOpts=[
|
|
action: (node) => handleDeleteClassify(node),
|
|
action: (node) => handleDeleteClassify(node),
|
|
}
|
|
}
|
|
]
|
|
]
|
|
-const classifyList=ref([
|
|
|
|
- {
|
|
|
|
- value:1,
|
|
|
|
- label:1
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- value:2,
|
|
|
|
- label:2
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- value:3,
|
|
|
|
- label:3
|
|
|
|
|
|
+const classifyList=ref([])
|
|
|
|
+// 获取分类
|
|
|
|
+async function getClassifyList(){
|
|
|
|
+ const res=await apiETAChartUser.classifyList()
|
|
|
|
+ if(res.Ret!==200)return
|
|
|
|
+ const arr=res.Data?.List||[]
|
|
|
|
+ classifyList.value=arr
|
|
|
|
+ if(arr.length>0){
|
|
|
|
+ selecClassify.value=arr[0].CollectClassifyId
|
|
}
|
|
}
|
|
-])
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-const treeIns=useTemplateRef('treeIns')
|
|
|
|
-function handleSortEnd({node}){
|
|
|
|
- const resArr=treeIns.value.getTreeData()//移动后的数组
|
|
|
|
- const moveTargetIndex=treeIns.value.getIndex(node.value)//被拖动的元素拖动后的位置
|
|
|
|
}
|
|
}
|
|
|
|
+getClassifyList()
|
|
|
|
|
|
|
|
+// 移动排序
|
|
|
|
+const treeIns=useTemplateRef('treeIns')
|
|
// dropPosition -1放在dropNode前面 0里面 1后面
|
|
// dropPosition -1放在dropNode前面 0里面 1后面
|
|
function handleAllowDrop({dropNode, dropPosition}){
|
|
function handleAllowDrop({dropNode, dropPosition}){
|
|
if(dropPosition===0) return false//不允许向里面拖动
|
|
if(dropPosition===0) return false//不允许向里面拖动
|
|
}
|
|
}
|
|
|
|
+async function handleSortEnd({node}){
|
|
|
|
+ const resArr=treeIns.value.getTreeData()//移动后的数组
|
|
|
|
+ const moveTargetIndex=treeIns.value.getIndex(node.value)//被拖动的元素拖动后的位置
|
|
|
|
+ const params={
|
|
|
|
+ PrevCollectClassifyId:moveTargetIndex===0?0:resArr[moveTargetIndex-1].CollectClassifyId,
|
|
|
|
+ NextCollectClassifyId:moveTargetIndex===resArr.length-1?0:resArr[moveTargetIndex+1].CollectClassifyId,
|
|
|
|
+ CollectClassifyId:node.value
|
|
|
|
+ }
|
|
|
|
+ const res=await apiETAChartUser.moveClassify(params)
|
|
|
|
+ if(res.Ret!==200){
|
|
|
|
+ getClassifyList()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ MessagePlugin.success("移动成功")
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
// 删除分类
|
|
// 删除分类
|
|
@@ -52,16 +78,24 @@ async function handleDeleteClassify(node){
|
|
header:'提示',
|
|
header:'提示',
|
|
body: '若删除该分类,则分类下关联的所有图表将被全部删除,是否继续?',
|
|
body: '若删除该分类,则分类下关联的所有图表将被全部删除,是否继续?',
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+ const res=await apiETAChartUser.deleteClassify({
|
|
|
|
+ CollectClassifyId:node.value
|
|
|
|
+ })
|
|
|
|
+ if(res.Ret!==200) return
|
|
|
|
+ MessagePlugin.success('删除成功')
|
|
|
|
+ getClassifyList()
|
|
}
|
|
}
|
|
|
|
|
|
const showEditClassify=ref(false)
|
|
const showEditClassify=ref(false)
|
|
const activeClassifyData=ref(null)
|
|
const activeClassifyData=ref(null)
|
|
-// 点击操作
|
|
|
|
|
|
+// 点击分类的操作
|
|
function clickHandler(option,node){
|
|
function clickHandler(option,node){
|
|
option.action(node);
|
|
option.action(node);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 转移分类
|
|
|
|
+const showMoveChart=ref(false)
|
|
|
|
+
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -70,21 +104,30 @@ function clickHandler(option,node){
|
|
<div class="classify-tree">
|
|
<div class="classify-tree">
|
|
<t-tree
|
|
<t-tree
|
|
ref="treeIns"
|
|
ref="treeIns"
|
|
|
|
+ :actived="[selecClassify]"
|
|
:data="classifyList"
|
|
:data="classifyList"
|
|
|
|
+ :keys="{value:'CollectClassifyId',label:'ClassifyName'}"
|
|
activable
|
|
activable
|
|
transition
|
|
transition
|
|
draggable
|
|
draggable
|
|
:allow-drop="handleAllowDrop"
|
|
:allow-drop="handleAllowDrop"
|
|
:onDragEnd="handleSortEnd"
|
|
:onDragEnd="handleSortEnd"
|
|
|
|
+ :onClick="handleClassifyItemClick"
|
|
>
|
|
>
|
|
<template #icon>
|
|
<template #icon>
|
|
<t-icon name="drag-move" style="font-size:20px"></t-icon>
|
|
<t-icon name="drag-move" style="font-size:20px"></t-icon>
|
|
</template>
|
|
</template>
|
|
<template #operations="{node}">
|
|
<template #operations="{node}">
|
|
- <t-dropdown :options="classifyOpts" trigger="hover" @click="clickHandler($event,node)">
|
|
|
|
|
|
+ <t-dropdown :options="classifyActions" trigger="hover" @click="clickHandler($event,node)">
|
|
<t-icon name="more" style="font-size:20px"></t-icon>
|
|
<t-icon name="more" style="font-size:20px"></t-icon>
|
|
</t-dropdown>
|
|
</t-dropdown>
|
|
</template>
|
|
</template>
|
|
|
|
+ <template #empty>
|
|
|
|
+ <div style="text-align:center">
|
|
|
|
+ <img style="width:50%" src="@/assets/imgs/nodata.png" alt="">
|
|
|
|
+ <div>暂无数据</div>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
</t-tree>
|
|
</t-tree>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div>
|
|
@@ -92,14 +135,20 @@ function clickHandler(option,node){
|
|
<t-icon name="add-rectangle" size="20px"></t-icon>
|
|
<t-icon name="add-rectangle" size="20px"></t-icon>
|
|
<span>添加分类</span>
|
|
<span>添加分类</span>
|
|
</div>
|
|
</div>
|
|
- <div class="opt-item">
|
|
|
|
|
|
+ <div class="opt-item" @click="showMoveChart=true">
|
|
<t-icon name="swap" size="20px"></t-icon>
|
|
<t-icon name="swap" size="20px"></t-icon>
|
|
<span>转移分类</span>
|
|
<span>转移分类</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 新增\编辑分类 -->
|
|
<!-- 新增\编辑分类 -->
|
|
- <EditClassify v-model:show="showEditClassify" :data="activeClassifyData"/>
|
|
|
|
|
|
+ <EditClassify
|
|
|
|
+ v-model:show="showEditClassify"
|
|
|
|
+ :data="activeClassifyData"
|
|
|
|
+ @change="getClassifyList"
|
|
|
|
+ />
|
|
|
|
+ <!-- 转移分类 -->
|
|
|
|
+ <MoveChart v-model:show="showMoveChart" :classifyOpts="classifyList"/>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -117,6 +166,9 @@ function clickHandler(option,node){
|
|
flex: 1;
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
overflow-y: auto;
|
|
padding-bottom: 30px;
|
|
padding-bottom: 30px;
|
|
|
|
+ :deep(.t-is-active){
|
|
|
|
+ background-color: var(--td-brand-color-light);
|
|
|
|
+ }
|
|
:deep(.t-tree__icon){
|
|
:deep(.t-tree__icon){
|
|
margin-left: 20px;
|
|
margin-left: 20px;
|
|
}
|
|
}
|