@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.
- package/es/components/curd/src/components/dialog.d.ts +20 -20
- package/es/components/curd/src/components/props.d.ts +2 -1
- package/es/components/curd/src/hooks/useCurd.d.ts +1 -0
- package/es/components/curd/src/types/curd.type.d.ts +2 -2
- package/es/components/forms/src/components/formButton.d.ts +1 -2
- package/es/components/forms/src/components/formIcon.d.ts +15 -15
- package/es/components/forms/src/hooks/useFormActions.d.ts +2 -2
- package/es/components/forms/src/index.d.ts +2 -2
- package/es/components/forms/src/types/form.type.d.ts +3 -17
- package/es/components/index.d.ts +1 -1
- package/es/components/modal/src/components/modal.d.ts +2 -2
- package/es/components/modal/src/components/modalFooter.d.ts +1 -1
- package/es/components/modal/src/index.d.ts +15 -15
- package/es/components/modal/src/props.d.ts +1 -1
- package/es/components/source/src/hooks/useFetch.d.ts +1 -1
- package/es/components/table/src/index.d.ts +3 -3
- package/es/components/table/src/props.d.ts +1 -2
- package/es/components/tree/src/props.d.ts +8 -1
- package/es/components/upload/src/upload.d.ts +3 -3
- package/es/index.js +43 -19
- package/es/style/components/icons/index.less +1 -1
- package/package.json +1 -10
- package/vite.config.js +10 -0
- package/src/assets/data/icons/actions.ts +0 -427
- package/src/assets/data/icons/code.ts +0 -10
- package/src/assets/data/icons/commuticate.ts +0 -190
- package/src/assets/data/icons/currency.ts +0 -46
- package/src/assets/data/icons/devices.ts +0 -128
- package/src/assets/data/icons/edit.ts +0 -165
- package/src/assets/data/icons/file.ts +0 -104
- package/src/assets/data/icons/math.ts +0 -53
- package/src/assets/data/icons/message.ts +0 -75
- package/src/assets/data/icons/navigate.ts +0 -181
- package/src/assets/data/icons/other.ts +0 -333
- package/src/assets/data/icons.ts +0 -58
- package/src/assets/imgs/header/avatar.png +0 -0
- package/src/assets/imgs/logo/logo.png +0 -0
- package/src/assets/locales/en_US.json +0 -3
- package/src/assets/locales/zh_CN.json +0 -3
- package/src/assets/style/index.less +0 -10
- package/src/assets/style/reset.less +0 -17
- package/src/components/container/index.less +0 -85
- package/src/components/container/index.ts +0 -8
- package/src/components/container/src/bar.ts +0 -107
- package/src/components/container/src/lazy-container.vue +0 -9
- package/src/components/container/src/scroll-bar.vue +0 -117
- package/src/components/container/src/scroll-container.vue +0 -61
- package/src/components/curd/index.ts +0 -5
- package/src/components/curd/src/components/dialog.vue +0 -73
- package/src/components/curd/src/components/props.ts +0 -32
- package/src/components/curd/src/hooks/useCurd.tsx +0 -87
- package/src/components/curd/src/types/curd.type.ts +0 -32
- package/src/components/excel/index.ts +0 -6
- package/src/components/excel/src/export2Excel.ts +0 -44
- package/src/components/forms/index.less +0 -107
- package/src/components/forms/index.ts +0 -11
- package/src/components/forms/src/componentMap.ts +0 -46
- package/src/components/forms/src/components/formButton.vue +0 -150
- package/src/components/forms/src/components/formIcon.vue +0 -51
- package/src/components/forms/src/components/formInputUseDialog.vue +0 -43
- package/src/components/forms/src/components/formItem.vue +0 -420
- package/src/components/forms/src/components/radioButton.vue +0 -58
- package/src/components/forms/src/const/form.const.ts +0 -7
- package/src/components/forms/src/hooks/helper.ts +0 -70
- package/src/components/forms/src/hooks/useForm.ts +0 -130
- package/src/components/forms/src/hooks/useFormActions.ts +0 -63
- package/src/components/forms/src/hooks/useFormEvents.ts +0 -248
- package/src/components/forms/src/hooks/useFormValue.ts +0 -49
- package/src/components/forms/src/hooks/useFormValues.ts +0 -131
- package/src/components/forms/src/hooks/useLabelWidth.ts +0 -57
- package/src/components/forms/src/index.vue +0 -310
- package/src/components/forms/src/prop.ts +0 -80
- package/src/components/forms/src/types/form.type.ts +0 -275
- package/src/components/icons/index.less +0 -101
- package/src/components/icons/index.ts +0 -7
- package/src/components/icons/src/pick-icon.vue +0 -119
- package/src/components/icons/src/svg-icon.vue +0 -117
- package/src/components/iframe/index.less +0 -3
- package/src/components/iframe/index.ts +0 -5
- package/src/components/iframe/src/index.less +0 -3
- package/src/components/iframe/src/index.vue +0 -38
- package/src/components/index.ts +0 -53
- package/src/components/modal/index.less +0 -60
- package/src/components/modal/index.ts +0 -8
- package/src/components/modal/src/components/close-icon.vue +0 -46
- package/src/components/modal/src/components/modal-wrap.vue +0 -128
- package/src/components/modal/src/components/modal.tsx +0 -30
- package/src/components/modal/src/components/modalFooter.vue +0 -46
- package/src/components/modal/src/hooks/useDrag.ts +0 -107
- package/src/components/modal/src/hooks/useFullScreen.ts +0 -29
- package/src/components/modal/src/hooks/useModal.ts +0 -200
- package/src/components/modal/src/index.vue +0 -184
- package/src/components/modal/src/props.ts +0 -44
- package/src/components/modal/src/types/modal.type.ts +0 -30
- package/src/components/router/base-router.vue +0 -11
- package/src/components/router/index.ts +0 -3
- package/src/components/source/index.ts +0 -1
- package/src/components/source/src/hooks/useFetch.ts +0 -42
- package/src/components/source/src/hooks/usePage.ts +0 -3
- package/src/components/source/src/hooks/useSource.ts +0 -214
- package/src/components/source/src/index.ts +0 -5
- package/src/components/source/src/types/source.type.ts +0 -58
- package/src/components/source/src/types/table.type.ts +0 -8
- package/src/components/table/index.less +0 -179
- package/src/components/table/index.ts +0 -7
- package/src/components/table/src/components/TableActions.vue +0 -108
- package/src/components/table/src/components/TableHeader.vue +0 -78
- package/src/components/table/src/components/TableRender.vue +0 -76
- package/src/components/table/src/components/editable/CellComponent.ts +0 -57
- package/src/components/table/src/components/editable/EditTableCell.vue +0 -181
- package/src/components/table/src/components/editable/componentMap.ts +0 -18
- package/src/components/table/src/components/editable/index.ts +0 -58
- package/src/components/table/src/components/setting/Column.vue +0 -354
- package/src/components/table/src/components/setting/Download.vue +0 -55
- package/src/components/table/src/components/setting/Fullscreen.vue +0 -43
- package/src/components/table/src/components/setting/Size.vue +0 -42
- package/src/components/table/src/components/setting/index.vue +0 -64
- package/src/components/table/src/const.ts +0 -13
- package/src/components/table/src/hooks/useColumns.ts +0 -326
- package/src/components/table/src/hooks/useCustomRow.ts +0 -86
- package/src/components/table/src/hooks/useDataSource.ts +0 -97
- package/src/components/table/src/hooks/useHeaderCode.ts +0 -89
- package/src/components/table/src/hooks/useLoading.ts +0 -29
- package/src/components/table/src/hooks/usePagination.ts +0 -76
- package/src/components/table/src/hooks/useRowSelection.ts +0 -145
- package/src/components/table/src/hooks/useRows.ts +0 -30
- package/src/components/table/src/hooks/useTable.ts +0 -90
- package/src/components/table/src/hooks/useTableHeader.ts +0 -48
- package/src/components/table/src/hooks/useTableInstance.ts +0 -29
- package/src/components/table/src/hooks/useTableScroll.ts +0 -229
- package/src/components/table/src/index.vue +0 -212
- package/src/components/table/src/props.ts +0 -160
- package/src/components/table/src/types/table.type.ts +0 -160
- package/src/components/table/src/types/tableHeader.type.ts +0 -27
- package/src/components/tree/index.less +0 -41
- package/src/components/tree/index.ts +0 -5
- package/src/components/tree/src/components/TreeHeader.vue +0 -97
- package/src/components/tree/src/hooks/useTree.ts +0 -239
- package/src/components/tree/src/index.vue +0 -392
- package/src/components/tree/src/props.ts +0 -133
- package/src/components/tree/src/type/tree.ts +0 -105
- package/src/components/tree/src/utils/tree.ts +0 -73
- package/src/components/type.ts +0 -0
- package/src/components/upload/index.less +0 -35
- package/src/components/upload/index.ts +0 -5
- package/src/components/upload/src/helper.ts +0 -60
- package/src/components/upload/src/props.ts +0 -51
- package/src/components/upload/src/upload.vue +0 -191
- package/src/directives/icon.ts +0 -36
- package/src/directives/index.ts +0 -26
- package/src/directives/permission.ts +0 -20
- package/src/global.d.ts +0 -8
- package/src/index.ts +0 -4
- package/src/theme/content/index.vue +0 -37
- package/src/theme/feature/back-top.vue +0 -11
- package/src/theme/feature/index.vue +0 -7
- package/src/theme/footer/index.less +0 -16
- package/src/theme/footer/index.vue +0 -24
- package/src/theme/header/components/bread-crumb.vue +0 -26
- package/src/theme/header/components/fullscreen.vue +0 -12
- package/src/theme/header/components/handler.ts +0 -81
- package/src/theme/header/components/index.ts +0 -21
- package/src/theme/header/components/lang-picker.vue +0 -36
- package/src/theme/header/components/logo.vue +0 -35
- package/src/theme/header/components/menu-search.vue +0 -62
- package/src/theme/header/components/notify.vue +0 -22
- package/src/theme/header/components/setting-theme.vue +0 -123
- package/src/theme/header/components/theme-drawer/enum.ts +0 -12
- package/src/theme/header/components/theme-drawer/feature.vue +0 -75
- package/src/theme/header/components/theme-drawer/index.ts +0 -7
- package/src/theme/header/components/theme-drawer/menu-type.vue +0 -40
- package/src/theme/header/components/theme-drawer/select-item.vue +0 -46
- package/src/theme/header/components/theme-drawer/switch-item.vue +0 -39
- package/src/theme/header/components/theme-drawer/theme-color.vue +0 -26
- package/src/theme/header/components/trigger.vue +0 -14
- package/src/theme/header/components/user-info.vue +0 -60
- package/src/theme/header/const/index.ts +0 -40
- package/src/theme/header/helper/menu-tree.ts +0 -64
- package/src/theme/header/index.less +0 -442
- package/src/theme/header/index.ts +0 -0
- package/src/theme/header/index.vue +0 -96
- package/src/theme/header/multiple-header.vue +0 -67
- package/src/theme/header/set-theme.less +0 -68
- package/src/theme/index.ts +0 -3
- package/src/theme/sider/components/basic-menu/basic-menu-item.vue +0 -14
- package/src/theme/sider/components/basic-menu/basic-menu.vue +0 -122
- package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +0 -46
- package/src/theme/sider/components/basic-menu/menu-item-content.vue +0 -13
- package/src/theme/sider/components/drag-bar.vue +0 -26
- package/src/theme/sider/components/layout-menu.vue +0 -132
- package/src/theme/sider/components/props.ts +0 -97
- package/src/theme/sider/components/sider-trigger.vue +0 -24
- package/src/theme/sider/helper/sider.ts +0 -52
- package/src/theme/sider/helper/split-menu.ts +0 -146
- package/src/theme/sider/hooks/useDragLine.ts +0 -86
- package/src/theme/sider/hooks/useOpenKeys.ts +0 -57
- package/src/theme/sider/index.less +0 -203
- package/src/theme/sider/index.vue +0 -88
- package/src/theme/tabs/components/TabContent.vue +0 -36
- package/src/theme/tabs/components/TabRedo.vue +0 -18
- package/src/theme/tabs/hooks/useMultifyTabs.ts +0 -96
- package/src/theme/tabs/hooks/useTabDropdown.ts +0 -89
- package/src/theme/tabs/index.less +0 -165
- package/src/theme/tabs/index.vue +0 -98
- package/src/theme/tabs/types/tabs.type.ts +0 -8
- package/src/theme/theme.less +0 -67
- package/src/theme/theme.vue +0 -90
- 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
|
-
}
|