@dt-frames/ui 1.0.13 → 1.0.15

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 (208) hide show
  1. package/es/components/curd/src/components/dialog.d.ts +20 -20
  2. package/es/components/curd/src/components/props.d.ts +2 -1
  3. package/es/components/curd/src/hooks/useCurd.d.ts +1 -0
  4. package/es/components/curd/src/types/curd.type.d.ts +2 -2
  5. package/es/components/forms/src/components/formButton.d.ts +1 -2
  6. package/es/components/forms/src/components/formIcon.d.ts +15 -15
  7. package/es/components/forms/src/hooks/useFormActions.d.ts +2 -2
  8. package/es/components/forms/src/index.d.ts +2 -2
  9. package/es/components/forms/src/types/form.type.d.ts +3 -17
  10. package/es/components/index.d.ts +1 -1
  11. package/es/components/modal/src/components/modal.d.ts +2 -2
  12. package/es/components/modal/src/components/modalFooter.d.ts +1 -1
  13. package/es/components/modal/src/index.d.ts +15 -15
  14. package/es/components/modal/src/props.d.ts +1 -1
  15. package/es/components/source/src/hooks/useFetch.d.ts +1 -1
  16. package/es/components/table/src/index.d.ts +3 -3
  17. package/es/components/table/src/props.d.ts +1 -2
  18. package/es/components/tree/src/props.d.ts +8 -1
  19. package/es/components/upload/src/upload.d.ts +3 -3
  20. package/es/index.js +43 -19
  21. package/es/style/components/icons/index.less +1 -1
  22. package/package.json +1 -10
  23. package/vite.config.js +10 -0
  24. package/src/assets/data/icons/actions.ts +0 -427
  25. package/src/assets/data/icons/code.ts +0 -10
  26. package/src/assets/data/icons/commuticate.ts +0 -190
  27. package/src/assets/data/icons/currency.ts +0 -46
  28. package/src/assets/data/icons/devices.ts +0 -128
  29. package/src/assets/data/icons/edit.ts +0 -165
  30. package/src/assets/data/icons/file.ts +0 -104
  31. package/src/assets/data/icons/math.ts +0 -53
  32. package/src/assets/data/icons/message.ts +0 -75
  33. package/src/assets/data/icons/navigate.ts +0 -181
  34. package/src/assets/data/icons/other.ts +0 -333
  35. package/src/assets/data/icons.ts +0 -58
  36. package/src/assets/imgs/header/avatar.png +0 -0
  37. package/src/assets/imgs/logo/logo.png +0 -0
  38. package/src/assets/locales/en_US.json +0 -3
  39. package/src/assets/locales/zh_CN.json +0 -3
  40. package/src/assets/style/index.less +0 -10
  41. package/src/assets/style/reset.less +0 -17
  42. package/src/components/container/index.less +0 -85
  43. package/src/components/container/index.ts +0 -8
  44. package/src/components/container/src/bar.ts +0 -107
  45. package/src/components/container/src/lazy-container.vue +0 -9
  46. package/src/components/container/src/scroll-bar.vue +0 -117
  47. package/src/components/container/src/scroll-container.vue +0 -61
  48. package/src/components/curd/index.ts +0 -5
  49. package/src/components/curd/src/components/dialog.vue +0 -73
  50. package/src/components/curd/src/components/props.ts +0 -32
  51. package/src/components/curd/src/hooks/useCurd.tsx +0 -87
  52. package/src/components/curd/src/types/curd.type.ts +0 -32
  53. package/src/components/excel/index.ts +0 -6
  54. package/src/components/excel/src/export2Excel.ts +0 -44
  55. package/src/components/forms/index.less +0 -107
  56. package/src/components/forms/index.ts +0 -11
  57. package/src/components/forms/src/componentMap.ts +0 -46
  58. package/src/components/forms/src/components/formButton.vue +0 -150
  59. package/src/components/forms/src/components/formIcon.vue +0 -51
  60. package/src/components/forms/src/components/formInputUseDialog.vue +0 -43
  61. package/src/components/forms/src/components/formItem.vue +0 -420
  62. package/src/components/forms/src/components/radioButton.vue +0 -58
  63. package/src/components/forms/src/const/form.const.ts +0 -7
  64. package/src/components/forms/src/hooks/helper.ts +0 -70
  65. package/src/components/forms/src/hooks/useForm.ts +0 -130
  66. package/src/components/forms/src/hooks/useFormActions.ts +0 -63
  67. package/src/components/forms/src/hooks/useFormEvents.ts +0 -248
  68. package/src/components/forms/src/hooks/useFormValue.ts +0 -49
  69. package/src/components/forms/src/hooks/useFormValues.ts +0 -131
  70. package/src/components/forms/src/hooks/useLabelWidth.ts +0 -57
  71. package/src/components/forms/src/index.vue +0 -310
  72. package/src/components/forms/src/prop.ts +0 -80
  73. package/src/components/forms/src/types/form.type.ts +0 -275
  74. package/src/components/icons/index.less +0 -101
  75. package/src/components/icons/index.ts +0 -7
  76. package/src/components/icons/src/pick-icon.vue +0 -119
  77. package/src/components/icons/src/svg-icon.vue +0 -117
  78. package/src/components/iframe/index.less +0 -3
  79. package/src/components/iframe/index.ts +0 -5
  80. package/src/components/iframe/src/index.less +0 -3
  81. package/src/components/iframe/src/index.vue +0 -38
  82. package/src/components/index.ts +0 -53
  83. package/src/components/modal/index.less +0 -60
  84. package/src/components/modal/index.ts +0 -8
  85. package/src/components/modal/src/components/close-icon.vue +0 -46
  86. package/src/components/modal/src/components/modal-wrap.vue +0 -128
  87. package/src/components/modal/src/components/modal.tsx +0 -30
  88. package/src/components/modal/src/components/modalFooter.vue +0 -46
  89. package/src/components/modal/src/hooks/useDrag.ts +0 -107
  90. package/src/components/modal/src/hooks/useFullScreen.ts +0 -29
  91. package/src/components/modal/src/hooks/useModal.ts +0 -200
  92. package/src/components/modal/src/index.vue +0 -184
  93. package/src/components/modal/src/props.ts +0 -44
  94. package/src/components/modal/src/types/modal.type.ts +0 -30
  95. package/src/components/router/base-router.vue +0 -11
  96. package/src/components/router/index.ts +0 -3
  97. package/src/components/source/index.ts +0 -1
  98. package/src/components/source/src/hooks/useFetch.ts +0 -42
  99. package/src/components/source/src/hooks/usePage.ts +0 -3
  100. package/src/components/source/src/hooks/useSource.ts +0 -214
  101. package/src/components/source/src/index.ts +0 -5
  102. package/src/components/source/src/types/source.type.ts +0 -58
  103. package/src/components/source/src/types/table.type.ts +0 -8
  104. package/src/components/table/index.less +0 -179
  105. package/src/components/table/index.ts +0 -7
  106. package/src/components/table/src/components/TableActions.vue +0 -108
  107. package/src/components/table/src/components/TableHeader.vue +0 -78
  108. package/src/components/table/src/components/TableRender.vue +0 -76
  109. package/src/components/table/src/components/editable/CellComponent.ts +0 -57
  110. package/src/components/table/src/components/editable/EditTableCell.vue +0 -181
  111. package/src/components/table/src/components/editable/componentMap.ts +0 -18
  112. package/src/components/table/src/components/editable/index.ts +0 -58
  113. package/src/components/table/src/components/setting/Column.vue +0 -354
  114. package/src/components/table/src/components/setting/Download.vue +0 -55
  115. package/src/components/table/src/components/setting/Fullscreen.vue +0 -43
  116. package/src/components/table/src/components/setting/Size.vue +0 -42
  117. package/src/components/table/src/components/setting/index.vue +0 -64
  118. package/src/components/table/src/const.ts +0 -13
  119. package/src/components/table/src/hooks/useColumns.ts +0 -326
  120. package/src/components/table/src/hooks/useCustomRow.ts +0 -86
  121. package/src/components/table/src/hooks/useDataSource.ts +0 -97
  122. package/src/components/table/src/hooks/useHeaderCode.ts +0 -89
  123. package/src/components/table/src/hooks/useLoading.ts +0 -29
  124. package/src/components/table/src/hooks/usePagination.ts +0 -76
  125. package/src/components/table/src/hooks/useRowSelection.ts +0 -145
  126. package/src/components/table/src/hooks/useRows.ts +0 -30
  127. package/src/components/table/src/hooks/useTable.ts +0 -90
  128. package/src/components/table/src/hooks/useTableHeader.ts +0 -48
  129. package/src/components/table/src/hooks/useTableInstance.ts +0 -29
  130. package/src/components/table/src/hooks/useTableScroll.ts +0 -229
  131. package/src/components/table/src/index.vue +0 -212
  132. package/src/components/table/src/props.ts +0 -160
  133. package/src/components/table/src/types/table.type.ts +0 -160
  134. package/src/components/table/src/types/tableHeader.type.ts +0 -27
  135. package/src/components/tree/index.less +0 -41
  136. package/src/components/tree/index.ts +0 -5
  137. package/src/components/tree/src/components/TreeHeader.vue +0 -97
  138. package/src/components/tree/src/hooks/useTree.ts +0 -239
  139. package/src/components/tree/src/index.vue +0 -392
  140. package/src/components/tree/src/props.ts +0 -133
  141. package/src/components/tree/src/type/tree.ts +0 -105
  142. package/src/components/tree/src/utils/tree.ts +0 -73
  143. package/src/components/type.ts +0 -0
  144. package/src/components/upload/index.less +0 -35
  145. package/src/components/upload/index.ts +0 -5
  146. package/src/components/upload/src/helper.ts +0 -60
  147. package/src/components/upload/src/props.ts +0 -51
  148. package/src/components/upload/src/upload.vue +0 -191
  149. package/src/directives/icon.ts +0 -36
  150. package/src/directives/index.ts +0 -26
  151. package/src/directives/permission.ts +0 -20
  152. package/src/global.d.ts +0 -8
  153. package/src/index.ts +0 -4
  154. package/src/theme/content/index.vue +0 -37
  155. package/src/theme/feature/back-top.vue +0 -11
  156. package/src/theme/feature/index.vue +0 -7
  157. package/src/theme/footer/index.less +0 -16
  158. package/src/theme/footer/index.vue +0 -24
  159. package/src/theme/header/components/bread-crumb.vue +0 -26
  160. package/src/theme/header/components/fullscreen.vue +0 -12
  161. package/src/theme/header/components/handler.ts +0 -81
  162. package/src/theme/header/components/index.ts +0 -21
  163. package/src/theme/header/components/lang-picker.vue +0 -36
  164. package/src/theme/header/components/logo.vue +0 -35
  165. package/src/theme/header/components/menu-search.vue +0 -62
  166. package/src/theme/header/components/notify.vue +0 -22
  167. package/src/theme/header/components/setting-theme.vue +0 -123
  168. package/src/theme/header/components/theme-drawer/enum.ts +0 -12
  169. package/src/theme/header/components/theme-drawer/feature.vue +0 -75
  170. package/src/theme/header/components/theme-drawer/index.ts +0 -7
  171. package/src/theme/header/components/theme-drawer/menu-type.vue +0 -40
  172. package/src/theme/header/components/theme-drawer/select-item.vue +0 -46
  173. package/src/theme/header/components/theme-drawer/switch-item.vue +0 -39
  174. package/src/theme/header/components/theme-drawer/theme-color.vue +0 -26
  175. package/src/theme/header/components/trigger.vue +0 -14
  176. package/src/theme/header/components/user-info.vue +0 -60
  177. package/src/theme/header/const/index.ts +0 -40
  178. package/src/theme/header/helper/menu-tree.ts +0 -64
  179. package/src/theme/header/index.less +0 -442
  180. package/src/theme/header/index.ts +0 -0
  181. package/src/theme/header/index.vue +0 -96
  182. package/src/theme/header/multiple-header.vue +0 -67
  183. package/src/theme/header/set-theme.less +0 -68
  184. package/src/theme/index.ts +0 -3
  185. package/src/theme/sider/components/basic-menu/basic-menu-item.vue +0 -14
  186. package/src/theme/sider/components/basic-menu/basic-menu.vue +0 -122
  187. package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +0 -46
  188. package/src/theme/sider/components/basic-menu/menu-item-content.vue +0 -13
  189. package/src/theme/sider/components/drag-bar.vue +0 -26
  190. package/src/theme/sider/components/layout-menu.vue +0 -132
  191. package/src/theme/sider/components/props.ts +0 -97
  192. package/src/theme/sider/components/sider-trigger.vue +0 -24
  193. package/src/theme/sider/helper/sider.ts +0 -52
  194. package/src/theme/sider/helper/split-menu.ts +0 -146
  195. package/src/theme/sider/hooks/useDragLine.ts +0 -86
  196. package/src/theme/sider/hooks/useOpenKeys.ts +0 -57
  197. package/src/theme/sider/index.less +0 -203
  198. package/src/theme/sider/index.vue +0 -88
  199. package/src/theme/tabs/components/TabContent.vue +0 -36
  200. package/src/theme/tabs/components/TabRedo.vue +0 -18
  201. package/src/theme/tabs/hooks/useMultifyTabs.ts +0 -96
  202. package/src/theme/tabs/hooks/useTabDropdown.ts +0 -89
  203. package/src/theme/tabs/index.less +0 -165
  204. package/src/theme/tabs/index.vue +0 -98
  205. package/src/theme/tabs/types/tabs.type.ts +0 -8
  206. package/src/theme/theme.less +0 -67
  207. package/src/theme/theme.vue +0 -90
  208. package/src/theme/transition.less +0 -99
@@ -1,326 +0,0 @@
1
- import type { PaginationProps } from 'ant-design-vue/lib/pagination'
2
- import { computed, ComputedRef, Ref, ref, unref, toRaw, watch, h } from "vue"
3
- import { cloneDeep, isEqual, omit } from 'lodash-es'
4
- import { renderEditCell } from '../components/editable'
5
- import { BasicColumn, BasicTableProps } from "../types/table.type"
6
- import { SetColumnsParams } from '../types/tableHeader.type'
7
- import { isArray, isBoolean, isFunction, isObject, isString, Recordable, useAppStore, getDictValueByCode } from '@dt-frames/core'
8
- import TableAction from '../components/TableActions.vue'
9
-
10
- // 索引列及操作列标识
11
- const INDEX_FLAG = 'INDEX'
12
- const ACTION_COLUMN = 'ACTION'
13
-
14
- // 处理单条数据的ellipsis 对齐方式
15
- function handleItem(item: BasicColumn, ellipsis: boolean) {
16
- const { appConf } = useAppStore();
17
- const { align } = appConf.ui.table
18
-
19
- const { key, dataIndex, children } = item
20
- item.align = item.align || align
21
-
22
- if( ellipsis ) {
23
- if (!key) item.key = dataIndex && dataIndex.toString()
24
-
25
- if (!isBoolean(item.ellipsis)) {
26
- item = Object.assign(item, {
27
- ellipsis,
28
- })
29
- }
30
- }
31
-
32
- if (children && children.length) {
33
- handleChildren(children, !!ellipsis);
34
- }
35
- }
36
-
37
- function handleChildren(children: BasicColumn[] | undefined, ellipsis: boolean) {
38
- if (!children) return
39
-
40
- children.forEach((item) => {
41
- const { children } = item
42
- handleItem(item, ellipsis)
43
- handleChildren(children, ellipsis)
44
- })
45
- }
46
-
47
- // 重新排序列
48
- function sortFixedColumn(columns: BasicColumn[]) {
49
- const fixedLeftColumn: BasicColumn[] = []
50
- const fixedRightColumn: BasicColumn[] = []
51
- const defaultColumn: BasicColumn[] = []
52
-
53
- for( let column of columns ) {
54
- if( column.defaultHidden ) continue
55
-
56
- if( column.fixed === 'left' ) {
57
- fixedLeftColumn.push( column )
58
- continue
59
- }
60
-
61
- if( column.fixed === 'right' ) {
62
- fixedRightColumn.push( column )
63
- continue
64
- }
65
-
66
- defaultColumn.push( column )
67
- }
68
-
69
- return [
70
- ...fixedLeftColumn,
71
- ...defaultColumn,
72
- ...fixedRightColumn
73
- ]
74
- }
75
-
76
- // 处理序号
77
- function handleIndexColumn(
78
- propsRef: ComputedRef<BasicTableProps>,
79
- getPaginationRef: ComputedRef<boolean | PaginationProps>,
80
- columns: BasicColumn[]
81
- ) {
82
- const { showIndexColumn, indexColumnProps, isTreeTable } = unref(propsRef)
83
-
84
- let pushIndexColumns = false
85
- if (unref(isTreeTable)) {
86
- return;
87
- }
88
-
89
- columns.forEach(() => {
90
- const indIndex = columns.findIndex((column) => column.flag === INDEX_FLAG);
91
- if (showIndexColumn) {
92
- pushIndexColumns = indIndex === -1;
93
- } else if (!showIndexColumn && indIndex !== -1) {
94
- columns.splice(indIndex, 1);
95
- }
96
- })
97
-
98
- if (!pushIndexColumns) return
99
-
100
- const isFixedLeft = columns.some((item) => item.fixed === 'left')
101
-
102
- columns.unshift({
103
- flag: INDEX_FLAG,
104
- width: 50,
105
- title: '序号',
106
- align: 'center',
107
- customRender: ( { index } ) => {
108
- const getPagination = unref(getPaginationRef)
109
-
110
- const { appConf } = useAppStore()
111
- const { defaultPageSize } = appConf.ui.table
112
-
113
- if (isBoolean(getPagination)) {
114
- return `${index + 1}`;
115
- }
116
-
117
- const { current = 1, pageSize = defaultPageSize } = getPagination;
118
- return ((current < 1 ? 1 : current) - 1) * pageSize + index + 1
119
- },
120
- ...(isFixedLeft
121
- ? {
122
- fixed: 'left',
123
- }
124
- : {}),
125
- ...indexColumnProps,
126
- })
127
- }
128
-
129
- // 处理操作栏的列
130
- function handleActionColumn(propsRef: ComputedRef<BasicTableProps>, columns: BasicColumn[]) {
131
- const { operations } = unref(propsRef)
132
-
133
- if (
134
- !operations
135
- || (isObject( operations ) && !operations?.btns )
136
- || ( isArray(operations) && !operations )
137
- ) return
138
-
139
- const hasIndex = columns.findIndex((column) => column.flag === ACTION_COLUMN)
140
-
141
- if( hasIndex === -1 ) {
142
- let column = isObject( operations ) ? operations
143
- : isArray( operations ) ? { btns: operations } : {}
144
-
145
- let expand = column.expand ? column.expand : false
146
- let columnObj = {
147
- fixed: 'right',
148
- title: '操作',
149
- align: 'center',
150
- expand,
151
- width: `${ (expand ? (column.btns.length * 30 + 40) : 70) }px`,
152
- ...column,
153
- flag: ACTION_COLUMN,
154
- }
155
-
156
- columns.push({
157
- ...(columnObj as any),
158
- customRender: ({ record, index}) => {
159
- return h(
160
- TableAction as any,
161
- omit({
162
- ...columnObj,
163
- record,
164
- index
165
- }, 'align')
166
- )
167
- }
168
- })
169
- }
170
- }
171
-
172
-
173
- export function useColumns(
174
- propsRef: ComputedRef<BasicTableProps>,
175
- getPaginationRef: ComputedRef<boolean | PaginationProps>,
176
- ) {
177
-
178
- const columnsRef = ref(unref(propsRef).columns) as unknown as Ref<BasicColumn[]>
179
- let cacheColumns = unref(propsRef).columns
180
-
181
- const getColumnsRef = computed(() => {
182
- const columns = cloneDeep(unref(columnsRef)) as BasicColumn[]
183
- if (!columns) return []
184
-
185
- const { ellipsis, resizable, minWidth = 50, maxWidth = 700 } = unref(propsRef)
186
-
187
- columns.forEach( (it, index) => {
188
- const { slots } = it
189
- it.width = it.width || (index === columns.length - 1 ? 119.9 : 120)
190
- if( Reflect.has(it, 'resizable') ? !!it.resizable : resizable ) {
191
- it.resizable = true
192
- it.minWidth = it.minWidth || minWidth
193
- it.maxWidth = it.maxWidth || maxWidth
194
- }
195
-
196
- handleItem(
197
- it,
198
- Reflect.has(it, 'ellipsis') ? !!it.ellipsis : !!ellipsis && !slots
199
- )
200
- } )
201
-
202
- handleIndexColumn(propsRef, getPaginationRef, columns)
203
- handleActionColumn(propsRef, columns)
204
-
205
- return columns
206
- })
207
-
208
- const getViewColumns = computed(() => {
209
- const viewColumns = sortFixedColumn(unref(getColumnsRef))
210
- const columns: BasicColumn[] = cloneDeep(viewColumns)
211
-
212
- return columns
213
- .filter( column => isIfShow(column) )
214
- .map(column => {
215
- if( column.edit ) {
216
- column.customRender = renderEditCell(column)
217
- }
218
-
219
- return column
220
- })
221
-
222
- })
223
-
224
- function isIfShow( column: BasicColumn ): boolean {
225
- const ifShow = column.ifShow
226
-
227
- return isBoolean(ifShow)
228
- ? ifShow
229
- : isFunction(ifShow) ? ifShow(column) : true
230
-
231
- }
232
-
233
- watch(
234
- () => unref(propsRef).columns,
235
- columns => {
236
- columnsRef.value = columns
237
- cacheColumns = columns.filter( it => !it.flag ) ?? []
238
- }
239
- )
240
-
241
-
242
- // 获取列信息
243
- function getColumns(opt?: SetColumnsParams) {
244
- const { ignoreIndex, ignoreAction, sort } = opt || {}
245
-
246
- let columns = toRaw(unref(getColumnsRef))
247
-
248
- if( ignoreIndex ) {
249
- columns = columns.filter( it => it.flag !== INDEX_FLAG )
250
- }
251
-
252
- if( ignoreAction ) {
253
- columns = columns.filter( it => it.flag !== ACTION_COLUMN )
254
- }
255
-
256
- // 重新排序
257
- if( sort ) {
258
- columns = sortFixedColumn( columns )
259
- }
260
-
261
- return columns
262
- }
263
-
264
-
265
- // 设置列信息
266
- function setColumns(columnList: Partial<BasicColumn>[] | string[] = []) {
267
- const columns = cloneDeep(columnList)
268
-
269
- if( !isArray( columns ) ) return
270
-
271
- // 重置所有的列
272
- if( !columns.length ) {
273
- columnsRef.value = []
274
- return
275
- }
276
-
277
- const cacheKeys = cacheColumns.map((item) => item.dataIndex)
278
-
279
- if( !isString( columns[0] ) ) {
280
- columnsRef.value = columns as BasicColumn[]
281
- } else {
282
- const columnKeys = columns as string[]
283
- const newColumns: BasicColumn[] = []
284
-
285
- cacheColumns.forEach( it => {
286
- newColumns.push({
287
- ...it,
288
- defaultHidden: !columnKeys.includes((it.dataIndex! || it.key) as string),
289
- })
290
- } )
291
-
292
-
293
- if( !isEqual(cacheKeys, columns) ) {
294
- newColumns.sort((prev, next) => {
295
- return columnKeys.indexOf(prev.dataIndex as string) - columnKeys.indexOf(next.dataIndex as string)
296
- })
297
- }
298
-
299
- columnsRef.value = newColumns
300
- }
301
- }
302
-
303
- function setCacheColumnsByField(dataIndex: string | undefined, value: Partial<BasicColumn>) {
304
- if (!dataIndex || !value) return
305
-
306
- cacheColumns.forEach((item) => {
307
- if (item.dataIndex === dataIndex) {
308
- Object.assign(item, value);
309
- return;
310
- }
311
- })
312
- }
313
-
314
- function getCacheColumns() {
315
- return cacheColumns;
316
- }
317
-
318
- return {
319
- getViewColumns,
320
- getColumnsRef,
321
- getColumns,
322
- setColumns,
323
- setCacheColumnsByField,
324
- getCacheColumns
325
- }
326
- }
@@ -1,86 +0,0 @@
1
- import { DtEvent, Recordable } from "@dt-frames/core"
2
- import { ComputedRef, unref } from "vue"
3
- import { BasicTableProps } from "../types/table.type"
4
-
5
- interface Options {
6
- setSelectedRowKeys: (keys: string[]) => void
7
- getSelectRowKeys: () => string[]
8
- clearSelectedRowKeys: () => void
9
- emit: any
10
- }
11
-
12
- export function useCustomRow(
13
- propsRef: ComputedRef<BasicTableProps>,
14
- { setSelectedRowKeys, getSelectRowKeys, clearSelectedRowKeys, emit }: Options
15
- ) {
16
- const customRow = (record: Recordable, index: number) => {
17
- return {
18
- onClick: (e) => {
19
- e?.stopPropagation()
20
-
21
- function handleClick() {
22
- const { rowSelection, rowKey, clickToRowSelect } = unref(propsRef)
23
- if (!rowSelection || !clickToRowSelect) return
24
-
25
- const keys = getSelectRowKeys()
26
- const key = record[rowKey]
27
- if (!key) return
28
-
29
- const isCheckbox = rowSelection.type === 'checkbox'
30
- if (isCheckbox) {
31
- const tr: HTMLElement = (e as MouseEvent)
32
- .composedPath?.()
33
- .find((dom: HTMLElement) => dom.tagName === 'TR') as HTMLElement;
34
- if (!tr) return
35
-
36
- const checkBox = tr.querySelector('input[type=checkbox]')
37
-
38
- if (!checkBox || checkBox.hasAttribute('disabled')) return
39
-
40
- if (!keys.includes(key)) {
41
- setSelectedRowKeys([...keys, key])
42
- return
43
- }
44
-
45
- const keyIndex = keys.findIndex((item) => item === key)
46
- keys.splice(keyIndex, 1)
47
- setSelectedRowKeys(keys)
48
- return
49
- }
50
-
51
- const isRadio = rowSelection.type === 'radio'
52
-
53
- if (isRadio) {
54
- if (!keys.includes(key)) {
55
- if (keys.length) {
56
- clearSelectedRowKeys()
57
- }
58
- setSelectedRowKeys([key])
59
- return
60
- }
61
- clearSelectedRowKeys()
62
- }
63
- }
64
-
65
- handleClick()
66
- emit('row-click', record, index, e)
67
- },
68
- onDblclick: (event: Event) => {
69
- emit('row-dbClick', record, index, event);
70
- },
71
- onContextmenu: (event: Event) => {
72
- emit('row-contextmenu', record, index, event);
73
- },
74
- onMouseenter: (event: Event) => {
75
- emit('row-mouseenter', record, index, event);
76
- },
77
- onMouseleave: (event: Event) => {
78
- emit('row-mouseleave', record, index, event);
79
- },
80
- }
81
- }
82
-
83
- return {
84
- customRow,
85
- }
86
- }
@@ -1,97 +0,0 @@
1
- import { ComputedRef, ref, Ref, unref, toRaw, watch, computed, onMounted } from "vue"
2
- import type { PaginationProps } from 'ant-design-vue/lib/pagination'
3
- import { BasicTableProps, SorterResult } from "../types/table.type"
4
- import { isFunction, Recordable, useAppStore, useTimeoutFn } from "@dt-frames/core"
5
-
6
- /**
7
- * 处理表格数据
8
- */
9
- type ActionsType = {
10
- getPaginationInfo: ComputedRef<boolean | PaginationProps>
11
- setPagination: (info: Partial<PaginationProps>) => void
12
- clearSelectedRowKeys: () => void
13
- }
14
-
15
- export function useDataSource(
16
- propsRef: ComputedRef<BasicTableProps>,
17
- {
18
- getPaginationInfo,
19
- setPagination,
20
- clearSelectedRowKeys,
21
- }: ActionsType,
22
- emit
23
- ) {
24
- // 拷贝一份表格数据 然后再做数据处理
25
- const dataSourceRef = ref<Recordable[]>([])
26
-
27
- watch(
28
- () => unref(propsRef).dataSource,
29
- (dataSource) => {
30
- dataSource && (dataSourceRef.value = dataSource)
31
- },
32
- {
33
- immediate: true
34
- }
35
- )
36
-
37
- const getDataSourceRef = computed( () => {
38
- return unref(dataSourceRef)
39
- } )
40
-
41
- // 表单改变事件
42
- function handleTableChange(
43
- pagination: PaginationProps,
44
- filters: Partial<Recordable<string[]>>,
45
- sorter: SorterResult,
46
- ) {
47
- const { sortFn, filterFn, onTableChange } = unref( propsRef )
48
- const { appConf } = useAppStore()
49
- const { current = 1, pageSize = appConf.ui.table.defaultPageSize } = pagination
50
-
51
- // clearSelectedRowKeys()
52
-
53
- setPagination( pagination )
54
-
55
- const params: Recordable = {}
56
-
57
- if( sorter && isFunction(sortFn) ) {
58
- params.sortInfo = sortFn(sorter)
59
- }
60
-
61
- if (filters && isFunction(filterFn)) {
62
- params.filterInfo = filterFn( filters )
63
- }
64
-
65
-
66
- return onTableChange({
67
- pagination: {
68
- current,
69
- pageSize
70
- },
71
- sort: unref( params.sortInfo ),
72
- filter: toRaw(unref( params.filterInfo )),
73
- showBtnLoading: false
74
- })
75
- }
76
-
77
-
78
- const { defSort, onTableChange } = unref( propsRef )
79
- const { appConf } = useAppStore()
80
-
81
- onTableChange({
82
- pagination: {
83
- current: 1,
84
- pageSize: appConf.ui.table.defaultPageSize
85
- },
86
- sort:defSort,
87
- filter: null,
88
- showBtnLoading: false
89
- }, false)
90
-
91
-
92
- return {
93
- getDataSourceRef,
94
- handleTableChange
95
- }
96
-
97
- }
@@ -1,89 +0,0 @@
1
- import { error, http, Recordable, useAppStore } from "@dt-frames/core"
2
- import { BasicColumn } from "../types/table.type"
3
-
4
- const codeMap = new Map()
5
-
6
- // 解析header
7
- export function useHeaderCode(code: string, templates: Recordable = {}, changeColumns: ( rows: BasicColumn[] ) => void) {
8
- const { appConf } = useAppStore()
9
-
10
- if( !appConf.pages.queryColumnApi ) {
11
- error('请在init.config.ts中配置queryColumnApi!')
12
- return
13
- }
14
-
15
-
16
- // 设置文字对齐方式
17
- const getAlign = ( key: number | null ) => key === 0 ? 'center' : key === 2 ? 'right' : 'left'
18
-
19
-
20
- // 渲染单元格
21
- const renderCell = ( type: number, ctx: string ): Recordable => {
22
- switch( type ) {
23
- // 时间
24
- case 0: return { date: ctx }
25
-
26
- // 字典
27
- case 1: return { dict: ctx }
28
-
29
- // 百分比
30
- case 5: return { percent: ctx }
31
-
32
- // structure
33
- case 7:
34
- if( !appConf.structure[ctx] ) {
35
- error(`未找到structure: ${ ctx } !`)
36
- return { }
37
- }
38
- return { dict: appConf.structure[ctx] }
39
-
40
- // 自定义模板
41
- case 10: return templates[ctx]
42
-
43
- // 数字
44
- case 11: return { number: ctx }
45
- }
46
- }
47
-
48
-
49
- function getColumns() {
50
- if( codeMap.get(code ) ) {
51
- changeColumns( codeMap.get(code ) )
52
- return
53
- }
54
-
55
- http.post(
56
- appConf.pages.queryColumnApi,
57
- { tableCode: code }
58
- ).then( rsp => {
59
- handleData(rsp)
60
- } )
61
- }
62
-
63
- function handleData(data: Recordable[]) {
64
- let rows: BasicColumn[] = []
65
-
66
- data.forEach( it => {
67
- let obj: BasicColumn = {
68
- title: it.cloumnName,
69
- dataIndex: it.cloumnCode,
70
- sorter: it.ifOrder,
71
- align: getAlign(it.textAlign),
72
- ifShow: Boolean( it.ifDisplay ),
73
- defaultHidden: !Boolean( it.ifDisplay )
74
- }
75
-
76
- if( it.cloumnType !== undefined ) obj.render = renderCell( it.cloumnType, it.dictCode )
77
-
78
- if( it.width ) obj.width = Number(it.width)
79
-
80
- rows.push(obj)
81
- } )
82
-
83
- codeMap.set(code, rows )
84
- changeColumns( rows )
85
- }
86
-
87
- getColumns()
88
-
89
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * 设置表格的loading状态
3
- * 这里做二次封装 主要原因是暴露一个方法 外面可以调用这个方法 从而改变loading状态
4
- */
5
-
6
- import { ComputedRef, ref, unref, watch, computed } from "vue"
7
- import { BasicTableProps } from "../types/table.type"
8
-
9
- export function useLoading(props: ComputedRef<BasicTableProps>) {
10
- const loadingRef = ref( unref(props).loading )
11
-
12
- watch(
13
- () => unref(props).loading,
14
- (v) => {
15
- loadingRef.value = v
16
- }
17
- )
18
-
19
- const getLoading = computed(() => unref(loadingRef))
20
-
21
- function setLoading( loading: boolean ) {
22
- loadingRef.value = loading
23
- }
24
-
25
- return {
26
- getLoading,
27
- setLoading
28
- }
29
- }
@@ -1,76 +0,0 @@
1
- import { computed, ComputedRef, ref, unref, watch } from "vue"
2
- import type { PaginationProps } from 'ant-design-vue/lib/pagination'
3
- import { BasicTableProps } from "../types/table.type"
4
- import { isBoolean, useAppStore } from "@dt-frames/core"
5
-
6
-
7
- export function usePagination(props: ComputedRef<BasicTableProps>) {
8
- const paginationRef = ref<PaginationProps>({})
9
- const show = ref(true)
10
-
11
- watch(
12
- () => unref(props).pagination,
13
- (pagination) => {
14
- if( !isBoolean(pagination) && pagination ) {
15
- paginationRef.value = {
16
- ...unref(paginationRef),
17
- ...(pagination ?? {})
18
- }
19
- }
20
- }
21
- )
22
-
23
- // 获取分页数据
24
- const getPaginationInfo = computed((): PaginationProps | boolean => {
25
- const { pagination } = unref( props )
26
-
27
- if( !unref(show) || isBoolean( pagination ) && !pagination ) {
28
- return false
29
- }
30
-
31
- const { appConf } = useAppStore()
32
- const { defaultPageSize, pageSizeOptions, size } = appConf.ui.table
33
-
34
- return {
35
- current: 1,
36
- pageSize: defaultPageSize,
37
- size: size === 'small' ? 'small' : 'default',
38
- defaultPageSize,
39
- showTotal: (total, range) => `总共${ total }页`,
40
- showSizeChanger: true,
41
- pageSizeOptions,
42
- showQuickJumper: true,
43
- ...(isBoolean(pagination) ? {} : pagination),
44
- ...unref(paginationRef),
45
- }
46
- })
47
-
48
- function setPagination(info: Partial<PaginationProps>) {
49
- const paginationInfo = unref( getPaginationInfo )
50
-
51
- paginationRef.value = {
52
- ...(!isBoolean(paginationInfo) ? paginationInfo : {}),
53
- ...info
54
- }
55
- }
56
-
57
- function getPagination() {
58
- return unref( getPaginationInfo )
59
- }
60
-
61
- function getShowPagination() {
62
- return unref(show);
63
- }
64
-
65
- async function setShowPagination(flag: boolean) {
66
- show.value = flag;
67
- }
68
-
69
- return {
70
- getPaginationInfo,
71
- setPagination,
72
- getPagination,
73
- getShowPagination,
74
- setShowPagination
75
- }
76
- }