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