wip: 表格列设置
This commit is contained in:
parent
0d159bacec
commit
747c26fbcc
|
@ -51,6 +51,7 @@
|
||||||
"qs": "^6.11.2",
|
"qs": "^6.11.2",
|
||||||
"url": "^0.11.3",
|
"url": "^0.11.3",
|
||||||
"vue": "3.3.10",
|
"vue": "3.3.10",
|
||||||
|
"vue-draggable-plus": "^0.3.2",
|
||||||
"vue-i18n": "9.8.0",
|
"vue-i18n": "9.8.0",
|
||||||
"vue-json-pretty": "^2.2.4",
|
"vue-json-pretty": "^2.2.4",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ElDrawer } from 'element-plus'
|
||||||
|
import { TableColumn } from '../types'
|
||||||
|
import { PropType, ref, watch, unref } from 'vue'
|
||||||
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
|
||||||
|
const modelValue = defineModel<boolean>()
|
||||||
|
|
||||||
|
const oldColumns = ref<TableColumn[]>()
|
||||||
|
|
||||||
|
const settingColumns = ref<TableColumn[]>()
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
columns: {
|
||||||
|
type: Array as PropType<TableColumn[]>,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.columns,
|
||||||
|
(columns) => {
|
||||||
|
if (!unref(oldColumns)) {
|
||||||
|
oldColumns.value = cloneDeep(columns?.filter((item) => item.field !== 'expand'))
|
||||||
|
}
|
||||||
|
if (!unref(settingColumns)) {
|
||||||
|
settingColumns.value = cloneDeep(columns?.filter((item) => item.field !== 'expand'))
|
||||||
|
console.log(settingColumns.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElDrawer v-model="modelValue" title="列设置"> djdjjddjdjd </ElDrawer>
|
||||||
|
</template>
|
|
@ -1,10 +1,11 @@
|
||||||
<script lang="tsx">
|
<script lang="tsx">
|
||||||
import { defineComponent, unref, computed, PropType } from 'vue'
|
import { defineComponent, unref, computed, PropType, ref } from 'vue'
|
||||||
import { ElTooltip, ElDropdown, ElDropdownMenu, ElDropdownItem, ComponentSize } from 'element-plus'
|
import { ElDropdown, ElDropdownMenu, ElDropdownItem, ComponentSize } from 'element-plus'
|
||||||
import { Icon } from '@/components/Icon'
|
import { Icon } from '@/components/Icon'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useAppStore } from '@/store/modules/app'
|
import { useAppStore } from '@/store/modules/app'
|
||||||
import { TableColumn } from '../types'
|
import { TableColumn } from '../types'
|
||||||
|
import ColumnSetting from './ColumnSetting.vue'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const sizeMap = computed(() => appStore.sizeMap)
|
const sizeMap = computed(() => appStore.sizeMap)
|
||||||
|
@ -13,6 +14,9 @@ const { t } = useI18n()
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'TableActions',
|
name: 'TableActions',
|
||||||
|
components: {
|
||||||
|
ColumnSetting
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
columns: {
|
columns: {
|
||||||
type: Array as PropType<TableColumn[]>,
|
type: Array as PropType<TableColumn[]>,
|
||||||
|
@ -20,7 +24,9 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['refresh', 'changSize'],
|
emits: ['refresh', 'changSize'],
|
||||||
setup(_, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
const showSetting = ref(false)
|
||||||
|
|
||||||
const refresh = () => {
|
const refresh = () => {
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
}
|
}
|
||||||
|
@ -29,31 +35,32 @@ export default defineComponent({
|
||||||
emit('changSize', size)
|
emit('changSize', size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showColumnSetting = () => {
|
||||||
|
showSetting.value = true
|
||||||
|
}
|
||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<>
|
<>
|
||||||
<div class="text-right h-28px flex items-center justify-end">
|
<div class="text-right h-28px flex items-center justify-end">
|
||||||
<ElTooltip content={t('common.refresh')} placement="top">
|
<div title="刷新" class="w-30px h-20px flex items-center justify-end" onClick={refresh}>
|
||||||
<span onClick={refresh}>
|
|
||||||
<Icon
|
<Icon
|
||||||
icon="ant-design:sync-outlined"
|
icon="ant-design:sync-outlined"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
hover-color="var(--el-color-primary)"
|
hover-color="var(--el-color-primary)"
|
||||||
/>
|
/>
|
||||||
</span>
|
</div>
|
||||||
</ElTooltip>
|
|
||||||
|
|
||||||
<ElTooltip content={t('common.size')} placement="top">
|
|
||||||
<ElDropdown trigger="click" onCommand={changSize}>
|
<ElDropdown trigger="click" onCommand={changSize}>
|
||||||
{{
|
{{
|
||||||
default: () => {
|
default: () => {
|
||||||
return (
|
return (
|
||||||
<span>
|
<div title="尺寸" class="w-30px h-20px flex items-center justify-end">
|
||||||
<Icon
|
<Icon
|
||||||
icon="ant-design:column-height-outlined"
|
icon="ant-design:column-height-outlined"
|
||||||
class="cursor-pointer mr-8px ml-8px"
|
class="cursor-pointer"
|
||||||
hover-color="var(--el-color-primary)"
|
hover-color="var(--el-color-primary)"
|
||||||
/>
|
/>
|
||||||
</span>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
dropdown: () => {
|
dropdown: () => {
|
||||||
|
@ -75,8 +82,20 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
</ElDropdown>
|
</ElDropdown>
|
||||||
</ElTooltip>
|
|
||||||
|
<div
|
||||||
|
title="列设置"
|
||||||
|
class="w-30px h-20px flex items-center justify-end"
|
||||||
|
onClick={showColumnSetting}
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
icon="ant-design:setting-outlined"
|
||||||
|
class="cursor-pointer"
|
||||||
|
hover-color="var(--el-color-primary)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<ColumnSetting v-model={showSetting.value} columns={props.columns} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,9 @@ export default {
|
||||||
lengthRange: 'The length should be between {min} and {max}',
|
lengthRange: 'The length should be between {min} and {max}',
|
||||||
notSpace: 'Spaces are not allowed',
|
notSpace: 'Spaces are not allowed',
|
||||||
notSpecialCharacters: 'Special characters are not allowed',
|
notSpecialCharacters: 'Special characters are not allowed',
|
||||||
isEqual: 'The two are not equal'
|
isEqual: 'The two are not equal',
|
||||||
|
// 列设置
|
||||||
|
setting: 'Setting'
|
||||||
},
|
},
|
||||||
lock: {
|
lock: {
|
||||||
lockScreen: 'Lock screen',
|
lockScreen: 'Lock screen',
|
||||||
|
|
|
@ -48,7 +48,8 @@ export default {
|
||||||
lengthRange: '长度在 {min} 到 {max} 个字符',
|
lengthRange: '长度在 {min} 到 {max} 个字符',
|
||||||
notSpace: '不能包含空格',
|
notSpace: '不能包含空格',
|
||||||
notSpecialCharacters: '不能包含特殊字符',
|
notSpecialCharacters: '不能包含特殊字符',
|
||||||
isEqual: '两次输入不一致'
|
isEqual: '两次输入不一致',
|
||||||
|
setting: '设置'
|
||||||
},
|
},
|
||||||
lock: {
|
lock: {
|
||||||
lockScreen: '锁定屏幕',
|
lockScreen: '锁定屏幕',
|
||||||
|
|
|
@ -58,10 +58,6 @@ const columns = reactive<TableColumn[]>([
|
||||||
label: t('tableDemo.index'),
|
label: t('tableDemo.index'),
|
||||||
type: 'index'
|
type: 'index'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
field: 'content',
|
|
||||||
label: t('tableDemo.header'),
|
|
||||||
children: [
|
|
||||||
{
|
{
|
||||||
field: 'title',
|
field: 'title',
|
||||||
label: t('tableDemo.title')
|
label: t('tableDemo.title')
|
||||||
|
@ -92,8 +88,6 @@ const columns = reactive<TableColumn[]>([
|
||||||
{
|
{
|
||||||
field: 'pageviews',
|
field: 'pageviews',
|
||||||
label: t('tableDemo.pageviews')
|
label: t('tableDemo.pageviews')
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'action',
|
field: 'action',
|
||||||
|
|
Loading…
Reference in New Issue