@complex-suite/component-antd 4.10.12
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/LayoutResizeObserver.ts +104 -0
- package/LocalResizeObserver.ts +46 -0
- package/README.md +67 -0
- package/antdConfig.ts +361 -0
- package/format.ts +458 -0
- package/history.md +325 -0
- package/icon.ts +65 -0
- package/index.test.ts +5 -0
- package/index.ts +55 -0
- package/package.json +39 -0
- package/plugin.ts +95 -0
- package/quick/QuickCascade.tsx +107 -0
- package/quick/QuickEdit.tsx +117 -0
- package/quick/QuickFloat.tsx +32 -0
- package/quick/QuickFloatModal.tsx +95 -0
- package/quick/QuickFloatValue.tsx +103 -0
- package/quick/QuickList.tsx +433 -0
- package/quick/data/FloatData.ts +77 -0
- package/src/AutoSpin.vue +39 -0
- package/src/AutoText.vue +101 -0
- package/src/ButtonView.tsx +62 -0
- package/src/CollapseArea.tsx +88 -0
- package/src/EditArea.tsx +205 -0
- package/src/EditView.tsx +179 -0
- package/src/FlexBox.tsx +74 -0
- package/src/FormList.tsx +226 -0
- package/src/ImageViewer.tsx +122 -0
- package/src/InfoArea.tsx +182 -0
- package/src/InfoView.tsx +150 -0
- package/src/MenuView.tsx +91 -0
- package/src/ModalView.tsx +274 -0
- package/src/MultipleImport.tsx +231 -0
- package/src/SearchArea.tsx +170 -0
- package/src/SelectText.vue +59 -0
- package/src/SimpleTable.tsx +256 -0
- package/src/SingleImport.tsx +189 -0
- package/src/TableView.tsx +415 -0
- package/src/components/AutoRender.tsx +19 -0
- package/src/components/ChoiceInfo.vue +73 -0
- package/src/components/PaginationView.tsx +103 -0
- package/src/components/TableMenu.tsx +93 -0
- package/src/dictionary/AutoEditItem.tsx +164 -0
- package/src/dictionary/AutoInfoItem.tsx +126 -0
- package/src/dictionary/AutoItem.tsx +219 -0
- package/src/icons/EmptyImage.vue +30 -0
- package/src/icons/ErrorImage.vue +30 -0
- package/src/style/index.css +304 -0
- package/tsconfig.json +8 -0
- package/type.ts +4 -0
- package/vitest.config.ts +11 -0
- package/widthCalculator.ts +20 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { defineComponent, h, PropType } from "vue"
|
|
2
|
+
import { Table } from 'ant-design-vue'
|
|
3
|
+
import type { TableColumnType, TableProps } from 'ant-design-vue'
|
|
4
|
+
import { deepCloneData, isArray, updateData } from "@complex-suite/utils"
|
|
5
|
+
import { ComplexList, DefaultInfo, PaginationData, DefaultMod, DefaultList } from "@complex-suite/data"
|
|
6
|
+
import type { orderType } from "@complex-suite/data"
|
|
7
|
+
import PaginationView from "./components/PaginationView"
|
|
8
|
+
import ChoiceInfo from "./components/ChoiceInfo.vue"
|
|
9
|
+
import TableMenu from "./components/TableMenu"
|
|
10
|
+
import type { TableMenuValue } from "./components/TableMenu"
|
|
11
|
+
import antdConfig from "../antdConfig"
|
|
12
|
+
|
|
13
|
+
export type customRenderPayload = { text: unknown, record: Record<PropertyKey, unknown>, index: number }
|
|
14
|
+
|
|
15
|
+
export type ColumnItemType = TableColumnType
|
|
16
|
+
|
|
17
|
+
export type autoType = {
|
|
18
|
+
expandWidth?: number
|
|
19
|
+
choiceWidth?: number
|
|
20
|
+
index?: {
|
|
21
|
+
prop: string
|
|
22
|
+
pagination: boolean
|
|
23
|
+
},
|
|
24
|
+
pagination?: {
|
|
25
|
+
auto?: boolean
|
|
26
|
+
default: string
|
|
27
|
+
front: string
|
|
28
|
+
end: boolean
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type tablePayload<T extends DefaultMod = (DefaultList | DefaultInfo)> = {
|
|
33
|
+
targetData: Record<PropertyKey, unknown>
|
|
34
|
+
type: string
|
|
35
|
+
index: number
|
|
36
|
+
payload: {
|
|
37
|
+
column: T
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TableViewDefaultProps {
|
|
42
|
+
listData?: ComplexList
|
|
43
|
+
columnList?: (DefaultList | DefaultInfo)[]
|
|
44
|
+
data?: Record<PropertyKey, unknown>[]
|
|
45
|
+
paginationData?: PaginationData
|
|
46
|
+
menu?: Record<string, TableMenuValue[]>
|
|
47
|
+
listProp?: string
|
|
48
|
+
auto?: autoType
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface TableViewProps extends TableViewDefaultProps {
|
|
52
|
+
tableProps?: TableProps
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface TableViewOption extends TableViewProps {
|
|
56
|
+
ref?: string
|
|
57
|
+
onMenu?: (prop: string, payload: tablePayload) => unknown
|
|
58
|
+
onPagination?: (prop: 'page' | 'size', page: number, size: number) => unknown
|
|
59
|
+
onChoice?: (idList: PropertyKey[], dataList: Record<PropertyKey, any>[]) => unknown
|
|
60
|
+
onSort?: (prop: PropertyKey, order: undefined | orderType) => unknown
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default defineComponent({
|
|
64
|
+
name: 'TableView',
|
|
65
|
+
emits: {
|
|
66
|
+
menu: (prop: string, _payload: tablePayload) => {
|
|
67
|
+
return typeof prop === 'string'
|
|
68
|
+
},
|
|
69
|
+
pagination: (prop: 'page' | 'size', _page: number, _size: number) => {
|
|
70
|
+
return prop === 'page' || prop === 'size'
|
|
71
|
+
},
|
|
72
|
+
choice: (_idList: PropertyKey[], _dataList: Record<PropertyKey, any>[]) => {
|
|
73
|
+
return true
|
|
74
|
+
},
|
|
75
|
+
sort: (_prop: PropertyKey, _order: undefined | orderType) => {
|
|
76
|
+
return true
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
props: {
|
|
80
|
+
listData: {
|
|
81
|
+
type: Object as PropType<TableViewProps['listData']>,
|
|
82
|
+
required: false
|
|
83
|
+
},
|
|
84
|
+
columnList: { // 定制列配置
|
|
85
|
+
type: Object as PropType<TableViewProps['columnList']>,
|
|
86
|
+
required: false
|
|
87
|
+
},
|
|
88
|
+
data: { // 单独指定列表数据,不从listData.$list中取值
|
|
89
|
+
type: Array as PropType<TableViewProps['data']>,
|
|
90
|
+
required: false
|
|
91
|
+
},
|
|
92
|
+
paginationData: { // 单独制定分页器数据,不从listData中取值
|
|
93
|
+
type: Object as PropType<TableViewProps['paginationData']>,
|
|
94
|
+
required: false,
|
|
95
|
+
default: null
|
|
96
|
+
},
|
|
97
|
+
menu: {
|
|
98
|
+
type: Object as PropType<TableViewProps['menu']>,
|
|
99
|
+
required: false
|
|
100
|
+
},
|
|
101
|
+
tableProps: {
|
|
102
|
+
type: Object as PropType<TableViewProps['tableProps']>,
|
|
103
|
+
required: false
|
|
104
|
+
},
|
|
105
|
+
listProp: {
|
|
106
|
+
type: String,
|
|
107
|
+
required: false,
|
|
108
|
+
default: 'list'
|
|
109
|
+
},
|
|
110
|
+
auto: {
|
|
111
|
+
type: Object as PropType<TableViewProps['auto']>,
|
|
112
|
+
required: false
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
data () {
|
|
116
|
+
return {}
|
|
117
|
+
},
|
|
118
|
+
computed: {
|
|
119
|
+
currentData () {
|
|
120
|
+
if (this.data) {
|
|
121
|
+
return this.data
|
|
122
|
+
} else {
|
|
123
|
+
return this.listData?.$list!
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
currentIdList() {
|
|
127
|
+
return this.currentData.map(item => {
|
|
128
|
+
return item[this.listData!.getDictionaryProp('id')!]
|
|
129
|
+
})
|
|
130
|
+
},
|
|
131
|
+
currentAuto() {
|
|
132
|
+
return updateData(deepCloneData(antdConfig.table.auto), this.auto)
|
|
133
|
+
},
|
|
134
|
+
currentPaginationData() {
|
|
135
|
+
if (this.paginationData) {
|
|
136
|
+
return this.paginationData
|
|
137
|
+
} else {
|
|
138
|
+
return this.listData?.$module.pagination
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
currentSort() {
|
|
142
|
+
return this.listData?.$module.sort
|
|
143
|
+
},
|
|
144
|
+
currentColumnList() {
|
|
145
|
+
const list = []
|
|
146
|
+
const columnList = this.columnList || this.listData!.getDictionaryPageList(this.listProp, this.listData!.getDictionaryList(this.listProp)!) as DefaultList[]
|
|
147
|
+
for (let i = 0; i < columnList.length; i++) {
|
|
148
|
+
const column = columnList[i]
|
|
149
|
+
const currentProp = column.$prop
|
|
150
|
+
const targetRender = this.$slots[currentProp] || antdConfig.componentConfig.parseData(column.$renders, 'target')
|
|
151
|
+
const pureRender = antdConfig.componentConfig.parseData(column.$renders, 'pure')
|
|
152
|
+
const menuOption = antdConfig.componentConfig.parseData(this.menu, currentProp)
|
|
153
|
+
const attrs = antdConfig.componentConfig.parseData(column.$local, 'target')
|
|
154
|
+
const columnItem: ColumnItemType = {
|
|
155
|
+
dataIndex: currentProp,
|
|
156
|
+
title: column.$name,
|
|
157
|
+
align: (column as DefaultList).align,
|
|
158
|
+
width: column.$width,
|
|
159
|
+
ellipsis: (column as DefaultList).ellipsis,
|
|
160
|
+
...antdConfig.componentConfig.parseAttrs(attrs)
|
|
161
|
+
}
|
|
162
|
+
if (this.currentSort) {
|
|
163
|
+
const config = this.currentSort.getConfig(currentProp)
|
|
164
|
+
if (config !== false) {
|
|
165
|
+
columnItem.sorter = config || true
|
|
166
|
+
if (currentProp === this.currentSort.getValue()) {
|
|
167
|
+
const order = this.currentSort.getOrder()
|
|
168
|
+
columnItem.sortOrder = order ? order === 'asc' ? 'ascend' : 'descend' : null
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (!pureRender) {
|
|
173
|
+
if (!menuOption || targetRender) {
|
|
174
|
+
columnItem.customRender = ({ text, record, index }: customRenderPayload) => {
|
|
175
|
+
if (currentProp === this.currentAuto.index.prop && !targetRender) {
|
|
176
|
+
// 自动index
|
|
177
|
+
return antdConfig.table.renderIndex(record, index, this.currentAuto.index.pagination ? this.currentPaginationData : undefined)
|
|
178
|
+
}
|
|
179
|
+
const payload: tablePayload = {
|
|
180
|
+
targetData: record,
|
|
181
|
+
type: this.listProp,
|
|
182
|
+
index: index,
|
|
183
|
+
payload: { column: column }
|
|
184
|
+
}
|
|
185
|
+
text = antdConfig.table.renderTableValue(text, payload)
|
|
186
|
+
if (targetRender) {
|
|
187
|
+
// 插槽
|
|
188
|
+
return targetRender({
|
|
189
|
+
text: text,
|
|
190
|
+
payload
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
if (columnItem.ellipsis) {
|
|
194
|
+
// 自动省略切自动换行
|
|
195
|
+
return antdConfig.table.renderAutoText(text as string, column, payload, antdConfig.componentConfig.parseData(column.$local, 'autoText'))
|
|
196
|
+
}
|
|
197
|
+
return text
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
columnItem.customRender = ({ record, index }: customRenderPayload) => {
|
|
201
|
+
const payload: tablePayload = {
|
|
202
|
+
targetData: record,
|
|
203
|
+
type: this.listProp,
|
|
204
|
+
index: index,
|
|
205
|
+
payload: { column: column }
|
|
206
|
+
}
|
|
207
|
+
return h(TableMenu, {
|
|
208
|
+
list: menuOption,
|
|
209
|
+
payload: payload,
|
|
210
|
+
onMenu: (prop: string, payload: tablePayload) => {
|
|
211
|
+
this.$emit('menu', prop, payload)
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
columnItem.customRender = ({ text, record, index }: customRenderPayload) => {
|
|
218
|
+
const payload: tablePayload = {
|
|
219
|
+
targetData: record,
|
|
220
|
+
type: this.listProp,
|
|
221
|
+
index: index,
|
|
222
|
+
payload: { column: column }
|
|
223
|
+
}
|
|
224
|
+
return pureRender({
|
|
225
|
+
text: text,
|
|
226
|
+
payload
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
list.push(columnItem)
|
|
231
|
+
}
|
|
232
|
+
return list
|
|
233
|
+
},
|
|
234
|
+
currentTableProps() {
|
|
235
|
+
const currentTableProps = this.tableProps ? { ...this.tableProps } : {}
|
|
236
|
+
if (!currentTableProps.columns) {
|
|
237
|
+
currentTableProps.columns = this.currentColumnList
|
|
238
|
+
}
|
|
239
|
+
if (!currentTableProps.dataSource) {
|
|
240
|
+
currentTableProps.dataSource = this.currentData
|
|
241
|
+
}
|
|
242
|
+
if (!currentTableProps.rowKey) {
|
|
243
|
+
currentTableProps.rowKey = this.listData?.getDictionaryProp('id') as string
|
|
244
|
+
}
|
|
245
|
+
if (currentTableProps.pagination == undefined) {
|
|
246
|
+
currentTableProps.pagination = false
|
|
247
|
+
}
|
|
248
|
+
const choice = this.listData?.$module.choice
|
|
249
|
+
if (choice) {
|
|
250
|
+
currentTableProps.rowSelection = {
|
|
251
|
+
columnWidth: 50,
|
|
252
|
+
selectedRowKeys: choice.data.id as (string | number)[],
|
|
253
|
+
onChange: (selectedRowKeys: (string | number)[], selectedRows: Record<string, unknown>[]) => {
|
|
254
|
+
const currentIdList = this.currentIdList
|
|
255
|
+
for (let i = 0; i < choice.data.id.length; i++) {
|
|
256
|
+
const rowKey = choice.data.id[i] as (string | number)
|
|
257
|
+
if (currentIdList.indexOf(rowKey) > -1) {
|
|
258
|
+
// 当前页数据
|
|
259
|
+
if (selectedRowKeys.indexOf(rowKey) === -1) {
|
|
260
|
+
// 已经被取消选择的数据,从数据中删除
|
|
261
|
+
choice.data.id.splice(i, 1)
|
|
262
|
+
choice.data.list.splice(i, 1)
|
|
263
|
+
i--
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
choice.pushData(selectedRowKeys, selectedRows)
|
|
268
|
+
this.$emit('choice', choice.data.id, choice.data.list)
|
|
269
|
+
},
|
|
270
|
+
...antdConfig.componentConfig.parseAttrs(antdConfig.componentConfig.parseData(choice.$local, 'target'))
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (this.currentSort) {
|
|
274
|
+
const onChange = currentTableProps.onChange
|
|
275
|
+
currentTableProps.onChange = (pagination, filters, sorter, extra) => {
|
|
276
|
+
if (extra.action === 'sort') {
|
|
277
|
+
// 排序变换时
|
|
278
|
+
let prop: undefined | string | number
|
|
279
|
+
let order: undefined | orderType
|
|
280
|
+
if (!isArray(sorter)) {
|
|
281
|
+
prop = sorter.field as string | number
|
|
282
|
+
order = sorter.order ? sorter.order === 'ascend' ? 'asc' : 'desc' : undefined
|
|
283
|
+
} else {
|
|
284
|
+
prop = sorter[0].field as string | number
|
|
285
|
+
order = sorter[0].order ? sorter[0].order === 'ascend' ? 'asc' : 'desc' : undefined
|
|
286
|
+
}
|
|
287
|
+
this.currentSort!.setData(prop, order)
|
|
288
|
+
const sortConfig = this.currentSort!.getConfig(prop)
|
|
289
|
+
if (sortConfig === true || sortConfig === undefined) {
|
|
290
|
+
// 配置项默认或为真时,自动重新获取数据
|
|
291
|
+
if (this.currentAuto.sort.auto) {
|
|
292
|
+
this.listData?.reloadData({
|
|
293
|
+
data: true,
|
|
294
|
+
ing: true,
|
|
295
|
+
sync: true,
|
|
296
|
+
trigger: {
|
|
297
|
+
from: 'sort',
|
|
298
|
+
action: 'order'
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
this.$emit('sort', prop, order)
|
|
304
|
+
}
|
|
305
|
+
if (onChange) {
|
|
306
|
+
onChange(pagination, filters, sorter, extra)
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return currentTableProps
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
methods: {
|
|
314
|
+
renderTable() {
|
|
315
|
+
return h('div', { class: 'complex-table-content' }, {
|
|
316
|
+
default: () => [
|
|
317
|
+
h(Table, {
|
|
318
|
+
...this.currentTableProps
|
|
319
|
+
})
|
|
320
|
+
]
|
|
321
|
+
})
|
|
322
|
+
},
|
|
323
|
+
renderFooter() {
|
|
324
|
+
const render = h('div', { class: 'complex-table-footer' }, {
|
|
325
|
+
default: () => [this.renderFooterLeft(), this.renderFooterRight()]
|
|
326
|
+
})
|
|
327
|
+
return render
|
|
328
|
+
},
|
|
329
|
+
renderFooterLeft() {
|
|
330
|
+
const render = h('div', { class: 'complex-table-footer-left' }, {
|
|
331
|
+
default: () => [this.renderChoiceInfo()]
|
|
332
|
+
})
|
|
333
|
+
return render
|
|
334
|
+
},
|
|
335
|
+
renderChoiceInfo() {
|
|
336
|
+
const choice = this.listData?.$module.choice
|
|
337
|
+
if (choice) {
|
|
338
|
+
const infoRender = antdConfig.componentConfig.parseData(choice.$renders, 'info')
|
|
339
|
+
if (!infoRender) {
|
|
340
|
+
return h(ChoiceInfo, {
|
|
341
|
+
class: 'complex-table-choice-info',
|
|
342
|
+
choice: choice,
|
|
343
|
+
...antdConfig.componentConfig.parseAttrs(antdConfig.componentConfig.parseData(choice.$local, 'info'))
|
|
344
|
+
})
|
|
345
|
+
} else {
|
|
346
|
+
return infoRender({
|
|
347
|
+
choice: choice,
|
|
348
|
+
...antdConfig.componentConfig.parseAttrs(antdConfig.componentConfig.parseData(choice.$local, 'info'))
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
} else {
|
|
352
|
+
return null
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
renderFooterRight() {
|
|
356
|
+
const render = h('div', { class: 'complex-table-footer-right' }, {
|
|
357
|
+
default: () => [this.renderPagination()]
|
|
358
|
+
})
|
|
359
|
+
return render
|
|
360
|
+
},
|
|
361
|
+
renderPagination() {
|
|
362
|
+
if (this.currentPaginationData) {
|
|
363
|
+
const data = h(PaginationView, {
|
|
364
|
+
pagination: this.currentPaginationData,
|
|
365
|
+
assign: true,
|
|
366
|
+
style: {
|
|
367
|
+
padding: '10px 0'
|
|
368
|
+
},
|
|
369
|
+
onPage: (page: number, size: number) => {
|
|
370
|
+
if (this.currentAuto.pagination.auto) {
|
|
371
|
+
this.listData?.reloadData({
|
|
372
|
+
data: true,
|
|
373
|
+
ing: true,
|
|
374
|
+
sync: true,
|
|
375
|
+
trigger: {
|
|
376
|
+
from: 'pagination',
|
|
377
|
+
action: 'page'
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
}
|
|
381
|
+
this.$emit('pagination', 'page', page, size)
|
|
382
|
+
},
|
|
383
|
+
onSize: (page: number, size: number) => {
|
|
384
|
+
if (this.currentAuto.pagination.auto) {
|
|
385
|
+
this.listData?.reloadData({
|
|
386
|
+
data: true,
|
|
387
|
+
ing: true,
|
|
388
|
+
sync: true,
|
|
389
|
+
trigger: {
|
|
390
|
+
from: 'pagination',
|
|
391
|
+
action: 'size'
|
|
392
|
+
}
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
this.$emit('pagination', 'size', page, size)
|
|
396
|
+
}
|
|
397
|
+
})
|
|
398
|
+
return data
|
|
399
|
+
} else {
|
|
400
|
+
return null
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
/**
|
|
405
|
+
* 主要模板
|
|
406
|
+
|
|
407
|
+
* @returns {VNode}
|
|
408
|
+
*/
|
|
409
|
+
render() {
|
|
410
|
+
const render = h('div', { class: 'complex-table' }, {
|
|
411
|
+
default: () => [this.renderTable(), this.renderFooter()]
|
|
412
|
+
})
|
|
413
|
+
return render
|
|
414
|
+
}
|
|
415
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineComponent, PropType } from "vue"
|
|
2
|
+
|
|
3
|
+
export default defineComponent({
|
|
4
|
+
name: 'AutoRender',
|
|
5
|
+
props: {
|
|
6
|
+
render: {
|
|
7
|
+
type: Function as PropType<() => unknown>,
|
|
8
|
+
required: true
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
/**
|
|
12
|
+
* 主要模板
|
|
13
|
+
|
|
14
|
+
* @returns {VNode}
|
|
15
|
+
*/
|
|
16
|
+
render() {
|
|
17
|
+
return this.render()
|
|
18
|
+
}
|
|
19
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<style scoped>
|
|
2
|
+
.complex-choice-info{
|
|
3
|
+
padding: 10px 0px;
|
|
4
|
+
line-height: 32px;
|
|
5
|
+
margin: 0;
|
|
6
|
+
}
|
|
7
|
+
.complex-choice-info-menu{
|
|
8
|
+
margin-left: 10px;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
}
|
|
11
|
+
</style>
|
|
12
|
+
<template>
|
|
13
|
+
<p class="complex-choice-info" v-if="show" >
|
|
14
|
+
<span v-show="size > 0" class="complex-choice-info-content" >{{ currentFormatInfo(payload) }}</span>
|
|
15
|
+
<span v-show="size === 0" class="complex-choice-info-content-empty complex-color-disabled" >{{ emptyContent }}</span>
|
|
16
|
+
<span v-if="menu" v-show="size > 0" class="complex-choice-info-menu complex-color-link" @click="onCancel" >取消选择</span>
|
|
17
|
+
</p>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import { PropType, defineComponent } from "vue"
|
|
22
|
+
import { ChoiceData } from "@complex-suite/data"
|
|
23
|
+
import antdConfig from "../../antdConfig"
|
|
24
|
+
|
|
25
|
+
export default defineComponent({
|
|
26
|
+
name: 'ChoiceInfo',
|
|
27
|
+
props: {
|
|
28
|
+
choice: {
|
|
29
|
+
type: Object as PropType<ChoiceData>,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
show: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
required: false,
|
|
35
|
+
default: () => antdConfig.choice.show
|
|
36
|
+
},
|
|
37
|
+
menu: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: false,
|
|
40
|
+
default: () => antdConfig.choice.menu
|
|
41
|
+
},
|
|
42
|
+
formatInfo: {
|
|
43
|
+
type: Function as PropType<(payload: { choice: ChoiceData, size: number, menu: boolean }) => string>,
|
|
44
|
+
required: false
|
|
45
|
+
},
|
|
46
|
+
emptyContent: {
|
|
47
|
+
type: String,
|
|
48
|
+
required: false,
|
|
49
|
+
default: () => antdConfig.choice.emptyContent
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
computed: {
|
|
53
|
+
size() {
|
|
54
|
+
return this.choice.getId().length
|
|
55
|
+
},
|
|
56
|
+
payload() {
|
|
57
|
+
return {
|
|
58
|
+
choice: this.choice,
|
|
59
|
+
size: this.size,
|
|
60
|
+
menu: this.menu
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
currentFormatInfo() {
|
|
64
|
+
return this.formatInfo || antdConfig.choice.formatInfo
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
methods: {
|
|
68
|
+
onCancel() {
|
|
69
|
+
this.choice.reset()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
</script>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { defineComponent, h, PropType } from "vue"
|
|
2
|
+
import { Pagination } from "ant-design-vue"
|
|
3
|
+
import { AttrsValue, PaginationData } from "@complex-suite/data"
|
|
4
|
+
import antdConfig from "../../antdConfig"
|
|
5
|
+
|
|
6
|
+
export default defineComponent({
|
|
7
|
+
name: 'PaginationView',
|
|
8
|
+
emits: {
|
|
9
|
+
page: (_page: number, _size: number) => true,
|
|
10
|
+
size: (_page: number, _size: number) => true,
|
|
11
|
+
},
|
|
12
|
+
props: {
|
|
13
|
+
pagination: {
|
|
14
|
+
type: Object as PropType<PaginationData>,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
assign: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
required: false,
|
|
20
|
+
default: true
|
|
21
|
+
},
|
|
22
|
+
simple: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
required: false,
|
|
25
|
+
default: false
|
|
26
|
+
},
|
|
27
|
+
formatInfo: {
|
|
28
|
+
type: Function as PropType<(payload: { pagination: PaginationData }) => string>,
|
|
29
|
+
required: false
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
computed: {
|
|
33
|
+
payload() {
|
|
34
|
+
return {
|
|
35
|
+
pagination: this.pagination
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
currentFormatInfo() {
|
|
39
|
+
return this.formatInfo || antdConfig.pagination.formatInfo
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
renderSlot() {
|
|
44
|
+
const slot = this.$slots.default || antdConfig.componentConfig.parseData(this.pagination.$renders, 'slot')
|
|
45
|
+
return slot ? slot(this.payload) : null
|
|
46
|
+
},
|
|
47
|
+
renderInfo() {
|
|
48
|
+
if (!this.simple) {
|
|
49
|
+
const infoRender = antdConfig.componentConfig.parseData(this.pagination.$renders, 'info')
|
|
50
|
+
return h('span', {
|
|
51
|
+
class: 'complex-pagination-info'
|
|
52
|
+
}, {
|
|
53
|
+
default: () => !infoRender ? this.currentFormatInfo(this.payload) : infoRender(this.payload)
|
|
54
|
+
})
|
|
55
|
+
} else {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
renderPagination() {
|
|
60
|
+
const targetRender = antdConfig.componentConfig.parseData(this.pagination.$renders, 'target')
|
|
61
|
+
if (!targetRender) {
|
|
62
|
+
const paginationAttrs = new AttrsValue({
|
|
63
|
+
props: {
|
|
64
|
+
current: this.pagination.page.data,
|
|
65
|
+
total: this.pagination.count,
|
|
66
|
+
pageSize: this.pagination.size.data,
|
|
67
|
+
pageSizeOptions: this.pagination.size.list.map(item => item.toString()),
|
|
68
|
+
showSizeChanger: this.pagination.size.show,
|
|
69
|
+
showQuickJumper: this.pagination.jumper,
|
|
70
|
+
simple: this.simple
|
|
71
|
+
},
|
|
72
|
+
on: {
|
|
73
|
+
change: (page: number, size: number) => {
|
|
74
|
+
if (this.assign !== false) {
|
|
75
|
+
this.pagination.setPage(page)
|
|
76
|
+
}
|
|
77
|
+
this.$emit('page', page, size)
|
|
78
|
+
},
|
|
79
|
+
showSizeChange: (page: number, size: number) => {
|
|
80
|
+
if (this.assign !== false) {
|
|
81
|
+
this.pagination.setPageAndSize({ page, size })
|
|
82
|
+
}
|
|
83
|
+
this.$emit('size', page, size)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
return h(Pagination, antdConfig.componentConfig.parseAttrs(paginationAttrs.merge(this.pagination.$attrs)))
|
|
88
|
+
} else {
|
|
89
|
+
return targetRender(this.payload)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* 主要模板
|
|
95
|
+
|
|
96
|
+
* @returns {VNode}
|
|
97
|
+
*/
|
|
98
|
+
render() {
|
|
99
|
+
return h('div', { class: 'complex-pagination' }, {
|
|
100
|
+
default: () => [this.renderSlot(), this.renderInfo(), this.renderPagination()]
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
})
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineComponent, h, PropType } from "vue"
|
|
2
|
+
import { camelToLine, debounce } from "@complex-suite/utils"
|
|
3
|
+
import type { MenuValue, DefaultMod } from "@complex-suite/data"
|
|
4
|
+
import type { tablePayload } from "../TableView"
|
|
5
|
+
import antdConfig from "../../antdConfig"
|
|
6
|
+
|
|
7
|
+
export interface TableMenuValue extends MenuValue<never, [tablePayload<DefaultMod>]> {
|
|
8
|
+
color?: string
|
|
9
|
+
class?: string[] | ((payload: tablePayload<DefaultMod>) => string[])
|
|
10
|
+
option?: Record<string, unknown>
|
|
11
|
+
children?: TableMenuValue[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default defineComponent({
|
|
15
|
+
name: 'TableMenu',
|
|
16
|
+
props: {
|
|
17
|
+
list: {
|
|
18
|
+
type: Object as PropType<TableMenuValue[]>,
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
payload: {
|
|
22
|
+
type: Object as PropType<tablePayload<DefaultMod>>,
|
|
23
|
+
required: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
methods: {
|
|
27
|
+
renderList(menuList: TableMenuValue[], payload: tablePayload<DefaultMod>) {
|
|
28
|
+
return menuList.map((menuItem) => {
|
|
29
|
+
let hidden = menuItem.hidden
|
|
30
|
+
if (hidden) {
|
|
31
|
+
if (typeof hidden === 'function') {
|
|
32
|
+
hidden = hidden(payload)
|
|
33
|
+
}
|
|
34
|
+
if (hidden) {
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let disabled = menuItem.disabled
|
|
40
|
+
if (disabled && typeof disabled === "function") {
|
|
41
|
+
disabled = disabled(payload)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let classList = ["complex-table-menu-item"]
|
|
45
|
+
if (menuItem.color) {
|
|
46
|
+
classList.push("complex-color-" + camelToLine(menuItem.color, "-"))
|
|
47
|
+
}
|
|
48
|
+
if (disabled) {
|
|
49
|
+
classList.push("complex-disabled complex-color-disabled")
|
|
50
|
+
}
|
|
51
|
+
if (menuItem.class) {
|
|
52
|
+
classList = classList.concat(typeof menuItem.class === "function" ? menuItem.class(payload) : menuItem.class)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const onClick = (e: MouseEvent) => {
|
|
56
|
+
if (menuItem.modifiers) {
|
|
57
|
+
if (menuItem.modifiers.includes('.stop')) {
|
|
58
|
+
e.stopPropagation()
|
|
59
|
+
}
|
|
60
|
+
if (menuItem.modifiers.includes('.prevent')) {
|
|
61
|
+
e.preventDefault()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
antdConfig.parseMenuConfirm(menuItem.confirm, () => {
|
|
65
|
+
this.$emit("menu", menuItem.prop, payload);
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return h(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
class: classList.join(" "),
|
|
73
|
+
onClick: menuItem.debounce ? debounce(onClick, menuItem.debounce, true) : onClick,
|
|
74
|
+
...menuItem.option,
|
|
75
|
+
},
|
|
76
|
+
{ default: () => menuItem.name }
|
|
77
|
+
)
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* 主要模板
|
|
83
|
+
|
|
84
|
+
* @returns {VNode}
|
|
85
|
+
*/
|
|
86
|
+
render() {
|
|
87
|
+
return h('span', {
|
|
88
|
+
class: 'complex-table-menu'
|
|
89
|
+
}, {
|
|
90
|
+
default: () => this.renderList(this.list, this.payload)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
})
|