@netang/quasar 0.0.53 → 0.0.55
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/.vuepress/client.js +39 -0
- package/_docs/docs/.vuepress/components/test.vue +23 -0
- package/_docs/docs/.vuepress/config.js +40 -0
- package/_docs/docs/.vuepress/configs/index.js +2 -0
- package/_docs/docs/.vuepress/configs/navbar/index.js +1 -0
- package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -0
- package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -0
- package/_docs/docs/.vuepress/configs/sidebar/zh.js +20 -0
- package/_docs/docs/.vuepress/public/css/index.css +3 -0
- package/_docs/docs/.vuepress/styles/index.scss +3 -0
- package/_docs/docs/components/field-table.md +63 -0
- package/_docs/docs/components/field-tree.md +1 -0
- package/{docs → _docs}/docs/index.md +0 -0
- package/{docs → _docs}/docs/utils/alert.md +0 -0
- package/{docs → _docs}/docs/utils/confirm.md +0 -0
- package/_docs/docs/utils/index.md +1 -0
- package/_docs/package.json +17 -0
- package/components/column-title/index.vue +2 -2
- package/components/data/index.vue +20 -23
- package/components/dialog/index.vue +26 -12
- package/components/dialog-table/index.vue +4 -2
- package/components/dragger/index.vue +3 -2
- package/components/drawer/index.vue +16 -9
- package/components/editor-code/index.vue +12 -5
- package/components/empty/index.vue +16 -1
- package/components/field-date/index.vue +48 -36
- package/components/field-table/index.vue +69 -43
- package/components/field-text/index.vue +6 -2
- package/components/field-tree/index.vue +40 -22
- package/components/input-number/index.vue +5 -4
- package/components/list-menu/index.vue +14 -2
- package/components/power-page/index.vue +10 -0
- package/components/private/components/index.js +7 -2
- package/components/private/components/move-to-tree/index.vue +7 -3
- package/components/private/edit-power-data/index.vue +92 -52
- package/components/private/table-visible-columns-button/index.vue +6 -2
- package/components/render/index.vue +21 -7
- package/components/search/index.vue +30 -2
- package/components/search-item/index.vue +24 -8
- package/components/select/index.vue +5 -2
- package/components/splitter/index.vue +13 -9
- package/components/table/index.vue +32 -5
- package/components/table-pagination/index.vue +0 -1
- package/components/table-splitter/index.vue +22 -3
- package/components/table-summary/index.vue +10 -3
- package/components/thumbnail/index.vue +16 -6
- package/components/toolbar/index.vue +0 -2
- package/components/uploader/index.vue +5 -2
- package/components/uploader-query/index.vue +48 -27
- package/components/value-format/index.vue +19 -12
- package/configs/area3.js +1 -0
- package/docs/404.html +33 -0
- package/docs/assets/404.html-60b35caa.js +1 -0
- package/docs/assets/404.html-d1e63d77.js +1 -0
- package/docs/assets/alert.html-568d4e94.js +1 -0
- package/docs/assets/alert.html-f5dbc3e9.js +1 -0
- package/docs/assets/app-8c3ae4de.js +6 -0
- package/docs/assets/back-to-top-8efcbe56.svg +1 -0
- package/docs/assets/confirm.html-7a1566f6.js +1 -0
- package/docs/assets/confirm.html-96f1b004.js +1 -0
- package/docs/assets/field-table.html-68d610b0.js +1 -0
- package/docs/assets/field-table.html-86cc3511.js +1 -0
- package/docs/assets/field-tree.html-45410c3c.js +1 -0
- package/docs/assets/field-tree.html-c98ac993.js +1 -0
- package/docs/assets/framework-204010b2.js +5 -0
- package/docs/assets/index.html-1695dd7c.js +1 -0
- package/docs/assets/index.html-65a4aa67.js +1 -0
- package/docs/assets/style-ac5a9aa6.css +1 -0
- package/docs/components/field-table.html +33 -0
- package/docs/components/field-tree.html +33 -0
- package/docs/index.html +33 -0
- package/docs/utils/alert.html +33 -0
- package/docs/utils/confirm.html +33 -0
- package/package.json +1 -1
- package/package2.json +30 -0
- package/store/index.js +3 -20
- package/utils/alert.js +3 -1
- package/utils/area.js +27 -14
- package/utils/arr.js +6 -2
- package/utils/auth.js +40 -35
- package/utils/bus.js +1 -1
- package/utils/config.js +42 -15
- package/utils/{confrim.js → confirm.js} +1 -1
- package/utils/copy.js +18 -0
- package/utils/dialog.js +7 -3
- package/utils/dict.js +5 -28
- package/utils/dictOptions.js +24 -0
- package/utils/form.js +6 -2
- package/utils/getData.js +21 -9
- package/utils/getFile.js +11 -5
- package/utils/getImage.js +23 -12
- package/utils/getTime.js +9 -4
- package/utils/index.js +61 -0
- package/utils/loading.js +3 -1
- package/utils/notify.js +1 -1
- package/utils/power.js +164 -118
- package/utils/previewImage.js +4 -2
- package/utils/price.js +12 -3
- package/utils/rule.js +5 -9
- package/utils/ruleValid.js +10 -0
- package/utils/search.js +81 -50
- package/utils/table.js +119 -87
- package/utils/timestamp.js +2 -2
- package/utils/toast.js +1 -1
- package/utils/tree.js +69 -46
- package/utils/uploader/qiniu.js +31 -15
- package/utils/uploader.js +87 -56
- package/utils/useAuth.js +12 -5
- package/utils/useRouter.js +16 -5
- package/utils/useUploader.js +0 -5
- package/docs/docs/.vuepress/config.js +0 -32
- package/docs/docs/components/field-table.md +0 -1
- package/docs/docs/components/field-tree.md +0 -1
- package/docs/package.json +0 -11
- package/utils/http.js +0 -251
package/utils/table.js
CHANGED
|
@@ -1,16 +1,47 @@
|
|
|
1
1
|
import { ref, computed, provide, inject, watch } from 'vue'
|
|
2
2
|
import { date, useQuasar } from 'quasar'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
|
|
14
|
+
import $n_router from '@netang/vue-utils/router'
|
|
15
|
+
|
|
16
|
+
import $n_forEach from '@netang/utils/forEach'
|
|
17
|
+
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
18
|
+
import $n_isValidString from '@netang/utils/isValidString'
|
|
19
|
+
import $n_indexOf from '@netang/utils/indexOf'
|
|
20
|
+
import $n_storage from '@netang/utils/storage'
|
|
21
|
+
|
|
22
|
+
import $n_isRequired from '@netang/utils/isRequired'
|
|
23
|
+
import $n_forIn from '@netang/utils/forIn'
|
|
24
|
+
import $n_runAsync from '@netang/utils/runAsync'
|
|
25
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
26
|
+
import $n_isValidValue from '@netang/utils/isValidValue'
|
|
27
|
+
import $n_toDate from '@netang/utils/toDate'
|
|
28
|
+
import $n_slash from '@netang/utils/slash'
|
|
29
|
+
import $n_http from '@netang/utils/http'
|
|
30
|
+
|
|
31
|
+
import $n_search, { setItemValue } from './search'
|
|
32
|
+
import $n_power from './power'
|
|
33
|
+
import $n_dict from './dict'
|
|
34
|
+
import $n_price from './price'
|
|
35
|
+
|
|
36
|
+
import { configs } from './config'
|
|
11
37
|
|
|
12
38
|
import { NRenderKey, NPowerKey, NTableKey } from './symbols'
|
|
13
39
|
|
|
40
|
+
const {
|
|
41
|
+
// 表格配置
|
|
42
|
+
tablesConfig,
|
|
43
|
+
} = configs
|
|
44
|
+
|
|
14
45
|
/**
|
|
15
46
|
* 创建表格
|
|
16
47
|
*/
|
|
@@ -23,10 +54,9 @@ function create(params) {
|
|
|
23
54
|
|
|
24
55
|
// 每页显示行数选项
|
|
25
56
|
const rowsPerPageOptions = [30, 40, 50, 100, 200, 500, 1000]
|
|
26
|
-
// const rowsPerPageOptions = [3, 40, 50, 100, 200, 500, 1000]
|
|
27
57
|
|
|
28
58
|
// 获取参数
|
|
29
|
-
const o = $
|
|
59
|
+
const o = $n_merge({
|
|
30
60
|
// 路由路径
|
|
31
61
|
path: '',
|
|
32
62
|
// 路由参数
|
|
@@ -98,21 +128,21 @@ function create(params) {
|
|
|
98
128
|
// 如果有渲染注入
|
|
99
129
|
if (!! $render) {
|
|
100
130
|
// 如果有表格传参, 则合并参数
|
|
101
|
-
const tableProps = $
|
|
102
|
-
if ($
|
|
103
|
-
$
|
|
131
|
+
const tableProps = $n_get($render, 'props.tableProps')
|
|
132
|
+
if ($n_isValidObject(tableProps)) {
|
|
133
|
+
$n_merge(o, tableProps)
|
|
104
134
|
}
|
|
105
135
|
}
|
|
106
136
|
|
|
107
137
|
// 获取权限注入
|
|
108
|
-
const $power = $
|
|
138
|
+
const $power = $n_has(params, '$power') ? params.$power : inject(NPowerKey)
|
|
109
139
|
const hasPowr = !! $power
|
|
110
140
|
|
|
111
141
|
// 获取选择类型(默认 single)
|
|
112
|
-
if (! $
|
|
142
|
+
if (! $n_has(o, 'selection') || ! $n_isValidString(o.selection)) {
|
|
113
143
|
if (hasPowr) {
|
|
114
|
-
o.selection = $
|
|
115
|
-
if (! $
|
|
144
|
+
o.selection = $n_get($power, 'powerPage.data.selection')
|
|
145
|
+
if (! $n_isValidString(o.selection)) {
|
|
116
146
|
o.selection = 'single'
|
|
117
147
|
}
|
|
118
148
|
} else {
|
|
@@ -121,21 +151,21 @@ function create(params) {
|
|
|
121
151
|
}
|
|
122
152
|
|
|
123
153
|
// 获取权限路由
|
|
124
|
-
const $route = $
|
|
154
|
+
const $route = $n_isValidString(o.path) ?
|
|
125
155
|
// 如果为自定义路由
|
|
126
|
-
$
|
|
156
|
+
$n_router.resolve({
|
|
127
157
|
path: o.path,
|
|
128
|
-
query: $
|
|
158
|
+
query: $n_isValidObject(o.query) ? o.query : {},
|
|
129
159
|
})
|
|
130
160
|
// 否则获取当前路由
|
|
131
|
-
: (hasPowr ? $power.getRoute() : $
|
|
161
|
+
: (hasPowr ? $power.getRoute() : $n_router.getRoute())
|
|
132
162
|
|
|
133
163
|
// 是否有权限按钮
|
|
134
164
|
const hasPowerBtns = hasPowr ? $power.powerBtns.value.length : false
|
|
135
165
|
|
|
136
166
|
// 表格已选数据
|
|
137
167
|
const tableSelected = hasPowr ? $power.tableSelected : ref([])
|
|
138
|
-
if ($
|
|
168
|
+
if ($n_isValidArray(o.selected)) {
|
|
139
169
|
tableSelected.value = o.selected
|
|
140
170
|
}
|
|
141
171
|
|
|
@@ -143,7 +173,7 @@ function create(params) {
|
|
|
143
173
|
const isCache = !! o.cache
|
|
144
174
|
|
|
145
175
|
// 缓存名
|
|
146
|
-
const cacheName = $route.fullPath ? $route.fullPath : ($
|
|
176
|
+
const cacheName = $route.fullPath ? $route.fullPath : ($n_isValidString(o.cache) ? o.cache : '')
|
|
147
177
|
|
|
148
178
|
// 表格列
|
|
149
179
|
const tableColumns = []
|
|
@@ -161,48 +191,48 @@ function create(params) {
|
|
|
161
191
|
const tableImgNames = ref([])
|
|
162
192
|
|
|
163
193
|
// 设置列参数
|
|
164
|
-
$
|
|
194
|
+
$n_forEach(o.columns, function(item) {
|
|
165
195
|
|
|
166
196
|
if (
|
|
167
|
-
! $
|
|
168
|
-
&& $
|
|
197
|
+
! $n_has(item, 'field')
|
|
198
|
+
&& $n_has(item, 'name')
|
|
169
199
|
) {
|
|
170
200
|
item.field = item.name
|
|
171
201
|
}
|
|
172
202
|
|
|
173
|
-
if (! $
|
|
203
|
+
if (! $n_has(item, 'align')) {
|
|
174
204
|
item.align = 'left'
|
|
175
205
|
}
|
|
176
206
|
|
|
177
207
|
// 是否隐藏
|
|
178
|
-
item.hide = $
|
|
208
|
+
item.hide = $n_get(item, 'hide') === true
|
|
179
209
|
|
|
180
210
|
// 如果有显示项
|
|
181
|
-
if ($
|
|
211
|
+
if ($n_get(item, 'visible') !== false) {
|
|
182
212
|
o.visibleColumns.push(item.field)
|
|
183
213
|
}
|
|
184
214
|
|
|
185
215
|
// 如果有时间戳
|
|
186
|
-
if ($
|
|
187
|
-
item.format = val => date.formatDate($
|
|
216
|
+
if ($n_has(item, 'time')) {
|
|
217
|
+
item.format = val => date.formatDate($n_toDate(val), item.time === true ? `YYYY-MM-DD HH:mm` : item.time)
|
|
188
218
|
|
|
189
219
|
// 如果有数据字典
|
|
190
|
-
} else if ($
|
|
191
|
-
item.format = val => $
|
|
220
|
+
} else if ($n_has(item, 'dict')) {
|
|
221
|
+
item.format = val => $n_dict(item.dict, val)
|
|
192
222
|
|
|
193
223
|
// 如果有图片
|
|
194
|
-
} else if ($
|
|
224
|
+
} else if ($n_has(item, 'img') && item.img === true) {
|
|
195
225
|
tableImgNames.value.push(item.name)
|
|
196
226
|
|
|
197
227
|
// 如果有价格
|
|
198
|
-
} else if ($
|
|
199
|
-
item.format = val => $
|
|
228
|
+
} else if ($n_has(item, 'price')) {
|
|
229
|
+
item.format = val => $n_price(val)
|
|
200
230
|
}
|
|
201
231
|
|
|
202
232
|
// 如果有路由
|
|
203
|
-
if ($
|
|
233
|
+
if ($n_get(item, 'route')) {
|
|
204
234
|
// 如果该值在当前路由路径中, 则显示
|
|
205
|
-
if ($
|
|
235
|
+
if ($n_indexOf($route.fullPath, item.route) > -1) {
|
|
206
236
|
tableColumns.push(item)
|
|
207
237
|
}
|
|
208
238
|
|
|
@@ -212,10 +242,10 @@ function create(params) {
|
|
|
212
242
|
})
|
|
213
243
|
|
|
214
244
|
// 获取可见列缓存
|
|
215
|
-
const visibleColumnsCache = o.showVisibleColumns && isCache ? $
|
|
245
|
+
const visibleColumnsCache = o.showVisibleColumns && isCache ? $n_storage.get('table:visible_columns:' + cacheName) : []
|
|
216
246
|
|
|
217
247
|
// 表格可见列
|
|
218
|
-
const tableVisibleColumns = ref(Array.isArray(visibleColumnsCache) ? visibleColumnsCache : $
|
|
248
|
+
const tableVisibleColumns = ref(Array.isArray(visibleColumnsCache) ? visibleColumnsCache : $n_uniq([...o.visibleColumns]))
|
|
219
249
|
|
|
220
250
|
// 表格加载状态
|
|
221
251
|
const tableLoading = ref(o.loading)
|
|
@@ -227,7 +257,7 @@ function create(params) {
|
|
|
227
257
|
const tablePagination = ref($route.fullPath ? o.pagination : {})
|
|
228
258
|
|
|
229
259
|
// 表格宫格
|
|
230
|
-
const tableGrid = ref(o.showGrid && isCache ? $
|
|
260
|
+
const tableGrid = ref(o.showGrid && isCache ? $n_storage.get('table:grid:' + cacheName) === true : false)
|
|
231
261
|
|
|
232
262
|
// 表格请求参数(将表格传参中的搜索参数剥离掉, 剩下的直接当做参数传递给服务器)
|
|
233
263
|
let tableRequestQuery = {}
|
|
@@ -254,7 +284,7 @@ function create(params) {
|
|
|
254
284
|
// 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
255
285
|
firstTableSearchValue,
|
|
256
286
|
// 表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
|
|
257
|
-
} = $
|
|
287
|
+
} = $n_search.getRawData(tableColumns, Object.assign({}, $route.query), o.searchFromQuery)
|
|
258
288
|
|
|
259
289
|
// 表格搜索数据值
|
|
260
290
|
const tableSearchValue = ref($route.fullPath ? firstTableSearchValue : [])
|
|
@@ -275,7 +305,7 @@ function create(params) {
|
|
|
275
305
|
const lists = []
|
|
276
306
|
|
|
277
307
|
// 先格式化权限按钮列表
|
|
278
|
-
$
|
|
308
|
+
$n_forEach($n_power.formatBtns($power.powerBtns.value), function(item) {
|
|
279
309
|
|
|
280
310
|
// 如果是固定按钮
|
|
281
311
|
if (item.fixed) {
|
|
@@ -294,10 +324,10 @@ function create(params) {
|
|
|
294
324
|
// 非手机模式
|
|
295
325
|
! $q.platform.is.mobile
|
|
296
326
|
// 有权限列表
|
|
297
|
-
&& $
|
|
327
|
+
&& $n_isValidArray($power.powerBtns.value)
|
|
298
328
|
) {
|
|
299
329
|
for (const item of $power.powerBtns.value) {
|
|
300
|
-
if ($
|
|
330
|
+
if ($n_has(item, 'data.dbclick') === true) {
|
|
301
331
|
return item
|
|
302
332
|
}
|
|
303
333
|
}
|
|
@@ -308,7 +338,7 @@ function create(params) {
|
|
|
308
338
|
* 是否显示固定在右边的权限按钮列表
|
|
309
339
|
*/
|
|
310
340
|
const showTableFixed = computed(function () {
|
|
311
|
-
return $
|
|
341
|
+
return $n_indexOf(tableVisibleColumns.value, 'settings') > -1
|
|
312
342
|
})
|
|
313
343
|
|
|
314
344
|
// ==========【监听数据】=============================================================================================
|
|
@@ -321,7 +351,7 @@ function create(params) {
|
|
|
321
351
|
|
|
322
352
|
// 设置宫格模式缓存(永久缓存)
|
|
323
353
|
// #if ! IS_DEV
|
|
324
|
-
$
|
|
354
|
+
$n_storage.set('table:grid:' + cacheName, val, 0)
|
|
325
355
|
// #endif
|
|
326
356
|
})
|
|
327
357
|
}
|
|
@@ -334,7 +364,7 @@ function create(params) {
|
|
|
334
364
|
|
|
335
365
|
// 设置可见列缓存(永久缓存)
|
|
336
366
|
// #if ! IS_DEV
|
|
337
|
-
$
|
|
367
|
+
$n_storage.set('table:visible_columns:' + cacheName, val, 0)
|
|
338
368
|
// #endif
|
|
339
369
|
})
|
|
340
370
|
}
|
|
@@ -345,10 +375,10 @@ function create(params) {
|
|
|
345
375
|
if (hasPowerBtns) {
|
|
346
376
|
watch(tableFixedPowerBtns, function (lists) {
|
|
347
377
|
|
|
348
|
-
const index = $
|
|
378
|
+
const index = $n_indexOf(tableVisibleColumns.value, 'settings')
|
|
349
379
|
|
|
350
380
|
// 如果有固定在右边的权限按钮列表
|
|
351
|
-
if ($
|
|
381
|
+
if ($n_isValidArray(lists)) {
|
|
352
382
|
|
|
353
383
|
// 如果设置不在可见列中
|
|
354
384
|
if (index === -1) {
|
|
@@ -387,9 +417,9 @@ function create(params) {
|
|
|
387
417
|
*/
|
|
388
418
|
function setQuery(query) {
|
|
389
419
|
|
|
390
|
-
if ($
|
|
420
|
+
if ($n_isValidObject(query)) {
|
|
391
421
|
|
|
392
|
-
query = $
|
|
422
|
+
query = $n_cloneDeep(query)
|
|
393
423
|
|
|
394
424
|
// 搜索参数键值数组
|
|
395
425
|
const searchQueryKey = []
|
|
@@ -400,11 +430,11 @@ function create(params) {
|
|
|
400
430
|
const NSearchValues = []
|
|
401
431
|
|
|
402
432
|
// 参数中是否有自定义搜索参数
|
|
403
|
-
const hasNSearch = $
|
|
433
|
+
const hasNSearch = $n_has(query, 'n_search')
|
|
404
434
|
if (hasNSearch) {
|
|
405
435
|
// 删除在搜索中存在的参数键值
|
|
406
|
-
$
|
|
407
|
-
if ($
|
|
436
|
+
$n_forIn(query.n_search, function (item, key) {
|
|
437
|
+
if ($n_has(query, key)) {
|
|
408
438
|
delete query[key]
|
|
409
439
|
}
|
|
410
440
|
})
|
|
@@ -413,14 +443,14 @@ function create(params) {
|
|
|
413
443
|
// 如果允许从参数中获取搜索值
|
|
414
444
|
if (o.searchFromQuery) {
|
|
415
445
|
|
|
416
|
-
$
|
|
446
|
+
$n_forEach(rawSearchOptions, function (item, index) {
|
|
417
447
|
|
|
418
448
|
const valueItem = tableSearchValue.value[index]
|
|
419
449
|
|
|
420
450
|
// 如果传参在搜素 n_search 参数中
|
|
421
|
-
if (hasNSearch && $
|
|
451
|
+
if (hasNSearch && $n_has(query.n_search, item.name)) {
|
|
422
452
|
const newSearchItem = query.n_search[item.name]
|
|
423
|
-
if ($
|
|
453
|
+
if ($n_isValidArray(newSearchItem)) {
|
|
424
454
|
valueItem[0].compare = newSearchItem[0].compare
|
|
425
455
|
valueItem[0].value = newSearchItem[0].value
|
|
426
456
|
|
|
@@ -433,23 +463,23 @@ function create(params) {
|
|
|
433
463
|
NSearchKeys.push(item.name)
|
|
434
464
|
|
|
435
465
|
// 如果传参在搜索参数中
|
|
436
|
-
} else if ($
|
|
466
|
+
} else if ($n_has(query, item.name)) {
|
|
437
467
|
// 设置单个搜索值
|
|
438
|
-
setItemValue(valueItem, $
|
|
468
|
+
setItemValue(valueItem, $n_isRequired(query[item.name]) ? query[item.name] : '')
|
|
439
469
|
// 设置参数中搜索的 key
|
|
440
470
|
searchQueryKey.push(item.name)
|
|
441
471
|
}
|
|
442
472
|
})
|
|
443
473
|
|
|
444
|
-
$
|
|
474
|
+
$n_forEach(searchQueryKey, function (key) {
|
|
445
475
|
delete query[key]
|
|
446
476
|
})
|
|
447
477
|
|
|
448
478
|
if (hasNSearch) {
|
|
449
|
-
$
|
|
479
|
+
$n_forIn(query.n_search, function(item, key) {
|
|
450
480
|
if (
|
|
451
481
|
NSearchKeys.indexOf(key) === -1
|
|
452
|
-
&& $
|
|
482
|
+
&& $n_isValidArray(item)
|
|
453
483
|
) {
|
|
454
484
|
item[0].field = key
|
|
455
485
|
NSearchValues.push(item[0])
|
|
@@ -463,8 +493,8 @@ function create(params) {
|
|
|
463
493
|
}
|
|
464
494
|
|
|
465
495
|
} else {
|
|
466
|
-
$
|
|
467
|
-
if ($
|
|
496
|
+
$n_forIn(query.n_search, function(item, key) {
|
|
497
|
+
if ($n_isValidArray(item)) {
|
|
468
498
|
item[0].field = key
|
|
469
499
|
NSearchValues.push(item[0])
|
|
470
500
|
if (item.length > 1) {
|
|
@@ -575,7 +605,7 @@ function create(params) {
|
|
|
575
605
|
|
|
576
606
|
const newValue = []
|
|
577
607
|
|
|
578
|
-
$
|
|
608
|
+
$n_forEach(rawSearchOptions, function (item, index) {
|
|
579
609
|
// 如果该搜索条件是隐藏的
|
|
580
610
|
if (item.hide) {
|
|
581
611
|
newValue.push(tableSearchValue.value[index])
|
|
@@ -586,7 +616,7 @@ function create(params) {
|
|
|
586
616
|
})
|
|
587
617
|
|
|
588
618
|
// 还原表格搜索数据
|
|
589
|
-
tableSearchValue.value = $
|
|
619
|
+
tableSearchValue.value = $n_cloneDeep(newValue)
|
|
590
620
|
|
|
591
621
|
// 表格重新加载
|
|
592
622
|
if (reload) {
|
|
@@ -623,7 +653,7 @@ function create(params) {
|
|
|
623
653
|
}
|
|
624
654
|
|
|
625
655
|
// 如果排序字段是有效值
|
|
626
|
-
if ($
|
|
656
|
+
if ($n_isValidValue(sortBy)) {
|
|
627
657
|
Object.assign(data, {
|
|
628
658
|
// 排序字段
|
|
629
659
|
order_by: sortBy,
|
|
@@ -633,20 +663,20 @@ function create(params) {
|
|
|
633
663
|
}
|
|
634
664
|
|
|
635
665
|
// 合并参数
|
|
636
|
-
$
|
|
666
|
+
$n_forIn(Object.assign({}, rawQuery, tableRequestQuery, o.data), function(value, key) {
|
|
637
667
|
// 如果有值
|
|
638
|
-
if ($
|
|
668
|
+
if ($n_isRequired(value)) {
|
|
639
669
|
data[key] = value
|
|
640
670
|
}
|
|
641
671
|
})
|
|
642
672
|
|
|
643
673
|
// 获取搜索值
|
|
644
|
-
const search = $
|
|
645
|
-
if ($
|
|
646
|
-
data.n_search = $
|
|
674
|
+
const search = $n_search.formatValue(rawSearchOptions, tableSearchValue.value)
|
|
675
|
+
if ($n_isValidArray(search)) {
|
|
676
|
+
data.n_search = $n_has(data, 'n_search') ? $n_concat(data.n_search, search) : search
|
|
647
677
|
}
|
|
648
678
|
|
|
649
|
-
if ($
|
|
679
|
+
if ($n_isNil(isSummary)) {
|
|
650
680
|
isSummary = isRequestSummary
|
|
651
681
|
}
|
|
652
682
|
|
|
@@ -687,8 +717,8 @@ function create(params) {
|
|
|
687
717
|
let result
|
|
688
718
|
|
|
689
719
|
// 如果有自定义请求方法
|
|
690
|
-
if ($
|
|
691
|
-
result = await $
|
|
720
|
+
if ($n_isFunction(o.request)) {
|
|
721
|
+
result = await $n_runAsync(o.request)({
|
|
692
722
|
data,
|
|
693
723
|
props,
|
|
694
724
|
rows: tableRows,
|
|
@@ -707,7 +737,7 @@ function create(params) {
|
|
|
707
737
|
// debounce: false,
|
|
708
738
|
}, o.httpSettings)
|
|
709
739
|
|
|
710
|
-
result = await $
|
|
740
|
+
result = await $n_http(opts)
|
|
711
741
|
}
|
|
712
742
|
|
|
713
743
|
const { status, data: res } = result
|
|
@@ -724,8 +754,8 @@ function create(params) {
|
|
|
724
754
|
|
|
725
755
|
// 如果请求表格合计
|
|
726
756
|
if (isRequestSummary) {
|
|
727
|
-
const summary = $
|
|
728
|
-
tableSummary.value = $
|
|
757
|
+
const summary = $n_get(res, 'summary')
|
|
758
|
+
tableSummary.value = $n_isValidObject(summary) ? summary : null
|
|
729
759
|
}
|
|
730
760
|
|
|
731
761
|
// 更新页码
|
|
@@ -740,8 +770,8 @@ function create(params) {
|
|
|
740
770
|
tablePagination.value.descending = descending
|
|
741
771
|
|
|
742
772
|
// 格式化单条数据
|
|
743
|
-
if ($
|
|
744
|
-
$
|
|
773
|
+
if ($n_isFunction(o.formatRow)) {
|
|
774
|
+
$n_forEach(rows, function(row) {
|
|
745
775
|
o.formatRow({
|
|
746
776
|
row,
|
|
747
777
|
rows: tableRows,
|
|
@@ -776,7 +806,7 @@ function create(params) {
|
|
|
776
806
|
opt[o.rowKey] = row[o.rowKey]
|
|
777
807
|
|
|
778
808
|
// 获取当前数据索引
|
|
779
|
-
const itemIndex = $
|
|
809
|
+
const itemIndex = $n_findIndex(tableSelected.value, opt)
|
|
780
810
|
|
|
781
811
|
// 如果不存在, 则添加
|
|
782
812
|
if (itemIndex === -1) {
|
|
@@ -801,7 +831,7 @@ function create(params) {
|
|
|
801
831
|
_tableRowClick(...e)
|
|
802
832
|
|
|
803
833
|
// 如果有自定义单击事件
|
|
804
|
-
if ($
|
|
834
|
+
if ($n_isFunction(o.rowClick)) {
|
|
805
835
|
o.rowClick(...e)
|
|
806
836
|
}
|
|
807
837
|
}
|
|
@@ -832,7 +862,7 @@ function create(params) {
|
|
|
832
862
|
_tableRowDblclick(...e)
|
|
833
863
|
|
|
834
864
|
// 如果有自定义双击表格行事件
|
|
835
|
-
if ($
|
|
865
|
+
if ($n_isFunction(o.tableRowDblclick)) {
|
|
836
866
|
o.tableRowDblclick(...e)
|
|
837
867
|
}
|
|
838
868
|
}
|
|
@@ -841,14 +871,14 @@ function create(params) {
|
|
|
841
871
|
* 设置表格搜索参数
|
|
842
872
|
*/
|
|
843
873
|
async function setTableSearchOptions(format) {
|
|
844
|
-
tableSearchOptions.value = await $
|
|
874
|
+
tableSearchOptions.value = await $n_search.getOptions(rawSearchOptions, format)
|
|
845
875
|
}
|
|
846
876
|
|
|
847
877
|
/**
|
|
848
878
|
* 是否有表格搜索值
|
|
849
879
|
*/
|
|
850
880
|
function hasTableSearchValue() {
|
|
851
|
-
return !! $
|
|
881
|
+
return !! $n_search.formatValue(rawSearchOptions, tableSearchValue.value).length
|
|
852
882
|
}
|
|
853
883
|
|
|
854
884
|
// 如果开启搜索
|
|
@@ -951,15 +981,17 @@ function create(params) {
|
|
|
951
981
|
* 获取表格配置
|
|
952
982
|
*/
|
|
953
983
|
function config(routePath, path, defaultValue) {
|
|
954
|
-
return $
|
|
984
|
+
return $n_cloneDeep($n_get(tablesConfig, $n_slash(routePath, 'start', false) + (path ? '.' + path : ''), defaultValue))
|
|
955
985
|
}
|
|
956
986
|
|
|
957
987
|
/**
|
|
958
988
|
* 业务表格
|
|
959
989
|
*/
|
|
960
|
-
|
|
990
|
+
const table = {
|
|
961
991
|
// 创建表格
|
|
962
992
|
create,
|
|
963
993
|
// 获取表格配置
|
|
964
994
|
config,
|
|
965
995
|
}
|
|
996
|
+
|
|
997
|
+
export default table
|
package/utils/timestamp.js
CHANGED
|
@@ -3,10 +3,10 @@ import { stateTimeDiff } from '../store'
|
|
|
3
3
|
/**
|
|
4
4
|
* 获取当前时间戳
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
export default function timestamp(isMicro = false) {
|
|
7
7
|
|
|
8
8
|
// 获取当前时间戳(毫秒)
|
|
9
|
-
const nowTime =
|
|
9
|
+
const nowTime = Date.now()
|
|
10
10
|
|
|
11
11
|
// 如果是毫秒
|
|
12
12
|
if (isMicro) {
|