@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.
Files changed (115) hide show
  1. package/_docs/docs/.vuepress/client.js +39 -0
  2. package/_docs/docs/.vuepress/components/test.vue +23 -0
  3. package/_docs/docs/.vuepress/config.js +40 -0
  4. package/_docs/docs/.vuepress/configs/index.js +2 -0
  5. package/_docs/docs/.vuepress/configs/navbar/index.js +1 -0
  6. package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -0
  7. package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -0
  8. package/_docs/docs/.vuepress/configs/sidebar/zh.js +20 -0
  9. package/_docs/docs/.vuepress/public/css/index.css +3 -0
  10. package/_docs/docs/.vuepress/styles/index.scss +3 -0
  11. package/_docs/docs/components/field-table.md +63 -0
  12. package/_docs/docs/components/field-tree.md +1 -0
  13. package/{docs → _docs}/docs/index.md +0 -0
  14. package/{docs → _docs}/docs/utils/alert.md +0 -0
  15. package/{docs → _docs}/docs/utils/confirm.md +0 -0
  16. package/_docs/docs/utils/index.md +1 -0
  17. package/_docs/package.json +17 -0
  18. package/components/column-title/index.vue +2 -2
  19. package/components/data/index.vue +20 -23
  20. package/components/dialog/index.vue +26 -12
  21. package/components/dialog-table/index.vue +4 -2
  22. package/components/dragger/index.vue +3 -2
  23. package/components/drawer/index.vue +16 -9
  24. package/components/editor-code/index.vue +12 -5
  25. package/components/empty/index.vue +16 -1
  26. package/components/field-date/index.vue +48 -36
  27. package/components/field-table/index.vue +69 -43
  28. package/components/field-text/index.vue +6 -2
  29. package/components/field-tree/index.vue +40 -22
  30. package/components/input-number/index.vue +5 -4
  31. package/components/list-menu/index.vue +14 -2
  32. package/components/power-page/index.vue +10 -0
  33. package/components/private/components/index.js +7 -2
  34. package/components/private/components/move-to-tree/index.vue +7 -3
  35. package/components/private/edit-power-data/index.vue +92 -52
  36. package/components/private/table-visible-columns-button/index.vue +6 -2
  37. package/components/render/index.vue +21 -7
  38. package/components/search/index.vue +30 -2
  39. package/components/search-item/index.vue +24 -8
  40. package/components/select/index.vue +5 -2
  41. package/components/splitter/index.vue +13 -9
  42. package/components/table/index.vue +32 -5
  43. package/components/table-pagination/index.vue +0 -1
  44. package/components/table-splitter/index.vue +22 -3
  45. package/components/table-summary/index.vue +10 -3
  46. package/components/thumbnail/index.vue +16 -6
  47. package/components/toolbar/index.vue +0 -2
  48. package/components/uploader/index.vue +5 -2
  49. package/components/uploader-query/index.vue +48 -27
  50. package/components/value-format/index.vue +19 -12
  51. package/configs/area3.js +1 -0
  52. package/docs/404.html +33 -0
  53. package/docs/assets/404.html-60b35caa.js +1 -0
  54. package/docs/assets/404.html-d1e63d77.js +1 -0
  55. package/docs/assets/alert.html-568d4e94.js +1 -0
  56. package/docs/assets/alert.html-f5dbc3e9.js +1 -0
  57. package/docs/assets/app-8c3ae4de.js +6 -0
  58. package/docs/assets/back-to-top-8efcbe56.svg +1 -0
  59. package/docs/assets/confirm.html-7a1566f6.js +1 -0
  60. package/docs/assets/confirm.html-96f1b004.js +1 -0
  61. package/docs/assets/field-table.html-68d610b0.js +1 -0
  62. package/docs/assets/field-table.html-86cc3511.js +1 -0
  63. package/docs/assets/field-tree.html-45410c3c.js +1 -0
  64. package/docs/assets/field-tree.html-c98ac993.js +1 -0
  65. package/docs/assets/framework-204010b2.js +5 -0
  66. package/docs/assets/index.html-1695dd7c.js +1 -0
  67. package/docs/assets/index.html-65a4aa67.js +1 -0
  68. package/docs/assets/style-ac5a9aa6.css +1 -0
  69. package/docs/components/field-table.html +33 -0
  70. package/docs/components/field-tree.html +33 -0
  71. package/docs/index.html +33 -0
  72. package/docs/utils/alert.html +33 -0
  73. package/docs/utils/confirm.html +33 -0
  74. package/package.json +1 -1
  75. package/package2.json +30 -0
  76. package/store/index.js +3 -20
  77. package/utils/alert.js +3 -1
  78. package/utils/area.js +27 -14
  79. package/utils/arr.js +6 -2
  80. package/utils/auth.js +40 -35
  81. package/utils/bus.js +1 -1
  82. package/utils/config.js +42 -15
  83. package/utils/{confrim.js → confirm.js} +1 -1
  84. package/utils/copy.js +18 -0
  85. package/utils/dialog.js +7 -3
  86. package/utils/dict.js +5 -28
  87. package/utils/dictOptions.js +24 -0
  88. package/utils/form.js +6 -2
  89. package/utils/getData.js +21 -9
  90. package/utils/getFile.js +11 -5
  91. package/utils/getImage.js +23 -12
  92. package/utils/getTime.js +9 -4
  93. package/utils/index.js +61 -0
  94. package/utils/loading.js +3 -1
  95. package/utils/notify.js +1 -1
  96. package/utils/power.js +164 -118
  97. package/utils/previewImage.js +4 -2
  98. package/utils/price.js +12 -3
  99. package/utils/rule.js +5 -9
  100. package/utils/ruleValid.js +10 -0
  101. package/utils/search.js +81 -50
  102. package/utils/table.js +119 -87
  103. package/utils/timestamp.js +2 -2
  104. package/utils/toast.js +1 -1
  105. package/utils/tree.js +69 -46
  106. package/utils/uploader/qiniu.js +31 -15
  107. package/utils/uploader.js +87 -56
  108. package/utils/useAuth.js +12 -5
  109. package/utils/useRouter.js +16 -5
  110. package/utils/useUploader.js +0 -5
  111. package/docs/docs/.vuepress/config.js +0 -32
  112. package/docs/docs/components/field-table.md +0 -1
  113. package/docs/docs/components/field-tree.md +0 -1
  114. package/docs/package.json +0 -11
  115. package/utils/http.js +0 -251
@@ -1,8 +1,10 @@
1
+ import $n_toast from './toast'
2
+
1
3
  /**
2
4
  * 预览图片
3
5
  */
4
- $n.previewImage = function(src) {
5
- $n.toast({
6
+ export default function previewImage(src) {
7
+ $n_toast({
6
8
  message: '预览图片还没做'
7
9
  })
8
10
  }
package/utils/price.js CHANGED
@@ -1,13 +1,22 @@
1
+ import $n_decimal from '@netang/utils/decimal'
2
+
3
+ import { configs } from './config'
4
+
5
+ const {
6
+ // 是否开启人民币分转元
7
+ priceCentToYuan,
8
+ } = configs
9
+
1
10
  /**
2
11
  * 换算金额
3
12
  */
4
- $n.price = function(value, params) {
5
- return $n.decimal(value, Object.assign({
13
+ export default function price(value, params) {
14
+ return $n_decimal(value, Object.assign({
6
15
  // 最小值
7
16
  min: 0,
8
17
  // 小数点位数
9
18
  decimalLength: 2,
10
19
  // 是否开启人民币分转元(如值 189 -> 1.89)
11
- centToYuan: $n.config('priceCent') === true,
20
+ centToYuan: priceCentToYuan === true,
12
21
  }, params))
13
22
  }
package/utils/rule.js CHANGED
@@ -1,17 +1,13 @@
1
+ import { validate as $n_validate } from '@netang/utils/validator'
2
+
1
3
  /**
2
- * 验证规则(用于表单验证)
4
+ * 单个验证规则(用于表单验证)
3
5
  */
4
- $n.rule = function (rule) {
6
+ export default function rule(rule) {
5
7
  return function(value) {
6
- const res = $n.validate(value, 'data', rule, '', '该值')
8
+ const res = $n_validate(value, 'data', rule, '', '该值')
7
9
  if (res) {
8
10
  return res
9
11
  }
10
12
  }
11
13
  }
12
-
13
- $n.ruleValid = function (rule) {
14
- return function(value) {
15
- return ! $n.validate(value, 'data', rule, '', '该值')
16
- }
17
- }
@@ -0,0 +1,10 @@
1
+ import { validate as $n_validate } from '@netang/utils/validator'
2
+
3
+ /**
4
+ * 单个验证真假规则(用于表单验证)
5
+ */
6
+ export default function ruleValid (rule) {
7
+ return function(value) {
8
+ return ! $n_validate(value, 'data', rule, '', '该值')
9
+ }
10
+ }
package/utils/search.js CHANGED
@@ -1,6 +1,35 @@
1
+ import $n_has from 'lodash/has'
2
+ import $n_cloneDeep from 'lodash/cloneDeep'
3
+ import $n_merge from 'lodash/merge'
4
+ import $n_isFunction from 'lodash/isFunction'
5
+ import $n_findIndex from 'lodash/findIndex'
6
+
7
+ import $n_forEach from '@netang/utils/forEach'
8
+ import $n_isValidArray from '@netang/utils/isValidArray'
9
+ import $n_join from '@netang/utils/join'
10
+ import $n_split from '@netang/utils/split'
11
+ import $n_indexOf from '@netang/utils/indexOf'
12
+
13
+ import $n_isRequired from '@netang/utils/isRequired'
14
+ import $n_forIn from '@netang/utils/forIn'
15
+ import $n_runAsync from '@netang/utils/runAsync'
16
+ import $n_isValidObject from '@netang/utils/isValidObject'
17
+ import $n_isValidValue from '@netang/utils/isValidValue'
18
+ import $n_trimString from '@netang/utils/trimString'
19
+ import $n_numberDeep from '@netang/utils/numberDeep'
20
+ import $n_toDate from '@netang/utils/toDate'
21
+
1
22
  import { date as quasarDate } from 'quasar'
2
23
  import { getQuickRange, quickRange } from '../components/field-date/methods'
3
24
 
25
+ import $n_dictOptions from './dictOptions'
26
+ import { configs } from './config'
27
+
28
+ const {
29
+ // 字典常量
30
+ dicts,
31
+ } = configs
32
+
4
33
  /**
5
34
  * 比较类型默认值
6
35
  */
@@ -40,7 +69,7 @@ function setItemCompare(item) {
40
69
  // 如果类型为日期
41
70
  if (item.type === 'date') {
42
71
  // 添加日期快捷选项
43
- $n.forEach(quickRange, function(label, key) {
72
+ $n_forEach(quickRange, function(label, key) {
44
73
  opts1.push({ label, value: key + 20 })
45
74
  })
46
75
 
@@ -54,8 +83,8 @@ function setItemCompare(item) {
54
83
 
55
84
  // 如果有比较类型
56
85
  if (
57
- $n.has(item, 'compare')
58
- && $n.isValidArray(item.compare)
86
+ $n_has(item, 'compare')
87
+ && $n_isValidArray(item.compare)
59
88
  ) {
60
89
  const {
61
90
  compare,
@@ -84,11 +113,11 @@ function setItemCompare(item) {
84
113
  item.compareOptions2 = []
85
114
 
86
115
  // 如果比较类型有 >
87
- if ($n.findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GT }) > -1) {
116
+ if ($n_findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GT }) > -1) {
88
117
  item.compareOptions2.push({ label: '<', value: dicts.SEARCH_COMPARE_TYPE__LT })
89
118
 
90
119
  // 如果比较类型有 >=
91
- } else if ($n.findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GTE }) > -1) {
120
+ } else if ($n_findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GTE }) > -1) {
92
121
  item.compareOptions2.push({ label: '≤', value: dicts.SEARCH_COMPARE_TYPE__LTE })
93
122
  }
94
123
  }
@@ -103,10 +132,10 @@ export function setItemValue(value, val) {
103
132
  // 比较类型为 in
104
133
  value[0].compare = dicts.SEARCH_COMPARE_TYPE__IN
105
134
  // 设置值为将数组转为逗号分隔的字符串
106
- value[0].value = $n.join(val, ',')
135
+ value[0].value = $n_join(val, ',')
107
136
 
108
137
  // 如果值是逗号隔开
109
- } else if ($n.split(val, ',').length > 1) {
138
+ } else if ($n_split(val, ',').length > 1) {
110
139
  // 比较类型为 in
111
140
  value[0].compare = dicts.SEARCH_COMPARE_TYPE__IN
112
141
  // 设置值为将数组转为逗号分隔的字符串
@@ -130,15 +159,15 @@ function formatItemValueCompare(value, { compareOptions1 }) {
130
159
  const value1 = value[0]
131
160
 
132
161
  // 如果值1 的比较条件不在值1 的限制范围内
133
- if ($n.findIndex(compareOptions1, { value: value1.compare }) === -1) {
162
+ if ($n_findIndex(compareOptions1, { value: value1.compare }) === -1) {
134
163
  // 则取比较条件中的第一个
135
164
  value1.compare = compareOptions1[0].value
136
165
  }
137
166
 
138
167
  // 如果比较类型不为 in / not in
139
- if ($n.indexOf([ dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN ], value1.compare) === -1) {
168
+ if ($n_indexOf([ dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN ], value1.compare) === -1) {
140
169
  // 如果值中含有逗号
141
- const arr = $n.split(value1.value, ',')
170
+ const arr = $n_split(value1.value, ',')
142
171
  if (arr.length > 1) {
143
172
  value1.value = arr[0]
144
173
  }
@@ -173,23 +202,23 @@ function getRawData(tableColumns, query, searchFromQuery = true) {
173
202
  // 搜索参数键值数组
174
203
  const searchQueryKey = []
175
204
 
176
- $n.forEach(tableColumns, function (item) {
177
- if ($n.has(item, 'search.type')) {
205
+ $n_forEach(tableColumns, function (item) {
206
+ if ($n_has(item, 'search.type')) {
178
207
 
179
208
  // 【设置原始表格搜索参数】
180
209
  // --------------------------------------------------
181
210
 
182
211
  // 搜索参数
183
- const newItem = $n.merge({
212
+ const newItem = $n_merge({
184
213
  // 标签
185
214
  label: item.label,
186
215
  }, item.search)
187
216
 
188
217
  // 标识
189
- newItem.name = $n.has(newItem, 'name') ? newItem.name : item.name
218
+ newItem.name = $n_has(newItem, 'name') ? newItem.name : item.name
190
219
 
191
220
  // 如果有字典标识
192
- if ($n.has(item, 'dict')) {
221
+ if ($n_has(item, 'dict')) {
193
222
  newItem.dict = item.dict
194
223
  }
195
224
 
@@ -226,16 +255,16 @@ function getRawData(tableColumns, query, searchFromQuery = true) {
226
255
  }
227
256
 
228
257
  // 添加原始表格搜索值
229
- rawTableSearchValue.push($n.cloneDeep(value))
258
+ rawTableSearchValue.push($n_cloneDeep(value))
230
259
 
231
260
  if (
232
261
  // 如果开启从参数中获取搜索值
233
262
  searchFromQuery
234
263
  // 如果在传参中有搜索参数
235
- && $n.has(query, newItem.name)
264
+ && $n_has(query, newItem.name)
236
265
  ) {
237
266
  // 如果有值
238
- if ($n.isRequired(query[newItem.name])) {
267
+ if ($n_isRequired(query[newItem.name])) {
239
268
  // 设置单个搜索值
240
269
  setItemValue(value, query[newItem.name])
241
270
  }
@@ -245,10 +274,10 @@ function getRawData(tableColumns, query, searchFromQuery = true) {
245
274
 
246
275
  // 否则, 如果表格参数中有设置初始值
247
276
  } else if (
248
- $n.has(newItem, 'value')
249
- && $n.isValidArray(newItem.value)
277
+ $n_has(newItem, 'value')
278
+ && $n_isValidArray(newItem.value)
250
279
  ) {
251
- value = $n.merge([], value, newItem.value)
280
+ value = $n_merge([], value, newItem.value)
252
281
  }
253
282
 
254
283
  // 格式化单个值的比较条件
@@ -260,7 +289,7 @@ function getRawData(tableColumns, query, searchFromQuery = true) {
260
289
  })
261
290
 
262
291
  if (searchQueryKey.length) {
263
- $n.forIn(query, function(val, key) {
292
+ $n_forIn(query, function(val, key) {
264
293
  if (searchQueryKey.indexOf(key) === -1) {
265
294
  rawQuery[key] = val
266
295
  }
@@ -288,43 +317,43 @@ async function getOptions(rawSearchOptions, format) {
288
317
 
289
318
  const lists = []
290
319
 
291
- if ($n.isValidArray(rawSearchOptions)) {
320
+ if ($n_isValidArray(rawSearchOptions)) {
292
321
  for (const item of rawSearchOptions) {
293
322
 
294
323
  const newItem = Object.assign({}, item)
295
324
 
296
325
  // 格式化单个参数
297
- if ($n.isFunction(format)) {
298
- const res = await $n.runAsync(format)(newItem)
299
- if ($n.isValidObject(res)) {
300
- $n.merge(newItem, res)
326
+ if ($n_isFunction(format)) {
327
+ const res = await $n_runAsync(format)(newItem)
328
+ if ($n_isValidObject(res)) {
329
+ $n_merge(newItem, res)
301
330
  }
302
331
  }
303
332
 
304
333
  // 如果有字典标识, 则一定是下拉菜单
305
- if ($n.has(newItem, 'dict')) {
306
- $n.merge(newItem, {
334
+ if ($n_has(newItem, 'dict')) {
335
+ $n_merge(newItem, {
307
336
  searchType: 'select',
308
337
  select: {
309
- options: $n.dictOptions(newItem.dict)
338
+ options: $n_dictOptions(newItem.dict)
310
339
  },
311
340
  })
312
341
 
313
342
  // 如果有下拉菜单选项
314
- } else if ($n.has(newItem, 'select')) {
343
+ } else if ($n_has(newItem, 'select')) {
315
344
  newItem.searchType = 'select'
316
345
  newItem.select = Object.assign({
317
346
  options: [],
318
347
  }, newItem.select)
319
348
 
320
349
  // 如果下拉选项是方法
321
- if ($n.isFunction(newItem.select.options)) {
350
+ if ($n_isFunction(newItem.select.options)) {
322
351
  // 读取下拉选项
323
- newItem.select.options = await $n.runAsync(newItem.select.options)()
352
+ newItem.select.options = await $n_runAsync(newItem.select.options)()
324
353
  }
325
354
 
326
355
  // 如果有树选项(调用的是 <n-field-tree> 组件)
327
- } else if ($n.has(newItem, 'tree')) {
356
+ } else if ($n_has(newItem, 'tree')) {
328
357
  newItem.searchType = 'tree'
329
358
  newItem.tree = Object.assign({
330
359
  nodes: [],
@@ -333,13 +362,13 @@ async function getOptions(rawSearchOptions, format) {
333
362
  }, newItem.tree)
334
363
 
335
364
  // 如果节点数组是方法
336
- if ($n.isFunction(newItem.tree.nodes)) {
365
+ if ($n_isFunction(newItem.tree.nodes)) {
337
366
  // 读取下拉选项
338
- newItem.tree.nodes = await $n.runAsync(newItem.tree.nodes)()
367
+ newItem.tree.nodes = await $n_runAsync(newItem.tree.nodes)()
339
368
  }
340
369
 
341
370
  // 如果有表格选项(调用的是 <n-field-table.md> 组件)
342
- } else if ($n.has(newItem, 'table')) {
371
+ } else if ($n_has(newItem, 'table')) {
343
372
  newItem.searchType = 'table'
344
373
  newItem.table = Object.assign({
345
374
  // 值字段(必填)
@@ -370,20 +399,20 @@ function formatValue(rawSearchOptions, searchValue) {
370
399
 
371
400
  const lists = []
372
401
 
373
- $n.forEach(rawSearchOptions, function ({ name, type }, itemIndex) {
402
+ $n_forEach(rawSearchOptions, function ({ name, type }, itemIndex) {
374
403
 
375
404
  // 添加值1
376
405
  function addValue1(value1) {
377
406
 
378
407
  // 如果有值1
379
- if ($n.isValidValue(value1.value)) {
408
+ if ($n_isValidValue(value1.value)) {
380
409
 
381
410
  // 如果值1 类型为 in / not in
382
- if ($n.indexOf([dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN], value1.compare) > -1) {
411
+ if ($n_indexOf([dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN], value1.compare) > -1) {
383
412
  const vals = []
384
- $n.forEach($n.split($n.trimString(value1.value).replaceAll(',', ','), ','), function (item) {
385
- item = $n.numberDeep(item)
386
- if ($n.isValidValue(item)) {
413
+ $n_forEach($n_split($n_trimString(value1.value).replaceAll(',', ','), ','), function (item) {
414
+ item = $n_numberDeep(item)
415
+ if ($n_isValidValue(item)) {
387
416
  vals.push(item)
388
417
  }
389
418
  })
@@ -401,7 +430,7 @@ function formatValue(rawSearchOptions, searchValue) {
401
430
  lists.push({
402
431
  field: name,
403
432
  compare: value1.compare,
404
- value: $n.numberDeep(value1.value),
433
+ value: $n_numberDeep(value1.value),
405
434
  })
406
435
  }
407
436
  }
@@ -432,14 +461,14 @@ function formatValue(rawSearchOptions, searchValue) {
432
461
  field: name,
433
462
  // ≥
434
463
  compare: dicts.SEARCH_COMPARE_TYPE__GTE,
435
- value: $n.numberDeep(quasarDate.formatDate($n.toDate(`${res.date.from} ${res.time.from}`), 'X')),
464
+ value: $n_numberDeep(quasarDate.formatDate($n_toDate(`${res.date.from} ${res.time.from}`), 'X')),
436
465
  },
437
466
  // 日期止
438
467
  {
439
468
  field: name,
440
469
  // ≤
441
470
  compare: dicts.SEARCH_COMPARE_TYPE__LTE,
442
- value: $n.numberDeep(quasarDate.formatDate($n.toDate(`${res.date.to} ${res.time.to}`), 'X')),
471
+ value: $n_numberDeep(quasarDate.formatDate($n_toDate(`${res.date.to} ${res.time.to}`), 'X')),
443
472
  }
444
473
  )
445
474
  }
@@ -450,13 +479,13 @@ function formatValue(rawSearchOptions, searchValue) {
450
479
  addValue1(value1)
451
480
 
452
481
  // 只有值1 类型为 > / ≥ 值2才有效
453
- if ($n.indexOf([dicts.SEARCH_COMPARE_TYPE__GT, dicts.SEARCH_COMPARE_TYPE__GTE], value1.compare) > -1) {
482
+ if ($n_indexOf([dicts.SEARCH_COMPARE_TYPE__GT, dicts.SEARCH_COMPARE_TYPE__GTE], value1.compare) > -1) {
454
483
  const value2 = searchValue[itemIndex][1]
455
- if ($n.isValidValue(value2.value)) {
484
+ if ($n_isValidValue(value2.value)) {
456
485
  lists.push({
457
486
  field: name,
458
487
  compare: value2.compare,
459
- value: $n.numberDeep(value2.value),
488
+ value: $n_numberDeep(value2.value),
460
489
  })
461
490
  }
462
491
  }
@@ -469,7 +498,7 @@ function formatValue(rawSearchOptions, searchValue) {
469
498
  /**
470
499
  * 搜素业务
471
500
  */
472
- $n.search = {
501
+ const search = {
473
502
  // 获取原始值
474
503
  getRawData,
475
504
  // 获取参数
@@ -477,3 +506,5 @@ $n.search = {
477
506
  // 格式化值
478
507
  formatValue,
479
508
  }
509
+
510
+ export default search