diff --git a/src/components/RightToolbar/index.vue b/src/components/RightToolbar/index.vue index 09036b72393d39259d66bdbc1ea46f18f8940128..0f4219f33bcf50988891db366bb3cd67bab89848 100644 --- a/src/components/RightToolbar/index.vue +++ b/src/components/RightToolbar/index.vue @@ -7,13 +7,23 @@ - - + + +
显示/隐藏列
+ + +
- - - @@ -29,15 +39,9 @@ const props = defineProps({ gutter: propTypes.number.def(10), }) +const columnRef = ref(); const emits = defineEmits(['update:showSearch', 'queryTable']); -// 显隐数据 -const value = ref>([]); -// 弹出层标题 -const title = ref("显示/隐藏"); -// 是否显示弹出层 -const open = ref(false); - const style = computed(() => { const ret: any = {}; if (props.gutter) { @@ -56,23 +60,19 @@ function refresh() { emits("queryTable"); } -// 右侧列表元素变化 -function dataChange(data: TransferKey[]) { - props.columns?.forEach((item) => { - item.visible = !data.includes(item.key); - }) -} - -// 打开显隐列dialog -const showColumn = () => { - open.value = true; +// 更改数据列的显示和隐藏 +function columnChange(...args: any[]) { + props.columns?.forEach((item) => { + item.visible = args[1].checkedKeys.includes(item.key); + }) } // 显隐列初始默认隐藏列 onMounted(() => { props.columns?.forEach((item) => { - if (!item.visible) { - value.value.push(item.key); + if (item.visible) { + columnRef.value?.setChecked(item.key, true, false); + // value.value.push(item.key); } }) }) @@ -91,4 +91,9 @@ onMounted(() => { .my-el-transfer { text-align: center; } +.tree-header{ + width: 100%; + line-height: 24px; + text-align: center; +} diff --git a/src/types/global.d.ts b/src/types/global.d.ts index b9bc5f4b439a8c1ba0fd7a63b4c5aca2eb9cea09..130f8553a9844725e8c40ffb4fab271d7d63cf61 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -13,6 +13,7 @@ declare global { key: number; label: string; visible: boolean; + children: Array; } /** diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 9a6d82cf95438348cbede8c3c24558f7de399aa4..284d941b37b42ad8fc94a4ea066a2f70bce2ea96 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -340,13 +340,13 @@ const upload = reactive({ }) // 列显隐信息 const columns = ref([ - { key: 0, label: `用户编号`, visible: false }, - { key: 1, label: `用户名称`, visible: true }, - { key: 2, label: `用户昵称`, visible: true }, - { key: 3, label: `部门`, visible: true }, - { key: 4, label: `手机号码`, visible: true }, - { key: 5, label: `状态`, visible: true }, - { key: 6, label: `创建时间`, visible: true } + { key: 0, label: `用户编号`, visible: false,children: [] }, + { key: 1, label: `用户名称`, visible: true,children: [] }, + { key: 2, label: `用户昵称`, visible: true,children: [] }, + { key: 3, label: `部门`, visible: true,children: [] }, + { key: 4, label: `手机号码`, visible: true,children: [] }, + { key: 5, label: `状态`, visible: true,children: [] }, + { key: 6, label: `创建时间`, visible: true,children: [] } ])