|
@ -21,11 +21,11 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
import { getCurrentInstance } from 'vue'; |
|
|
import { getCurrentInstance,ComponentInternalInstance } from 'vue'; |
|
|
import mitt from '@/plugins/bus'; |
|
|
import mitt from '@/plugins/bus'; |
|
|
const { proxy } = getCurrentInstance(); |
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance |
|
|
const defaultCheckedKeys = ref([]); //默认选项 |
|
|
const defaultCheckedKeys = ref([]); //默认选项 |
|
|
const checkList = ref([]); //选中的隐藏项 |
|
|
const checkList = ref<TreeVo[]>([]); //选中的隐藏项 |
|
|
|
|
|
|
|
|
interface TreeVo { |
|
|
interface TreeVo { |
|
|
id?: number; |
|
|
id?: number; |
|
@ -33,7 +33,7 @@ interface TreeVo { |
|
|
colType: string; |
|
|
colType: string; |
|
|
field: string; |
|
|
field: string; |
|
|
fixed?: string; |
|
|
fixed?: string; |
|
|
show: boolean; |
|
|
visible: boolean; |
|
|
title: string; |
|
|
title: string; |
|
|
width: number; |
|
|
width: number; |
|
|
controlValue?: number; |
|
|
controlValue?: number; |
|
@ -51,9 +51,9 @@ const props: any = defineProps({ |
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
treeData.value = props.headerData; |
|
|
treeData.value = props.headerData; |
|
|
const checkData = []; |
|
|
const checkData:any = []; |
|
|
props.headerData.map((item: TreeVo) => { |
|
|
props.headerData.map((item: TreeVo) => { |
|
|
if (item.show) { |
|
|
if (item.visible) { |
|
|
checkData.push(item.id); |
|
|
checkData.push(item.id); |
|
|
checkList.value.push(item); |
|
|
checkList.value.push(item); |
|
|
if (item.children && item.children.length) { |
|
|
if (item.children && item.children.length) { |
|
@ -255,7 +255,7 @@ const defaultProps = { |
|
|
// }, |
|
|
// }, |
|
|
// ]; |
|
|
// ]; |
|
|
|
|
|
|
|
|
function allowDrop(draggingNode, dropNode, type) { |
|
|
function allowDrop(draggingNode:any, dropNode:any, type:any) { |
|
|
// 只允许同级拖拽,不允许改变原来的目录结构 |
|
|
// 只允许同级拖拽,不允许改变原来的目录结构 |
|
|
if (type !== 'inner') { |
|
|
if (type !== 'inner') { |
|
|
let control = draggingNode.level === dropNode.level ? true : false; |
|
|
let control = draggingNode.level === dropNode.level ? true : false; |
|
@ -266,14 +266,14 @@ function allowDrop(draggingNode, dropNode, type) { |
|
|
const treeCheckChange = (data: TreeVo, checked: boolean, indeterminate: boolean) => { |
|
|
const treeCheckChange = (data: TreeVo, checked: boolean, indeterminate: boolean) => { |
|
|
//当复选框被点击的时候触发 |
|
|
//当复选框被点击的时候触发 |
|
|
console.log(data, checked, indeterminate); |
|
|
console.log(data, checked, indeterminate); |
|
|
data.show = checked; |
|
|
data.visible = checked; |
|
|
console.log(treeData.value); |
|
|
console.log(treeData.value); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const nodeDrop = () => { |
|
|
const nodeDrop = () => { |
|
|
//拖拽成功完成时触发的事件 |
|
|
//拖拽成功完成时触发的事件 |
|
|
nextTick(() => { |
|
|
nextTick(() => { |
|
|
proxy.$refs.tree.setCheckedKeys(defaultCheckedKeys.value); |
|
|
proxy?.$refs.tree.setCheckedKeys(defaultCheckedKeys.value); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|