@dt-frames/ui 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -15
- package/es/assets/style/reset.less +0 -3
- package/es/components/iframe/index.d.ts +2 -2
- package/es/components/index.d.ts +2 -2
- package/es/index.css +1 -1
- package/es/index.js +34 -392
- package/es/style/assets/style/reset.less +0 -3
- package/es/style/components/forms/index.less +84 -0
- package/es/style/components/iframe/index.less +3 -0
- package/es/style/components/modal/index.less +63 -0
- package/es/style/components/table/index.less +162 -0
- package/es/style/theme/sider/index.less +25 -25
- package/es/style/theme/theme.less +2 -1
- package/es/theme/header/components/notify.d.ts +0 -1
- package/es/theme/header/components/user-info.d.ts +1 -1
- package/package.json +47 -40
- package/src/assets/data/icons/actions.ts +427 -0
- package/src/assets/data/icons/code.ts +10 -0
- package/src/assets/data/icons/commuticate.ts +190 -0
- package/src/assets/data/icons/currency.ts +46 -0
- package/src/assets/data/icons/devices.ts +128 -0
- package/src/assets/data/icons/edit.ts +165 -0
- package/src/assets/data/icons/file.ts +104 -0
- package/src/assets/data/icons/math.ts +53 -0
- package/src/assets/data/icons/message.ts +75 -0
- package/src/assets/data/icons/navigate.ts +181 -0
- package/src/assets/data/icons/other.ts +333 -0
- package/src/assets/data/icons.ts +58 -0
- package/src/assets/imgs/logo/logo.png +0 -0
- package/src/assets/locales/en_US.json +3 -0
- package/src/assets/locales/zh_CN.json +3 -0
- package/src/assets/style/index.less +10 -0
- package/src/assets/style/reset.less +17 -0
- package/src/components/container/index.less +85 -0
- package/src/components/container/index.ts +8 -0
- package/src/components/container/src/bar.ts +107 -0
- package/src/components/container/src/lazy-container.vue +9 -0
- package/src/components/container/src/scroll-bar.vue +117 -0
- package/src/components/container/src/scroll-container.vue +61 -0
- package/src/components/curd/index.ts +5 -0
- package/src/components/curd/src/components/dialog.vue +65 -0
- package/src/components/curd/src/components/props.ts +32 -0
- package/src/components/curd/src/hooks/useCurd.tsx +72 -0
- package/src/components/curd/src/types/curd.type.ts +29 -0
- package/src/components/excel/index.ts +6 -0
- package/src/components/excel/src/export2Excel.ts +44 -0
- package/src/components/forms/index.less +84 -0
- package/src/components/forms/index.ts +12 -0
- package/src/components/forms/src/componentMap.ts +44 -0
- package/src/components/forms/src/components/formButton.vue +150 -0
- package/src/components/forms/src/components/formIcon.vue +50 -0
- package/src/components/forms/src/components/formItem.vue +407 -0
- package/src/components/forms/src/components/radioButton.vue +58 -0
- package/src/components/forms/src/const/form.const.ts +7 -0
- package/src/components/forms/src/hooks/helper.ts +70 -0
- package/src/components/forms/src/hooks/useForm.ts +130 -0
- package/src/components/forms/src/hooks/useFormActions.ts +63 -0
- package/src/components/forms/src/hooks/useFormEvents.ts +247 -0
- package/src/components/forms/src/hooks/useFormValue.ts +49 -0
- package/src/components/forms/src/hooks/useFormValues.ts +131 -0
- package/src/components/forms/src/hooks/useLabelWidth.ts +57 -0
- package/src/components/forms/src/index.vue +306 -0
- package/src/components/forms/src/prop.ts +80 -0
- package/src/components/forms/src/types/form.type.ts +269 -0
- package/src/components/icons/index.less +96 -0
- package/src/components/icons/index.ts +7 -0
- package/src/components/icons/src/pick-icon.vue +117 -0
- package/src/components/icons/src/svg-icon.vue +117 -0
- package/src/components/iframe/index.less +3 -0
- package/src/components/iframe/index.ts +5 -0
- package/src/components/iframe/src/index.vue +38 -0
- package/src/components/index.ts +46 -0
- package/src/components/modal/index.less +63 -0
- package/src/components/modal/index.ts +8 -0
- package/src/components/modal/src/components/close-icon.vue +47 -0
- package/src/components/modal/src/components/modal-wrap.vue +118 -0
- package/src/components/modal/src/components/modal.tsx +30 -0
- package/src/components/modal/src/components/modalFooter.vue +38 -0
- package/src/components/modal/src/hooks/useDrag.ts +107 -0
- package/src/components/modal/src/hooks/useFullScreen.ts +27 -0
- package/src/components/modal/src/hooks/useModal.ts +177 -0
- package/src/components/modal/src/index.vue +173 -0
- package/src/components/modal/src/props.ts +43 -0
- package/src/components/modal/src/types/modal.type.ts +27 -0
- package/src/components/router/base-router.vue +11 -0
- package/src/components/router/index.ts +3 -0
- package/src/components/source/index.ts +1 -0
- package/src/components/source/src/hooks/useFetch.ts +70 -0
- package/src/components/source/src/hooks/usePage.ts +3 -0
- package/src/components/source/src/hooks/useSource.ts +178 -0
- package/src/components/source/src/index.ts +5 -0
- package/src/components/source/src/types/source.type.ts +68 -0
- package/src/components/source/src/types/table.type.ts +8 -0
- package/src/components/table/index.less +162 -0
- package/src/components/table/index.ts +7 -0
- package/src/components/table/src/components/TableActions.vue +108 -0
- package/src/components/table/src/components/TableHeader.vue +77 -0
- package/src/components/table/src/components/TableRender.vue +76 -0
- package/src/components/table/src/components/setting/Column.vue +355 -0
- package/src/components/table/src/components/setting/Download.vue +55 -0
- package/src/components/table/src/components/setting/Fullscreen.vue +43 -0
- package/src/components/table/src/components/setting/Size.vue +42 -0
- package/src/components/table/src/components/setting/index.vue +64 -0
- package/src/components/table/src/const.ts +13 -0
- package/src/components/table/src/hooks/useColumns.ts +319 -0
- package/{es/assets/app-antd-dark-theme-style.e3b0c442.css → src/components/table/src/hooks/useCustomRow.ts} +0 -0
- package/src/components/table/src/hooks/useDataSource.ts +99 -0
- package/src/components/table/src/hooks/useLoading.ts +29 -0
- package/src/components/table/src/hooks/usePagination.ts +76 -0
- package/src/components/table/src/hooks/useRowSelection.ts +146 -0
- package/src/components/table/src/hooks/useRows.ts +30 -0
- package/src/components/table/src/hooks/useTable.ts +77 -0
- package/src/components/table/src/hooks/useTableHeader.ts +48 -0
- package/src/components/table/src/hooks/useTableInstance.ts +29 -0
- package/src/components/table/src/hooks/useTableScroll.ts +227 -0
- package/src/components/table/src/index.vue +198 -0
- package/src/components/table/src/props.ts +152 -0
- package/src/components/table/src/types/table.type.ts +133 -0
- package/src/components/table/src/types/tableHeader.type.ts +27 -0
- package/{es/assets/app-theme-style.e3b0c442.css → src/components/type.ts} +0 -0
- package/src/directives/icon.ts +36 -0
- package/src/directives/index.ts +26 -0
- package/src/directives/permission.ts +20 -0
- package/src/global.d.ts +8 -0
- package/src/index.ts +4 -0
- package/src/theme/content/index.vue +37 -0
- package/src/theme/feature/back-top.vue +11 -0
- package/src/theme/feature/index.vue +7 -0
- package/src/theme/footer/index.less +16 -0
- package/src/theme/footer/index.vue +24 -0
- package/src/theme/header/components/bread-crumb.vue +26 -0
- package/src/theme/header/components/fullscreen.vue +12 -0
- package/src/theme/header/components/handler.ts +81 -0
- package/src/theme/header/components/index.ts +21 -0
- package/src/theme/header/components/lang-picker.vue +36 -0
- package/src/theme/header/components/logo.vue +33 -0
- package/src/theme/header/components/menu-search.vue +62 -0
- package/src/theme/header/components/notify.vue +22 -0
- package/src/theme/header/components/setting-theme.vue +123 -0
- package/src/theme/header/components/theme-drawer/enum.ts +12 -0
- package/src/theme/header/components/theme-drawer/feature.vue +75 -0
- package/src/theme/header/components/theme-drawer/index.ts +7 -0
- package/src/theme/header/components/theme-drawer/menu-type.vue +40 -0
- package/src/theme/header/components/theme-drawer/select-item.vue +46 -0
- package/src/theme/header/components/theme-drawer/switch-item.vue +39 -0
- package/src/theme/header/components/theme-drawer/theme-color.vue +26 -0
- package/src/theme/header/components/trigger.vue +14 -0
- package/src/theme/header/components/user-info.vue +43 -0
- package/src/theme/header/const/index.ts +40 -0
- package/src/theme/header/helper/menu-tree.ts +64 -0
- package/src/theme/header/index.less +438 -0
- package/src/theme/header/index.ts +0 -0
- package/src/theme/header/index.vue +96 -0
- package/src/theme/header/multiple-header.vue +67 -0
- package/src/theme/header/set-theme.less +68 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/sider/components/basic-menu/basic-menu-item.vue +14 -0
- package/src/theme/sider/components/basic-menu/basic-menu.vue +122 -0
- package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +46 -0
- package/src/theme/sider/components/basic-menu/menu-item-content.vue +13 -0
- package/src/theme/sider/components/drag-bar.vue +26 -0
- package/src/theme/sider/components/layout-menu.vue +132 -0
- package/src/theme/sider/components/props.ts +97 -0
- package/src/theme/sider/components/sider-trigger.vue +24 -0
- package/src/theme/sider/helper/sider.ts +52 -0
- package/src/theme/sider/helper/split-menu.ts +146 -0
- package/src/theme/sider/hooks/useDragLine.ts +86 -0
- package/src/theme/sider/hooks/useOpenKeys.ts +57 -0
- package/src/theme/sider/index.less +203 -0
- package/src/theme/sider/index.vue +88 -0
- package/src/theme/tabs/components/TabContent.vue +36 -0
- package/src/theme/tabs/components/TabRedo.vue +18 -0
- package/src/theme/tabs/hooks/useMultifyTabs.ts +96 -0
- package/src/theme/tabs/hooks/useTabDropdown.ts +89 -0
- package/src/theme/tabs/index.less +165 -0
- package/src/theme/tabs/index.vue +98 -0
- package/src/theme/tabs/types/tabs.type.ts +8 -0
- package/src/theme/theme.less +67 -0
- package/src/theme/theme.vue +90 -0
- package/src/theme/transition.less +99 -0
- package/es/assets/data/icon.d.ts +0 -4
- package/es/assets/data/icon.ts +0 -69
- package/es/assets/data/icon11.ts +0 -69
- package/es/assets/style/var.less +0 -42
- package/es/components/icons/pick-icon.d.ts +0 -529
- package/es/components/icons/svg-icon.d.ts +0 -44
- package/es/components/table/src/hooks/useFormat.d.ts +0 -2
- package/es/components/table/src/hooks/useVirtualScroll.d.ts +0 -5
- package/es/components/table/src/utils/format.d.ts +0 -1
- package/es/style/assets/style/var.less +0 -42
- package/es/theme/content/index.d.ts +0 -29
- package/es/theme/header/components/menu-search.d.ts +0 -528
- package/es/theme/header/components/setting-theme.d.ts +0 -2550
- package/es/theme/header/index.d.ts +0 -4369
- package/es/theme/header/multiple-header.d.ts +0 -2001
- package/es/theme/styles/hooks/changeTheme.d.ts +0 -1
- package/es/theme/styles/hooks/generate.d.ts +0 -13
- package/es/theme/styles/index.d.ts +0 -2
- package/es/theme/tabs/components/TabRedo.d.ts +0 -49
- package/es/theme/tabs/index.d.ts +0 -1399
- package/es/theme/theme/initTheme.d.ts +0 -3
- package/es/theme/theme/util.d.ts +0 -5
- package/es/theme/theme.d.ts +0 -4911
- package/es/themes/generate.ts +0 -74
- package/es/themes/index.ts +0 -10
- package/es/themes/modifyVars.ts +0 -33
- package/es/themes/themePlugiin.ts +0 -74
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Tooltip placement="top">
|
|
3
|
+
<template #title>
|
|
4
|
+
<span>列控制</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<Popover
|
|
8
|
+
placement="bottomLeft"
|
|
9
|
+
trigger="click"
|
|
10
|
+
:overlayClassName="`${prefixCls}__cloumn-list`"
|
|
11
|
+
@visibleChange="handleVisibleChange"
|
|
12
|
+
:getPopupContainer="getPopupContainer"
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
<template #title>
|
|
16
|
+
<div :class="`${ prefixCls }__popover-title`">
|
|
17
|
+
<Checkbox
|
|
18
|
+
:indeterminate="indeterminate"
|
|
19
|
+
v-model:checked="state.checkAll"
|
|
20
|
+
@change="onCheckAllChange"
|
|
21
|
+
>
|
|
22
|
+
列展示
|
|
23
|
+
</Checkbox>
|
|
24
|
+
|
|
25
|
+
<Checkbox v-model:checked="checkIndex" @change="handleIndexCheckChange">
|
|
26
|
+
序列号
|
|
27
|
+
</Checkbox>
|
|
28
|
+
|
|
29
|
+
<Checkbox v-model:checked="checkSelect" @change="handleSelectCheckChange" :disabled="!defaultRowSelection">
|
|
30
|
+
复选框
|
|
31
|
+
</Checkbox>
|
|
32
|
+
|
|
33
|
+
<Button size="small" type="link" @click="reset">重置</Button>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<template #content>
|
|
38
|
+
<CheckboxGroup v-model:value="state.checkedList" @change="onChange" ref="columnListRef">
|
|
39
|
+
<template v-for="item in plainOptions" :key="item.value">
|
|
40
|
+
<!-- v-if="!!(item as any).ifShow" -->
|
|
41
|
+
<div :class="`${ prefixCls }__check-item`">
|
|
42
|
+
<span v-icon="'ant-design:drag-outlined'" :size="16" :className="'drag-icon'"></span>
|
|
43
|
+
|
|
44
|
+
<Checkbox :value="item.value">
|
|
45
|
+
{{ item.label }}
|
|
46
|
+
</Checkbox>
|
|
47
|
+
|
|
48
|
+
<Tooltip
|
|
49
|
+
placement="bottomLeft"
|
|
50
|
+
:mouseLeaveDelay="0.4"
|
|
51
|
+
:getPopupContainer="getPopupContainer"
|
|
52
|
+
>
|
|
53
|
+
<template #title>固定到左侧</template>
|
|
54
|
+
<span :class="{
|
|
55
|
+
disabled: !state.checkedList.includes(item.value),
|
|
56
|
+
active: item.fixed === 'left'
|
|
57
|
+
}">
|
|
58
|
+
<DtIcon
|
|
59
|
+
:icon-class="'mdi:arrow-collapse-left'"
|
|
60
|
+
:className="`${ prefixCls }__fixed-left`"
|
|
61
|
+
@click="handleColumnFixed(item, 'left')"
|
|
62
|
+
:size="16"
|
|
63
|
+
></DtIcon>
|
|
64
|
+
</span>
|
|
65
|
+
</Tooltip>
|
|
66
|
+
|
|
67
|
+
<Divider type="vertical" />
|
|
68
|
+
|
|
69
|
+
<Tooltip
|
|
70
|
+
placement="bottomLeft"
|
|
71
|
+
:mouseLeaveDelay="0.4"
|
|
72
|
+
:getPopupContainer="getPopupContainer"
|
|
73
|
+
>
|
|
74
|
+
<template #title>固定到右侧</template>
|
|
75
|
+
<span :class="{
|
|
76
|
+
disabled: !state.checkedList.includes(item.value),
|
|
77
|
+
active: item.fixed === 'right',
|
|
78
|
+
}">
|
|
79
|
+
<DtIcon
|
|
80
|
+
:icon-class="'mdi:arrow-collapse-right'"
|
|
81
|
+
:className="`${prefixCls}__fixed-right`"
|
|
82
|
+
@click="handleColumnFixed(item, 'right')"
|
|
83
|
+
:size="16"
|
|
84
|
+
></DtIcon>
|
|
85
|
+
</span>
|
|
86
|
+
|
|
87
|
+
</Tooltip>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
</CheckboxGroup>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<span v-icon="'ant-design:setting-outlined'"></span>
|
|
94
|
+
</Popover>
|
|
95
|
+
</Tooltip>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<script lang="ts" setup>
|
|
99
|
+
import { Tooltip, Popover, Checkbox, Button, CheckboxGroup, Divider } from 'ant-design-vue'
|
|
100
|
+
import { getPopupContainer as getParentContainer, isNullAndUnDef } from '@dt-frames/core'
|
|
101
|
+
import { DtIcon } from '../../../../icons/index'
|
|
102
|
+
import { computed, reactive, ref, unref, watchEffect, useAttrs } from 'vue'
|
|
103
|
+
import type { ColumnStateType, ColumnOptionsType } from '../../types/tableHeader.type'
|
|
104
|
+
import { getTableInstance } from '../../hooks/useTableInstance'
|
|
105
|
+
import { BasicColumn } from '../../types/table.type'
|
|
106
|
+
import { nextTick } from 'process'
|
|
107
|
+
import { isFunction } from '@vueuse/core'
|
|
108
|
+
import { cloneDeep, omit } from 'lodash-es'
|
|
109
|
+
|
|
110
|
+
import Sortablejs from 'sortablejs'
|
|
111
|
+
import type Sortable from 'sortablejs'
|
|
112
|
+
import { CheckboxChangeEvent } from 'ant-design-vue/lib/checkbox/interface'
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const emits = defineEmits([
|
|
116
|
+
'columns-change'
|
|
117
|
+
])
|
|
118
|
+
|
|
119
|
+
const attrs = useAttrs()
|
|
120
|
+
|
|
121
|
+
const prefixCls = 'column-setting'
|
|
122
|
+
|
|
123
|
+
const table = getTableInstance()
|
|
124
|
+
const defaultRowSelection = omit(table.getRowSelection(), 'selectedRowKeys')
|
|
125
|
+
|
|
126
|
+
let inited = false
|
|
127
|
+
|
|
128
|
+
const cachePlainOptions = ref<ColumnOptionsType[]>([])
|
|
129
|
+
const plainOptions = ref<ColumnOptionsType[]>([])
|
|
130
|
+
const plainSortOptions = ref<ColumnOptionsType[]>([])
|
|
131
|
+
|
|
132
|
+
// 列表实例
|
|
133
|
+
const columnListRef = ref(null)
|
|
134
|
+
|
|
135
|
+
// 是否显示序列号
|
|
136
|
+
const checkIndex = ref(false)
|
|
137
|
+
// 是否显示复选框
|
|
138
|
+
const checkSelect = ref(false)
|
|
139
|
+
|
|
140
|
+
const getValues = computed(() => {
|
|
141
|
+
return unref(table?.getBind);
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
let sortable: Sortable
|
|
145
|
+
let sortableOrder: string[] = []
|
|
146
|
+
|
|
147
|
+
const state = reactive<ColumnStateType>({
|
|
148
|
+
checkAll: true,
|
|
149
|
+
checkedList: [],
|
|
150
|
+
defaultCheckList: []
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
// 列展示半选状态
|
|
154
|
+
const indeterminate = computed(() => {
|
|
155
|
+
let len = plainOptions.value.length
|
|
156
|
+
let checkedLen = state.checkedList.length
|
|
157
|
+
|
|
158
|
+
unref(checkIndex) && checkedLen--
|
|
159
|
+
|
|
160
|
+
return checkedLen > 0 && checkedLen < len
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
watchEffect(() => {
|
|
164
|
+
const columns = table.getColumns()
|
|
165
|
+
|
|
166
|
+
if( columns && columns.length ) {
|
|
167
|
+
init()
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
watchEffect(() => {
|
|
172
|
+
const values = unref(getValues)
|
|
173
|
+
|
|
174
|
+
checkIndex.value = !!values.showIndexColumn
|
|
175
|
+
checkSelect.value = !!values.rowSelection
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
function handleVisibleChange() {
|
|
180
|
+
if( inited ) return
|
|
181
|
+
|
|
182
|
+
nextTick(() => {
|
|
183
|
+
const columnListEl = unref( columnListRef )
|
|
184
|
+
if( !columnListEl ) return
|
|
185
|
+
|
|
186
|
+
const el = columnListEl.$el as any
|
|
187
|
+
if( !el ) return
|
|
188
|
+
|
|
189
|
+
sortable = Sortablejs.create(unref(el), {
|
|
190
|
+
animation: 500,
|
|
191
|
+
delay: 400,
|
|
192
|
+
delayOnTouchOnly: true,
|
|
193
|
+
handle: '.drag-icon ',
|
|
194
|
+
onEnd: (evt) => {
|
|
195
|
+
const { oldIndex, newIndex } = evt
|
|
196
|
+
|
|
197
|
+
if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const columns = cloneDeep(plainSortOptions.value)
|
|
202
|
+
|
|
203
|
+
if (oldIndex > newIndex) {
|
|
204
|
+
columns.splice(newIndex, 0, columns[oldIndex]);
|
|
205
|
+
columns.splice(oldIndex + 1, 1)
|
|
206
|
+
} else {
|
|
207
|
+
columns.splice(newIndex + 1, 0, columns[oldIndex]);
|
|
208
|
+
columns.splice(oldIndex, 1)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
plainSortOptions.value = columns
|
|
212
|
+
setColumns(columns)
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
sortableOrder = sortable.toArray()
|
|
217
|
+
inited = true
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 全选复选框改变
|
|
222
|
+
function onCheckAllChange(e: CheckboxChangeEvent) {
|
|
223
|
+
const checkList = plainOptions.value.map((item) => item.value)
|
|
224
|
+
|
|
225
|
+
if( e.target.checked ) {
|
|
226
|
+
state.checkedList = checkList
|
|
227
|
+
setColumns(checkList)
|
|
228
|
+
}else {
|
|
229
|
+
state.checkedList = []
|
|
230
|
+
setColumns([])
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// 显示序列号
|
|
235
|
+
function handleIndexCheckChange(e: CheckboxChangeEvent) {
|
|
236
|
+
table.setProps({
|
|
237
|
+
showIndexColumn: e.target.checked,
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// table上是否显示复选框
|
|
242
|
+
function handleSelectCheckChange(e: CheckboxChangeEvent) {
|
|
243
|
+
table.setProps({
|
|
244
|
+
rowSelection: e.target.checked ? defaultRowSelection : null,
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// 复选框选择
|
|
249
|
+
function onChange(checkedList: string[]) {
|
|
250
|
+
const len = plainSortOptions.value.length
|
|
251
|
+
state.checkAll = checkedList.length === len
|
|
252
|
+
|
|
253
|
+
const sortList = unref(plainSortOptions).map((item) => item.value)
|
|
254
|
+
checkedList.sort((prev, next) => {
|
|
255
|
+
return sortList.indexOf(prev) - sortList.indexOf(next);
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
setColumns(checkedList)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 重置所有选项
|
|
262
|
+
function reset() {
|
|
263
|
+
state.checkedList = [...state.defaultCheckList]
|
|
264
|
+
state.checkAll = true
|
|
265
|
+
|
|
266
|
+
plainOptions.value = unref(cachePlainOptions)
|
|
267
|
+
plainSortOptions.value = unref(cachePlainOptions)
|
|
268
|
+
setColumns(table.getCacheColumns())
|
|
269
|
+
sortable.sort(sortableOrder)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getColumns() {
|
|
273
|
+
return table.getColumns({
|
|
274
|
+
ignoreIndex: true,
|
|
275
|
+
ignoreAction: true
|
|
276
|
+
}).reduce( (ret, it) => {
|
|
277
|
+
ret.push({
|
|
278
|
+
label: it.title,
|
|
279
|
+
value: it.dataIndex || it.title,
|
|
280
|
+
...it
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
return ret
|
|
284
|
+
}, [] )
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function handleColumnFixed(item: BasicColumn, fixed?: 'left' | 'right') {
|
|
288
|
+
if (!state.checkedList.includes(item.dataIndex as string)) return
|
|
289
|
+
|
|
290
|
+
const columns = getColumns() as BasicColumn[]
|
|
291
|
+
const isFixed = item.fixed === fixed ? false : fixed
|
|
292
|
+
const index = columns.findIndex( col => col.dataIndex === item.dataIndex )
|
|
293
|
+
|
|
294
|
+
if( index !== -1 ) {
|
|
295
|
+
columns[index].fixed = isFixed
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
item.fixed = isFixed
|
|
299
|
+
|
|
300
|
+
if (isFixed && !item.width) {
|
|
301
|
+
item.width = 100;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
table.setCacheColumnsByField?.(item.dataIndex as string, { fixed: isFixed })
|
|
305
|
+
setColumns(columns)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function setColumns(columns: BasicColumn[] | string[]) {
|
|
309
|
+
table.setColumns(columns)
|
|
310
|
+
|
|
311
|
+
const data = unref(plainSortOptions).map( col => {
|
|
312
|
+
const visable = columns.findIndex(
|
|
313
|
+
(c: BasicColumn | string) => c === col.value || (typeof c !== 'string' && c.dataIndex === col.value)
|
|
314
|
+
) !== -1
|
|
315
|
+
|
|
316
|
+
return { dataIndex: col.value, fixed: col.fixed, visable }
|
|
317
|
+
} )
|
|
318
|
+
|
|
319
|
+
emits('columns-change', data)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function init() {
|
|
323
|
+
const columns = getColumns()
|
|
324
|
+
|
|
325
|
+
const checkList = table
|
|
326
|
+
.getColumns({ ignoreAction: true })
|
|
327
|
+
.map( it => it.defaultHidden ? '' : (it.dataIndex || it.title) )
|
|
328
|
+
.filter( Boolean ) as string[]
|
|
329
|
+
|
|
330
|
+
if(!plainOptions.value.length) {
|
|
331
|
+
|
|
332
|
+
plainOptions.value = columns
|
|
333
|
+
plainSortOptions.value = columns
|
|
334
|
+
cachePlainOptions.value = cloneDeep(columns)
|
|
335
|
+
state.defaultCheckList = checkList
|
|
336
|
+
|
|
337
|
+
} else {
|
|
338
|
+
unref( plainOptions )
|
|
339
|
+
.forEach(
|
|
340
|
+
(it: BasicColumn) =>
|
|
341
|
+
it.fixed === columns.find(col => col.dataIndex === it.dataIndex)?.fixed
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
state.isInit = true
|
|
346
|
+
state.checkedList = checkList
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
function getPopupContainer() {
|
|
351
|
+
return isFunction(attrs.getPopupContainer)
|
|
352
|
+
? attrs.getPopupContainer()
|
|
353
|
+
: getParentContainer();
|
|
354
|
+
}
|
|
355
|
+
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- -->
|
|
3
|
+
<Tooltip placement="top">
|
|
4
|
+
<template #title>
|
|
5
|
+
<span>导出</span>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<Dropdown
|
|
9
|
+
placement="bottom"
|
|
10
|
+
:trigger="['click']"
|
|
11
|
+
:getPopupContainer="getPopupContainer"
|
|
12
|
+
>
|
|
13
|
+
<span v-icon="'ic:baseline-file-download'"></span>
|
|
14
|
+
|
|
15
|
+
<template #overlay>
|
|
16
|
+
<Menu
|
|
17
|
+
@click="handleTitleClick"
|
|
18
|
+
>
|
|
19
|
+
<MenuItem key="current"> <span>导出当前页</span> </MenuItem>
|
|
20
|
+
<MenuItem key="select"> <span>导出选中列</span> </MenuItem>
|
|
21
|
+
<MenuItem key="all"> <span>导出所有列</span> </MenuItem>
|
|
22
|
+
</Menu>
|
|
23
|
+
</template>
|
|
24
|
+
</Dropdown>
|
|
25
|
+
</Tooltip>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { getPopupContainer } from '@dt-frames/core';
|
|
30
|
+
import { unref } from 'vue'
|
|
31
|
+
import { Tooltip, Dropdown, Menu, MenuItem } from 'ant-design-vue'
|
|
32
|
+
import { DtIcon } from '../../../../icons/index'
|
|
33
|
+
import { getTableInstance } from '../../hooks/useTableInstance';
|
|
34
|
+
|
|
35
|
+
const table = getTableInstance()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function handleTitleClick({ key }) {
|
|
40
|
+
const { onDownload, columns: allColumns, dataSource, rowSelection } = unref(table.getBind)
|
|
41
|
+
|
|
42
|
+
const excludesFlag = [ 'ACTION', 'CHECKBOX', 'RADIO' ]
|
|
43
|
+
const columns = allColumns.filter( it => !excludesFlag.includes(it.flag) )
|
|
44
|
+
|
|
45
|
+
onDownload( {
|
|
46
|
+
type: key,
|
|
47
|
+
columns,
|
|
48
|
+
rows: key === 'select'
|
|
49
|
+
? table.getSelectRows()
|
|
50
|
+
: key === 'current'
|
|
51
|
+
? dataSource
|
|
52
|
+
: []
|
|
53
|
+
} )
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Tooltip placement="top">
|
|
3
|
+
<template #title>
|
|
4
|
+
<span v-if="!isFullscreen">全屏</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<span @click="toggle">
|
|
8
|
+
<span v-if="!isFullscreen" v-icon="'ic:baseline-fullscreen'"></span>
|
|
9
|
+
<span v-else v-icon="'ic:baseline-fullscreen-exit'"></span>
|
|
10
|
+
</span>
|
|
11
|
+
</Tooltip>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import { ref, watch } from 'vue'
|
|
16
|
+
import { useFullscreen } from '@vueuse/core';
|
|
17
|
+
import { Tooltip } from 'ant-design-vue'
|
|
18
|
+
import { DtIcon } from '../../../../icons/index'
|
|
19
|
+
import { getTableInstance } from '../../hooks/useTableInstance';
|
|
20
|
+
|
|
21
|
+
const table = getTableInstance()
|
|
22
|
+
const wrapEl = ref(null)
|
|
23
|
+
|
|
24
|
+
const { toggle, isFullscreen } = useFullscreen(wrapEl)
|
|
25
|
+
|
|
26
|
+
watch(
|
|
27
|
+
() => table.tableElRef.value,
|
|
28
|
+
( v: any ) => {
|
|
29
|
+
const getParent = ( el ) => {
|
|
30
|
+
if( !el || !el.parentNode ) return null
|
|
31
|
+
|
|
32
|
+
// 找到路由的下一层 进行全屏
|
|
33
|
+
if(el.parentNode.className.indexOf('dt-layout-content') !== -1) {
|
|
34
|
+
wrapEl.value = el.parentNode
|
|
35
|
+
} else {
|
|
36
|
+
getParent( el.parentNode )
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getParent(v.$el)
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Tooltip>
|
|
3
|
+
<template #title>密度</template>
|
|
4
|
+
|
|
5
|
+
<Dropdown
|
|
6
|
+
placement="bottom"
|
|
7
|
+
:trigger="['click']"
|
|
8
|
+
:getPopupContainer="getPopupContainer"
|
|
9
|
+
>
|
|
10
|
+
<span v-icon="'ant-design:column-height-outlined'"></span>
|
|
11
|
+
|
|
12
|
+
<template #overlay>
|
|
13
|
+
<Menu
|
|
14
|
+
@click="handleTitleClick"
|
|
15
|
+
selectable
|
|
16
|
+
v-model:selectedKeys="selectedKeysRef"
|
|
17
|
+
>
|
|
18
|
+
<MenuItem key="default"> <span>默认</span> </MenuItem>
|
|
19
|
+
<MenuItem key="middle"> <span>中等</span> </MenuItem>
|
|
20
|
+
<MenuItem key="small"> <span>紧凑</span> </MenuItem>
|
|
21
|
+
</Menu>
|
|
22
|
+
</template>
|
|
23
|
+
</Dropdown>
|
|
24
|
+
</Tooltip>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
import { getPopupContainer } from '@dt-frames/core';
|
|
29
|
+
import { Tooltip, Dropdown, Menu, MenuItem } from 'ant-design-vue'
|
|
30
|
+
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
|
|
31
|
+
import { ref } from 'vue'
|
|
32
|
+
import { getTableInstance } from '../../hooks/useTableInstance';
|
|
33
|
+
import { SizeType } from '../../types/table.type';
|
|
34
|
+
|
|
35
|
+
const table = getTableInstance()
|
|
36
|
+
const selectedKeysRef = ref<SizeType[]>([table.getSize()])
|
|
37
|
+
|
|
38
|
+
function handleTitleClick({ key }: MenuInfo) {
|
|
39
|
+
selectedKeysRef.value = [key as SizeType]
|
|
40
|
+
table.setProps({ size: key as SizeType })
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Download></Download>
|
|
3
|
+
<SizeSetting v-if="getSetting.size" />
|
|
4
|
+
<ColumnSetting
|
|
5
|
+
v-if="getSetting.setting"
|
|
6
|
+
@columns-change="handleColumnChange"
|
|
7
|
+
/>
|
|
8
|
+
|
|
9
|
+
<FullscreenSetting v-if="getSetting.fullscreen"></FullscreenSetting>
|
|
10
|
+
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { computed, defineComponent, unref } from "vue"
|
|
15
|
+
import type { PropType } from 'vue'
|
|
16
|
+
import { TableSetting } from "../../types/table.type"
|
|
17
|
+
import ColumnSetting from './Column.vue'
|
|
18
|
+
import FullscreenSetting from './Fullscreen.vue'
|
|
19
|
+
import SizeSetting from './Size.vue'
|
|
20
|
+
import Download from './Download.vue'
|
|
21
|
+
|
|
22
|
+
type ColumnChangeParam = {
|
|
23
|
+
dataIndex: string;
|
|
24
|
+
fixed: boolean | 'left' | 'right' | undefined;
|
|
25
|
+
visible: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
name: 'table-setting',
|
|
30
|
+
components: {
|
|
31
|
+
ColumnSetting,
|
|
32
|
+
FullscreenSetting,
|
|
33
|
+
SizeSetting,
|
|
34
|
+
Download
|
|
35
|
+
},
|
|
36
|
+
props: {
|
|
37
|
+
setting: {
|
|
38
|
+
type: Object as PropType<TableSetting>,
|
|
39
|
+
default: () => ({}),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
emits: ['columns-change'],
|
|
43
|
+
setup(props, { emit }) {
|
|
44
|
+
const getSetting = computed((): TableSetting => {
|
|
45
|
+
return {
|
|
46
|
+
redo: true,
|
|
47
|
+
size: true,
|
|
48
|
+
setting: true,
|
|
49
|
+
fullscreen: true,
|
|
50
|
+
...props.setting,
|
|
51
|
+
};
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
function handleColumnChange(data: ColumnChangeParam[]) {
|
|
55
|
+
emit('columns-change', data);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
getSetting,
|
|
60
|
+
handleColumnChange
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
</script>
|