@dt-frames/ui 1.0.0 → 1.0.1

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.
Files changed (165) hide show
  1. package/package.json +1 -10
  2. package/src/assets/data/icons/actions.ts +0 -427
  3. package/src/assets/data/icons/code.ts +0 -10
  4. package/src/assets/data/icons/commuticate.ts +0 -190
  5. package/src/assets/data/icons/currency.ts +0 -46
  6. package/src/assets/data/icons/devices.ts +0 -128
  7. package/src/assets/data/icons/edit.ts +0 -165
  8. package/src/assets/data/icons/file.ts +0 -104
  9. package/src/assets/data/icons/math.ts +0 -53
  10. package/src/assets/data/icons/message.ts +0 -75
  11. package/src/assets/data/icons/navigate.ts +0 -181
  12. package/src/assets/data/icons/other.ts +0 -333
  13. package/src/assets/data/icons.ts +0 -58
  14. package/src/assets/imgs/logo/logo.png +0 -0
  15. package/src/assets/locales/en_US.json +0 -3
  16. package/src/assets/locales/zh_CN.json +0 -3
  17. package/src/assets/style/index.less +0 -10
  18. package/src/assets/style/reset.less +0 -20
  19. package/src/components/container/index.less +0 -85
  20. package/src/components/container/index.ts +0 -8
  21. package/src/components/container/src/bar.ts +0 -107
  22. package/src/components/container/src/lazy-container.vue +0 -9
  23. package/src/components/container/src/scroll-bar.vue +0 -117
  24. package/src/components/container/src/scroll-container.vue +0 -61
  25. package/src/components/curd/index.ts +0 -5
  26. package/src/components/curd/src/components/dialog.vue +0 -65
  27. package/src/components/curd/src/components/props.ts +0 -32
  28. package/src/components/curd/src/hooks/useCurd.tsx +0 -72
  29. package/src/components/curd/src/types/curd.type.ts +0 -29
  30. package/src/components/excel/index.ts +0 -6
  31. package/src/components/excel/src/export2Excel.ts +0 -44
  32. package/src/components/forms/index.ts +0 -12
  33. package/src/components/forms/src/componentMap.ts +0 -44
  34. package/src/components/forms/src/components/formButton.vue +0 -150
  35. package/src/components/forms/src/components/formIcon.vue +0 -50
  36. package/src/components/forms/src/components/formItem.vue +0 -407
  37. package/src/components/forms/src/components/radioButton.vue +0 -58
  38. package/src/components/forms/src/const/form.const.ts +0 -7
  39. package/src/components/forms/src/hooks/helper.ts +0 -70
  40. package/src/components/forms/src/hooks/useForm.ts +0 -130
  41. package/src/components/forms/src/hooks/useFormActions.ts +0 -63
  42. package/src/components/forms/src/hooks/useFormEvents.ts +0 -247
  43. package/src/components/forms/src/hooks/useFormValue.ts +0 -49
  44. package/src/components/forms/src/hooks/useFormValues.ts +0 -131
  45. package/src/components/forms/src/hooks/useLabelWidth.ts +0 -57
  46. package/src/components/forms/src/index.less +0 -82
  47. package/src/components/forms/src/index.vue +0 -306
  48. package/src/components/forms/src/prop.ts +0 -80
  49. package/src/components/forms/src/types/form.type.ts +0 -269
  50. package/src/components/icons/index.ts +0 -7
  51. package/src/components/icons/src/index.less +0 -96
  52. package/src/components/icons/src/pick-icon.vue +0 -117
  53. package/src/components/icons/src/svg-icon.vue +0 -117
  54. package/src/components/iframe/index.ts +0 -5
  55. package/src/components/iframe/src/index.less +0 -3
  56. package/src/components/iframe/src/index.vue +0 -38
  57. package/src/components/index.ts +0 -46
  58. package/src/components/modal/index.ts +0 -8
  59. package/src/components/modal/src/components/close-icon.vue +0 -47
  60. package/src/components/modal/src/components/modal-wrap.vue +0 -118
  61. package/src/components/modal/src/components/modal.tsx +0 -30
  62. package/src/components/modal/src/components/modalFooter.vue +0 -38
  63. package/src/components/modal/src/hooks/useDrag.ts +0 -107
  64. package/src/components/modal/src/hooks/useFullScreen.ts +0 -27
  65. package/src/components/modal/src/hooks/useModal.ts +0 -177
  66. package/src/components/modal/src/index.less +0 -60
  67. package/src/components/modal/src/index.vue +0 -173
  68. package/src/components/modal/src/props.ts +0 -43
  69. package/src/components/modal/src/types/modal.type.ts +0 -27
  70. package/src/components/router/base-router.vue +0 -11
  71. package/src/components/router/index.ts +0 -3
  72. package/src/components/source/index.ts +0 -1
  73. package/src/components/source/src/hooks/useFetch.ts +0 -70
  74. package/src/components/source/src/hooks/usePage.ts +0 -3
  75. package/src/components/source/src/hooks/useSource.ts +0 -178
  76. package/src/components/source/src/index.ts +0 -5
  77. package/src/components/source/src/types/source.type.ts +0 -68
  78. package/src/components/source/src/types/table.type.ts +0 -8
  79. package/src/components/table/index.ts +0 -7
  80. package/src/components/table/src/components/TableActions.vue +0 -108
  81. package/src/components/table/src/components/TableHeader.vue +0 -77
  82. package/src/components/table/src/components/TableRender.vue +0 -76
  83. package/src/components/table/src/components/setting/Column.vue +0 -355
  84. package/src/components/table/src/components/setting/Download.vue +0 -55
  85. package/src/components/table/src/components/setting/Fullscreen.vue +0 -43
  86. package/src/components/table/src/components/setting/Size.vue +0 -42
  87. package/src/components/table/src/components/setting/index.vue +0 -64
  88. package/src/components/table/src/const.ts +0 -13
  89. package/src/components/table/src/hooks/useColumns.ts +0 -319
  90. package/src/components/table/src/hooks/useCustomRow.ts +0 -0
  91. package/src/components/table/src/hooks/useDataSource.ts +0 -99
  92. package/src/components/table/src/hooks/useLoading.ts +0 -29
  93. package/src/components/table/src/hooks/usePagination.ts +0 -76
  94. package/src/components/table/src/hooks/useRowSelection.ts +0 -146
  95. package/src/components/table/src/hooks/useRows.ts +0 -30
  96. package/src/components/table/src/hooks/useTable.ts +0 -77
  97. package/src/components/table/src/hooks/useTableHeader.ts +0 -48
  98. package/src/components/table/src/hooks/useTableInstance.ts +0 -29
  99. package/src/components/table/src/hooks/useTableScroll.ts +0 -227
  100. package/src/components/table/src/index.less +0 -162
  101. package/src/components/table/src/index.vue +0 -198
  102. package/src/components/table/src/props.ts +0 -152
  103. package/src/components/table/src/types/table.type.ts +0 -133
  104. package/src/components/table/src/types/tableHeader.type.ts +0 -27
  105. package/src/components/type.ts +0 -0
  106. package/src/directives/icon.ts +0 -36
  107. package/src/directives/index.ts +0 -26
  108. package/src/directives/permission.ts +0 -21
  109. package/src/global.d.ts +0 -8
  110. package/src/index.ts +0 -4
  111. package/src/theme/content/index.vue +0 -37
  112. package/src/theme/feature/back-top.vue +0 -11
  113. package/src/theme/feature/index.vue +0 -7
  114. package/src/theme/footer/index.less +0 -16
  115. package/src/theme/footer/index.vue +0 -24
  116. package/src/theme/header/components/bread-crumb.vue +0 -26
  117. package/src/theme/header/components/fullscreen.vue +0 -14
  118. package/src/theme/header/components/handler.ts +0 -81
  119. package/src/theme/header/components/index.ts +0 -21
  120. package/src/theme/header/components/lang-picker.vue +0 -36
  121. package/src/theme/header/components/logo.vue +0 -33
  122. package/src/theme/header/components/menu-search.vue +0 -62
  123. package/src/theme/header/components/notify.vue +0 -23
  124. package/src/theme/header/components/setting-theme.vue +0 -123
  125. package/src/theme/header/components/theme-drawer/enum.ts +0 -12
  126. package/src/theme/header/components/theme-drawer/feature.vue +0 -75
  127. package/src/theme/header/components/theme-drawer/index.ts +0 -7
  128. package/src/theme/header/components/theme-drawer/menu-type.vue +0 -40
  129. package/src/theme/header/components/theme-drawer/select-item.vue +0 -46
  130. package/src/theme/header/components/theme-drawer/switch-item.vue +0 -39
  131. package/src/theme/header/components/theme-drawer/theme-color.vue +0 -26
  132. package/src/theme/header/components/trigger.vue +0 -14
  133. package/src/theme/header/components/user-info.vue +0 -43
  134. package/src/theme/header/const/index.ts +0 -40
  135. package/src/theme/header/helper/menu-tree.ts +0 -67
  136. package/src/theme/header/index.less +0 -438
  137. package/src/theme/header/index.ts +0 -0
  138. package/src/theme/header/index.vue +0 -96
  139. package/src/theme/header/multiple-header.vue +0 -67
  140. package/src/theme/header/set-theme.less +0 -68
  141. package/src/theme/index.ts +0 -3
  142. package/src/theme/sider/components/basic-menu/basic-menu-item.vue +0 -14
  143. package/src/theme/sider/components/basic-menu/basic-menu.vue +0 -122
  144. package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +0 -46
  145. package/src/theme/sider/components/basic-menu/menu-item-content.vue +0 -13
  146. package/src/theme/sider/components/drag-bar.vue +0 -26
  147. package/src/theme/sider/components/layout-menu.vue +0 -132
  148. package/src/theme/sider/components/props.ts +0 -97
  149. package/src/theme/sider/components/sider-trigger.vue +0 -24
  150. package/src/theme/sider/helper/sider.ts +0 -52
  151. package/src/theme/sider/helper/split-menu.ts +0 -147
  152. package/src/theme/sider/hooks/useDragLine.ts +0 -86
  153. package/src/theme/sider/hooks/useOpenKeys.ts +0 -57
  154. package/src/theme/sider/index.less +0 -203
  155. package/src/theme/sider/index.vue +0 -88
  156. package/src/theme/tabs/components/TabContent.vue +0 -37
  157. package/src/theme/tabs/components/TabRedo.vue +0 -18
  158. package/src/theme/tabs/hooks/useMultifyTabs.ts +0 -96
  159. package/src/theme/tabs/hooks/useTabDropdown.ts +0 -89
  160. package/src/theme/tabs/index.less +0 -165
  161. package/src/theme/tabs/index.vue +0 -98
  162. package/src/theme/tabs/types/tabs.type.ts +0 -8
  163. package/src/theme/theme.less +0 -66
  164. package/src/theme/theme.vue +0 -89
  165. package/src/theme/transition.less +0 -99
@@ -1,108 +0,0 @@
1
- <template>
2
- <template v-if="props.expand">
3
- <span v-for="item in props.btns" class="dt-table-action-btn">
4
- <Tooltip placement="bottom" v-if="item.ifShow">
5
- <template #title>{{ item.title }}</template>
6
- <span v-icon="item.icon" :color="item.color" @click="handleAction(item)"></span>
7
- </Tooltip>
8
- </span>
9
- </template>
10
-
11
- <template v-else>
12
- <Dropdown
13
- :getPopupContainer="getPopupContainer"
14
- :trigger="['click']"
15
- >
16
- <DtIcon :icon-class="'mdi:cog-outline'"></DtIcon>
17
-
18
- <template #overlay>
19
- <Menu class="dt-action-select">
20
- <template v-for="item in props.btns">
21
- <MenuItem
22
- v-if="item.ifShow"
23
- @click="handleAction(item)"
24
- >
25
- <DtIcon :icon-class="item.icon" :color="item.color"></DtIcon>
26
- <span>{{ item.title }}</span>
27
- </MenuItem>
28
- </template>
29
-
30
- </Menu>
31
- </template>
32
-
33
- </Dropdown>
34
-
35
- </template>
36
-
37
- </template>
38
-
39
- <script lang="ts" setup>
40
- import { PropType, watch, useAttrs } from 'vue';
41
- import { Tooltip, Dropdown, Menu, MenuItem } from 'ant-design-vue'
42
- import { BtnsType } from '../types/table.type';
43
- import { DtIcon } from '../../../icons/index'
44
- import { isBoolean, isFunction, getPopupContainer as getParentContainer } from '@dt-frames/core';
45
-
46
- const props = defineProps({
47
- fixed: {
48
- type: String as PropType<boolean | 'left' | 'right' | undefined>,
49
- default: 'right'
50
- },
51
- title: {
52
- type: String
53
- },
54
- expand: {
55
- type: Boolean,
56
- default: false
57
- },
58
- width: {
59
- type: String,
60
- default: '70px'
61
- },
62
- btns: {
63
- type: Array as PropType<BtnsType[]>,
64
- default: []
65
- },
66
- flag: {
67
- type: String as PropType<'ACTION'>
68
- },
69
- record: {
70
- default: { }
71
- },
72
- index: {
73
- type: Number
74
- }
75
- })
76
-
77
- watch(
78
- () => props.btns,
79
- (btns) => {
80
- btns.map( it => {
81
- it.ifShow = isBoolean( it.ifShow )
82
- ? it.ifShow
83
- : isFunction( it.ifShow )
84
- ? it.ifShow( props.record )
85
- : true
86
- } )
87
- },{
88
- immediate: true
89
- }
90
- )
91
-
92
- function handleAction(it: BtnsType) {
93
- if( isFunction( it.action ) ) {
94
- it.action({
95
- row: props.record,
96
- index: props.index
97
- })
98
- }
99
- }
100
-
101
- const attrs = useAttrs()
102
- function getPopupContainer() {
103
- return isFunction(attrs.getPopupContainer)
104
- ? attrs.getPopupContainer()
105
- : getParentContainer();
106
- }
107
-
108
- </script>
@@ -1,77 +0,0 @@
1
- <template>
2
- <div class="dt-table-header">
3
- <div class="dt-table-header-actions">
4
- <div class="dt-table-header-actions__left">
5
- <FormButtons
6
- v-bind="getActionsProps"
7
- @handle-method="handleMethod"
8
- ></FormButtons>
9
- <slot name="toolbar"></slot>
10
- </div>
11
-
12
- <div class="dt-table-header-actions__right">
13
- <TableSettinCom
14
- @columns-change="handleColumnChange"
15
- ></TableSettinCom>
16
- </div>
17
- </div>
18
-
19
- <div v-if="$slots.headerTop" style="margin: 5px">
20
- <slot name="headerTop"></slot>
21
- </div>
22
- </div>
23
- </template>
24
-
25
- <script lang="ts">
26
- import { defineComponent, PropType } from "vue"
27
- import { Button } from 'ant-design-vue'
28
- import type { BtnsType, ColumnChangeParam, TableSetting } from "../types/table.type"
29
- import TableSettinCom from './setting/index.vue'
30
- import { DtIcon } from '../../../icons/index'
31
- import { FormButtons } from "../../../forms"
32
- import { isFunction } from "@dt-frames/core"
33
-
34
- export default defineComponent({
35
- name: 'table-header',
36
- components: {
37
- TableSettinCom,
38
- Button,
39
- DtIcon,
40
- FormButtons
41
- },
42
- props: {
43
- tableTools: {
44
- type: Object as PropType<TableSetting>
45
- },
46
- toolbar: {
47
- type: Array as PropType<BtnsType[]>,
48
- default: []
49
- }
50
- },
51
- emits: ['columns-change'],
52
- setup(props, { emit }) {
53
- function handleColumnChange(data: ColumnChangeParam[]) {
54
- emit('columns-change', data);
55
- }
56
-
57
- function handleMethod( e ) {
58
- if( isFunction(e.onClick) ) {
59
- e.onClick()
60
- }
61
- }
62
-
63
- const getActionsProps = {
64
- mode: null,
65
- showAdvancedButton: false,
66
- show: true,
67
- buttonList: props.toolbar
68
- } as any
69
-
70
- return {
71
- getActionsProps,
72
- handleColumnChange,
73
- handleMethod
74
- }
75
- }
76
- })
77
- </script>
@@ -1,76 +0,0 @@
1
- <script lang="tsx">
2
- import { getDictValueByCode, isFunction, isObject, Recordable, formatNumber, isVnode } from '@dt-frames/core'
3
- import dayjs from 'dayjs'
4
- import { defineComponent, PropType, unref, ref, h, toRaw, render as render1, resolveComponent, resolveDynamicComponent, createVNode } from 'vue'
5
- import { BasicColumn } from '../types/table.type'
6
-
7
- export default defineComponent({
8
- name: 'TableFormat',
9
- props: {
10
- column: {
11
- type: Object as PropType<BasicColumn>
12
- },
13
- record: {
14
- type: Object as PropType<Recordable>
15
- },
16
- index: {
17
- type: Number
18
- }
19
- },
20
- setup(props: {
21
- column: BasicColumn,
22
- record: Recordable,
23
- index: number
24
- }) {
25
- let renderText = ref()
26
-
27
- function renderCell() {
28
- const { column, record, index } = props
29
- const { render, dataIndex } = column
30
- const text = record[dataIndex.toString()]
31
-
32
- if( isFunction(render) ) {
33
- renderText.value = render(text, record, index)
34
- }
35
-
36
- if( isObject(render) ) {
37
- const { dict, date, number, percent } = render as Recordable
38
-
39
- if( dict ) {
40
- renderText = getDictValueByCode(text, dict)
41
- }
42
-
43
- if( date ) {
44
- renderText.value = dayjs(text).format(date || 'YYYY-MM-DD')
45
- }
46
-
47
- if( number ) {
48
- renderText.value = formatNumber(text, number)
49
- }
50
-
51
- if( percent ) {
52
- renderText.value = formatNumber((text || 0) * 100, percent) + '%'
53
- }
54
-
55
- if( isVnode(render) ) {
56
- renderText.value = render
57
- }
58
-
59
- if( render['setup'] ) {
60
- renderText.value = createVNode(render as any, { text })
61
- }
62
-
63
-
64
- } else {
65
- console.log(text)
66
- renderText.value = text
67
- }
68
- }
69
-
70
- renderCell()
71
-
72
- return () => <span>{unref(renderText)}</span>
73
- }
74
- })
75
-
76
- </script>
@@ -1,355 +0,0 @@
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>
@@ -1,55 +0,0 @@
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>