@netang/quasar 0.2.54 → 0.2.57
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/components/field-table/index.vue +1 -0
- package/components/mixed-table/index.vue +1 -6
- package/package.json +1 -1
- package/sass/quasar/common.scss +5 -0
- package/sass/quasar/table.scss +12 -0
- package/utils/$power.js +37 -34
- package/utils/$table.js +1394 -1364
- package/utils/useSearch.js +603 -603
package/utils/$table.js
CHANGED
|
@@ -1,1364 +1,1394 @@
|
|
|
1
|
-
import { ref, computed, provide, inject, watch } from 'vue'
|
|
2
|
-
import { useQuasar } from 'quasar'
|
|
3
|
-
|
|
4
|
-
import $n_has from 'lodash/has'
|
|
5
|
-
import $n_get from 'lodash/get'
|
|
6
|
-
import $n_cloneDeep from 'lodash/cloneDeep'
|
|
7
|
-
import $n_merge from 'lodash/merge'
|
|
8
|
-
import $n_isFunction from 'lodash/isFunction'
|
|
9
|
-
import $n_findIndex from 'lodash/findIndex'
|
|
10
|
-
import $n_uniq from 'lodash/uniq'
|
|
11
|
-
import $n_concat from 'lodash/concat'
|
|
12
|
-
import $n_isNil from 'lodash/isNil'
|
|
13
|
-
import $n_isArray from 'lodash/isArray'
|
|
14
|
-
|
|
15
|
-
import $n_router from '@netang/utils/vue/router'
|
|
16
|
-
|
|
17
|
-
import $n_forEach from '@netang/utils/forEach'
|
|
18
|
-
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
19
|
-
import $n_isValidString from '@netang/utils/isValidString'
|
|
20
|
-
import $n_indexOf from '@netang/utils/indexOf'
|
|
21
|
-
import $n_storage from '@netang/utils/storage'
|
|
22
|
-
|
|
23
|
-
import $n_isRequired from '@netang/utils/isRequired'
|
|
24
|
-
import $n_forIn from '@netang/utils/forIn'
|
|
25
|
-
import $n_run from '@netang/utils/run'
|
|
26
|
-
import $n_runAsync from '@netang/utils/runAsync'
|
|
27
|
-
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
28
|
-
import $n_isValidValue from '@netang/utils/isValidValue'
|
|
29
|
-
import $n_slash from '@netang/utils/slash'
|
|
30
|
-
import $n_http from '@netang/utils/http'
|
|
31
|
-
import $n_cb from '@netang/utils/cb'
|
|
32
|
-
|
|
33
|
-
import $n_$power from './$power'
|
|
34
|
-
import $n_dict from './dict'
|
|
35
|
-
import $n_price from './price'
|
|
36
|
-
import $n_getTime from './getTime'
|
|
37
|
-
|
|
38
|
-
import { configs } from './config'
|
|
39
|
-
|
|
40
|
-
import {
|
|
41
|
-
// 设置单个搜索值
|
|
42
|
-
setItemValue,
|
|
43
|
-
// 从表格列获取原始值
|
|
44
|
-
getRawData,
|
|
45
|
-
// 获取参数
|
|
46
|
-
getOptions,
|
|
47
|
-
// 格式化值
|
|
48
|
-
formatValue,
|
|
49
|
-
} from './useSearch'
|
|
50
|
-
|
|
51
|
-
import { NRenderKey, NPowerKey, NTableKey } from './symbols'
|
|
52
|
-
|
|
53
|
-
const {
|
|
54
|
-
// 表格配置
|
|
55
|
-
tablesConfig,
|
|
56
|
-
// 字典常量
|
|
57
|
-
dicts,
|
|
58
|
-
} = configs
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 创建表格
|
|
62
|
-
*/
|
|
63
|
-
function create(options) {
|
|
64
|
-
|
|
65
|
-
// ==========【数据】=================================================================================================
|
|
66
|
-
|
|
67
|
-
// quasar 对象
|
|
68
|
-
const $q = useQuasar()
|
|
69
|
-
|
|
70
|
-
// 每页显示行数选项
|
|
71
|
-
const rowsPerPageOptions = [30, 40, 50, 100, 200, 500, 1000]
|
|
72
|
-
|
|
73
|
-
// 原始参数
|
|
74
|
-
const rawOptions = {
|
|
75
|
-
// 路由路径
|
|
76
|
-
path: '',
|
|
77
|
-
// 请求地址(默认为 path)
|
|
78
|
-
url: '',
|
|
79
|
-
// 路由参数
|
|
80
|
-
query: {},
|
|
81
|
-
// 附加请求数据
|
|
82
|
-
data: {},
|
|
83
|
-
// 表格行唯一键值
|
|
84
|
-
rowKey: 'id',
|
|
85
|
-
// 选择类型, 可选值 none single(默认) multiple
|
|
86
|
-
// selection: '',
|
|
87
|
-
// 分隔栏, 可选值 horizontal vertical cell none
|
|
88
|
-
separator: 'cell',
|
|
89
|
-
// 初始已选数据
|
|
90
|
-
selected: [],
|
|
91
|
-
// 初始表格加载状态
|
|
92
|
-
loading: false,
|
|
93
|
-
// 表格列数据(对象数组)
|
|
94
|
-
columns: [],
|
|
95
|
-
// 初始可见列
|
|
96
|
-
visibleColumns: [],
|
|
97
|
-
// 表格行数据
|
|
98
|
-
rows: [],
|
|
99
|
-
// 表格翻页参数
|
|
100
|
-
pagination: {
|
|
101
|
-
// 页码
|
|
102
|
-
page: 1,
|
|
103
|
-
// 每页的数据条数
|
|
104
|
-
rowsPerPage: $n_has(options, 'rowsPerPageOptions') ? options.rowsPerPageOptions[0] : rowsPerPageOptions[0],
|
|
105
|
-
// 数据总数(服务器返回)
|
|
106
|
-
rowsNumber: 1,
|
|
107
|
-
// 排序字段
|
|
108
|
-
sortBy: null,
|
|
109
|
-
// sortBy: 'id',
|
|
110
|
-
// 是否降序排列
|
|
111
|
-
descending: true,
|
|
112
|
-
},
|
|
113
|
-
// 每页显示行数选项
|
|
114
|
-
rowsPerPageOptions,
|
|
115
|
-
// 请求前执行
|
|
116
|
-
requestBefore: null,
|
|
117
|
-
// 请求成功执行
|
|
118
|
-
requestSuccess: null,
|
|
119
|
-
// 请求失败执行
|
|
120
|
-
requestFail: null,
|
|
121
|
-
// 请求后执行
|
|
122
|
-
requestAfter: null,
|
|
123
|
-
// 自定义请求方法
|
|
124
|
-
request: null,
|
|
125
|
-
// 格式化单条数据
|
|
126
|
-
formatRow: null,
|
|
127
|
-
// http 设置
|
|
128
|
-
httpSettings: {},
|
|
129
|
-
// 是否开启初始搜素
|
|
130
|
-
search: true,
|
|
131
|
-
// 是否开启合计
|
|
132
|
-
summary: false,
|
|
133
|
-
// 从参数中获取搜索值
|
|
134
|
-
searchFromQuery: true,
|
|
135
|
-
// 是否显示宫格
|
|
136
|
-
showGrid: false,
|
|
137
|
-
// 是否显示可见列
|
|
138
|
-
showVisibleColumns: true,
|
|
139
|
-
// 是否开启缓存
|
|
140
|
-
cache: true,
|
|
141
|
-
// 是否刷新后清空已选数据
|
|
142
|
-
refreshResetSelected: true,
|
|
143
|
-
|
|
144
|
-
// 单击表格行事件
|
|
145
|
-
rowClick: null,
|
|
146
|
-
// 双击表格行事件
|
|
147
|
-
rowDblClick: null,
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
let o
|
|
151
|
-
let $power
|
|
152
|
-
let hasPowr
|
|
153
|
-
let $render
|
|
154
|
-
let $route
|
|
155
|
-
let hasPowerBtns
|
|
156
|
-
let tableSelected
|
|
157
|
-
let isCache
|
|
158
|
-
let cacheName
|
|
159
|
-
let tableColumns
|
|
160
|
-
let tableImgs
|
|
161
|
-
|
|
162
|
-
// 是否显示可见列
|
|
163
|
-
let tableShowVisibleColumns
|
|
164
|
-
// 表格可见列
|
|
165
|
-
let tableVisibleColumns
|
|
166
|
-
// 表格加载状态
|
|
167
|
-
let tableLoading
|
|
168
|
-
// 表格行数据
|
|
169
|
-
let tableRows
|
|
170
|
-
// 表格翻页参数
|
|
171
|
-
let tablePagination
|
|
172
|
-
// 表格宫格
|
|
173
|
-
let tableGrid
|
|
174
|
-
// 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
|
|
175
|
-
let tableRequestQuery
|
|
176
|
-
// 是否请求表格合计
|
|
177
|
-
let isRequestSummary
|
|
178
|
-
// 表格合计
|
|
179
|
-
let tableSummary
|
|
180
|
-
// 表格选择类型
|
|
181
|
-
let tableSelection
|
|
182
|
-
// 表格分隔栏
|
|
183
|
-
let tableSeparator
|
|
184
|
-
|
|
185
|
-
// 原始参数
|
|
186
|
-
let rawQuery
|
|
187
|
-
// 原始表格搜索参数
|
|
188
|
-
let rawSearchOptions
|
|
189
|
-
// 原始表格搜索值(空表格搜索值, 用于搜索重置)
|
|
190
|
-
let rawTableSearchValue
|
|
191
|
-
// 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
192
|
-
let firstTableSearchValue
|
|
193
|
-
|
|
194
|
-
// 表格搜索数据值
|
|
195
|
-
let tableSearchValue
|
|
196
|
-
// 表格搜索参数
|
|
197
|
-
let tableSearchOptions
|
|
198
|
-
// 是否已加载
|
|
199
|
-
let _isTableLoaded
|
|
200
|
-
|
|
201
|
-
// 是否已生成数据
|
|
202
|
-
let _isCreated = false
|
|
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
|
-
tableSelected
|
|
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
|
-
item
|
|
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
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
//
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
//
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
//
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
//
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
//
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
//
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
//
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
//
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
//
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
//
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
//
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
//
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
//
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
//
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
//
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
//
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
//
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
//
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
//
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
//
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
//
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
//
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
//
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
//
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
//
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
//
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
//
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
//
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
if (
|
|
672
|
-
|
|
673
|
-
$
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
if (
|
|
809
|
-
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
.
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
//
|
|
895
|
-
$
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
//
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
//
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
//
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
//
|
|
1051
|
-
$
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
if (
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
//
|
|
1227
|
-
|
|
1228
|
-
//
|
|
1229
|
-
|
|
1230
|
-
//
|
|
1231
|
-
|
|
1232
|
-
//
|
|
1233
|
-
|
|
1234
|
-
//
|
|
1235
|
-
|
|
1236
|
-
//
|
|
1237
|
-
|
|
1238
|
-
//
|
|
1239
|
-
|
|
1240
|
-
//
|
|
1241
|
-
|
|
1242
|
-
//
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
//
|
|
1250
|
-
|
|
1251
|
-
//
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
//
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
//
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1
|
+
import { ref, computed, provide, inject, watch, nextTick } from 'vue'
|
|
2
|
+
import { useQuasar } from 'quasar'
|
|
3
|
+
|
|
4
|
+
import $n_has from 'lodash/has'
|
|
5
|
+
import $n_get from 'lodash/get'
|
|
6
|
+
import $n_cloneDeep from 'lodash/cloneDeep'
|
|
7
|
+
import $n_merge from 'lodash/merge'
|
|
8
|
+
import $n_isFunction from 'lodash/isFunction'
|
|
9
|
+
import $n_findIndex from 'lodash/findIndex'
|
|
10
|
+
import $n_uniq from 'lodash/uniq'
|
|
11
|
+
import $n_concat from 'lodash/concat'
|
|
12
|
+
import $n_isNil from 'lodash/isNil'
|
|
13
|
+
import $n_isArray from 'lodash/isArray'
|
|
14
|
+
|
|
15
|
+
import $n_router from '@netang/utils/vue/router'
|
|
16
|
+
|
|
17
|
+
import $n_forEach from '@netang/utils/forEach'
|
|
18
|
+
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
19
|
+
import $n_isValidString from '@netang/utils/isValidString'
|
|
20
|
+
import $n_indexOf from '@netang/utils/indexOf'
|
|
21
|
+
import $n_storage from '@netang/utils/storage'
|
|
22
|
+
|
|
23
|
+
import $n_isRequired from '@netang/utils/isRequired'
|
|
24
|
+
import $n_forIn from '@netang/utils/forIn'
|
|
25
|
+
import $n_run from '@netang/utils/run'
|
|
26
|
+
import $n_runAsync from '@netang/utils/runAsync'
|
|
27
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
28
|
+
import $n_isValidValue from '@netang/utils/isValidValue'
|
|
29
|
+
import $n_slash from '@netang/utils/slash'
|
|
30
|
+
import $n_http from '@netang/utils/http'
|
|
31
|
+
import $n_cb from '@netang/utils/cb'
|
|
32
|
+
|
|
33
|
+
import $n_$power from './$power'
|
|
34
|
+
import $n_dict from './dict'
|
|
35
|
+
import $n_price from './price'
|
|
36
|
+
import $n_getTime from './getTime'
|
|
37
|
+
|
|
38
|
+
import { configs } from './config'
|
|
39
|
+
|
|
40
|
+
import {
|
|
41
|
+
// 设置单个搜索值
|
|
42
|
+
setItemValue,
|
|
43
|
+
// 从表格列获取原始值
|
|
44
|
+
getRawData,
|
|
45
|
+
// 获取参数
|
|
46
|
+
getOptions,
|
|
47
|
+
// 格式化值
|
|
48
|
+
formatValue,
|
|
49
|
+
} from './useSearch'
|
|
50
|
+
|
|
51
|
+
import { NRenderKey, NPowerKey, NTableKey } from './symbols'
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
// 表格配置
|
|
55
|
+
tablesConfig,
|
|
56
|
+
// 字典常量
|
|
57
|
+
dicts,
|
|
58
|
+
} = configs
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 创建表格
|
|
62
|
+
*/
|
|
63
|
+
function create(options) {
|
|
64
|
+
|
|
65
|
+
// ==========【数据】=================================================================================================
|
|
66
|
+
|
|
67
|
+
// quasar 对象
|
|
68
|
+
const $q = useQuasar()
|
|
69
|
+
|
|
70
|
+
// 每页显示行数选项
|
|
71
|
+
const rowsPerPageOptions = [30, 40, 50, 100, 200, 500, 1000]
|
|
72
|
+
|
|
73
|
+
// 原始参数
|
|
74
|
+
const rawOptions = {
|
|
75
|
+
// 路由路径
|
|
76
|
+
path: '',
|
|
77
|
+
// 请求地址(默认为 path)
|
|
78
|
+
url: '',
|
|
79
|
+
// 路由参数
|
|
80
|
+
query: {},
|
|
81
|
+
// 附加请求数据
|
|
82
|
+
data: {},
|
|
83
|
+
// 表格行唯一键值
|
|
84
|
+
rowKey: 'id',
|
|
85
|
+
// 选择类型, 可选值 none single(默认) multiple
|
|
86
|
+
// selection: '',
|
|
87
|
+
// 分隔栏, 可选值 horizontal vertical cell none
|
|
88
|
+
separator: 'cell',
|
|
89
|
+
// 初始已选数据
|
|
90
|
+
selected: [],
|
|
91
|
+
// 初始表格加载状态
|
|
92
|
+
loading: false,
|
|
93
|
+
// 表格列数据(对象数组)
|
|
94
|
+
columns: [],
|
|
95
|
+
// 初始可见列
|
|
96
|
+
visibleColumns: [],
|
|
97
|
+
// 表格行数据
|
|
98
|
+
rows: [],
|
|
99
|
+
// 表格翻页参数
|
|
100
|
+
pagination: {
|
|
101
|
+
// 页码
|
|
102
|
+
page: 1,
|
|
103
|
+
// 每页的数据条数
|
|
104
|
+
rowsPerPage: $n_has(options, 'rowsPerPageOptions') ? options.rowsPerPageOptions[0] : rowsPerPageOptions[0],
|
|
105
|
+
// 数据总数(服务器返回)
|
|
106
|
+
rowsNumber: 1,
|
|
107
|
+
// 排序字段
|
|
108
|
+
sortBy: null,
|
|
109
|
+
// sortBy: 'id',
|
|
110
|
+
// 是否降序排列
|
|
111
|
+
descending: true,
|
|
112
|
+
},
|
|
113
|
+
// 每页显示行数选项
|
|
114
|
+
rowsPerPageOptions,
|
|
115
|
+
// 请求前执行
|
|
116
|
+
requestBefore: null,
|
|
117
|
+
// 请求成功执行
|
|
118
|
+
requestSuccess: null,
|
|
119
|
+
// 请求失败执行
|
|
120
|
+
requestFail: null,
|
|
121
|
+
// 请求后执行
|
|
122
|
+
requestAfter: null,
|
|
123
|
+
// 自定义请求方法
|
|
124
|
+
request: null,
|
|
125
|
+
// 格式化单条数据
|
|
126
|
+
formatRow: null,
|
|
127
|
+
// http 设置
|
|
128
|
+
httpSettings: {},
|
|
129
|
+
// 是否开启初始搜素
|
|
130
|
+
search: true,
|
|
131
|
+
// 是否开启合计
|
|
132
|
+
summary: false,
|
|
133
|
+
// 从参数中获取搜索值
|
|
134
|
+
searchFromQuery: true,
|
|
135
|
+
// 是否显示宫格
|
|
136
|
+
showGrid: false,
|
|
137
|
+
// 是否显示可见列
|
|
138
|
+
showVisibleColumns: true,
|
|
139
|
+
// 是否开启缓存
|
|
140
|
+
cache: true,
|
|
141
|
+
// 是否刷新后清空已选数据
|
|
142
|
+
refreshResetSelected: true,
|
|
143
|
+
|
|
144
|
+
// 单击表格行事件
|
|
145
|
+
rowClick: null,
|
|
146
|
+
// 双击表格行事件
|
|
147
|
+
rowDblClick: null,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
let o
|
|
151
|
+
let $power
|
|
152
|
+
let hasPowr
|
|
153
|
+
let $render
|
|
154
|
+
let $route
|
|
155
|
+
let hasPowerBtns
|
|
156
|
+
let tableSelected
|
|
157
|
+
let isCache
|
|
158
|
+
let cacheName
|
|
159
|
+
let tableColumns
|
|
160
|
+
let tableImgs
|
|
161
|
+
|
|
162
|
+
// 是否显示可见列
|
|
163
|
+
let tableShowVisibleColumns
|
|
164
|
+
// 表格可见列
|
|
165
|
+
let tableVisibleColumns
|
|
166
|
+
// 表格加载状态
|
|
167
|
+
let tableLoading
|
|
168
|
+
// 表格行数据
|
|
169
|
+
let tableRows
|
|
170
|
+
// 表格翻页参数
|
|
171
|
+
let tablePagination
|
|
172
|
+
// 表格宫格
|
|
173
|
+
let tableGrid
|
|
174
|
+
// 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
|
|
175
|
+
let tableRequestQuery
|
|
176
|
+
// 是否请求表格合计
|
|
177
|
+
let isRequestSummary
|
|
178
|
+
// 表格合计
|
|
179
|
+
let tableSummary
|
|
180
|
+
// 表格选择类型
|
|
181
|
+
let tableSelection
|
|
182
|
+
// 表格分隔栏
|
|
183
|
+
let tableSeparator
|
|
184
|
+
|
|
185
|
+
// 原始参数
|
|
186
|
+
let rawQuery
|
|
187
|
+
// 原始表格搜索参数
|
|
188
|
+
let rawSearchOptions
|
|
189
|
+
// 原始表格搜索值(空表格搜索值, 用于搜索重置)
|
|
190
|
+
let rawTableSearchValue
|
|
191
|
+
// 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
192
|
+
let firstTableSearchValue
|
|
193
|
+
|
|
194
|
+
// 表格搜索数据值
|
|
195
|
+
let tableSearchValue
|
|
196
|
+
// 表格搜索参数
|
|
197
|
+
let tableSearchOptions
|
|
198
|
+
// 是否已加载
|
|
199
|
+
let _isTableLoaded
|
|
200
|
+
|
|
201
|
+
// 是否已生成数据
|
|
202
|
+
let _isCreated = false
|
|
203
|
+
|
|
204
|
+
// 表格节点
|
|
205
|
+
const tableRef = ref(null)
|
|
206
|
+
|
|
207
|
+
// 创建表格
|
|
208
|
+
reCreate(options)
|
|
209
|
+
|
|
210
|
+
// 已生成数据
|
|
211
|
+
_isCreated = true
|
|
212
|
+
|
|
213
|
+
// ==========【方法】================================================================================================
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 重新创建表格
|
|
217
|
+
*/
|
|
218
|
+
function reCreate(options) {
|
|
219
|
+
|
|
220
|
+
// 获取参数
|
|
221
|
+
o = $n_merge({}, rawOptions, options)
|
|
222
|
+
|
|
223
|
+
// 获取权限注入
|
|
224
|
+
$power = $n_has(options, '$power') ? options.$power : (_isCreated ? $power : inject(NPowerKey))
|
|
225
|
+
hasPowr = !! $power
|
|
226
|
+
|
|
227
|
+
// 获取渲染注入
|
|
228
|
+
$render = $n_has(options, '$render') ? options.$render : (_isCreated ? $render : inject(NRenderKey))
|
|
229
|
+
if (!! $render) {
|
|
230
|
+
// 如果有表格传参, 则合并参数
|
|
231
|
+
const tableProps = $n_get($render, 'props.tableProps')
|
|
232
|
+
if ($n_isValidObject(tableProps)) {
|
|
233
|
+
$n_merge(o, tableProps)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// 获取选择类型(默认 single)
|
|
238
|
+
if (! $n_has(o, 'selection') || ! $n_isValidString(o.selection)) {
|
|
239
|
+
if (hasPowr) {
|
|
240
|
+
o.selection = $n_get($power, 'powerPage.data.selection')
|
|
241
|
+
if (! $n_isValidString(o.selection)) {
|
|
242
|
+
o.selection = 'single'
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
o.selection = 'single'
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// 自定义参数
|
|
250
|
+
const optionsQuery = $n_isValidObject(o.query) ? o.query : {}
|
|
251
|
+
|
|
252
|
+
// 如果为自定义路由
|
|
253
|
+
if ($n_isValidString(o.path)) {
|
|
254
|
+
// 获取权限路由
|
|
255
|
+
$route = $n_router.resolve({
|
|
256
|
+
path: o.path,
|
|
257
|
+
query: optionsQuery,
|
|
258
|
+
})
|
|
259
|
+
// 否则获取当前路由
|
|
260
|
+
} else {
|
|
261
|
+
// 获取权限路由
|
|
262
|
+
$route = hasPowr ? $power.getRoute() : $n_router.getRoute()
|
|
263
|
+
Object.assign($route.query, optionsQuery)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// 是否有权限按钮
|
|
267
|
+
const _hasPowerBtns = hasPowr ? $power.powerBtns.value.length : false
|
|
268
|
+
if (_isCreated) {
|
|
269
|
+
hasPowerBtns.value = _hasPowerBtns
|
|
270
|
+
} else {
|
|
271
|
+
hasPowerBtns = ref(_hasPowerBtns)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// 表格已选数据
|
|
275
|
+
if (hasPowr) {
|
|
276
|
+
tableSelected = $power.tableSelected
|
|
277
|
+
} else if (_isCreated) {
|
|
278
|
+
tableSelected.value = []
|
|
279
|
+
} else {
|
|
280
|
+
tableSelected = ref([])
|
|
281
|
+
}
|
|
282
|
+
if ($n_isValidArray(o.selected)) {
|
|
283
|
+
tableSelected.value = o.selected
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// 是否开启缓存
|
|
287
|
+
isCache = !! o.cache
|
|
288
|
+
|
|
289
|
+
// 缓存名
|
|
290
|
+
cacheName = $route.path ? $route.path : ($n_isValidString(o.cache) ? o.cache : '')
|
|
291
|
+
|
|
292
|
+
// 表格列
|
|
293
|
+
const _tableColumns = []
|
|
294
|
+
|
|
295
|
+
// 如果有权限按钮
|
|
296
|
+
if (hasPowerBtns.value) {
|
|
297
|
+
// 添加操作列
|
|
298
|
+
o.columns.push({
|
|
299
|
+
label: '操作',
|
|
300
|
+
name: 'settings',
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// 表格图片
|
|
305
|
+
if (_isCreated) {
|
|
306
|
+
tableImgs.value = []
|
|
307
|
+
} else {
|
|
308
|
+
tableImgs = ref([])
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 设置表格列数据
|
|
312
|
+
// 设置列参数
|
|
313
|
+
$n_forEach(o.columns, function(item) {
|
|
314
|
+
|
|
315
|
+
if (
|
|
316
|
+
! $n_has(item, 'field')
|
|
317
|
+
&& $n_has(item, 'name')
|
|
318
|
+
) {
|
|
319
|
+
item.field = item.name
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (! $n_has(item, 'align')) {
|
|
323
|
+
item.align = 'left'
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// 是否隐藏
|
|
327
|
+
item.hide = $n_get(item, 'hide') === true
|
|
328
|
+
|
|
329
|
+
// 如果有显示项
|
|
330
|
+
if ($n_get(item, 'visible') !== false) {
|
|
331
|
+
o.visibleColumns.push(item.field)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// 如果有时间戳
|
|
335
|
+
if ($n_has(item, 'time')) {
|
|
336
|
+
if (! $n_has(item, 'format')) {
|
|
337
|
+
item.format = val => $n_getTime(val, { format: item.time === true ? `YYYY-MM-DD HH:mm` : item.time }, '-')
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// 如果有数据字典
|
|
341
|
+
} else if ($n_has(item, 'dict')) {
|
|
342
|
+
if (! $n_has(item, 'format')) {
|
|
343
|
+
item.format = $n_isArray(item.dict)
|
|
344
|
+
? function (val) {
|
|
345
|
+
for (const e of item.dict) {
|
|
346
|
+
if (e.value === val) {
|
|
347
|
+
return e.label
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return ''
|
|
351
|
+
}
|
|
352
|
+
: val => $n_dict(item.dict, val)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// 如果有图片
|
|
356
|
+
} else if ($n_has(item, 'img')) {
|
|
357
|
+
tableImgs.value.push({
|
|
358
|
+
name: item.name,
|
|
359
|
+
count: item.img === true ? 1 : item.img,
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
// 如果有价格
|
|
363
|
+
} else if ($n_has(item, 'price')) {
|
|
364
|
+
if (! $n_has(item, 'format')) {
|
|
365
|
+
item.format = val => $n_price(val)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// 如果有路由
|
|
370
|
+
if ($n_get(item, 'route')) {
|
|
371
|
+
// 如果该值在当前路由路径中, 则显示
|
|
372
|
+
if ($n_indexOf($route.fullPath, item.route) > -1) {
|
|
373
|
+
_tableColumns.push(item)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
} else {
|
|
377
|
+
_tableColumns.push(item)
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
// 表格可见列
|
|
382
|
+
const _tableVisibleColumns = o.showVisibleColumns && isCache ?
|
|
383
|
+
$n_cb($n_storage.get('table:visible_columns:' + cacheName), e => Array.isArray(e) ? e : $n_uniq([...o.visibleColumns]))
|
|
384
|
+
: $n_uniq([...o.visibleColumns])
|
|
385
|
+
|
|
386
|
+
// 表格翻页参数
|
|
387
|
+
const _tablePagination = $route.fullPath ? o.pagination : {}
|
|
388
|
+
|
|
389
|
+
// 表格宫格
|
|
390
|
+
const _tableGrid = isCache && $n_storage.get('table:grid:' + cacheName) === true ? true : o.showGrid
|
|
391
|
+
|
|
392
|
+
// 获取原始数据
|
|
393
|
+
const r = getRawData(_tableColumns, Object.assign({}, $route.query), o.searchFromQuery)
|
|
394
|
+
|
|
395
|
+
// 原始参数
|
|
396
|
+
rawQuery = r.rawQuery
|
|
397
|
+
// 原始表格搜索参数
|
|
398
|
+
rawSearchOptions = r.rawSearchOptions
|
|
399
|
+
// 原始表格搜索值(空表格搜索值, 用于搜索重置)
|
|
400
|
+
rawTableSearchValue = r.rawTableSearchValue
|
|
401
|
+
// 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
402
|
+
firstTableSearchValue = r.firstTableSearchValue
|
|
403
|
+
|
|
404
|
+
// 表格搜索数据值
|
|
405
|
+
const _tableSearchValue = $route.fullPath ? firstTableSearchValue : []
|
|
406
|
+
|
|
407
|
+
if (_isCreated) {
|
|
408
|
+
|
|
409
|
+
// 表格列
|
|
410
|
+
tableColumns.value = _tableColumns
|
|
411
|
+
|
|
412
|
+
// 表格是否显示可见列
|
|
413
|
+
tableShowVisibleColumns.value = o.showVisibleColumns
|
|
414
|
+
|
|
415
|
+
// 表格可见列
|
|
416
|
+
tableVisibleColumns.value = _tableVisibleColumns
|
|
417
|
+
|
|
418
|
+
// 表格加载状态
|
|
419
|
+
tableLoading.value = o.loading
|
|
420
|
+
|
|
421
|
+
// 表格行数据
|
|
422
|
+
tableRows.value = o.rows
|
|
423
|
+
|
|
424
|
+
// 表格翻页参数
|
|
425
|
+
tablePagination.value = _tablePagination
|
|
426
|
+
|
|
427
|
+
// 表格宫格
|
|
428
|
+
tableGrid.value = _tableGrid
|
|
429
|
+
|
|
430
|
+
// 表格合计
|
|
431
|
+
tableSummary.value = null
|
|
432
|
+
|
|
433
|
+
// 表格选择类型
|
|
434
|
+
tableSelection.value = o.selection
|
|
435
|
+
|
|
436
|
+
// 表格分隔栏
|
|
437
|
+
tableSeparator.value = o.separator
|
|
438
|
+
|
|
439
|
+
// 表格搜索数据值
|
|
440
|
+
tableSearchValue.value = _tableSearchValue
|
|
441
|
+
|
|
442
|
+
// 表格搜索参数
|
|
443
|
+
tableSearchOptions.value = null
|
|
444
|
+
|
|
445
|
+
} else {
|
|
446
|
+
|
|
447
|
+
// 表格列
|
|
448
|
+
tableColumns = ref(_tableColumns)
|
|
449
|
+
|
|
450
|
+
// 表格是否显示可见列
|
|
451
|
+
tableShowVisibleColumns = ref(o.showVisibleColumns)
|
|
452
|
+
|
|
453
|
+
// 表格可见列
|
|
454
|
+
tableVisibleColumns = ref(_tableVisibleColumns)
|
|
455
|
+
|
|
456
|
+
// 表格加载状态
|
|
457
|
+
tableLoading = ref(o.loading)
|
|
458
|
+
|
|
459
|
+
// 表格行数据
|
|
460
|
+
tableRows = ref(o.rows)
|
|
461
|
+
|
|
462
|
+
// 表格翻页参数
|
|
463
|
+
tablePagination = ref(_tablePagination)
|
|
464
|
+
|
|
465
|
+
// 表格宫格
|
|
466
|
+
tableGrid = ref(_tableGrid)
|
|
467
|
+
|
|
468
|
+
// 表格合计
|
|
469
|
+
tableSummary = ref(null)
|
|
470
|
+
|
|
471
|
+
// 表格选择类型
|
|
472
|
+
tableSelection = ref(o.selection)
|
|
473
|
+
|
|
474
|
+
// 表格分隔栏
|
|
475
|
+
tableSeparator = ref(o.separator)
|
|
476
|
+
|
|
477
|
+
// 表格搜索数据值
|
|
478
|
+
tableSearchValue = ref(_tableSearchValue)
|
|
479
|
+
|
|
480
|
+
// 表格搜索参数
|
|
481
|
+
tableSearchOptions = ref(null)
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
|
|
485
|
+
tableRequestQuery = {}
|
|
486
|
+
|
|
487
|
+
// 是否请求表格合计
|
|
488
|
+
isRequestSummary = false
|
|
489
|
+
|
|
490
|
+
// 是否已加载
|
|
491
|
+
_isTableLoaded = false
|
|
492
|
+
|
|
493
|
+
// 如果开启搜索
|
|
494
|
+
if (o.search) {
|
|
495
|
+
// 设置表格搜索参数
|
|
496
|
+
setTableSearchOptions()
|
|
497
|
+
.finally()
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
if (_isCreated) {
|
|
501
|
+
|
|
502
|
+
// 重新赋值
|
|
503
|
+
Object.assign(resTable, {
|
|
504
|
+
// 当前路由全路径
|
|
505
|
+
routeFullPath: $route.fullPath,
|
|
506
|
+
// 当前路由路径
|
|
507
|
+
routePath: $route.path,
|
|
508
|
+
// 当前路由参数
|
|
509
|
+
routeQuery: $route.query,
|
|
510
|
+
// 表格行唯一键值
|
|
511
|
+
tableRowKey: o.rowKey,
|
|
512
|
+
// 表格每页显示行数选项
|
|
513
|
+
tableRowsPerPageOptions: o.rowsPerPageOptions,
|
|
514
|
+
})
|
|
515
|
+
|
|
516
|
+
if (hasPowr) {
|
|
517
|
+
$power.update(function(data, _data) {
|
|
518
|
+
_data.$table = resTable
|
|
519
|
+
})
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// ==========【计算属性】=============================================================================================
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* 固定在表格右边的权限按钮列表
|
|
528
|
+
*/
|
|
529
|
+
const tableFixedPowerBtns = computed(function () {
|
|
530
|
+
|
|
531
|
+
const lists = []
|
|
532
|
+
|
|
533
|
+
if (hasPowerBtns.value) {
|
|
534
|
+
|
|
535
|
+
// 先格式化权限按钮列表
|
|
536
|
+
$n_forEach($n_$power.formatBtns($power.powerBtns.value), function(item) {
|
|
537
|
+
// 如果是固定按钮
|
|
538
|
+
if (item.fixed) {
|
|
539
|
+
lists.push(item)
|
|
540
|
+
}
|
|
541
|
+
})
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return lists
|
|
545
|
+
})
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* 获取权限按钮中可双击的按钮
|
|
549
|
+
*/
|
|
550
|
+
const tableDbClickPowerBtn = computed(function () {
|
|
551
|
+
if (
|
|
552
|
+
// 如果有权限按钮
|
|
553
|
+
hasPowerBtns.value
|
|
554
|
+
// 非手机模式
|
|
555
|
+
&& ! $q.platform.is.mobile
|
|
556
|
+
// 有权限列表
|
|
557
|
+
&& $n_isValidArray($power.powerBtns.value)
|
|
558
|
+
) {
|
|
559
|
+
for (const item of $power.powerBtns.value) {
|
|
560
|
+
if ($n_has(item, 'data.dbclick') === true) {
|
|
561
|
+
return item
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
})
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* 是否显示固定在右边的权限按钮列表
|
|
569
|
+
*/
|
|
570
|
+
const showTableFixed = computed(function () {
|
|
571
|
+
return $n_indexOf(tableVisibleColumns.value, 'settings') > -1
|
|
572
|
+
})
|
|
573
|
+
|
|
574
|
+
// ==========【监听数据】=============================================================================================
|
|
575
|
+
|
|
576
|
+
// #if ! IS_DEV
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* 监听表格宫格模式
|
|
580
|
+
*/
|
|
581
|
+
watch(tableGrid, function(val) {
|
|
582
|
+
if (isCache) {
|
|
583
|
+
// 设置宫格模式缓存(永久缓存)
|
|
584
|
+
$n_storage.set('table:grid:' + cacheName, val, 0)
|
|
585
|
+
}
|
|
586
|
+
})
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* 监听表格可见列
|
|
590
|
+
*/
|
|
591
|
+
watch(tableVisibleColumns, function(val) {
|
|
592
|
+
if (o.showVisibleColumns && isCache) {
|
|
593
|
+
// 设置监听表格可见列缓存(永久缓存)
|
|
594
|
+
$n_storage.set('table:visible_columns:' + cacheName, val, 0)
|
|
595
|
+
}
|
|
596
|
+
})
|
|
597
|
+
|
|
598
|
+
// #endif
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* 监听固定在右边的权限按钮列表
|
|
602
|
+
*/
|
|
603
|
+
watch(tableFixedPowerBtns, function (lists) {
|
|
604
|
+
|
|
605
|
+
if (! hasPowerBtns.value) {
|
|
606
|
+
return
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const index = $n_indexOf(tableVisibleColumns.value, 'settings')
|
|
610
|
+
|
|
611
|
+
// 如果有固定在右边的权限按钮列表
|
|
612
|
+
if ($n_isValidArray(lists)) {
|
|
613
|
+
|
|
614
|
+
// 如果设置不在可见列中
|
|
615
|
+
if (index === -1) {
|
|
616
|
+
|
|
617
|
+
// 如果非手机模式
|
|
618
|
+
if (! $q.platform.is.mobile) {
|
|
619
|
+
|
|
620
|
+
// 则将设置加入可见列中
|
|
621
|
+
tableVisibleColumns.value.push('settings')
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// 否则在可见列中 && 如果是手机模式
|
|
625
|
+
} else if ($q.platform.is.mobile) {
|
|
626
|
+
|
|
627
|
+
// 则将设置从可见列中删除
|
|
628
|
+
tableVisibleColumns.value.splice(index, 1)
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// 否则如果设置在可见列中
|
|
632
|
+
} else if (index > -1) {
|
|
633
|
+
|
|
634
|
+
// 则将设置从可见列中删除
|
|
635
|
+
tableVisibleColumns.value.splice(index, 1)
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
}, {
|
|
639
|
+
// 立即执行
|
|
640
|
+
immediate: true,
|
|
641
|
+
})
|
|
642
|
+
|
|
643
|
+
// ==========【方法】================================================================================================
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* 设置表格节点节点
|
|
647
|
+
*/
|
|
648
|
+
function setTableRef(target) {
|
|
649
|
+
tableRef.value = target
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* 设置表格传参
|
|
654
|
+
*/
|
|
655
|
+
function setQuery(query) {
|
|
656
|
+
|
|
657
|
+
if ($n_isValidObject(query)) {
|
|
658
|
+
|
|
659
|
+
query = $n_cloneDeep(query)
|
|
660
|
+
|
|
661
|
+
// 搜索参数键值数组
|
|
662
|
+
const searchQueryKey = []
|
|
663
|
+
|
|
664
|
+
// 搜索键值数组
|
|
665
|
+
const NSearchKeys = []
|
|
666
|
+
// 搜索数组
|
|
667
|
+
const NSearchValues = []
|
|
668
|
+
|
|
669
|
+
// 参数中是否有自定义搜索参数
|
|
670
|
+
const hasNSearch = $n_has(query, 'n_search')
|
|
671
|
+
if (hasNSearch) {
|
|
672
|
+
// 删除在搜索中存在的参数键值
|
|
673
|
+
$n_forIn(query.n_search, function (item, key) {
|
|
674
|
+
if ($n_has(query, key)) {
|
|
675
|
+
delete query[key]
|
|
676
|
+
}
|
|
677
|
+
})
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// 如果允许从参数中获取搜索值
|
|
681
|
+
if (o.searchFromQuery) {
|
|
682
|
+
|
|
683
|
+
$n_forEach(rawSearchOptions, function (item, index) {
|
|
684
|
+
|
|
685
|
+
const valueItem = tableSearchValue.value[index]
|
|
686
|
+
|
|
687
|
+
// 如果传参在搜素 n_search 参数中
|
|
688
|
+
if (hasNSearch && $n_has(query.n_search, item.name)) {
|
|
689
|
+
const newSearchItem = query.n_search[item.name]
|
|
690
|
+
if ($n_isValidArray(newSearchItem)) {
|
|
691
|
+
valueItem[0].compare = newSearchItem[0].compare
|
|
692
|
+
valueItem[0].value = newSearchItem[0].value
|
|
693
|
+
|
|
694
|
+
if (newSearchItem.length > 1) {
|
|
695
|
+
valueItem[1].compare = newSearchItem[1].compare
|
|
696
|
+
valueItem[1].value = newSearchItem[1].value
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
// 设置搜索的 key
|
|
700
|
+
NSearchKeys.push(item.name)
|
|
701
|
+
|
|
702
|
+
// 如果传参在搜索参数中
|
|
703
|
+
} else if ($n_has(query, item.name)) {
|
|
704
|
+
// 设置单个搜索值
|
|
705
|
+
setItemValue(valueItem, $n_isRequired(query[item.name]) ? query[item.name] : '')
|
|
706
|
+
// 设置参数中搜索的 key
|
|
707
|
+
searchQueryKey.push(item.name)
|
|
708
|
+
}
|
|
709
|
+
})
|
|
710
|
+
|
|
711
|
+
$n_forEach(searchQueryKey, function (key) {
|
|
712
|
+
delete query[key]
|
|
713
|
+
})
|
|
714
|
+
|
|
715
|
+
if (hasNSearch) {
|
|
716
|
+
$n_forIn(query.n_search, function(item, key) {
|
|
717
|
+
if (
|
|
718
|
+
NSearchKeys.indexOf(key) === -1
|
|
719
|
+
&& $n_isValidArray(item)
|
|
720
|
+
) {
|
|
721
|
+
item[0].field = key
|
|
722
|
+
NSearchValues.push(item[0])
|
|
723
|
+
|
|
724
|
+
if (item.length > 1) {
|
|
725
|
+
item[1].field = key
|
|
726
|
+
NSearchValues.push(item[1])
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
})
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
} else {
|
|
733
|
+
$n_forIn(query.n_search, function(item, key) {
|
|
734
|
+
if ($n_isValidArray(item)) {
|
|
735
|
+
item[0].field = key
|
|
736
|
+
NSearchValues.push(item[0])
|
|
737
|
+
if (item.length > 1) {
|
|
738
|
+
item[1].field = key
|
|
739
|
+
NSearchValues.push(item[1])
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
})
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
if (NSearchValues.length) {
|
|
746
|
+
query.n_search = NSearchValues
|
|
747
|
+
} else if (hasNSearch) {
|
|
748
|
+
delete query.n_search
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
tableRequestQuery = query
|
|
752
|
+
return
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
tableRequestQuery = {}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* 表格是否已加载
|
|
761
|
+
*/
|
|
762
|
+
function isTableLoaded() {
|
|
763
|
+
return _isTableLoaded
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* 表格加载(只加载一次)
|
|
768
|
+
*/
|
|
769
|
+
async function tableLoad() {
|
|
770
|
+
|
|
771
|
+
// 如果表格已加载过了
|
|
772
|
+
if (_isTableLoaded) {
|
|
773
|
+
// 则无任何操作
|
|
774
|
+
return
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// 表格重新加载
|
|
778
|
+
await tableReload()
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* 表格重新加载
|
|
783
|
+
*/
|
|
784
|
+
async function tableReload(params = null) {
|
|
785
|
+
|
|
786
|
+
// 表格已加载
|
|
787
|
+
_isTableLoaded = true
|
|
788
|
+
|
|
789
|
+
if (! $route.fullPath) {
|
|
790
|
+
return
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// 请求表格合计
|
|
794
|
+
if (o.summary) {
|
|
795
|
+
isRequestSummary = true
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// 请求表格数据
|
|
799
|
+
// $tableRef?.requestServerInteraction({
|
|
800
|
+
// pagination: o.pagination,
|
|
801
|
+
// })
|
|
802
|
+
|
|
803
|
+
await tableRequest(Object.assign({
|
|
804
|
+
pagination: o.pagination,
|
|
805
|
+
}, params))
|
|
806
|
+
|
|
807
|
+
// 清空表格已选数据
|
|
808
|
+
if (o.refreshResetSelected) {
|
|
809
|
+
tableSelected.value = []
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* 表格刷新
|
|
815
|
+
*/
|
|
816
|
+
async function tableRefresh() {
|
|
817
|
+
|
|
818
|
+
if (! $route.fullPath) {
|
|
819
|
+
return
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// 请求表格合计
|
|
823
|
+
if (o.summary) {
|
|
824
|
+
isRequestSummary = true
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// 请求表格数据
|
|
828
|
+
// $tableRef.requestServerInteraction()
|
|
829
|
+
await tableRequest({
|
|
830
|
+
pagination: tablePagination.value,
|
|
831
|
+
})
|
|
832
|
+
|
|
833
|
+
// 清空表格已选数据
|
|
834
|
+
if (o.refreshResetSelected) {
|
|
835
|
+
tableSelected.value = []
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* 表格搜索重置
|
|
841
|
+
*/
|
|
842
|
+
function tableSearchReset(reload = true, params = null) {
|
|
843
|
+
|
|
844
|
+
const newValue = []
|
|
845
|
+
|
|
846
|
+
$n_forEach(rawSearchOptions, function (item, index) {
|
|
847
|
+
// 如果该搜索条件是隐藏的
|
|
848
|
+
if (item.hide) {
|
|
849
|
+
newValue.push(tableSearchValue.value[index])
|
|
850
|
+
// 否则为初始值
|
|
851
|
+
} else {
|
|
852
|
+
newValue.push(rawTableSearchValue[index])
|
|
853
|
+
}
|
|
854
|
+
})
|
|
855
|
+
|
|
856
|
+
// 还原表格搜索数据
|
|
857
|
+
tableSearchValue.value = $n_cloneDeep(newValue)
|
|
858
|
+
|
|
859
|
+
// 表格重新加载
|
|
860
|
+
if (reload) {
|
|
861
|
+
tableReload(params)
|
|
862
|
+
.finally()
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* 获取表格请求数据
|
|
868
|
+
*/
|
|
869
|
+
function getTableRequestData(props, isSummary = undefined) {
|
|
870
|
+
|
|
871
|
+
// 解构数据
|
|
872
|
+
const {
|
|
873
|
+
// filter,
|
|
874
|
+
pagination: {
|
|
875
|
+
// 页码
|
|
876
|
+
page,
|
|
877
|
+
// 每页的数据条数
|
|
878
|
+
rowsPerPage,
|
|
879
|
+
// 排序字段
|
|
880
|
+
sortBy,
|
|
881
|
+
// 是否降序排列
|
|
882
|
+
descending,
|
|
883
|
+
}
|
|
884
|
+
} = props
|
|
885
|
+
|
|
886
|
+
// 请求数据
|
|
887
|
+
const data = {
|
|
888
|
+
// 页码
|
|
889
|
+
page,
|
|
890
|
+
// 每页的数据条数
|
|
891
|
+
per_page: rowsPerPage,
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// 如果排序字段是有效值
|
|
895
|
+
if ($n_isValidValue(sortBy)) {
|
|
896
|
+
Object.assign(data, {
|
|
897
|
+
// 排序字段
|
|
898
|
+
order_by: sortBy,
|
|
899
|
+
// 是否降序排列
|
|
900
|
+
is_desc: descending ? 1 : 0,
|
|
901
|
+
})
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// 合并参数
|
|
905
|
+
$n_forIn(Object.assign({}, rawQuery, tableRequestQuery, o.data), function(value, key) {
|
|
906
|
+
// 如果有值
|
|
907
|
+
if ($n_isRequired(value)) {
|
|
908
|
+
data[key] = value
|
|
909
|
+
}
|
|
910
|
+
})
|
|
911
|
+
|
|
912
|
+
// 获取搜索值
|
|
913
|
+
const search = formatValue(rawSearchOptions, tableSearchValue.value)
|
|
914
|
+
if ($n_isValidArray(search)) {
|
|
915
|
+
data.n_search = $n_has(data, 'n_search') ? $n_concat(data.n_search, search) : search
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if ($n_isNil(isSummary)) {
|
|
919
|
+
isSummary = isRequestSummary
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// 如果请求表格合计
|
|
923
|
+
if (isSummary) {
|
|
924
|
+
data.summary = 1
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
return data
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* 请求数据
|
|
932
|
+
*/
|
|
933
|
+
async function tableRequest(props) {
|
|
934
|
+
|
|
935
|
+
// 加载
|
|
936
|
+
tableLoading.value = true
|
|
937
|
+
|
|
938
|
+
// 解构数据
|
|
939
|
+
const {
|
|
940
|
+
// filter,
|
|
941
|
+
pagination: {
|
|
942
|
+
// 页码
|
|
943
|
+
page,
|
|
944
|
+
// 每页的数据条数
|
|
945
|
+
rowsPerPage,
|
|
946
|
+
// 排序字段
|
|
947
|
+
sortBy,
|
|
948
|
+
// 是否降序排列
|
|
949
|
+
descending,
|
|
950
|
+
}
|
|
951
|
+
} = props
|
|
952
|
+
|
|
953
|
+
// http 请求参数
|
|
954
|
+
let httpOptions = Object.assign({
|
|
955
|
+
// 请求数据
|
|
956
|
+
url: $n_isValidString(o.url) ? o.url : $route.path,
|
|
957
|
+
// 请求数据
|
|
958
|
+
data: getTableRequestData(props, isRequestSummary),
|
|
959
|
+
// ~~~~~~ 先开启防抖, 如果后期遇到表格加载不出来的情况, 再关闭防抖
|
|
960
|
+
// 关闭防抖(允许重复请求)
|
|
961
|
+
debounce: false,
|
|
962
|
+
}, o.httpSettings)
|
|
963
|
+
|
|
964
|
+
// 下一步
|
|
965
|
+
async function next() {
|
|
966
|
+
|
|
967
|
+
const e = $n_isFunction(o.request)
|
|
968
|
+
// 如果有自定义请求方法
|
|
969
|
+
? await $n_runAsync(o.request)({
|
|
970
|
+
// http 请求参数
|
|
971
|
+
httpOptions,
|
|
972
|
+
// 表格声明属性
|
|
973
|
+
props,
|
|
974
|
+
// 表格行数据
|
|
975
|
+
rows: tableRows,
|
|
976
|
+
// 表格已选数据
|
|
977
|
+
selected: tableSelected,
|
|
978
|
+
})
|
|
979
|
+
// 否则请求服务器
|
|
980
|
+
: await $n_http(httpOptions)
|
|
981
|
+
|
|
982
|
+
const { status, data: res } = e
|
|
983
|
+
|
|
984
|
+
// 返回结果数据
|
|
985
|
+
const resultData = Object.assign({
|
|
986
|
+
// 请求地址
|
|
987
|
+
requestUrl: httpOptions.url,
|
|
988
|
+
// 参数
|
|
989
|
+
options: httpOptions,
|
|
990
|
+
// 请求数据
|
|
991
|
+
requestData: httpOptions.data,
|
|
992
|
+
}, e)
|
|
993
|
+
|
|
994
|
+
// 请求后执行
|
|
995
|
+
if (await $n_runAsync(o.requestAfter)(resultData) === false) {
|
|
996
|
+
return
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// 请求成功
|
|
1000
|
+
if (status) {
|
|
1001
|
+
|
|
1002
|
+
// 下一步
|
|
1003
|
+
function nextSuccess() {
|
|
1004
|
+
|
|
1005
|
+
const {
|
|
1006
|
+
// 返回数据
|
|
1007
|
+
rows,
|
|
1008
|
+
// 数据总数
|
|
1009
|
+
total,
|
|
1010
|
+
} = res
|
|
1011
|
+
|
|
1012
|
+
// 如果请求表格合计
|
|
1013
|
+
if (isRequestSummary) {
|
|
1014
|
+
const summary = $n_get(res, 'summary')
|
|
1015
|
+
tableSummary.value = $n_isValidObject(summary) ? summary : null
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// 更新页码
|
|
1019
|
+
tablePagination.value.page = page
|
|
1020
|
+
// 更新每页的数据条数
|
|
1021
|
+
tablePagination.value.rowsPerPage = rowsPerPage
|
|
1022
|
+
// 更新数据总数
|
|
1023
|
+
tablePagination.value.rowsNumber = total
|
|
1024
|
+
// 更新排序字段
|
|
1025
|
+
tablePagination.value.sortBy = sortBy
|
|
1026
|
+
// 更新是否降序排列
|
|
1027
|
+
tablePagination.value.descending = descending
|
|
1028
|
+
|
|
1029
|
+
// 格式化单条数据
|
|
1030
|
+
if ($n_isFunction(o.formatRow)) {
|
|
1031
|
+
$n_forEach(rows, function(row) {
|
|
1032
|
+
o.formatRow({
|
|
1033
|
+
row,
|
|
1034
|
+
rows: tableRows,
|
|
1035
|
+
selected: tableSelected,
|
|
1036
|
+
})
|
|
1037
|
+
})
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// 清除现有数据并添加新数据
|
|
1041
|
+
tableRows.value.splice(0, tableRows.value.length, ...rows)
|
|
1042
|
+
|
|
1043
|
+
// 取消请求表格合计
|
|
1044
|
+
isRequestSummary = false
|
|
1045
|
+
|
|
1046
|
+
// 取消加载
|
|
1047
|
+
tableLoading.value = false
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// 请求成功执行
|
|
1051
|
+
if (await $n_runAsync(o.requestSuccess)(Object.assign({ next: nextSuccess }, resultData)) === false) {
|
|
1052
|
+
return
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
nextSuccess()
|
|
1056
|
+
|
|
1057
|
+
// 否则请求失败
|
|
1058
|
+
} else {
|
|
1059
|
+
|
|
1060
|
+
// 请求失败执行
|
|
1061
|
+
$n_run(o.requestFail)(resultData)
|
|
1062
|
+
|
|
1063
|
+
// 取消请求表格合计
|
|
1064
|
+
isRequestSummary = false
|
|
1065
|
+
|
|
1066
|
+
// 取消加载
|
|
1067
|
+
tableLoading.value = false
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// 请求后, 将表格列表置顶
|
|
1071
|
+
|
|
1072
|
+
await nextTick()
|
|
1073
|
+
|
|
1074
|
+
const $el = tableRef.value?.$el
|
|
1075
|
+
if ($el) {
|
|
1076
|
+
let dom = $el.querySelector('.q-virtual-scroll--vertical')
|
|
1077
|
+
if (dom) {
|
|
1078
|
+
dom.scrollTop = 0
|
|
1079
|
+
}
|
|
1080
|
+
dom = $el.querySelector('.q-table__grid-content')
|
|
1081
|
+
if (dom) {
|
|
1082
|
+
dom.scrollTop = 0
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
if (o.requestBefore) {
|
|
1088
|
+
|
|
1089
|
+
// 请求前执行
|
|
1090
|
+
const resBefore = await $n_runAsync(o.requestBefore)({
|
|
1091
|
+
options: httpOptions,
|
|
1092
|
+
next,
|
|
1093
|
+
})
|
|
1094
|
+
if (resBefore !== void 0) {
|
|
1095
|
+
if (resBefore === false) {
|
|
1096
|
+
return
|
|
1097
|
+
}
|
|
1098
|
+
httpOptions = resBefore
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// 下一步
|
|
1103
|
+
next()
|
|
1104
|
+
.finally()
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* 单击表格行
|
|
1109
|
+
*/
|
|
1110
|
+
function _tableRowClick(e, row) {
|
|
1111
|
+
|
|
1112
|
+
// 如果选择类型为无
|
|
1113
|
+
if (tableSelection.value === 'none') {
|
|
1114
|
+
// 则无任何操作
|
|
1115
|
+
return
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
const opt = {}
|
|
1119
|
+
opt[o.rowKey] = row[o.rowKey]
|
|
1120
|
+
|
|
1121
|
+
// 获取当前数据索引
|
|
1122
|
+
const itemIndex = $n_findIndex(tableSelected.value, opt)
|
|
1123
|
+
|
|
1124
|
+
// 如果不存在, 则添加
|
|
1125
|
+
if (itemIndex === -1) {
|
|
1126
|
+
|
|
1127
|
+
// 如果选择类型为单选
|
|
1128
|
+
if (tableSelection.value === 'single') {
|
|
1129
|
+
tableSelected.value = [ row ]
|
|
1130
|
+
|
|
1131
|
+
// 否则为多选
|
|
1132
|
+
} else {
|
|
1133
|
+
tableSelected.value.push(row)
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
// 否则删除
|
|
1137
|
+
} else {
|
|
1138
|
+
tableSelected.value.splice(itemIndex, 1)
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
function tableRowClick(...e) {
|
|
1142
|
+
|
|
1143
|
+
// 单击表格行
|
|
1144
|
+
_tableRowClick(...e)
|
|
1145
|
+
|
|
1146
|
+
// 如果有自定义单击事件
|
|
1147
|
+
if ($n_isFunction(o.rowClick)) {
|
|
1148
|
+
o.rowClick(...e)
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* 双击表格行
|
|
1154
|
+
*/
|
|
1155
|
+
function _tableRowDblclick(e, row) {
|
|
1156
|
+
|
|
1157
|
+
// 如果选择类型为无
|
|
1158
|
+
if (tableSelection.value === 'none') {
|
|
1159
|
+
// 则无任何操作
|
|
1160
|
+
return
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
if (
|
|
1164
|
+
// 有权限
|
|
1165
|
+
hasPowr
|
|
1166
|
+
// 有双击的权限按钮
|
|
1167
|
+
&& tableDbClickPowerBtn.value
|
|
1168
|
+
) {
|
|
1169
|
+
$power.powerBtnClick(tableDbClickPowerBtn.value, [ row ])
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function tableRowDblclick(...e) {
|
|
1173
|
+
|
|
1174
|
+
// 双击表格行
|
|
1175
|
+
_tableRowDblclick(...e)
|
|
1176
|
+
|
|
1177
|
+
// 如果有自定义双击表格行事件
|
|
1178
|
+
if ($n_isFunction(o.tableRowDblclick)) {
|
|
1179
|
+
o.tableRowDblclick(...e)
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* 设置表格搜索参数
|
|
1185
|
+
*/
|
|
1186
|
+
async function setTableSearchOptions(format) {
|
|
1187
|
+
tableSearchOptions.value = await getOptions(rawSearchOptions, format)
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* 获取表格搜索值
|
|
1192
|
+
*/
|
|
1193
|
+
function getTableSearchValue() {
|
|
1194
|
+
return formatValue(rawSearchOptions, tableSearchValue.value)
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* 是否有表格搜索值
|
|
1199
|
+
*/
|
|
1200
|
+
// function hasTableSearchValue() {
|
|
1201
|
+
// return !! formatValue(rawSearchOptions, tableSearchValue.value).length
|
|
1202
|
+
// }
|
|
1203
|
+
|
|
1204
|
+
// ==========【返回】=================================================================================================
|
|
1205
|
+
|
|
1206
|
+
const resTable = {
|
|
1207
|
+
// 当前路由全路径
|
|
1208
|
+
routeFullPath: $route.fullPath,
|
|
1209
|
+
// 当前路由路径
|
|
1210
|
+
routePath: $route.path,
|
|
1211
|
+
// 当前路由参数
|
|
1212
|
+
routeQuery: $route.query,
|
|
1213
|
+
// 表格行唯一键值
|
|
1214
|
+
tableRowKey: o.rowKey,
|
|
1215
|
+
// 表格每页显示行数选项
|
|
1216
|
+
tableRowsPerPageOptions: o.rowsPerPageOptions,
|
|
1217
|
+
|
|
1218
|
+
// 表格节点
|
|
1219
|
+
tableRef,
|
|
1220
|
+
// 表格加载状态
|
|
1221
|
+
tableLoading,
|
|
1222
|
+
// 表格选择类型
|
|
1223
|
+
tableSelection,
|
|
1224
|
+
// 表格分隔栏
|
|
1225
|
+
tableSeparator,
|
|
1226
|
+
// 表格列数据(对象数组)
|
|
1227
|
+
tableColumns,
|
|
1228
|
+
// 表格是否显示可见列
|
|
1229
|
+
tableShowVisibleColumns,
|
|
1230
|
+
// 表格可见列
|
|
1231
|
+
tableVisibleColumns,
|
|
1232
|
+
// 表格行数据
|
|
1233
|
+
tableRows,
|
|
1234
|
+
// 表格翻页参数
|
|
1235
|
+
tablePagination,
|
|
1236
|
+
// 表格已选数据
|
|
1237
|
+
tableSelected,
|
|
1238
|
+
// 固定在右边的权限按钮列表
|
|
1239
|
+
tableFixedPowerBtns,
|
|
1240
|
+
// 是否显示固定在右边的权限按钮列表
|
|
1241
|
+
showTableFixed,
|
|
1242
|
+
// 表格图片
|
|
1243
|
+
tableImgs,
|
|
1244
|
+
|
|
1245
|
+
// 表格宫格
|
|
1246
|
+
tableGrid,
|
|
1247
|
+
// 表格合计
|
|
1248
|
+
tableSummary,
|
|
1249
|
+
// 表格搜索数据
|
|
1250
|
+
tableSearchValue,
|
|
1251
|
+
// 表格搜索参数
|
|
1252
|
+
tableSearchOptions,
|
|
1253
|
+
|
|
1254
|
+
// 设置表格节点
|
|
1255
|
+
setTableRef,
|
|
1256
|
+
// 设置表格传参
|
|
1257
|
+
setQuery,
|
|
1258
|
+
// 表格是否已加载
|
|
1259
|
+
isTableLoaded,
|
|
1260
|
+
// 表格加载(只加载一次)
|
|
1261
|
+
tableLoad,
|
|
1262
|
+
// 表格重新加载
|
|
1263
|
+
tableReload,
|
|
1264
|
+
// 表格刷新
|
|
1265
|
+
tableRefresh,
|
|
1266
|
+
// 表格搜索重置
|
|
1267
|
+
tableSearchReset,
|
|
1268
|
+
// 获取表格请求数据
|
|
1269
|
+
getTableRequestData,
|
|
1270
|
+
// 表格请求数据
|
|
1271
|
+
tableRequest,
|
|
1272
|
+
// 表格单击表格行
|
|
1273
|
+
tableRowClick,
|
|
1274
|
+
// 表格双击表格行
|
|
1275
|
+
tableRowDblclick,
|
|
1276
|
+
// 设置表格搜索参数
|
|
1277
|
+
setTableSearchOptions,
|
|
1278
|
+
|
|
1279
|
+
// 获取表格搜索值
|
|
1280
|
+
getTableSearchValue,
|
|
1281
|
+
// 是否有表格搜索值
|
|
1282
|
+
// hasTableSearchValue,
|
|
1283
|
+
|
|
1284
|
+
// 获取当前路由
|
|
1285
|
+
getRoute() {
|
|
1286
|
+
return $route
|
|
1287
|
+
},
|
|
1288
|
+
// 重新创建表格
|
|
1289
|
+
reCreate,
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
if (hasPowr) {
|
|
1293
|
+
$power.update(function(data, _data) {
|
|
1294
|
+
_data.$table = resTable
|
|
1295
|
+
})
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// 提供可以被后代组件注入的值
|
|
1299
|
+
provide(NTableKey, resTable)
|
|
1300
|
+
|
|
1301
|
+
return resTable
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* 获取表格配置
|
|
1306
|
+
*/
|
|
1307
|
+
function config(routePath, path, defaultValue) {
|
|
1308
|
+
const res = $n_get(tablesConfig, $n_slash(routePath, 'start', false) + (path ? '.' + path : ''), defaultValue)
|
|
1309
|
+
return $n_cloneDeep($n_isFunction(res) ? res() : res)
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* 获取表格浏览数据
|
|
1314
|
+
*/
|
|
1315
|
+
async function getViewData(options) {
|
|
1316
|
+
|
|
1317
|
+
const {
|
|
1318
|
+
url,
|
|
1319
|
+
field,
|
|
1320
|
+
value: httpValue,
|
|
1321
|
+
data: httpData,
|
|
1322
|
+
} = Object.assign({
|
|
1323
|
+
field: 'id',
|
|
1324
|
+
value: [],
|
|
1325
|
+
data: {},
|
|
1326
|
+
}, options)
|
|
1327
|
+
|
|
1328
|
+
const _isValidValue = $n_isValidValue(httpValue)
|
|
1329
|
+
const hasSearch = $n_has(httpData, 'n_search')
|
|
1330
|
+
if (_isValidValue || $n_isValidArray(httpValue) || hasSearch) {
|
|
1331
|
+
|
|
1332
|
+
const n_search = []
|
|
1333
|
+
let per_page = 1
|
|
1334
|
+
|
|
1335
|
+
if (! hasSearch) {
|
|
1336
|
+
|
|
1337
|
+
let value
|
|
1338
|
+
let compare
|
|
1339
|
+
|
|
1340
|
+
if (_isValidValue) {
|
|
1341
|
+
compare = dicts.SEARCH_COMPARE_TYPE__EQUAL
|
|
1342
|
+
value = httpValue
|
|
1343
|
+
} else {
|
|
1344
|
+
compare = dicts.SEARCH_COMPARE_TYPE__IN
|
|
1345
|
+
value = $n_uniq(httpValue)
|
|
1346
|
+
per_page = value.length
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
n_search.push({
|
|
1350
|
+
field,
|
|
1351
|
+
compare,
|
|
1352
|
+
value,
|
|
1353
|
+
})
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
const { status, data } = await $n_http({
|
|
1357
|
+
url,
|
|
1358
|
+
// 头部请求
|
|
1359
|
+
headers: {
|
|
1360
|
+
// 添加头部查看请求
|
|
1361
|
+
Pview: 1,
|
|
1362
|
+
},
|
|
1363
|
+
data: Object.assign({
|
|
1364
|
+
n_search,
|
|
1365
|
+
page: 1,
|
|
1366
|
+
per_page,
|
|
1367
|
+
}, httpData),
|
|
1368
|
+
})
|
|
1369
|
+
|
|
1370
|
+
if (
|
|
1371
|
+
status
|
|
1372
|
+
&& $n_isValidArray($n_get(data, 'rows'))
|
|
1373
|
+
) {
|
|
1374
|
+
return data.rows
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
return []
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* 业务表格
|
|
1383
|
+
*/
|
|
1384
|
+
const $table = {
|
|
1385
|
+
// 创建表格
|
|
1386
|
+
create,
|
|
1387
|
+
// 获取表格配置
|
|
1388
|
+
config,
|
|
1389
|
+
|
|
1390
|
+
// 获取表格浏览数据
|
|
1391
|
+
getViewData,
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
export default $table
|