|
@@ -1,10 +1,11 @@
|
|
|
<script lang="tsx">
|
|
|
-import { defineComponent, unref, computed, PropType } from 'vue'
|
|
|
-import { ElTooltip, ElDropdown, ElDropdownMenu, ElDropdownItem, ComponentSize } from 'element-plus'
|
|
|
+import { defineComponent, unref, computed, PropType, ref } from 'vue'
|
|
|
+import { ElDropdown, ElDropdownMenu, ElDropdownItem, ComponentSize } from 'element-plus'
|
|
|
import { Icon } from '@/components/Icon'
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
import { useAppStore } from '@/store/modules/app'
|
|
|
import { TableColumn } from '../types'
|
|
|
+import ColumnSetting from './ColumnSetting.vue'
|
|
|
|
|
|
const appStore = useAppStore()
|
|
|
const sizeMap = computed(() => appStore.sizeMap)
|
|
@@ -13,6 +14,9 @@ const { t } = useI18n()
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'TableActions',
|
|
|
+ components: {
|
|
|
+ ColumnSetting
|
|
|
+ },
|
|
|
props: {
|
|
|
columns: {
|
|
|
type: Array as PropType<TableColumn[]>,
|
|
@@ -20,7 +24,9 @@ export default defineComponent({
|
|
|
}
|
|
|
},
|
|
|
emits: ['refresh', 'changSize'],
|
|
|
- setup(_, { emit }) {
|
|
|
+ setup(props, { emit }) {
|
|
|
+ const showSetting = ref(false)
|
|
|
+
|
|
|
const refresh = () => {
|
|
|
emit('refresh')
|
|
|
}
|
|
@@ -29,54 +35,67 @@ export default defineComponent({
|
|
|
emit('changSize', size)
|
|
|
}
|
|
|
|
|
|
+ const showColumnSetting = () => {
|
|
|
+ showSetting.value = true
|
|
|
+ }
|
|
|
+
|
|
|
return () => (
|
|
|
<>
|
|
|
<div class="text-right h-28px flex items-center justify-end">
|
|
|
- <ElTooltip content={t('common.refresh')} placement="top">
|
|
|
- <span onClick={refresh}>
|
|
|
- <Icon
|
|
|
- icon="ant-design:sync-outlined"
|
|
|
- class="cursor-pointer"
|
|
|
- hover-color="var(--el-color-primary)"
|
|
|
- />
|
|
|
- </span>
|
|
|
- </ElTooltip>
|
|
|
+ <div title="刷新" class="w-30px h-20px flex items-center justify-end" onClick={refresh}>
|
|
|
+ <Icon
|
|
|
+ icon="ant-design:sync-outlined"
|
|
|
+ class="cursor-pointer"
|
|
|
+ hover-color="var(--el-color-primary)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <ElDropdown trigger="click" onCommand={changSize}>
|
|
|
+ {{
|
|
|
+ default: () => {
|
|
|
+ return (
|
|
|
+ <div title="尺寸" class="w-30px h-20px flex items-center justify-end">
|
|
|
+ <Icon
|
|
|
+ icon="ant-design:column-height-outlined"
|
|
|
+ class="cursor-pointer"
|
|
|
+ hover-color="var(--el-color-primary)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ },
|
|
|
+ dropdown: () => {
|
|
|
+ return (
|
|
|
+ <ElDropdownMenu>
|
|
|
+ {{
|
|
|
+ default: () => {
|
|
|
+ return unref(sizeMap).map((v) => {
|
|
|
+ return (
|
|
|
+ <ElDropdownItem key={v} command={v}>
|
|
|
+ {t(`size.${v}`)}
|
|
|
+ </ElDropdownItem>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ </ElDropdownMenu>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ </ElDropdown>
|
|
|
|
|
|
- <ElTooltip content={t('common.size')} placement="top">
|
|
|
- <ElDropdown trigger="click" onCommand={changSize}>
|
|
|
- {{
|
|
|
- default: () => {
|
|
|
- return (
|
|
|
- <span>
|
|
|
- <Icon
|
|
|
- icon="ant-design:column-height-outlined"
|
|
|
- class="cursor-pointer mr-8px ml-8px"
|
|
|
- hover-color="var(--el-color-primary)"
|
|
|
- />
|
|
|
- </span>
|
|
|
- )
|
|
|
- },
|
|
|
- dropdown: () => {
|
|
|
- return (
|
|
|
- <ElDropdownMenu>
|
|
|
- {{
|
|
|
- default: () => {
|
|
|
- return unref(sizeMap).map((v) => {
|
|
|
- return (
|
|
|
- <ElDropdownItem key={v} command={v}>
|
|
|
- {t(`size.${v}`)}
|
|
|
- </ElDropdownItem>
|
|
|
- )
|
|
|
- })
|
|
|
- }
|
|
|
- }}
|
|
|
- </ElDropdownMenu>
|
|
|
- )
|
|
|
- }
|
|
|
- }}
|
|
|
- </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>
|
|
|
+ <ColumnSetting v-model={showSetting.value} columns={props.columns} />
|
|
|
</>
|
|
|
)
|
|
|
}
|