@netang/quasar 0.0.20

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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/components/column-title/index.vue +32 -0
  4. package/components/dialog/components/index.js +6 -0
  5. package/components/dialog/components/move-to-tree/index.vue +150 -0
  6. package/components/dialog/index.vue +330 -0
  7. package/components/dialog-table/index.vue +92 -0
  8. package/components/dragger/index.vue +202 -0
  9. package/components/drawer/index.vue +262 -0
  10. package/components/field-date/index.vue +844 -0
  11. package/components/field-date/methods.js +100 -0
  12. package/components/field-table/index.vue +468 -0
  13. package/components/field-text/index.vue +167 -0
  14. package/components/field-tree/index.vue +435 -0
  15. package/components/input-number/index.vue +324 -0
  16. package/components/input-number/number.js +67 -0
  17. package/components/input-price-cent/index.vue +213 -0
  18. package/components/input-price-yuan/index.vue +179 -0
  19. package/components/layout/index.vue +119 -0
  20. package/components/list-menu/index.vue +137 -0
  21. package/components/list-menu-item/index.vue +79 -0
  22. package/components/power-data/index.vue +667 -0
  23. package/components/search/index.vue +176 -0
  24. package/components/search-item/index.vue +219 -0
  25. package/components/select/index.vue +71 -0
  26. package/components/select-filter/index.vue +75 -0
  27. package/components/table/index.vue +347 -0
  28. package/components/table-column-fixed/index.vue +68 -0
  29. package/components/table-pagination/index.vue +83 -0
  30. package/components/table-summary/index.vue +91 -0
  31. package/components/thumbnail/index.vue +87 -0
  32. package/components/toolbar/container.vue +31 -0
  33. package/components/toolbar/index.vue +405 -0
  34. package/components/uploader/index.vue +157 -0
  35. package/components/uploader-query/index.vue +731 -0
  36. package/package.json +21 -0
  37. package/sass/common.scss +165 -0
  38. package/sass/index.scss +14 -0
  39. package/sass/line.scss +39 -0
  40. package/sass/quasar/btn.scss +46 -0
  41. package/sass/quasar/common.scss +3 -0
  42. package/sass/quasar/dialog.scss +7 -0
  43. package/sass/quasar/drawer.scss +6 -0
  44. package/sass/quasar/field.scss +210 -0
  45. package/sass/quasar/loading.scss +6 -0
  46. package/sass/quasar/menu.scss +8 -0
  47. package/sass/quasar/table.scss +112 -0
  48. package/sass/quasar/toolbar.scss +22 -0
  49. package/store/index.js +32 -0
  50. package/utils/$area.js +387 -0
  51. package/utils/$auth.js +135 -0
  52. package/utils/$dialog.js +43 -0
  53. package/utils/$role.js +807 -0
  54. package/utils/$rule.js +17 -0
  55. package/utils/$search.js +336 -0
  56. package/utils/$table.js +802 -0
  57. package/utils/$tree.js +620 -0
  58. package/utils/$uploader.js +1029 -0
  59. package/utils/alert.js +10 -0
  60. package/utils/bus.js +6 -0
  61. package/utils/config.js +22 -0
  62. package/utils/confrim.js +11 -0
  63. package/utils/dict.js +44 -0
  64. package/utils/getData.js +61 -0
  65. package/utils/getFile.js +30 -0
  66. package/utils/getImage.js +136 -0
  67. package/utils/getTime.js +94 -0
  68. package/utils/http.js +251 -0
  69. package/utils/loading.js +13 -0
  70. package/utils/notify.js +13 -0
  71. package/utils/previewImage.js +8 -0
  72. package/utils/symbols.js +3 -0
  73. package/utils/timestamp.js +18 -0
  74. package/utils/toast.js +13 -0
  75. package/utils/uploader/aliyun.js +6 -0
  76. package/utils/uploader/local.js +8 -0
  77. package/utils/uploader/qiniu.js +311 -0
  78. package/utils/useAuth.js +26 -0
  79. package/utils/useRouter.js +36 -0
  80. package/utils/useUploader.js +58 -0
package/utils/$rule.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 验证规则(用于表单验证)
3
+ */
4
+ utils.$rule = function (rule) {
5
+ return function(value) {
6
+ const res = utils.validate(value, 'data', rule, '', '该值')
7
+ if (res) {
8
+ return res
9
+ }
10
+ }
11
+ }
12
+
13
+ utils.$ruleValid = function (rule) {
14
+ return function(value) {
15
+ return ! utils.validate(value, 'data', rule, '', '该值')
16
+ }
17
+ }
@@ -0,0 +1,336 @@
1
+ import { date as quasarDate } from 'quasar'
2
+ import { getQuickRange } from '../components/field-date/methods'
3
+
4
+ /**
5
+ * 比较类型默认值
6
+ */
7
+ const COMPARE_TYPE_MAPS = {
8
+ // 数字
9
+ number: [dicts.SEARCH_TYPE__EQUAL, dicts.SEARCH_TYPE__LT],
10
+ // 文字
11
+ text: [dicts.SEARCH_TYPE__LIKE, dicts.SEARCH_TYPE__LT],
12
+ // 价格
13
+ price: [dicts.SEARCH_TYPE__EQUAL, dicts.SEARCH_TYPE__LT],
14
+ // 日期
15
+ date: [dicts.SEARCH_TYPE__GTE, dicts.SEARCH_TYPE__LTE],
16
+ }
17
+
18
+ /**
19
+ * 设置单个搜索值
20
+ */
21
+ export function setItemValue(value, val) {
22
+
23
+ // 如果值为数组
24
+ if (Array.isArray(val)) {
25
+ // 比较类型为 in
26
+ value[0].type = dicts.SEARCH_TYPE__IN
27
+ // 设置值为将数组转为逗号分隔的字符串
28
+ value[0].value = val.join(',')
29
+
30
+ // 否则为单个值
31
+ } else {
32
+ // 比较类型为 ==
33
+ value[0].type = dicts.SEARCH_TYPE__EQUAL
34
+ // 设置值为当前值
35
+ value[0].value = val
36
+ }
37
+ }
38
+
39
+ /**
40
+ * 从表格列获取原始值
41
+ */
42
+ function getRawData(tableColumns, query, searchFromQuery = true) {
43
+
44
+ // 原始参数
45
+ const rawQuery = {}
46
+ // 原始表格搜索参数
47
+ const rawSearchOptions = []
48
+ // 原始表格搜索值(空表格搜索值, 用于搜索重置)
49
+ const rawTableSearchValue = []
50
+ // 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
51
+ const firstTableSearchValue = []
52
+
53
+ // 搜索参数键值数组
54
+ const searchQueryKey = []
55
+
56
+ utils.forEach(tableColumns, function (item) {
57
+ if (_.has(item, 'search.type')) {
58
+
59
+ // 【设置原始表格搜索参数】
60
+ // --------------------------------------------------
61
+
62
+ // 搜索参数
63
+ const newItem = _.merge({
64
+ // 标签
65
+ label: item.label,
66
+ }, item.search)
67
+
68
+ // 标识
69
+ newItem.name = _.has(newItem, 'name') ? newItem.name : item.name
70
+
71
+ // 如果有字典标识
72
+ if (_.has(item, 'dict')) {
73
+ newItem.dict = item.dict
74
+ }
75
+
76
+ // 原始表格搜索参数
77
+ rawSearchOptions.push(newItem)
78
+
79
+ // 【原始表格搜索值】
80
+ // --------------------------------------------------
81
+
82
+ let value = [
83
+ // 值1
84
+ {
85
+ // 比较类型
86
+ type: COMPARE_TYPE_MAPS[item.search.type][0],
87
+ // 值
88
+ value: '',
89
+ },
90
+ // 值2
91
+ {
92
+ // 比较类型
93
+ type: COMPARE_TYPE_MAPS[item.search.type][1],
94
+ // 值
95
+ value: '',
96
+ },
97
+ ]
98
+
99
+ // 如果是日期
100
+ if (item.search.type === 'date') {
101
+ // 设置日期类型
102
+ value[0].dateType = 'day'
103
+ }
104
+
105
+ // 添加原始表格搜索值
106
+ rawTableSearchValue.push(_.cloneDeep(value))
107
+
108
+ if (
109
+ // 如果开启从参数中获取搜索值
110
+ searchFromQuery
111
+ // 如果在传参中有搜索参数
112
+ && _.has(query, newItem.name)
113
+ ) {
114
+ // 如果有值
115
+ if (utils.isRequired(query[newItem.name])) {
116
+ // 设置单个搜索值
117
+ setItemValue(value, query[newItem.name])
118
+ }
119
+
120
+ // 设置参数中搜索的 key
121
+ searchQueryKey.push(newItem.name)
122
+
123
+ // 否则, 如果表格参数中有设置初始值
124
+ } else if (_.has(item, 'search.value') && utils.isValidArray(item.search.value)) {
125
+ value = _.merge([], value, item.search.value)
126
+ }
127
+
128
+ // 首次初始表格搜索值
129
+ firstTableSearchValue.push(value)
130
+ }
131
+ })
132
+
133
+ if (searchQueryKey.length) {
134
+ utils.forIn(query, function(val, key) {
135
+ if (searchQueryKey.indexOf(key) === -1) {
136
+ rawQuery[key] = val
137
+ }
138
+ })
139
+ } else {
140
+ Object.assign(rawQuery, query)
141
+ }
142
+
143
+ return {
144
+ // 原始参数
145
+ rawQuery,
146
+ // 原始表格搜索参数
147
+ rawSearchOptions,
148
+ // 原始表格搜索值(空表格搜索值, 用于搜索重置)
149
+ rawTableSearchValue,
150
+ // 首次表格搜索值(如果表格搜索参数中带了初始值, 则设置初始值)
151
+ firstTableSearchValue,
152
+ }
153
+ }
154
+
155
+ /**
156
+ * 获取参数
157
+ */
158
+ async function getOptions(rawSearchOptions, format) {
159
+
160
+ const lists = []
161
+
162
+ if (utils.isValidArray(rawSearchOptions)) {
163
+ for (const item of rawSearchOptions) {
164
+
165
+ const newItem = Object.assign({}, item)
166
+
167
+ // 格式化单个参数
168
+ if (_.isFunction(format)) {
169
+ const res = await utils.runAsync(format)(newItem)
170
+ if (utils.isValidObject(res)) {
171
+ _.merge(newItem, res)
172
+ }
173
+ }
174
+
175
+ // 如果有字典标识, 则一定是下拉菜单
176
+ if (_.has(newItem, 'dict')) {
177
+ _.merge(newItem, {
178
+ searchType: 'select',
179
+ select: {
180
+ options: utils.dictOptions(newItem.dict)
181
+ },
182
+ })
183
+
184
+ // 如果有下拉菜单选项
185
+ } else if (_.has(newItem, 'select')) {
186
+ newItem.searchType = 'select'
187
+ newItem.select = Object.assign({
188
+ options: [],
189
+ }, newItem.select)
190
+
191
+ // 如果下拉选项是方法
192
+ if (_.isFunction(newItem.select.options)) {
193
+ // 读取下拉选项
194
+ newItem.select.options = await utils.runAsync(newItem.select.options)()
195
+ }
196
+
197
+ // 如果有树选项
198
+ } else if (_.has(newItem, 'tree')) {
199
+ newItem.searchType = 'tree'
200
+ newItem.tree = Object.assign({
201
+ nodes: [],
202
+ accordion: true,
203
+ }, newItem.tree)
204
+
205
+ // 如果节点数组是方法
206
+ if (_.isFunction(newItem.tree.nodes)) {
207
+ // 读取下拉选项
208
+ newItem.tree.nodes = await utils.runAsync(newItem.tree.nodes)()
209
+ }
210
+
211
+ // 否则为输入框
212
+ } else {
213
+ newItem.searchType = 'input'
214
+ }
215
+
216
+ lists.push(newItem)
217
+ }
218
+ }
219
+
220
+ return lists
221
+ }
222
+
223
+ /**
224
+ * 格式化值
225
+ */
226
+ function formatValue(rawSearchOptions, searchValue) {
227
+
228
+ const lists = []
229
+
230
+ utils.forEach(rawSearchOptions, function ({ name, type }, itemIndex) {
231
+
232
+ // 添加值1
233
+ function addValue1(value1) {
234
+
235
+ // 如果有值1
236
+ if (utils.isValidValue(value1.value)) {
237
+
238
+ // 如果值1 类型为 in / not in
239
+ if (utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], value1.type) > -1) {
240
+ const vals = []
241
+ utils.forEach(utils.split(utils.trimString(value1.value).replaceAll(',', ','), ','), function (item) {
242
+ item = utils.numberDeep(item)
243
+ if (utils.isValidValue(item)) {
244
+ vals.push(item)
245
+ }
246
+ })
247
+ if (vals.length) {
248
+ lists.push({
249
+ field: name,
250
+ type: value1.type,
251
+ value: vals,
252
+ })
253
+ }
254
+ return
255
+ }
256
+
257
+ // 否则添加值1
258
+ lists.push({
259
+ field: name,
260
+ type: value1.type,
261
+ value: utils.numberDeep(value1.value),
262
+ })
263
+ }
264
+ }
265
+
266
+ // 第一个值
267
+ const value1 = searchValue[itemIndex][0]
268
+
269
+ // 如果是文字
270
+ if (type === 'text') {
271
+ // 添加值1
272
+ addValue1(value1)
273
+
274
+ // 否则为数字
275
+ } else {
276
+
277
+ if (
278
+ // 如果是日期
279
+ type === 'date'
280
+ // 如果类型为快捷日期
281
+ && value1.type >= 20
282
+ ) {
283
+ const res = getQuickRange(value1.type - 20, true)
284
+ if (res) {
285
+
286
+ lists.push(
287
+ // 日期起
288
+ {
289
+ field: name,
290
+ // ≥
291
+ type: dicts.SEARCH_TYPE__GTE,
292
+ value: utils.numberDeep(quasarDate.formatDate(utils.toDate(`${res.date.from} ${res.time.from}`), 'X')),
293
+ },
294
+ // 日期止
295
+ {
296
+ field: name,
297
+ // ≤
298
+ type: dicts.SEARCH_TYPE__LTE,
299
+ value: utils.numberDeep(quasarDate.formatDate(utils.toDate(`${res.date.to} ${res.time.to}`), 'X')),
300
+ }
301
+ )
302
+ }
303
+ return
304
+ }
305
+
306
+ // 添加值1
307
+ addValue1(value1)
308
+
309
+ // 只有值1 类型为 > / ≥ 值2才有效
310
+ if (utils.indexOf([dicts.SEARCH_TYPE__GT, dicts.SEARCH_TYPE__GTE], value1.type) > -1) {
311
+ const value2 = searchValue[itemIndex][1]
312
+ if (utils.isValidValue(value2.value)) {
313
+ lists.push({
314
+ field: name,
315
+ type: value2.type,
316
+ value: utils.numberDeep(value2.value),
317
+ })
318
+ }
319
+ }
320
+ }
321
+ })
322
+
323
+ return lists
324
+ }
325
+
326
+ /**
327
+ * 搜素业务
328
+ */
329
+ utils.$search = {
330
+ // 获取原始值
331
+ getRawData,
332
+ // 获取参数
333
+ getOptions,
334
+ // 格式化值
335
+ formatValue,
336
+ }