lw-cdp-ui 1.2.21 → 1.2.22
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/dist/components/lwTable/index.js +444 -376
- package/dist/components/lwTable/index.vue +13 -22
- package/dist/lw-cdp-ui.esm.js +3009 -2970
- package/dist/lw-cdp-ui.umd.js +11 -11
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -3,379 +3,447 @@ import { onBeforeMount, reactive, ref, watch, toRefs, getCurrentInstance } from
|
|
|
3
3
|
import dayjs from 'dayjs'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
6
|
+
name: 'lwTable',
|
|
7
|
+
// 组件属性定义
|
|
8
|
+
props: {
|
|
9
|
+
refName: { type: String, default: 'multipleTableRef' }, // 表格ref名称
|
|
10
|
+
tableName: { type: String, default: '' }, // 表格名称
|
|
11
|
+
isRadio: { type: Boolean, default: false }, // 是否单选
|
|
12
|
+
bordered: { type: Boolean, default: true }, // 是否显示边框
|
|
13
|
+
stripe: { type: Boolean, default: false }, // 是否显示斑马纹
|
|
14
|
+
summaryMethod: { type: Function, default: () => [] }, // 合计行计算方法
|
|
15
|
+
rowKey: { type: String, default: 'id' }, // 行数据的唯一标识
|
|
16
|
+
defaultSelectData: { type: Array, default: () => [] }, // 默认选中的数据
|
|
17
|
+
searchParams: { type: Object, default: () => ({ page: 1, size: 20 }) }, // 查询参数
|
|
18
|
+
selectStatus: { type: Function, default: () => true }, // 选择状态判断函数
|
|
19
|
+
pageSizes: { type: Array, default: () => [10, 20, 30, 40, 50] }, // 分页大小选项
|
|
20
|
+
isShowPagination: { type: Boolean, default: true }, // 是否显示分页
|
|
21
|
+
tableData: { type: Array, default: [] }, // 表格数据
|
|
22
|
+
totalCount: { type: Number, default: 0 }, // 数据总数
|
|
23
|
+
tableColumns: { type: Array, default: [] }, // 表格列配置
|
|
24
|
+
hoverable: { type: Boolean, default: true }, // 是否启用悬停效果
|
|
25
|
+
defaultExpandAll: { type: Boolean, default: false }, // 是否默认展开所有行
|
|
26
|
+
isSetting: { type: Boolean, default: false }, // 是否启用设置功能
|
|
27
|
+
saveKey: { type: String, default: '' }, // 保存设置的键名
|
|
28
|
+
orderPage: { type: Boolean, default: false }, // 是否为订单页面
|
|
29
|
+
tableSize: { type: String, default: 'large' }, // 表格大小
|
|
30
|
+
loading: { type: Boolean, default: false }, // 加载状态
|
|
31
|
+
rowSelection: { type: Boolean, default: false }, // 是否可选择行
|
|
32
|
+
selectedKeys: { type: Array }, // 选中的键值数组
|
|
33
|
+
selectDatas: { type: Array }, // 选中的数据数组
|
|
34
|
+
hideTool: { type: Boolean, default: true }, // 是否隐藏工具栏
|
|
35
|
+
virtualListProps: { type: Object, default: undefined }, // 虚拟列表属性
|
|
36
|
+
draggable: { type: Object }, // 拖拽配置
|
|
37
|
+
maxHeight: { type: String, default: 'calc(100vh - 270px)' } // 最大高度
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
setup(props, context) {
|
|
41
|
+
// 表格引用
|
|
42
|
+
const multipleTable = ref()
|
|
43
|
+
|
|
44
|
+
// 获取全局实例
|
|
45
|
+
const {
|
|
46
|
+
proxy: { $bus, $tool }
|
|
47
|
+
} = getCurrentInstance()
|
|
48
|
+
|
|
49
|
+
// 全屏相关状态
|
|
50
|
+
const { isFullscreen, toggle: toggleFullScreen } = useFullscreen()
|
|
51
|
+
|
|
52
|
+
// 响应式状态数据
|
|
53
|
+
const state = reactive({
|
|
54
|
+
dialogVisible: false, // 对话框可见性
|
|
55
|
+
tableSettingTitle: '选择字段', // 表格设置标题
|
|
56
|
+
tableHeaderListAll: [], // 所有表头列表
|
|
57
|
+
checkedList: [], // 已选中列表
|
|
58
|
+
defaultProps: {
|
|
59
|
+
children: 'children',
|
|
60
|
+
label: 'label'
|
|
61
|
+
},
|
|
62
|
+
num: 0, // 计数器
|
|
63
|
+
endFixed: false, // 是否固定末尾
|
|
64
|
+
filterHeader: [], // 过滤后的表头
|
|
65
|
+
tableSize: props.tableSize, // 表格大小
|
|
66
|
+
checkedKeys: [], // 选中的键
|
|
67
|
+
treeData: [], // 树形数据
|
|
68
|
+
allCheck: true, // 是否全选
|
|
69
|
+
lastColumsFixed: true, // 最后一列是否固定
|
|
70
|
+
tableHeaders: [], // 表格表头
|
|
71
|
+
fixNum: 0 // 固定列数量
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
// 过滤数据处理
|
|
75
|
+
const filterData = () => {
|
|
76
|
+
let list = props.tableColumns
|
|
77
|
+
state.checkedKeys = []
|
|
78
|
+
let arr = []
|
|
79
|
+
list.forEach((item, index) => {
|
|
80
|
+
if (!item.key) {
|
|
81
|
+
item.key = $tool.getUUID()
|
|
82
|
+
}
|
|
83
|
+
if (!!item.checked || item.checked == undefined) {
|
|
84
|
+
state.checkedKeys.push(item.key)
|
|
85
|
+
arr.push(item)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
state.treeData = list
|
|
89
|
+
state.tableHeaders = arr
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 组件挂载前
|
|
93
|
+
onBeforeMount(async () => {
|
|
94
|
+
// 监听窗口大小变化,处理全屏状态
|
|
95
|
+
window.addEventListener('resize', () => {
|
|
96
|
+
let isFull =
|
|
97
|
+
document.mozFullScreen ||
|
|
98
|
+
document.fullScreen ||
|
|
99
|
+
document.webkitIsFullScreen ||
|
|
100
|
+
document.webkitRequestFullScreen ||
|
|
101
|
+
document.mozRequestFullScreen ||
|
|
102
|
+
document.msFullscreenEnabled
|
|
103
|
+
if (isFull === undefined) {
|
|
104
|
+
isFull = false
|
|
105
|
+
}
|
|
106
|
+
if (isFull == false) {
|
|
107
|
+
$bus.$emit('tableFullScreen', false)
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// 监听表格列变化
|
|
113
|
+
watch(
|
|
114
|
+
() => props.tableColumns,
|
|
115
|
+
(newVal) => {
|
|
116
|
+
filterData()
|
|
117
|
+
},
|
|
118
|
+
{ deep: true, immediate: true }
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
// 选择相关的响应式引用
|
|
122
|
+
const selectedKeysForm = ref([])
|
|
123
|
+
const selectGoodsDatas = ref([])
|
|
124
|
+
const selectAllGoods = ref([])
|
|
125
|
+
|
|
126
|
+
// 监听表格数据变化
|
|
127
|
+
watch(
|
|
128
|
+
() => props.tableData,
|
|
129
|
+
(newVal) => {
|
|
130
|
+
// 合并并去重数据
|
|
131
|
+
const allArr = [...newVal, ...selectAllGoods.value]
|
|
132
|
+
const allObj = {}
|
|
133
|
+
const newAllArr = allArr.reduce((cur, next) => {
|
|
134
|
+
allObj[next[props.rowKey]] ? '' : (allObj[next[props.rowKey]] = true && cur.push(next))
|
|
135
|
+
return cur
|
|
136
|
+
}, [])
|
|
137
|
+
selectAllGoods.value = newAllArr || []
|
|
138
|
+
},
|
|
139
|
+
{ deep: true, immediate: true }
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
// 监听选中键变化
|
|
143
|
+
watch(
|
|
144
|
+
() => props.selectedKeys,
|
|
145
|
+
(newVal) => {
|
|
146
|
+
selectedKeysForm.value = newVal
|
|
147
|
+
selectGoodsDatas.value = []
|
|
148
|
+
|
|
149
|
+
if (selectAllGoods.value.length && !!newVal) {
|
|
150
|
+
// 过滤并合并选中数据
|
|
151
|
+
const data = selectAllGoods.value.filter((item) => {
|
|
152
|
+
return newVal.includes(item[props.rowKey])
|
|
153
|
+
})
|
|
154
|
+
const arr = [...data, ...selectGoodsDatas.value]
|
|
155
|
+
const obj = {}
|
|
156
|
+
const newArr = arr.reduce((cur, next) => {
|
|
157
|
+
obj[next[props.rowKey]] ? '' : (obj[next[props.rowKey]] = true && cur.push(next))
|
|
158
|
+
return cur
|
|
159
|
+
}, [])
|
|
160
|
+
selectGoodsDatas.value = newArr || []
|
|
161
|
+
context.emit('update:selectDatas', newArr)
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{ deep: true, immediate: true }
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
// 拖拽处理函数
|
|
168
|
+
const handleChange = (currentData) => {
|
|
169
|
+
context.emit('draggable', currentData)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 选择变化处理函数
|
|
173
|
+
const handleSelectionChange = (val) => {
|
|
174
|
+
context.emit('multipleSelection', val)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 当前项变化处理函数
|
|
178
|
+
const handleCurrentChange = (val) => {
|
|
179
|
+
context.emit('currentChange', val)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 分页大小变化处理函数
|
|
183
|
+
const sizeChange = (val) => {
|
|
184
|
+
props.searchParams.size = val
|
|
185
|
+
context.emit('getTableData')
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 页码变化处理函数
|
|
189
|
+
const currentChange = (page) => {
|
|
190
|
+
props.searchParams.page = page - 1
|
|
191
|
+
context.emit('getTableData', props.searchParams.page)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// 刷新处理函数
|
|
195
|
+
const refresh = () => {
|
|
196
|
+
currentChange(1)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 切换行选择状态
|
|
200
|
+
const toggleRowChange = (row, status) => {
|
|
201
|
+
multipleTable.value.toggleRowSelection(row, status)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 清除表格选择
|
|
205
|
+
const clearTableSelection = (row, status) => {
|
|
206
|
+
multipleTable.value.clearSelection()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 允许拖拽放置判断
|
|
210
|
+
const allowDrop = (draggingNode, dropNode, type) => {
|
|
211
|
+
return type !== 'inner'
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// 允许拖拽判断
|
|
215
|
+
const allowDrag = (draggingNode) => {
|
|
216
|
+
return draggingNode.data.label.indexOf('Level three 3-1-1') === -1
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 表格设置处理函数
|
|
220
|
+
const tableSetting = () => {
|
|
221
|
+
state.tableSettingTitle = '选择字段'
|
|
222
|
+
state.dialogVisible = true
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// 下一步处理函数
|
|
226
|
+
const next = () => {
|
|
227
|
+
if (state.checkedList.length === 0) {
|
|
228
|
+
Message.error('选择字段不可以为空!')
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
state.tableSettingTitle = '排序'
|
|
232
|
+
|
|
233
|
+
state.treeData = []
|
|
234
|
+
let num = 0
|
|
235
|
+
let list = JSON.parse(JSON.stringify(state.checkedList))
|
|
236
|
+
list.forEach((item, index) => {
|
|
237
|
+
props.tableHeader.forEach((it) => {
|
|
238
|
+
if (item === it.label) {
|
|
239
|
+
let obj = {
|
|
240
|
+
label: item,
|
|
241
|
+
children: [],
|
|
242
|
+
index: index,
|
|
243
|
+
fixed: it.fixed ? it.fixed : ''
|
|
244
|
+
}
|
|
245
|
+
state.treeData.push(obj)
|
|
246
|
+
if (it.fixed === 'left') {
|
|
247
|
+
num++
|
|
248
|
+
} else if (it.fixed === 'right') {
|
|
249
|
+
state.endFixed = true
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
state.num = num
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// 上一步处理函数
|
|
259
|
+
const prev = () => {
|
|
260
|
+
state.tableSettingTitle = '选择字段'
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// 表头确认处理函数
|
|
264
|
+
const tableHeaderConfirm = () => {
|
|
265
|
+
if ((state.num > 2 && state.endFixed) || (state.num > 3 && !state.endFixed)) {
|
|
266
|
+
Message.error('固定列最多只能选择3列!')
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
state.tableHeaderList = []
|
|
270
|
+
state.treeData.forEach((item, index) => {
|
|
271
|
+
if (state.num > 0 && state.num > index) {
|
|
272
|
+
item.fixed = 'left'
|
|
273
|
+
} else if (state.endFixed && index === state.treeData.length - 1) {
|
|
274
|
+
item.fixed = 'right'
|
|
275
|
+
} else {
|
|
276
|
+
item.fixed = ''
|
|
277
|
+
}
|
|
278
|
+
state.tableHeaderList.push(item)
|
|
279
|
+
})
|
|
280
|
+
state.dialogVisible = false
|
|
281
|
+
let obj = {
|
|
282
|
+
userId: 1,
|
|
283
|
+
json: state.tableHeaderList
|
|
284
|
+
}
|
|
285
|
+
localStorage.setItem('userTable', JSON.stringify(obj))
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 下载处理函数
|
|
289
|
+
const download = (url) => {
|
|
290
|
+
let fileUrl =
|
|
291
|
+
(process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') && location.hostname !== 'localhost'
|
|
292
|
+
? location.origin + url
|
|
293
|
+
: 'http://dev.yihai.lianwei.com.cn' + url
|
|
294
|
+
window.open(fileUrl, '_blank')
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// 排序变化处理函数
|
|
298
|
+
const sortChange = ({ column, prop, order }) => {
|
|
299
|
+
props.searchParams.sortField = prop?.split(',')[0]
|
|
300
|
+
props.searchParams.sortType = order
|
|
301
|
+
const data = { ...props.searchParams }
|
|
302
|
+
context.emit('getTableData', data)
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// 获取表头处理函数
|
|
306
|
+
const getHeader = (header) => {
|
|
307
|
+
context.emit('getHeader', header)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// 选择处理函数
|
|
311
|
+
const handleSelect = (v) => {
|
|
312
|
+
state.tableSize = v
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// 全选处理函数
|
|
316
|
+
const checkAll = (selected) => {
|
|
317
|
+
if (selected) {
|
|
318
|
+
state.tableHeaders = JSON.parse(JSON.stringify(props.tableColumns))
|
|
319
|
+
state.tableHeaders.forEach((item, index) => {
|
|
320
|
+
if (!item.key) {
|
|
321
|
+
item.key = $tool.getUUID()
|
|
322
|
+
}
|
|
323
|
+
state.checkedKeys.push(item.key)
|
|
324
|
+
})
|
|
325
|
+
} else {
|
|
326
|
+
state.tableHeaders = []
|
|
327
|
+
state.checkedKeys = []
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
state.treeData.forEach((item) => {
|
|
331
|
+
item.checked = selected
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// 树形选择处理函数
|
|
336
|
+
const treeCheck = () => {
|
|
337
|
+
let list = state.treeData.filter((t) => state.checkedKeys.includes(t.key))
|
|
338
|
+
state.tableHeaders = list
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 表格全屏切换处理函数
|
|
342
|
+
const tableToggleFullScreen = () => {
|
|
343
|
+
$bus.$emit('tableFullScreen', !isFullscreen.value)
|
|
344
|
+
toggleFullScreen()
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// 固定列数量变化处理函数
|
|
348
|
+
const fixNumChange = () => {
|
|
349
|
+
let num = state.fixNum
|
|
350
|
+
if (num > 0) {
|
|
351
|
+
state.tableHeaders.forEach((item, index) => {
|
|
352
|
+
if (index < num) {
|
|
353
|
+
item.fixed = 'left'
|
|
354
|
+
item.width = item.width ?? '120'
|
|
355
|
+
}
|
|
356
|
+
})
|
|
357
|
+
} else {
|
|
358
|
+
state.tableHeaders.forEach((item) => {
|
|
359
|
+
if (item.fixed === 'left') {
|
|
360
|
+
delete item.fixed
|
|
361
|
+
}
|
|
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
|
+
// 设置选择处理函数
|
|
373
|
+
const setSelect = (rowKey, status) => {
|
|
374
|
+
multipleTable.value.select(rowKey, status)
|
|
375
|
+
const selectedKeys = [...props.selectedKeys]
|
|
376
|
+
context.emit('update:selectedKeys', status ? selectedKeys.push(rowKey) : selectedKeys.filter((item) => item !== rowKey))
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// 全选处理函数
|
|
380
|
+
const selectAll = (status) => {
|
|
381
|
+
context.emit('update:selectedKeys', status ? props.tableData.map((item) => item[props.rowKey]) : [])
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// 选择处理函数
|
|
385
|
+
const select = (rowKeys, rowKey, record) => {
|
|
386
|
+
context.emit('update:selectedKeys', rowKeys)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// 列宽变化处理函数
|
|
390
|
+
const changeColWidth = (newWidth, oldWidth, { property }) => {}
|
|
391
|
+
|
|
392
|
+
// 权限检查函数
|
|
393
|
+
const checkAuth = (auth) => {
|
|
394
|
+
const data = JSON.parse(localStorage.getItem('userAuthInfo'))
|
|
395
|
+
const { menus, authorities } = data
|
|
396
|
+
if (!auth) return true
|
|
397
|
+
if (Array.isArray(auth)) {
|
|
398
|
+
return auth.some((permission) => [...menus, ...authorities].includes(permission))
|
|
399
|
+
} else if (typeof auth === 'string') {
|
|
400
|
+
return [...menus, ...authorities].includes(auth)
|
|
401
|
+
}
|
|
402
|
+
return false
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// 操作过滤函数
|
|
406
|
+
const filterOperations = (operations, row) => {
|
|
407
|
+
return operations.filter((o) => (!o?.isShow || o.isShow(row)) && checkAuth(o.auth))
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// 返回所有需要暴露的属性和方法
|
|
411
|
+
return {
|
|
412
|
+
...toRefs(state),
|
|
413
|
+
checkAuth,
|
|
414
|
+
filterOperations,
|
|
415
|
+
refresh,
|
|
416
|
+
dayjs,
|
|
417
|
+
handleChange,
|
|
418
|
+
handleSelectionChange,
|
|
419
|
+
handleCurrentChange,
|
|
420
|
+
sizeChange,
|
|
421
|
+
currentChange,
|
|
422
|
+
multipleTable,
|
|
423
|
+
allowDrop,
|
|
424
|
+
allowDrag,
|
|
425
|
+
tableSetting,
|
|
426
|
+
next,
|
|
427
|
+
prev,
|
|
428
|
+
tableHeaderConfirm,
|
|
429
|
+
toggleRowChange,
|
|
430
|
+
clearTableSelection,
|
|
431
|
+
download,
|
|
432
|
+
sortChange,
|
|
433
|
+
getHeader,
|
|
434
|
+
handleSelect,
|
|
435
|
+
checkAll,
|
|
436
|
+
tableToggleFullScreen,
|
|
437
|
+
isFullscreen,
|
|
438
|
+
treeCheck,
|
|
439
|
+
fixNumChange,
|
|
440
|
+
setSelectAll,
|
|
441
|
+
setSelect,
|
|
442
|
+
selectedKeysForm,
|
|
443
|
+
selectGoodsDatas,
|
|
444
|
+
selectAll,
|
|
445
|
+
select,
|
|
446
|
+
changeColWidth
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|