lw-cdp-ui 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/components/lwForm/index.vue +312 -312
- package/dist/components/lwIconSelect/iconSelect.js +288 -288
- package/dist/components/lwIconSelect/index.vue +142 -142
- package/dist/components/lwLayout/components/NavMenu.vue +36 -36
- package/dist/components/lwLayout/components/aside.vue +291 -291
- package/dist/components/lwLayout/components/bu.vue +72 -70
- package/dist/components/lwLayout/components/iframeView.vue +57 -57
- package/dist/components/lwLayout/components/lang.vue +76 -76
- package/dist/components/lwLayout/components/setting.vue +80 -80
- package/dist/components/lwLayout/components/sideM.vue +137 -136
- package/dist/components/lwLayout/components/tags.vue +329 -329
- package/dist/components/lwLayout/components/topbar.vue +70 -70
- package/dist/components/lwLayout/components/userbar.vue +210 -209
- package/dist/components/lwLayout/index.vue +399 -398
- package/dist/components/lwLogin/index.vue +446 -383
- package/dist/components/lwSearch/date/date.vue +110 -110
- package/dist/components/lwSearch/dateRange/dateRange.vue +110 -110
- package/dist/components/lwSearch/dates/dates.vue +366 -366
- package/dist/components/lwSearch/index.vue +636 -636
- package/dist/components/lwSearch/input/input.vue +54 -54
- package/dist/components/lwSearch/locale/en-us.js +10 -10
- package/dist/components/lwSearch/locale/zh-cn.js +10 -10
- package/dist/components/lwSearch/select/select.vue +57 -57
- package/dist/components/lwSvgIcon/index.vue +28 -28
- package/dist/components/lwTable/index.js +425 -425
- package/dist/components/lwTable/index.scss +229 -229
- package/dist/components/lwTable/index.vue +225 -226
- package/dist/components/lwTable/locale/en-US.js +26 -26
- package/dist/components/lwTable/locale/zh-CN.js +26 -26
- package/dist/components/lwTable/useFullscreen.js +73 -73
- package/dist/components/lwTableSelect/index.vue +254 -254
- package/dist/components/lwTableSelect/tableSelect.js +23 -23
- package/dist/components/lwUpload/index.vue +365 -365
- package/dist/en-US-YCjgxjEt.js.map +1 -1
- package/dist/en-us-CziFtIQi.js.map +1 -1
- package/dist/lw-cdp-ui.esm.js +754 -726
- package/dist/lw-cdp-ui.esm.js.map +1 -1
- package/dist/lw-cdp-ui.umd.js +4 -4
- package/dist/lw-cdp-ui.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/zh-CN-BdDNsX4e.js.map +1 -1
- package/dist/zh-cn-DJpQp_O7.js.map +1 -1
- package/package.json +45 -45
|
@@ -1,425 +1,425 @@
|
|
|
1
|
-
import { useFullscreen } from './useFullscreen'
|
|
2
|
-
import { onBeforeMount, reactive, ref, watch, toRefs, getCurrentInstance } from 'vue'
|
|
3
|
-
import dayjs from 'dayjs'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
name: 'lwTable',
|
|
7
|
-
props: {
|
|
8
|
-
refName: { type: String, default: 'multipleTableRef' },
|
|
9
|
-
tableName: { type: String, default: '' },
|
|
10
|
-
isRadio: { type: Boolean, default: false },
|
|
11
|
-
bordered: { type: Boolean, default: true },
|
|
12
|
-
stripe: { type: Boolean, default: false },
|
|
13
|
-
summaryMethod: { type: Function, default: () => [] },
|
|
14
|
-
rowKey: { type: String, default: 'id' },
|
|
15
|
-
defaultSelectData: { type: Array, default: () => [] },
|
|
16
|
-
searchParams: { type: Object, default: () => ({ page: 1, size: 20 }) },
|
|
17
|
-
selectStatus: { type: Function, default: () => true },
|
|
18
|
-
pageSizes: { type: Array, default: () => [10, 20, 30, 40, 50] },
|
|
19
|
-
isShowPagination: { type: Boolean, default: true },
|
|
20
|
-
tableData: { type: Array, default: [] },
|
|
21
|
-
totalCount: { type: Number, default: 0 },
|
|
22
|
-
tableColumns: { type: Array, default: [] },
|
|
23
|
-
hoverable: { type: Boolean, default: true },
|
|
24
|
-
defaultExpandAll: { type: Boolean, default: false },
|
|
25
|
-
isSetting: { type: Boolean, default: false },
|
|
26
|
-
saveKey: { type: String, default: '' },
|
|
27
|
-
orderPage: { type: Boolean, default: false },
|
|
28
|
-
tableSize: { type: String, default: 'large' },
|
|
29
|
-
loading: { type: Boolean, default: false },
|
|
30
|
-
rowSelection: { type: Object },
|
|
31
|
-
selectedKeys: { type: Array },
|
|
32
|
-
selectDatas: { type: Array },
|
|
33
|
-
hideTool: { type: Boolean, default: true },
|
|
34
|
-
virtualListProps: { type: Object, default: undefined },
|
|
35
|
-
draggable: { type: Object },
|
|
36
|
-
maxHeight: { type: String }
|
|
37
|
-
},
|
|
38
|
-
setup(props, context) {
|
|
39
|
-
const multipleTable = ref()
|
|
40
|
-
const {
|
|
41
|
-
proxy: { $bus, $tool }
|
|
42
|
-
} = getCurrentInstance()
|
|
43
|
-
const { isFullscreen, toggle: toggleFullScreen } = useFullscreen()
|
|
44
|
-
const state = reactive({
|
|
45
|
-
dialogVisible: false,
|
|
46
|
-
tableSettingTitle: '选择字段',
|
|
47
|
-
|
|
48
|
-
tableHeaderListAll: [],
|
|
49
|
-
checkedList: [],
|
|
50
|
-
defaultProps: {
|
|
51
|
-
children: 'children',
|
|
52
|
-
label: 'label'
|
|
53
|
-
},
|
|
54
|
-
num: 0,
|
|
55
|
-
endFixed: false,
|
|
56
|
-
filterHeader: [],
|
|
57
|
-
tableSize: props.tableSize,
|
|
58
|
-
|
|
59
|
-
checkedKeys: [],
|
|
60
|
-
treeData: [],
|
|
61
|
-
allCheck: true,
|
|
62
|
-
lastColumsFixed: true,
|
|
63
|
-
tableHeaders: [],
|
|
64
|
-
fixNum: 0
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
onBeforeMount(async () => {
|
|
68
|
-
let list = props.tableColumns
|
|
69
|
-
|
|
70
|
-
state.checkedKeys = []
|
|
71
|
-
|
|
72
|
-
list.forEach((item, index) => {
|
|
73
|
-
if (!item.key) {
|
|
74
|
-
item.key = $tool.getUUID()
|
|
75
|
-
}
|
|
76
|
-
state.checkedKeys.push(item.key)
|
|
77
|
-
item.checked = true
|
|
78
|
-
})
|
|
79
|
-
state.treeData = list
|
|
80
|
-
state.tableHeaders = state.treeData
|
|
81
|
-
|
|
82
|
-
window.addEventListener('resize', () => {
|
|
83
|
-
let isFull =
|
|
84
|
-
document.mozFullScreen || document.fullScreen || document.webkitIsFullScreen || document.webkitRequestFullScreen || document.mozRequestFullScreen || document.msFullscreenEnabled
|
|
85
|
-
if (isFull === undefined) {
|
|
86
|
-
isFull = false
|
|
87
|
-
}
|
|
88
|
-
if (isFull == false) {
|
|
89
|
-
$bus.$emit('tableFullScreen', false)
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
watch(
|
|
95
|
-
() => props.tableColumns,
|
|
96
|
-
(newVal) => {
|
|
97
|
-
let list = props.tableColumns
|
|
98
|
-
|
|
99
|
-
state.checkedKeys = []
|
|
100
|
-
let arr = []
|
|
101
|
-
list.forEach((item, index) => {
|
|
102
|
-
if (!item.key) {
|
|
103
|
-
item.key = $tool.getUUID()
|
|
104
|
-
}
|
|
105
|
-
if (!!item.checked || item.checked == undefined) {
|
|
106
|
-
state.checkedKeys.push(item.key)
|
|
107
|
-
arr.push(item)
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
state.treeData = list
|
|
111
|
-
state.tableHeaders = arr
|
|
112
|
-
},
|
|
113
|
-
{ deep: true, immediate: true }
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
const selectedKeysForm = ref([])
|
|
117
|
-
const selectGoodsDatas = ref([])
|
|
118
|
-
const selectAllGoods = ref([])
|
|
119
|
-
|
|
120
|
-
watch(
|
|
121
|
-
() => props.tableData,
|
|
122
|
-
(newVal) => {
|
|
123
|
-
const allArr = [...newVal, ...selectAllGoods.value]
|
|
124
|
-
const allObj = {}
|
|
125
|
-
const newAllArr = allArr.reduce((cur, next) => {
|
|
126
|
-
allObj[next[props.rowKey]] ? '' : (allObj[next[props.rowKey]] = true && cur.push(next))
|
|
127
|
-
return cur
|
|
128
|
-
}, [])
|
|
129
|
-
selectAllGoods.value = newAllArr || []
|
|
130
|
-
},
|
|
131
|
-
{ deep: true, immediate: true }
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
watch(
|
|
135
|
-
() => props.selectedKeys,
|
|
136
|
-
(newVal) => {
|
|
137
|
-
selectedKeysForm.value = newVal
|
|
138
|
-
selectGoodsDatas.value = []
|
|
139
|
-
|
|
140
|
-
if (selectAllGoods.value.length && !!newVal) {
|
|
141
|
-
const data = selectAllGoods.value.filter((item) => {
|
|
142
|
-
return newVal.includes(item[props.rowKey])
|
|
143
|
-
})
|
|
144
|
-
const arr = [...data, ...selectGoodsDatas.value]
|
|
145
|
-
const obj = {}
|
|
146
|
-
const newArr = arr.reduce((cur, next) => {
|
|
147
|
-
obj[next[props.rowKey]] ? '' : (obj[next[props.rowKey]] = true && cur.push(next))
|
|
148
|
-
return cur
|
|
149
|
-
}, [])
|
|
150
|
-
selectGoodsDatas.value = newArr || []
|
|
151
|
-
context.emit('update:selectDatas', newArr)
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
{ deep: true, immediate: true }
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
const handleChange = (currentData) => {
|
|
158
|
-
context.emit('draggable', currentData)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const handleSelectionChange = (val) => {
|
|
162
|
-
context.emit('multipleSelection', val)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const handleCurrentChange = (val) => {
|
|
166
|
-
context.emit('currentChange', val)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const sizeChange = (val) => {
|
|
170
|
-
props.searchParams.size = val
|
|
171
|
-
const data = { ...props.searchParams }
|
|
172
|
-
context.emit('getTableData', data)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const currentChange = (page) => {
|
|
176
|
-
props.searchParams.page = page - 1
|
|
177
|
-
|
|
178
|
-
const data = { ...props.searchParams }
|
|
179
|
-
if (!props.reserveSelection) {
|
|
180
|
-
}
|
|
181
|
-
context.emit('getTableData', props.searchParams.page)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const refresh = () => {
|
|
185
|
-
currentChange(1)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const toggleRowChange = (row, status) => {
|
|
189
|
-
multipleTable.value.toggleRowSelection(row, status)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const clearTableSelection = (row, status) => {
|
|
193
|
-
multipleTable.value.clearSelection()
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const allowDrop = (draggingNode, dropNode, type) => {
|
|
197
|
-
return type !== 'inner'
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const allowDrag = (draggingNode) => {
|
|
201
|
-
return draggingNode.data.label.indexOf('Level three 3-1-1') === -1
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const tableSetting = () => {
|
|
205
|
-
state.tableSettingTitle = '选择字段'
|
|
206
|
-
state.dialogVisible = true
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const next = () => {
|
|
210
|
-
if (state.checkedList.length === 0) {
|
|
211
|
-
Message.error('选择字段不可以为空!')
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
state.tableSettingTitle = '排序'
|
|
215
|
-
|
|
216
|
-
state.treeData = []
|
|
217
|
-
let num = 0
|
|
218
|
-
let list = JSON.parse(JSON.stringify(state.checkedList))
|
|
219
|
-
list.forEach((item, index) => {
|
|
220
|
-
props.tableHeader.forEach((it) => {
|
|
221
|
-
if (item === it.label) {
|
|
222
|
-
let obj = {
|
|
223
|
-
label: item,
|
|
224
|
-
children: [],
|
|
225
|
-
index: index,
|
|
226
|
-
fixed: it.fixed ? it.fixed : ''
|
|
227
|
-
}
|
|
228
|
-
state.treeData.push(obj)
|
|
229
|
-
if (it.fixed === 'left') {
|
|
230
|
-
num++
|
|
231
|
-
} else if (it.fixed === 'right') {
|
|
232
|
-
state.endFixed = true
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
state.num = num
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const prev = () => {
|
|
242
|
-
state.tableSettingTitle = '选择字段'
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const tableHeaderConfirm = () => {
|
|
246
|
-
if ((state.num > 2 && state.endFixed) || (state.num > 3 && !state.endFixed)) {
|
|
247
|
-
Message.error('固定列最多只能选择3列!')
|
|
248
|
-
return
|
|
249
|
-
}
|
|
250
|
-
state.tableHeaderList = []
|
|
251
|
-
state.treeData.forEach((item, index) => {
|
|
252
|
-
if (state.num > 0 && state.num > index) {
|
|
253
|
-
item.fixed = 'left'
|
|
254
|
-
} else if (state.endFixed && index === state.treeData.length - 1) {
|
|
255
|
-
item.fixed = 'right'
|
|
256
|
-
} else {
|
|
257
|
-
item.fixed = ''
|
|
258
|
-
}
|
|
259
|
-
state.tableHeaderList.push(item)
|
|
260
|
-
})
|
|
261
|
-
state.dialogVisible = false
|
|
262
|
-
let obj = {
|
|
263
|
-
userId: 1,
|
|
264
|
-
json: state.tableHeaderList
|
|
265
|
-
}
|
|
266
|
-
localStorage.setItem('userTable', JSON.stringify(obj))
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const download = (url) => {
|
|
270
|
-
let fileUrl =
|
|
271
|
-
(process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') && location.hostname !== 'localhost' ? location.origin + url : 'http://dev.yihai.lianwei.com.cn' + url
|
|
272
|
-
window.open(fileUrl, '_blank')
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const sortChange = ({ column, prop, order }) => {
|
|
276
|
-
props.searchParams.sortField = prop?.split(',')[0]
|
|
277
|
-
props.searchParams.sortType = order
|
|
278
|
-
const data = { ...props.searchParams }
|
|
279
|
-
context.emit('getTableData', data)
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const getHeader = (header) => {
|
|
283
|
-
context.emit('getHeader', header)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const handleSelect = (v) => {
|
|
287
|
-
state.tableSize = v
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const onDrop = (info) => {
|
|
291
|
-
let dropPosition = info.dropPosition
|
|
292
|
-
let dragNode = info.dragNode
|
|
293
|
-
let dropNode = info.dropNode
|
|
294
|
-
const data = state.treeData
|
|
295
|
-
const loop = (data, key, callback) => {
|
|
296
|
-
data.some((item, index, arr) => {
|
|
297
|
-
if (item.title === key) {
|
|
298
|
-
callback(item, index, arr)
|
|
299
|
-
return true
|
|
300
|
-
}
|
|
301
|
-
if (item.children) {
|
|
302
|
-
return loop(item.children, key, callback)
|
|
303
|
-
}
|
|
304
|
-
return false
|
|
305
|
-
})
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (dropPosition === 0) {
|
|
309
|
-
} else {
|
|
310
|
-
loop(data, dragNode.title, (_, index, arr) => {
|
|
311
|
-
arr.splice(index, 1)
|
|
312
|
-
})
|
|
313
|
-
loop(data, dropNode.title, (_, index, arr) => {
|
|
314
|
-
arr.splice(dropPosition < 0 ? index : index + 1, 0, dragNode)
|
|
315
|
-
})
|
|
316
|
-
}
|
|
317
|
-
state.tableHeaders = state.treeData
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const checkAll = (selected) => {
|
|
321
|
-
if (selected) {
|
|
322
|
-
state.tableHeaders = JSON.parse(JSON.stringify(props.tableColumns))
|
|
323
|
-
state.tableHeaders.forEach((item, index) => {
|
|
324
|
-
if (!item.key) {
|
|
325
|
-
item.key = $tool.getUUID()
|
|
326
|
-
}
|
|
327
|
-
state.checkedKeys.push(item.key)
|
|
328
|
-
})
|
|
329
|
-
} else {
|
|
330
|
-
state.tableHeaders = []
|
|
331
|
-
state.checkedKeys = []
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
state.treeData.forEach((item) => {
|
|
335
|
-
item.checked = selected
|
|
336
|
-
})
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const treeCheck = () => {
|
|
340
|
-
let list = state.treeData.filter((t) => state.checkedKeys.includes(t.key))
|
|
341
|
-
state.tableHeaders = list
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
const tableToggleFullScreen = () => {
|
|
345
|
-
$bus.$emit('tableFullScreen', !isFullscreen.value)
|
|
346
|
-
toggleFullScreen()
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
const fixNumChange = () => {
|
|
350
|
-
let num = state.fixNum
|
|
351
|
-
if (num > 0) {
|
|
352
|
-
state.tableHeaders.forEach((item, index) => {
|
|
353
|
-
if (index < num) {
|
|
354
|
-
item.fixed = 'left'
|
|
355
|
-
item.width = item.width ?? '120'
|
|
356
|
-
}
|
|
357
|
-
})
|
|
358
|
-
} else {
|
|
359
|
-
state.tableHeaders.forEach((item) => {
|
|
360
|
-
if (item.fixed === 'left') {
|
|
361
|
-
delete item.fixed
|
|
362
|
-
}
|
|
363
|
-
})
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const setSelectAll = (status) => {
|
|
368
|
-
multipleTable.value.selectAll(status)
|
|
369
|
-
context.emit('update:selectedKeys', status ? props.tableData.map((item) => item.id) : [])
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const setSelect = (rowKey, status) => {
|
|
373
|
-
multipleTable.value.select(rowKey, status)
|
|
374
|
-
const selectedKeys = [...props.selectedKeys]
|
|
375
|
-
context.emit('update:selectedKeys', status ? selectedKeys.push(rowKey) : selectedKeys.filter((item) => item !== rowKey))
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
const selectAll = (status) => {
|
|
379
|
-
context.emit('update:selectedKeys', status ? props.tableData.map((item) => item[props.rowKey]) : [])
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
const select = (rowKeys, rowKey, record) => {
|
|
383
|
-
context.emit('update:selectedKeys', rowKeys)
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const changeColWidth = (newWidth, oldWidth, { property }) => {}
|
|
387
|
-
|
|
388
|
-
return {
|
|
389
|
-
...toRefs(state),
|
|
390
|
-
refresh,
|
|
391
|
-
dayjs,
|
|
392
|
-
handleChange,
|
|
393
|
-
handleSelectionChange,
|
|
394
|
-
handleCurrentChange,
|
|
395
|
-
sizeChange,
|
|
396
|
-
currentChange,
|
|
397
|
-
multipleTable,
|
|
398
|
-
allowDrop,
|
|
399
|
-
allowDrag,
|
|
400
|
-
tableSetting,
|
|
401
|
-
next,
|
|
402
|
-
prev,
|
|
403
|
-
tableHeaderConfirm,
|
|
404
|
-
toggleRowChange,
|
|
405
|
-
clearTableSelection,
|
|
406
|
-
download,
|
|
407
|
-
sortChange,
|
|
408
|
-
getHeader,
|
|
409
|
-
handleSelect,
|
|
410
|
-
onDrop,
|
|
411
|
-
checkAll,
|
|
412
|
-
tableToggleFullScreen,
|
|
413
|
-
isFullscreen,
|
|
414
|
-
treeCheck,
|
|
415
|
-
fixNumChange,
|
|
416
|
-
setSelectAll,
|
|
417
|
-
setSelect,
|
|
418
|
-
selectedKeysForm,
|
|
419
|
-
selectGoodsDatas,
|
|
420
|
-
selectAll,
|
|
421
|
-
select,
|
|
422
|
-
changeColWidth
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
1
|
+
import { useFullscreen } from './useFullscreen'
|
|
2
|
+
import { onBeforeMount, reactive, ref, watch, toRefs, getCurrentInstance } from 'vue'
|
|
3
|
+
import dayjs from 'dayjs'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name: 'lwTable',
|
|
7
|
+
props: {
|
|
8
|
+
refName: { type: String, default: 'multipleTableRef' },
|
|
9
|
+
tableName: { type: String, default: '' },
|
|
10
|
+
isRadio: { type: Boolean, default: false },
|
|
11
|
+
bordered: { type: Boolean, default: true },
|
|
12
|
+
stripe: { type: Boolean, default: false },
|
|
13
|
+
summaryMethod: { type: Function, default: () => [] },
|
|
14
|
+
rowKey: { type: String, default: 'id' },
|
|
15
|
+
defaultSelectData: { type: Array, default: () => [] },
|
|
16
|
+
searchParams: { type: Object, default: () => ({ page: 1, size: 20 }) },
|
|
17
|
+
selectStatus: { type: Function, default: () => true },
|
|
18
|
+
pageSizes: { type: Array, default: () => [10, 20, 30, 40, 50] },
|
|
19
|
+
isShowPagination: { type: Boolean, default: true },
|
|
20
|
+
tableData: { type: Array, default: [] },
|
|
21
|
+
totalCount: { type: Number, default: 0 },
|
|
22
|
+
tableColumns: { type: Array, default: [] },
|
|
23
|
+
hoverable: { type: Boolean, default: true },
|
|
24
|
+
defaultExpandAll: { type: Boolean, default: false },
|
|
25
|
+
isSetting: { type: Boolean, default: false },
|
|
26
|
+
saveKey: { type: String, default: '' },
|
|
27
|
+
orderPage: { type: Boolean, default: false },
|
|
28
|
+
tableSize: { type: String, default: 'large' },
|
|
29
|
+
loading: { type: Boolean, default: false },
|
|
30
|
+
rowSelection: { type: Object },
|
|
31
|
+
selectedKeys: { type: Array },
|
|
32
|
+
selectDatas: { type: Array },
|
|
33
|
+
hideTool: { type: Boolean, default: true },
|
|
34
|
+
virtualListProps: { type: Object, default: undefined },
|
|
35
|
+
draggable: { type: Object },
|
|
36
|
+
maxHeight: { type: String }
|
|
37
|
+
},
|
|
38
|
+
setup(props, context) {
|
|
39
|
+
const multipleTable = ref()
|
|
40
|
+
const {
|
|
41
|
+
proxy: { $bus, $tool }
|
|
42
|
+
} = getCurrentInstance()
|
|
43
|
+
const { isFullscreen, toggle: toggleFullScreen } = useFullscreen()
|
|
44
|
+
const state = reactive({
|
|
45
|
+
dialogVisible: false,
|
|
46
|
+
tableSettingTitle: '选择字段',
|
|
47
|
+
|
|
48
|
+
tableHeaderListAll: [],
|
|
49
|
+
checkedList: [],
|
|
50
|
+
defaultProps: {
|
|
51
|
+
children: 'children',
|
|
52
|
+
label: 'label'
|
|
53
|
+
},
|
|
54
|
+
num: 0,
|
|
55
|
+
endFixed: false,
|
|
56
|
+
filterHeader: [],
|
|
57
|
+
tableSize: props.tableSize,
|
|
58
|
+
|
|
59
|
+
checkedKeys: [],
|
|
60
|
+
treeData: [],
|
|
61
|
+
allCheck: true,
|
|
62
|
+
lastColumsFixed: true,
|
|
63
|
+
tableHeaders: [],
|
|
64
|
+
fixNum: 0
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
onBeforeMount(async () => {
|
|
68
|
+
let list = props.tableColumns
|
|
69
|
+
|
|
70
|
+
state.checkedKeys = []
|
|
71
|
+
|
|
72
|
+
list.forEach((item, index) => {
|
|
73
|
+
if (!item.key) {
|
|
74
|
+
item.key = $tool.getUUID()
|
|
75
|
+
}
|
|
76
|
+
state.checkedKeys.push(item.key)
|
|
77
|
+
item.checked = true
|
|
78
|
+
})
|
|
79
|
+
state.treeData = list
|
|
80
|
+
state.tableHeaders = state.treeData
|
|
81
|
+
|
|
82
|
+
window.addEventListener('resize', () => {
|
|
83
|
+
let isFull =
|
|
84
|
+
document.mozFullScreen || document.fullScreen || document.webkitIsFullScreen || document.webkitRequestFullScreen || document.mozRequestFullScreen || document.msFullscreenEnabled
|
|
85
|
+
if (isFull === undefined) {
|
|
86
|
+
isFull = false
|
|
87
|
+
}
|
|
88
|
+
if (isFull == false) {
|
|
89
|
+
$bus.$emit('tableFullScreen', false)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
watch(
|
|
95
|
+
() => props.tableColumns,
|
|
96
|
+
(newVal) => {
|
|
97
|
+
let list = props.tableColumns
|
|
98
|
+
|
|
99
|
+
state.checkedKeys = []
|
|
100
|
+
let arr = []
|
|
101
|
+
list.forEach((item, index) => {
|
|
102
|
+
if (!item.key) {
|
|
103
|
+
item.key = $tool.getUUID()
|
|
104
|
+
}
|
|
105
|
+
if (!!item.checked || item.checked == undefined) {
|
|
106
|
+
state.checkedKeys.push(item.key)
|
|
107
|
+
arr.push(item)
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
state.treeData = list
|
|
111
|
+
state.tableHeaders = arr
|
|
112
|
+
},
|
|
113
|
+
{ deep: true, immediate: true }
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
const selectedKeysForm = ref([])
|
|
117
|
+
const selectGoodsDatas = ref([])
|
|
118
|
+
const selectAllGoods = ref([])
|
|
119
|
+
|
|
120
|
+
watch(
|
|
121
|
+
() => props.tableData,
|
|
122
|
+
(newVal) => {
|
|
123
|
+
const allArr = [...newVal, ...selectAllGoods.value]
|
|
124
|
+
const allObj = {}
|
|
125
|
+
const newAllArr = allArr.reduce((cur, next) => {
|
|
126
|
+
allObj[next[props.rowKey]] ? '' : (allObj[next[props.rowKey]] = true && cur.push(next))
|
|
127
|
+
return cur
|
|
128
|
+
}, [])
|
|
129
|
+
selectAllGoods.value = newAllArr || []
|
|
130
|
+
},
|
|
131
|
+
{ deep: true, immediate: true }
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
watch(
|
|
135
|
+
() => props.selectedKeys,
|
|
136
|
+
(newVal) => {
|
|
137
|
+
selectedKeysForm.value = newVal
|
|
138
|
+
selectGoodsDatas.value = []
|
|
139
|
+
|
|
140
|
+
if (selectAllGoods.value.length && !!newVal) {
|
|
141
|
+
const data = selectAllGoods.value.filter((item) => {
|
|
142
|
+
return newVal.includes(item[props.rowKey])
|
|
143
|
+
})
|
|
144
|
+
const arr = [...data, ...selectGoodsDatas.value]
|
|
145
|
+
const obj = {}
|
|
146
|
+
const newArr = arr.reduce((cur, next) => {
|
|
147
|
+
obj[next[props.rowKey]] ? '' : (obj[next[props.rowKey]] = true && cur.push(next))
|
|
148
|
+
return cur
|
|
149
|
+
}, [])
|
|
150
|
+
selectGoodsDatas.value = newArr || []
|
|
151
|
+
context.emit('update:selectDatas', newArr)
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{ deep: true, immediate: true }
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
const handleChange = (currentData) => {
|
|
158
|
+
context.emit('draggable', currentData)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const handleSelectionChange = (val) => {
|
|
162
|
+
context.emit('multipleSelection', val)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const handleCurrentChange = (val) => {
|
|
166
|
+
context.emit('currentChange', val)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const sizeChange = (val) => {
|
|
170
|
+
props.searchParams.size = val
|
|
171
|
+
const data = { ...props.searchParams }
|
|
172
|
+
context.emit('getTableData', data)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const currentChange = (page) => {
|
|
176
|
+
props.searchParams.page = page - 1
|
|
177
|
+
|
|
178
|
+
const data = { ...props.searchParams }
|
|
179
|
+
if (!props.reserveSelection) {
|
|
180
|
+
}
|
|
181
|
+
context.emit('getTableData', props.searchParams.page)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const refresh = () => {
|
|
185
|
+
currentChange(1)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const toggleRowChange = (row, status) => {
|
|
189
|
+
multipleTable.value.toggleRowSelection(row, status)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const clearTableSelection = (row, status) => {
|
|
193
|
+
multipleTable.value.clearSelection()
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const allowDrop = (draggingNode, dropNode, type) => {
|
|
197
|
+
return type !== 'inner'
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const allowDrag = (draggingNode) => {
|
|
201
|
+
return draggingNode.data.label.indexOf('Level three 3-1-1') === -1
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const tableSetting = () => {
|
|
205
|
+
state.tableSettingTitle = '选择字段'
|
|
206
|
+
state.dialogVisible = true
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const next = () => {
|
|
210
|
+
if (state.checkedList.length === 0) {
|
|
211
|
+
Message.error('选择字段不可以为空!')
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
state.tableSettingTitle = '排序'
|
|
215
|
+
|
|
216
|
+
state.treeData = []
|
|
217
|
+
let num = 0
|
|
218
|
+
let list = JSON.parse(JSON.stringify(state.checkedList))
|
|
219
|
+
list.forEach((item, index) => {
|
|
220
|
+
props.tableHeader.forEach((it) => {
|
|
221
|
+
if (item === it.label) {
|
|
222
|
+
let obj = {
|
|
223
|
+
label: item,
|
|
224
|
+
children: [],
|
|
225
|
+
index: index,
|
|
226
|
+
fixed: it.fixed ? it.fixed : ''
|
|
227
|
+
}
|
|
228
|
+
state.treeData.push(obj)
|
|
229
|
+
if (it.fixed === 'left') {
|
|
230
|
+
num++
|
|
231
|
+
} else if (it.fixed === 'right') {
|
|
232
|
+
state.endFixed = true
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
state.num = num
|
|
238
|
+
})
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const prev = () => {
|
|
242
|
+
state.tableSettingTitle = '选择字段'
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const tableHeaderConfirm = () => {
|
|
246
|
+
if ((state.num > 2 && state.endFixed) || (state.num > 3 && !state.endFixed)) {
|
|
247
|
+
Message.error('固定列最多只能选择3列!')
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
state.tableHeaderList = []
|
|
251
|
+
state.treeData.forEach((item, index) => {
|
|
252
|
+
if (state.num > 0 && state.num > index) {
|
|
253
|
+
item.fixed = 'left'
|
|
254
|
+
} else if (state.endFixed && index === state.treeData.length - 1) {
|
|
255
|
+
item.fixed = 'right'
|
|
256
|
+
} else {
|
|
257
|
+
item.fixed = ''
|
|
258
|
+
}
|
|
259
|
+
state.tableHeaderList.push(item)
|
|
260
|
+
})
|
|
261
|
+
state.dialogVisible = false
|
|
262
|
+
let obj = {
|
|
263
|
+
userId: 1,
|
|
264
|
+
json: state.tableHeaderList
|
|
265
|
+
}
|
|
266
|
+
localStorage.setItem('userTable', JSON.stringify(obj))
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const download = (url) => {
|
|
270
|
+
let fileUrl =
|
|
271
|
+
(process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') && location.hostname !== 'localhost' ? location.origin + url : 'http://dev.yihai.lianwei.com.cn' + url
|
|
272
|
+
window.open(fileUrl, '_blank')
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const sortChange = ({ column, prop, order }) => {
|
|
276
|
+
props.searchParams.sortField = prop?.split(',')[0]
|
|
277
|
+
props.searchParams.sortType = order
|
|
278
|
+
const data = { ...props.searchParams }
|
|
279
|
+
context.emit('getTableData', data)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const getHeader = (header) => {
|
|
283
|
+
context.emit('getHeader', header)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const handleSelect = (v) => {
|
|
287
|
+
state.tableSize = v
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const onDrop = (info) => {
|
|
291
|
+
let dropPosition = info.dropPosition
|
|
292
|
+
let dragNode = info.dragNode
|
|
293
|
+
let dropNode = info.dropNode
|
|
294
|
+
const data = state.treeData
|
|
295
|
+
const loop = (data, key, callback) => {
|
|
296
|
+
data.some((item, index, arr) => {
|
|
297
|
+
if (item.title === key) {
|
|
298
|
+
callback(item, index, arr)
|
|
299
|
+
return true
|
|
300
|
+
}
|
|
301
|
+
if (item.children) {
|
|
302
|
+
return loop(item.children, key, callback)
|
|
303
|
+
}
|
|
304
|
+
return false
|
|
305
|
+
})
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (dropPosition === 0) {
|
|
309
|
+
} else {
|
|
310
|
+
loop(data, dragNode.title, (_, index, arr) => {
|
|
311
|
+
arr.splice(index, 1)
|
|
312
|
+
})
|
|
313
|
+
loop(data, dropNode.title, (_, index, arr) => {
|
|
314
|
+
arr.splice(dropPosition < 0 ? index : index + 1, 0, dragNode)
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
state.tableHeaders = state.treeData
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const checkAll = (selected) => {
|
|
321
|
+
if (selected) {
|
|
322
|
+
state.tableHeaders = JSON.parse(JSON.stringify(props.tableColumns))
|
|
323
|
+
state.tableHeaders.forEach((item, index) => {
|
|
324
|
+
if (!item.key) {
|
|
325
|
+
item.key = $tool.getUUID()
|
|
326
|
+
}
|
|
327
|
+
state.checkedKeys.push(item.key)
|
|
328
|
+
})
|
|
329
|
+
} else {
|
|
330
|
+
state.tableHeaders = []
|
|
331
|
+
state.checkedKeys = []
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
state.treeData.forEach((item) => {
|
|
335
|
+
item.checked = selected
|
|
336
|
+
})
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const treeCheck = () => {
|
|
340
|
+
let list = state.treeData.filter((t) => state.checkedKeys.includes(t.key))
|
|
341
|
+
state.tableHeaders = list
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const tableToggleFullScreen = () => {
|
|
345
|
+
$bus.$emit('tableFullScreen', !isFullscreen.value)
|
|
346
|
+
toggleFullScreen()
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const fixNumChange = () => {
|
|
350
|
+
let num = state.fixNum
|
|
351
|
+
if (num > 0) {
|
|
352
|
+
state.tableHeaders.forEach((item, index) => {
|
|
353
|
+
if (index < num) {
|
|
354
|
+
item.fixed = 'left'
|
|
355
|
+
item.width = item.width ?? '120'
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
} else {
|
|
359
|
+
state.tableHeaders.forEach((item) => {
|
|
360
|
+
if (item.fixed === 'left') {
|
|
361
|
+
delete item.fixed
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const setSelectAll = (status) => {
|
|
368
|
+
multipleTable.value.selectAll(status)
|
|
369
|
+
context.emit('update:selectedKeys', status ? props.tableData.map((item) => item.id) : [])
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const setSelect = (rowKey, status) => {
|
|
373
|
+
multipleTable.value.select(rowKey, status)
|
|
374
|
+
const selectedKeys = [...props.selectedKeys]
|
|
375
|
+
context.emit('update:selectedKeys', status ? selectedKeys.push(rowKey) : selectedKeys.filter((item) => item !== rowKey))
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const selectAll = (status) => {
|
|
379
|
+
context.emit('update:selectedKeys', status ? props.tableData.map((item) => item[props.rowKey]) : [])
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const select = (rowKeys, rowKey, record) => {
|
|
383
|
+
context.emit('update:selectedKeys', rowKeys)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const changeColWidth = (newWidth, oldWidth, { property }) => {}
|
|
387
|
+
|
|
388
|
+
return {
|
|
389
|
+
...toRefs(state),
|
|
390
|
+
refresh,
|
|
391
|
+
dayjs,
|
|
392
|
+
handleChange,
|
|
393
|
+
handleSelectionChange,
|
|
394
|
+
handleCurrentChange,
|
|
395
|
+
sizeChange,
|
|
396
|
+
currentChange,
|
|
397
|
+
multipleTable,
|
|
398
|
+
allowDrop,
|
|
399
|
+
allowDrag,
|
|
400
|
+
tableSetting,
|
|
401
|
+
next,
|
|
402
|
+
prev,
|
|
403
|
+
tableHeaderConfirm,
|
|
404
|
+
toggleRowChange,
|
|
405
|
+
clearTableSelection,
|
|
406
|
+
download,
|
|
407
|
+
sortChange,
|
|
408
|
+
getHeader,
|
|
409
|
+
handleSelect,
|
|
410
|
+
onDrop,
|
|
411
|
+
checkAll,
|
|
412
|
+
tableToggleFullScreen,
|
|
413
|
+
isFullscreen,
|
|
414
|
+
treeCheck,
|
|
415
|
+
fixNumChange,
|
|
416
|
+
setSelectAll,
|
|
417
|
+
setSelect,
|
|
418
|
+
selectedKeysForm,
|
|
419
|
+
selectGoodsDatas,
|
|
420
|
+
selectAll,
|
|
421
|
+
select,
|
|
422
|
+
changeColWidth
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|