@netang/quasar 0.1.16 → 0.1.18
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/_docs/docs/utils/table.md +1 -0
- package/components/field-table/index.vue +2 -2
- package/components/private/edit-power-data/index.vue +1 -1
- package/components/private/table-visible-columns-button/index.vue +109 -109
- package/components/table/index.vue +13 -13
- package/package.json +1 -1
- package/utils/$table.js +370 -200
- package/utils/$tree.js +712 -713
package/utils/$table.js
CHANGED
|
@@ -65,8 +65,8 @@ function create(options) {
|
|
|
65
65
|
// 每页显示行数选项
|
|
66
66
|
const rowsPerPageOptions = [30, 40, 50, 100, 200, 500, 1000]
|
|
67
67
|
|
|
68
|
-
//
|
|
69
|
-
const
|
|
68
|
+
// 原始参数
|
|
69
|
+
const rawOptions = {
|
|
70
70
|
// 路由路径
|
|
71
71
|
path: '',
|
|
72
72
|
// 请求地址(默认为 path)
|
|
@@ -96,7 +96,7 @@ function create(options) {
|
|
|
96
96
|
// 页码
|
|
97
97
|
page: 1,
|
|
98
98
|
// 每页的数据条数
|
|
99
|
-
rowsPerPage: rowsPerPageOptions[0],
|
|
99
|
+
rowsPerPage: $n_has(options, 'rowsPerPageOptions') ? options.rowsPerPageOptions[0] : rowsPerPageOptions[0],
|
|
100
100
|
// 数据总数(服务器返回)
|
|
101
101
|
rowsNumber: 1,
|
|
102
102
|
// 排序字段
|
|
@@ -132,195 +132,367 @@ function create(options) {
|
|
|
132
132
|
rowClick: null,
|
|
133
133
|
// 双击表格行事件
|
|
134
134
|
rowDblClick: null,
|
|
135
|
-
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let o
|
|
138
|
+
let $power
|
|
139
|
+
let hasPowr
|
|
140
|
+
let $render
|
|
141
|
+
let $route
|
|
142
|
+
let hasPowerBtns
|
|
143
|
+
let tableSelected
|
|
144
|
+
let isCache
|
|
145
|
+
let cacheName
|
|
146
|
+
let tableColumns
|
|
147
|
+
let tableImgNames
|
|
148
|
+
|
|
149
|
+
// 获取可见列缓存
|
|
150
|
+
let visibleColumnsCache
|
|
151
|
+
// 表格可见列
|
|
152
|
+
let tableVisibleColumns
|
|
153
|
+
// 表格加载状态
|
|
154
|
+
let tableLoading
|
|
155
|
+
// 表格行数据
|
|
156
|
+
let tableRows
|
|
157
|
+
// 表格翻页参数
|
|
158
|
+
let tablePagination
|
|
159
|
+
// 表格宫格
|
|
160
|
+
let tableGrid
|
|
161
|
+
// 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
|
|
162
|
+
let tableRequestQuery
|
|
163
|
+
// 是否请求表格合计
|
|
164
|
+
let isRequestSummary
|
|
165
|
+
// 表格合计
|
|
166
|
+
let tableSummary
|
|
167
|
+
// 表格选择类型
|
|
168
|
+
let tableSelection
|
|
169
|
+
// 表格分隔栏
|
|
170
|
+
let tableSeparator
|
|
171
|
+
|
|
172
|
+
// 原始参数
|
|
173
|
+
let rawQuery
|
|
174
|
+
// 原始表格搜索参数
|
|
175
|
+
let rawSearchOptions
|
|
176
|
+
// 原始表格搜索值(空表格搜索值, 用于搜索重置)
|
|
177
|
+
let rawTableSearchValue
|
|
178
|
+
// 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
179
|
+
let firstTableSearchValue
|
|
180
|
+
|
|
181
|
+
// 表格搜索数据值
|
|
182
|
+
let tableSearchValue
|
|
183
|
+
// 表格搜索参数
|
|
184
|
+
let tableSearchOptions
|
|
185
|
+
// 是否已加载
|
|
186
|
+
let _isTableLoaded
|
|
187
|
+
|
|
188
|
+
// 是否已生成数据
|
|
189
|
+
let _isCreated = false
|
|
136
190
|
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
191
|
+
// 创建表格
|
|
192
|
+
reCreate(options)
|
|
193
|
+
|
|
194
|
+
// 已生成数据
|
|
195
|
+
_isCreated = true
|
|
196
|
+
|
|
197
|
+
// ==========【方法】================================================================================================
|
|
140
198
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
199
|
+
/**
|
|
200
|
+
* 重新创建表格
|
|
201
|
+
*/
|
|
202
|
+
function reCreate(options) {
|
|
203
|
+
|
|
204
|
+
// 获取参数
|
|
205
|
+
o = $n_merge({}, rawOptions, options)
|
|
206
|
+
|
|
207
|
+
// 获取权限注入
|
|
208
|
+
$power = $n_has(options, '$power') ? options.$power : (_isCreated ? $power : inject(NPowerKey))
|
|
209
|
+
hasPowr = !! $power
|
|
210
|
+
|
|
211
|
+
// 获取渲染注入
|
|
212
|
+
$render = $n_has(options, '$render') ? options.$render : (_isCreated ? $render : inject(NRenderKey))
|
|
213
|
+
if (!! $render) {
|
|
214
|
+
// 如果有表格传参, 则合并参数
|
|
215
|
+
const tableProps = $n_get($render, 'props.tableProps')
|
|
216
|
+
if ($n_isValidObject(tableProps)) {
|
|
217
|
+
$n_merge(o, tableProps)
|
|
218
|
+
}
|
|
148
219
|
}
|
|
149
|
-
}
|
|
150
220
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
221
|
+
// 获取选择类型(默认 single)
|
|
222
|
+
if (! $n_has(o, 'selection') || ! $n_isValidString(o.selection)) {
|
|
223
|
+
if (hasPowr) {
|
|
224
|
+
o.selection = $n_get($power, 'powerPage.data.selection')
|
|
225
|
+
if (! $n_isValidString(o.selection)) {
|
|
226
|
+
o.selection = 'single'
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
156
229
|
o.selection = 'single'
|
|
157
230
|
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 获取权限路由
|
|
234
|
+
$route = $n_isValidString(o.path) ?
|
|
235
|
+
// 如果为自定义路由
|
|
236
|
+
$n_router.resolve({
|
|
237
|
+
path: o.path,
|
|
238
|
+
query: $n_isValidObject(o.query) ? o.query : {},
|
|
239
|
+
})
|
|
240
|
+
// 否则获取当前路由
|
|
241
|
+
: (hasPowr ? $power.getRoute() : $n_router.getRoute())
|
|
242
|
+
|
|
243
|
+
// 是否有权限按钮
|
|
244
|
+
const _hasPowerBtns = hasPowr ? $power.powerBtns.value.length : false
|
|
245
|
+
if (_isCreated) {
|
|
246
|
+
hasPowerBtns.value = _hasPowerBtns
|
|
158
247
|
} else {
|
|
159
|
-
|
|
248
|
+
hasPowerBtns = ref(_hasPowerBtns)
|
|
160
249
|
}
|
|
161
|
-
}
|
|
162
250
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
251
|
+
// 表格已选数据
|
|
252
|
+
if (hasPowr) {
|
|
253
|
+
tableSelected = $power.tableSelected
|
|
254
|
+
} else if (_isCreated) {
|
|
255
|
+
tableSelected.value = []
|
|
256
|
+
} else {
|
|
257
|
+
tableSelected = ref([])
|
|
258
|
+
}
|
|
259
|
+
if ($n_isValidArray(o.selected)) {
|
|
260
|
+
tableSelected.value = o.selected
|
|
261
|
+
}
|
|
172
262
|
|
|
173
|
-
|
|
174
|
-
|
|
263
|
+
// 是否开启缓存
|
|
264
|
+
isCache = !! o.cache
|
|
175
265
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if ($n_isValidArray(o.selected)) {
|
|
179
|
-
tableSelected.value = o.selected
|
|
180
|
-
}
|
|
266
|
+
// 缓存名
|
|
267
|
+
cacheName = $route.path ? $route.path : ($n_isValidString(o.cache) ? o.cache : '')
|
|
181
268
|
|
|
182
|
-
|
|
183
|
-
|
|
269
|
+
// 表格列
|
|
270
|
+
const _tableColumns = []
|
|
184
271
|
|
|
185
|
-
|
|
186
|
-
|
|
272
|
+
// 如果有权限按钮
|
|
273
|
+
if (hasPowerBtns.value) {
|
|
274
|
+
// 添加操作列
|
|
275
|
+
o.columns.push({
|
|
276
|
+
label: '操作',
|
|
277
|
+
name: 'settings',
|
|
278
|
+
})
|
|
279
|
+
}
|
|
187
280
|
|
|
188
|
-
|
|
189
|
-
|
|
281
|
+
// 表格图片标识数组
|
|
282
|
+
if (_isCreated) {
|
|
283
|
+
tableImgNames.value = []
|
|
284
|
+
} else {
|
|
285
|
+
tableImgNames = ref([])
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 设置表格列数据
|
|
289
|
+
// 设置列参数
|
|
290
|
+
$n_forEach(o.columns, function(item) {
|
|
291
|
+
|
|
292
|
+
if (
|
|
293
|
+
! $n_has(item, 'field')
|
|
294
|
+
&& $n_has(item, 'name')
|
|
295
|
+
) {
|
|
296
|
+
item.field = item.name
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (! $n_has(item, 'align')) {
|
|
300
|
+
item.align = 'left'
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// 是否隐藏
|
|
304
|
+
item.hide = $n_get(item, 'hide') === true
|
|
305
|
+
|
|
306
|
+
// 如果有显示项
|
|
307
|
+
if ($n_get(item, 'visible') !== false) {
|
|
308
|
+
o.visibleColumns.push(item.field)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 如果有时间戳
|
|
312
|
+
if ($n_has(item, 'time')) {
|
|
313
|
+
item.format = val => $n_getTime(val, { format: item.time === true ? `YYYY-MM-DD HH:mm` : item.time }, '-')
|
|
314
|
+
|
|
315
|
+
// 如果有数据字典
|
|
316
|
+
} else if ($n_has(item, 'dict')) {
|
|
317
|
+
item.format = val => $n_dict(item.dict, val)
|
|
318
|
+
|
|
319
|
+
// 如果有图片
|
|
320
|
+
} else if ($n_has(item, 'img') && item.img === true) {
|
|
321
|
+
tableImgNames.value.push(item.name)
|
|
322
|
+
|
|
323
|
+
// 如果有价格
|
|
324
|
+
} else if ($n_has(item, 'price')) {
|
|
325
|
+
item.format = val => $n_price(val)
|
|
326
|
+
}
|
|
190
327
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
328
|
+
// 如果有路由
|
|
329
|
+
if ($n_get(item, 'route')) {
|
|
330
|
+
// 如果该值在当前路由路径中, 则显示
|
|
331
|
+
if ($n_indexOf($route.fullPath, item.route) > -1) {
|
|
332
|
+
_tableColumns.push(item)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
} else {
|
|
336
|
+
_tableColumns.push(item)
|
|
337
|
+
}
|
|
197
338
|
})
|
|
198
|
-
}
|
|
199
339
|
|
|
200
|
-
|
|
201
|
-
|
|
340
|
+
// 获取可见列缓存
|
|
341
|
+
visibleColumnsCache = o.showVisibleColumns && isCache ? $n_storage.get('table:visible_columns:' + cacheName) : []
|
|
202
342
|
|
|
203
|
-
|
|
204
|
-
|
|
343
|
+
// 表格可见列
|
|
344
|
+
const _tableVisibleColumns = Array.isArray(visibleColumnsCache) ? visibleColumnsCache : $n_uniq([...o.visibleColumns])
|
|
205
345
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
&& $n_has(item, 'name')
|
|
209
|
-
) {
|
|
210
|
-
item.field = item.name
|
|
211
|
-
}
|
|
346
|
+
// 表格翻页参数
|
|
347
|
+
const _tablePagination = $route.fullPath ? o.pagination : {}
|
|
212
348
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
349
|
+
// 表格宫格
|
|
350
|
+
const _tableGrid = o.showGrid && isCache ? $n_storage.get('table:grid:' + cacheName) === true : false
|
|
351
|
+
|
|
352
|
+
// 获取原始数据
|
|
353
|
+
const r = getRawData(_tableColumns, Object.assign({}, $route.query), o.searchFromQuery)
|
|
354
|
+
// 原始参数
|
|
355
|
+
rawQuery = r.rawQuery
|
|
356
|
+
// 原始表格搜索参数
|
|
357
|
+
rawSearchOptions = r.rawSearchOptions
|
|
358
|
+
// 原始表格搜索值(空表格搜索值, 用于搜索重置)
|
|
359
|
+
rawTableSearchValue = r.rawTableSearchValue
|
|
360
|
+
// 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
361
|
+
firstTableSearchValue = r.firstTableSearchValue
|
|
216
362
|
|
|
217
|
-
//
|
|
218
|
-
|
|
363
|
+
// 表格搜索数据值
|
|
364
|
+
const _tableSearchValue = $route.fullPath ? firstTableSearchValue : []
|
|
219
365
|
|
|
220
|
-
|
|
221
|
-
if ($n_get(item, 'visible') !== false) {
|
|
222
|
-
o.visibleColumns.push(item.field)
|
|
223
|
-
}
|
|
366
|
+
if (_isCreated) {
|
|
224
367
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
item.format = val => $n_getTime(val, { format: item.time === true ? `YYYY-MM-DD HH:mm` : item.time }, '-')
|
|
368
|
+
// 表格列
|
|
369
|
+
tableColumns.value = _tableColumns
|
|
228
370
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
item.format = val => $n_dict(item.dict, val)
|
|
371
|
+
// 表格可见列
|
|
372
|
+
tableVisibleColumns.value = _tableVisibleColumns
|
|
232
373
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
tableImgNames.value.push(item.name)
|
|
374
|
+
// 表格加载状态
|
|
375
|
+
tableLoading.value = o.loading
|
|
236
376
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
item.format = val => $n_price(val)
|
|
240
|
-
}
|
|
377
|
+
// 表格行数据
|
|
378
|
+
tableRows.value = o.rows
|
|
241
379
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
380
|
+
// 表格翻页参数
|
|
381
|
+
tablePagination.value = _tablePagination
|
|
382
|
+
|
|
383
|
+
// 表格宫格
|
|
384
|
+
tableGrid.value = _tableGrid
|
|
385
|
+
|
|
386
|
+
// 表格合计
|
|
387
|
+
tableSummary.value = null
|
|
388
|
+
|
|
389
|
+
// 表格选择类型
|
|
390
|
+
tableSelection.value = o.selection
|
|
391
|
+
|
|
392
|
+
// 表格分隔栏
|
|
393
|
+
tableSeparator.value = o.separator
|
|
394
|
+
|
|
395
|
+
// 表格搜索数据值
|
|
396
|
+
tableSearchValue.value = _tableSearchValue
|
|
397
|
+
|
|
398
|
+
// 表格搜索参数
|
|
399
|
+
tableSearchOptions.value = null
|
|
248
400
|
|
|
249
401
|
} else {
|
|
250
|
-
tableColumns.push(item)
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
402
|
|
|
254
|
-
|
|
255
|
-
|
|
403
|
+
// 表格列
|
|
404
|
+
tableColumns = ref(_tableColumns)
|
|
256
405
|
|
|
257
|
-
|
|
258
|
-
|
|
406
|
+
// 表格可见列
|
|
407
|
+
tableVisibleColumns = ref(_tableVisibleColumns)
|
|
259
408
|
|
|
260
|
-
|
|
261
|
-
|
|
409
|
+
// 表格加载状态
|
|
410
|
+
tableLoading = ref(o.loading)
|
|
262
411
|
|
|
263
|
-
|
|
264
|
-
|
|
412
|
+
// 表格行数据
|
|
413
|
+
tableRows = ref(o.rows)
|
|
265
414
|
|
|
266
|
-
|
|
267
|
-
|
|
415
|
+
// 表格翻页参数
|
|
416
|
+
tablePagination = ref(_tablePagination)
|
|
268
417
|
|
|
269
|
-
|
|
270
|
-
|
|
418
|
+
// 表格宫格
|
|
419
|
+
tableGrid = ref(_tableGrid)
|
|
271
420
|
|
|
272
|
-
|
|
273
|
-
|
|
421
|
+
// 表格合计
|
|
422
|
+
tableSummary = ref(null)
|
|
274
423
|
|
|
275
|
-
|
|
276
|
-
|
|
424
|
+
// 表格选择类型
|
|
425
|
+
tableSelection = ref(o.selection)
|
|
277
426
|
|
|
278
|
-
|
|
279
|
-
|
|
427
|
+
// 表格分隔栏
|
|
428
|
+
tableSeparator = ref(o.separator)
|
|
280
429
|
|
|
281
|
-
|
|
282
|
-
|
|
430
|
+
// 表格搜索数据值
|
|
431
|
+
tableSearchValue = ref(_tableSearchValue)
|
|
283
432
|
|
|
284
|
-
|
|
285
|
-
|
|
433
|
+
// 表格搜索参数
|
|
434
|
+
tableSearchOptions = ref(null)
|
|
435
|
+
}
|
|
286
436
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
rawQuery,
|
|
290
|
-
// 原始表格搜索参数
|
|
291
|
-
rawSearchOptions,
|
|
292
|
-
// 原始表格搜索值(空表格搜索值, 用于搜索重置)
|
|
293
|
-
rawTableSearchValue,
|
|
294
|
-
// 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
295
|
-
firstTableSearchValue,
|
|
296
|
-
// 表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
297
|
-
} = getRawData(tableColumns, Object.assign({}, $route.query), o.searchFromQuery)
|
|
437
|
+
// 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
|
|
438
|
+
tableRequestQuery = {}
|
|
298
439
|
|
|
299
|
-
|
|
300
|
-
|
|
440
|
+
// 是否请求表格合计
|
|
441
|
+
isRequestSummary = false
|
|
301
442
|
|
|
302
|
-
|
|
303
|
-
|
|
443
|
+
// 是否已加载
|
|
444
|
+
_isTableLoaded = false
|
|
304
445
|
|
|
305
|
-
|
|
306
|
-
|
|
446
|
+
// 如果开启搜索
|
|
447
|
+
if (o.search) {
|
|
448
|
+
// 设置表格搜索参数
|
|
449
|
+
setTableSearchOptions()
|
|
450
|
+
.finally()
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (_isCreated) {
|
|
454
|
+
|
|
455
|
+
// 重新赋值
|
|
456
|
+
Object.assign(resTable, {
|
|
457
|
+
// 当前路由全路径
|
|
458
|
+
routeFullPath: $route.fullPath,
|
|
459
|
+
// 当前路由路径
|
|
460
|
+
routePath: $route.path,
|
|
461
|
+
// 当前路由参数
|
|
462
|
+
routeQuery: $route.query,
|
|
463
|
+
// 表格行唯一键值
|
|
464
|
+
tableRowKey: o.rowKey,
|
|
465
|
+
// 表格每页显示行数选项
|
|
466
|
+
tableRowsPerPageOptions: o.rowsPerPageOptions,
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
if (hasPowr) {
|
|
470
|
+
$power.update(function(data, _data) {
|
|
471
|
+
_data.$table = resTable
|
|
472
|
+
})
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
307
476
|
|
|
308
477
|
// ==========【计算属性】=============================================================================================
|
|
309
478
|
|
|
310
479
|
/**
|
|
311
480
|
* 固定在表格右边的权限按钮列表
|
|
312
481
|
*/
|
|
313
|
-
const tableFixedPowerBtns =
|
|
482
|
+
const tableFixedPowerBtns = computed(function () {
|
|
314
483
|
|
|
315
484
|
const lists = []
|
|
316
485
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
//
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
486
|
+
if (hasPowerBtns.value) {
|
|
487
|
+
|
|
488
|
+
// 先格式化权限按钮列表
|
|
489
|
+
$n_forEach($n_$power.formatBtns($power.powerBtns.value), function(item) {
|
|
490
|
+
// 如果是固定按钮
|
|
491
|
+
if (item.fixed) {
|
|
492
|
+
lists.push(item)
|
|
493
|
+
}
|
|
494
|
+
})
|
|
495
|
+
}
|
|
324
496
|
|
|
325
497
|
return lists
|
|
326
498
|
})
|
|
@@ -328,10 +500,12 @@ function create(options) {
|
|
|
328
500
|
/**
|
|
329
501
|
* 获取权限按钮中可双击的按钮
|
|
330
502
|
*/
|
|
331
|
-
const tableDbClickPowerBtn =
|
|
503
|
+
const tableDbClickPowerBtn = computed(function () {
|
|
332
504
|
if (
|
|
505
|
+
// 如果有权限按钮
|
|
506
|
+
hasPowerBtns.value
|
|
333
507
|
// 非手机模式
|
|
334
|
-
! $q.platform.is.mobile
|
|
508
|
+
&& ! $q.platform.is.mobile
|
|
335
509
|
// 有权限列表
|
|
336
510
|
&& $n_isValidArray($power.powerBtns.value)
|
|
337
511
|
) {
|
|
@@ -352,72 +526,72 @@ function create(options) {
|
|
|
352
526
|
|
|
353
527
|
// ==========【监听数据】=============================================================================================
|
|
354
528
|
|
|
355
|
-
|
|
356
|
-
* 监听表格宫格模式
|
|
357
|
-
*/
|
|
358
|
-
if (o.showGrid && isCache) {
|
|
359
|
-
watch(tableGrid, function(val) {
|
|
529
|
+
// #if ! IS_DEV
|
|
360
530
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
531
|
+
/**
|
|
532
|
+
* 监听表格宫格模式
|
|
533
|
+
*/
|
|
534
|
+
watch(tableGrid, function(val) {
|
|
535
|
+
if (o.showGrid && isCache) {
|
|
536
|
+
// 设置宫格模式缓存(永久缓存)
|
|
537
|
+
$n_storage.set('table:grid:' + cacheName, val, 0)
|
|
538
|
+
}
|
|
365
539
|
})
|
|
366
|
-
}
|
|
367
540
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (o.showVisibleColumns && isCache) {
|
|
541
|
+
/**
|
|
542
|
+
* 监听表格可见列
|
|
543
|
+
*/
|
|
372
544
|
watch(tableVisibleColumns, function(val) {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
// #endif
|
|
545
|
+
if (o.showVisibleColumns && isCache) {
|
|
546
|
+
// 设置监听表格可见列缓存(永久缓存)
|
|
547
|
+
$n_storage.set('table:visible_columns:' + cacheName, val, 0)
|
|
548
|
+
}
|
|
378
549
|
})
|
|
379
|
-
|
|
550
|
+
|
|
551
|
+
// #endif
|
|
380
552
|
|
|
381
553
|
/**
|
|
382
554
|
* 监听固定在右边的权限按钮列表
|
|
383
555
|
*/
|
|
384
|
-
|
|
385
|
-
watch(tableFixedPowerBtns, function (lists) {
|
|
386
|
-
|
|
387
|
-
const index = $n_indexOf(tableVisibleColumns.value, 'settings')
|
|
556
|
+
watch(tableFixedPowerBtns, function (lists) {
|
|
388
557
|
|
|
389
|
-
|
|
390
|
-
|
|
558
|
+
if (! hasPowerBtns.value) {
|
|
559
|
+
return
|
|
560
|
+
}
|
|
391
561
|
|
|
392
|
-
|
|
393
|
-
if (index === -1) {
|
|
562
|
+
const index = $n_indexOf(tableVisibleColumns.value, 'settings')
|
|
394
563
|
|
|
395
|
-
|
|
396
|
-
|
|
564
|
+
// 如果有固定在右边的权限按钮列表
|
|
565
|
+
if ($n_isValidArray(lists)) {
|
|
397
566
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
567
|
+
// 如果设置不在可见列中
|
|
568
|
+
if (index === -1) {
|
|
401
569
|
|
|
402
|
-
//
|
|
403
|
-
|
|
570
|
+
// 如果非手机模式
|
|
571
|
+
if (! $q.platform.is.mobile) {
|
|
404
572
|
|
|
405
|
-
//
|
|
406
|
-
tableVisibleColumns.value.
|
|
573
|
+
// 则将设置加入可见列中
|
|
574
|
+
tableVisibleColumns.value.push('settings')
|
|
407
575
|
}
|
|
408
576
|
|
|
409
|
-
//
|
|
410
|
-
} else if (
|
|
577
|
+
// 否则在可见列中 && 如果是手机模式
|
|
578
|
+
} else if ($q.platform.is.mobile) {
|
|
411
579
|
|
|
412
580
|
// 则将设置从可见列中删除
|
|
413
581
|
tableVisibleColumns.value.splice(index, 1)
|
|
414
582
|
}
|
|
415
583
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
584
|
+
// 否则如果设置在可见列中
|
|
585
|
+
} else if (index > -1) {
|
|
586
|
+
|
|
587
|
+
// 则将设置从可见列中删除
|
|
588
|
+
tableVisibleColumns.value.splice(index, 1)
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
}, {
|
|
592
|
+
// 立即执行
|
|
593
|
+
immediate: true,
|
|
594
|
+
})
|
|
421
595
|
|
|
422
596
|
// ==========【方法】================================================================================================
|
|
423
597
|
|
|
@@ -885,13 +1059,6 @@ function create(options) {
|
|
|
885
1059
|
return !! formatValue(rawSearchOptions, tableSearchValue.value).length
|
|
886
1060
|
}
|
|
887
1061
|
|
|
888
|
-
// 如果开启搜索
|
|
889
|
-
if (o.search) {
|
|
890
|
-
// 设置表格搜索参数
|
|
891
|
-
setTableSearchOptions()
|
|
892
|
-
.finally()
|
|
893
|
-
}
|
|
894
|
-
|
|
895
1062
|
// ==========【返回】=================================================================================================
|
|
896
1063
|
|
|
897
1064
|
const resTable = {
|
|
@@ -901,21 +1068,17 @@ function create(options) {
|
|
|
901
1068
|
routePath: $route.path,
|
|
902
1069
|
// 当前路由参数
|
|
903
1070
|
routeQuery: $route.query,
|
|
904
|
-
//
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1071
|
+
// 表格行唯一键值
|
|
1072
|
+
tableRowKey: o.rowKey,
|
|
1073
|
+
// 表格每页显示行数选项
|
|
1074
|
+
tableRowsPerPageOptions: o.rowsPerPageOptions,
|
|
908
1075
|
|
|
909
1076
|
// 表格加载状态
|
|
910
1077
|
tableLoading,
|
|
911
|
-
// 表格行唯一键值
|
|
912
|
-
tableRowKey: o.rowKey,
|
|
913
1078
|
// 表格选择类型
|
|
914
1079
|
tableSelection,
|
|
915
1080
|
// 表格分隔栏
|
|
916
1081
|
tableSeparator,
|
|
917
|
-
// 表格每页显示行数选项
|
|
918
|
-
tableRowsPerPageOptions: rowsPerPageOptions,
|
|
919
1082
|
// 表格列数据(对象数组)
|
|
920
1083
|
tableColumns,
|
|
921
1084
|
// 表格可见列
|
|
@@ -967,6 +1130,13 @@ function create(options) {
|
|
|
967
1130
|
|
|
968
1131
|
// 是否有表格搜索值
|
|
969
1132
|
hasTableSearchValue,
|
|
1133
|
+
|
|
1134
|
+
// 获取当前路由
|
|
1135
|
+
getRoute() {
|
|
1136
|
+
return $route
|
|
1137
|
+
},
|
|
1138
|
+
// 重新创建表格
|
|
1139
|
+
reCreate,
|
|
970
1140
|
}
|
|
971
1141
|
|
|
972
1142
|
if (hasPowr) {
|