@netang/quasar 0.2.11 → 0.2.13

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 (40) hide show
  1. package/components/data/index.vue +20 -20
  2. package/components/dialog/index.vue +2 -2
  3. package/components/dragger/index.vue +203 -203
  4. package/components/field-date/methods.js +100 -100
  5. package/components/field-text/index.vue +165 -165
  6. package/components/input-number/index.vue +21 -13
  7. package/components/list-menu/index.vue +149 -149
  8. package/components/list-menu-item/index.vue +79 -79
  9. package/components/price/index.vue +188 -188
  10. package/components/private/components/index.js +11 -11
  11. package/components/table-pagination/index.vue +192 -192
  12. package/components/thumbnail/index.vue +72 -72
  13. package/components/value-format/index.vue +274 -274
  14. package/configs/area3.js +1 -1
  15. package/docs/css/index.css +3 -3
  16. package/package.json +1 -1
  17. package/sass/line.scss +39 -39
  18. package/sass/quasar/btn.scss +46 -46
  19. package/sass/quasar/common.scss +3 -3
  20. package/sass/quasar/drawer.scss +6 -6
  21. package/sass/quasar/loading.scss +6 -6
  22. package/sass/quasar/toolbar.scss +22 -22
  23. package/store/index.js +29 -29
  24. package/utils/$auth.js +127 -127
  25. package/utils/$rule.js +13 -13
  26. package/utils/$ruleValid.js +10 -10
  27. package/utils/alert.js +12 -12
  28. package/utils/area.js +400 -400
  29. package/utils/arr.js +51 -51
  30. package/utils/bus.js +6 -6
  31. package/utils/confirm.js +11 -11
  32. package/utils/copy.js +30 -30
  33. package/utils/dictOptions.js +28 -28
  34. package/utils/loading.js +15 -15
  35. package/utils/notify.js +13 -13
  36. package/utils/price.js +18 -18
  37. package/utils/symbols.js +18 -18
  38. package/utils/toast.js +13 -13
  39. package/utils/useAuth.js +30 -30
  40. package/utils/useRouter.js +47 -47
package/utils/area.js CHANGED
@@ -1,400 +1,400 @@
1
- import $n_cloneDeep from 'lodash/cloneDeep'
2
- import $n_get from 'lodash/get'
3
- import $n_isValidArray from '@netang/utils/isValidArray'
4
- import $n_indexOf from '@netang/utils/indexOf'
5
- import $n_toTree from '@netang/utils/toTree'
6
- import $n_trimString from '@netang/utils/trimString'
7
- import $n_replaceAll from '@netang/utils/replaceAll'
8
-
9
- // 地址数据缓存
10
- let _areaData = null
11
-
12
- /**
13
- * 获取地区数据
14
- */
15
- function getData(level = 3, options) {
16
- return _getData(() => import('../configs/area3'), level, options)
17
- }
18
- function _getData(areaData, level, options) {
19
- return new Promise(function(resolve) {
20
-
21
- // 执行
22
- function run() {
23
-
24
- const para = Object.assign({
25
- // 忽略地区 id
26
- ignore: [],
27
- }, options)
28
-
29
- // 克隆树数据
30
- const treeData = $n_cloneDeep(_areaData)
31
- const all = {}
32
- const rows = []
33
-
34
- // 是否有忽略省市区 id
35
- const isIgnore = $n_isValidArray(para.ignore)
36
- function checkIgnore(id) {
37
- return isIgnore && $n_indexOf(para.ignore, id) > -1
38
- }
39
-
40
- // 省
41
- for (const item1 of treeData) {
42
-
43
- // 如果有忽略省
44
- if (checkIgnore(item1[1])) {
45
- continue
46
- }
47
-
48
- all[item1[1]] = {
49
- id: item1[1],
50
- pid: 0,
51
- title: item1[0],
52
- level: 1,
53
- }
54
-
55
- // 市
56
- if (level > 1 && $n_isValidArray(item1[2])) {
57
-
58
- for (let index2 = 0, len2 = item1[2].length; index2 < len2; index2++) {
59
- const item2 = item1[2][index2]
60
-
61
- // 如果有忽略市
62
- if (checkIgnore(item2[1])) {
63
- continue
64
- }
65
-
66
- all[item2[1]] = {
67
- id: item2[1],
68
- pid: item1[1],
69
- title: item2[0],
70
- level: 2,
71
- }
72
- item1[2][index2] = all[item2[1]]
73
-
74
- // 区
75
- if (level > 2 && $n_isValidArray(item2[2])) {
76
- for (let index3 = 0, len3 = item2[2].length; index3 < len3; index3++) {
77
- const item3 = item2[2][index3]
78
-
79
- // 如果有忽略区
80
- if (checkIgnore(item3[1])) {
81
- continue
82
- }
83
-
84
- all[item3[1]] = {
85
- id: item3[1],
86
- pid: item2[1],
87
- title: item3[0],
88
- level: 3,
89
- }
90
- item2[2][index3] = all[item3[1]]
91
- }
92
- }
93
- }
94
- }
95
- }
96
-
97
- for (const key in all) {
98
- rows.push(all[key])
99
- }
100
-
101
- resolve($n_toTree({
102
- data: rows,
103
- }))
104
- }
105
-
106
- if (_areaData) {
107
- run()
108
- return
109
- }
110
-
111
- areaData()
112
- .then((res)=>{
113
- _areaData = res.default
114
- run()
115
- })
116
- })
117
- }
118
-
119
- /**
120
- * 替换地址
121
- */
122
- function replaceArea(val) {
123
- val = $n_trimString(val)
124
- return val.replace(/直辖市/g, '')
125
- .replace(/市/g, '')
126
- .replace(/区/g, '')
127
- .replace(/自治县/g, '')
128
- .replace(/自治州/g, '')
129
- .replace(/县/g, '')
130
- }
131
-
132
- /**
133
- * 获取地区详情
134
- */
135
- async function getInfo(options) {
136
-
137
- let {
138
- // 地址数据
139
- areaData,
140
- // 级别
141
- level,
142
- // 地区编码
143
- code,
144
- // 省文字
145
- provinceText,
146
- // 市文字
147
- cityText,
148
- // 区文字
149
- areaText,
150
- // 详细区域文字
151
- regionText,
152
-
153
- } = Object.assign({
154
- // 地址数据
155
- areaData: null,
156
- // 级别
157
- level: 3,
158
- // 地区编码
159
- code: 0,
160
- // 省文字
161
- provinceText: '',
162
- // 市文字
163
- cityText: '',
164
- // 区文字
165
- areaText: '',
166
- // 详细区域文字
167
- regionText: '',
168
- }, options)
169
-
170
- if (! areaData) {
171
- areaData = await getData(level)
172
- }
173
-
174
- const { attrs, nodes, tree } = areaData
175
-
176
- // 先通过地区编码来查找
177
- let data = $n_get(nodes, code)
178
-
179
- // 如果没有找到, 则通过文字来查找
180
- if (! data) {
181
-
182
- function getData() {
183
-
184
- // 获取省 start --------------------------------------------------
185
- const isAreaText = provinceText && cityText
186
- if (isAreaText || regionText) {
187
-
188
- for (const item1 of tree) {
189
-
190
- const {
191
- text: text1,
192
- children: children1,
193
- } = item1
194
-
195
- const _text1 = $n_replaceAll(text1, '省', '')
196
-
197
- if (
198
- isAreaText ?
199
- (
200
- provinceText === text1
201
- || $n_replaceAll(provinceText, '省', '') === _text1
202
- )
203
- : regionText.indexOf(_text1) > -1
204
- ) {
205
-
206
- // 获取市 start --------------------------------------------------
207
- if ($n_isValidArray(children1)) {
208
-
209
- for (const item2 of children1) {
210
-
211
- const {
212
- text: text2,
213
- children: children2,
214
- } = item2
215
-
216
- const _text2 = replaceArea(text2)
217
-
218
- if (
219
- isAreaText ?
220
- (
221
- cityText === text2
222
- || replaceArea(cityText) === _text2
223
- )
224
- : regionText.indexOf(_text2) > -1
225
- ) {
226
- // 获取区 start --------------------------------------------------
227
- if ($n_isValidArray(children2)) {
228
-
229
- if (areaText || regionText) {
230
-
231
- for (const item3 of children2) {
232
-
233
- const {
234
- text: text3,
235
- } = item3
236
- const _text3 = replaceArea(text3)
237
-
238
- if (
239
- areaText ?
240
- (
241
- areaText === text3
242
- || replaceArea(areaText) === _text3
243
- )
244
- : regionText.indexOf(_text3) > -1
245
- ) {
246
- return item3
247
- }
248
- }
249
- }
250
-
251
- if (! data) {
252
- return children2[0]
253
- }
254
- }
255
- return false
256
- // 获取市 end --------------------------------------------------
257
- }
258
- }
259
- }
260
- return false
261
- // 获取市 end --------------------------------------------------
262
- }
263
- }
264
- }
265
- return false
266
- }
267
-
268
- data = getData()
269
- if (! data) {
270
- return false
271
- }
272
- }
273
-
274
- // 获取区
275
- const {
276
- attr,
277
- } = data
278
-
279
- const res = Object.assign({}, attr)
280
-
281
- let province
282
- let city
283
- let area
284
-
285
- // 如果为区
286
- if (level === 3) {
287
-
288
- // 获取区
289
- area = attr
290
-
291
- // 获取市
292
- city = attrs[area.pid]
293
-
294
- // 获取省
295
- province = attrs[city.pid]
296
-
297
- // 如果为市
298
- } else if (level === 2) {
299
-
300
- // 获取市
301
- city = attr
302
-
303
- // 获取市下第一个区
304
- area = nodes[city.id].children[0]
305
-
306
- // 获取省
307
- province = attrs[city.pid]
308
-
309
- // 否则为省
310
- } else {
311
-
312
- // 获取省
313
- province = attr
314
-
315
- // 获取省下第一个市
316
- city = nodes[province.id].children[0]
317
-
318
- // 获取市下第一个区
319
- area = nodes[city.id].children[0]
320
- }
321
-
322
- // 获取地区
323
- res.region = [
324
- province,
325
- ]
326
-
327
- // 获取地区 ids 数组
328
- res.region_ids = [
329
- province.id,
330
- ]
331
-
332
- // 获取地区文字
333
- const texts = [
334
- province.title,
335
- ]
336
-
337
- if (level >= 2) {
338
- res.region.push(city)
339
- res.region_ids.push(city.id)
340
-
341
- if (city.title !== province.title) {
342
- texts.push(city.title)
343
- }
344
-
345
- if (level === 3) {
346
- res.region.push(area)
347
- res.region_ids.push(area.id)
348
-
349
- const _areaText = area.title.replace('市辖区', '')
350
- if (texts[texts.length - 1] !== _areaText) {
351
- texts.push(_areaText)
352
- }
353
- }
354
- }
355
-
356
- res.region_text = texts.join('')
357
-
358
- // 返回数据示例
359
- // level: 3
360
- // pid: 140700
361
- // region:
362
- // [
363
- // {
364
- // level: 1
365
- // pid: 0
366
- // text: "山西省"
367
- // value: 140000
368
- // },
369
- // {
370
- // level: 2
371
- // pid: 140000
372
- // text: "晋中市"
373
- // value: 140700
374
- // },
375
- // {
376
- // level: 3
377
- // pid: 140700
378
- // text: "介休市"
379
- // value: 140781
380
- // }
381
- // ]
382
- // region_ids: [140000, 140700, 140781]
383
- // region_text: "山西省晋中市介休市"
384
- // text: "介休市"
385
- // value: 140781
386
-
387
- return res
388
- }
389
-
390
- /**
391
- * 地区
392
- */
393
- const area = {
394
- // 获取地区数据
395
- getData,
396
- // 获取地区详情
397
- getInfo,
398
- }
399
-
400
- export default area
1
+ import $n_cloneDeep from 'lodash/cloneDeep'
2
+ import $n_get from 'lodash/get'
3
+ import $n_isValidArray from '@netang/utils/isValidArray'
4
+ import $n_indexOf from '@netang/utils/indexOf'
5
+ import $n_toTree from '@netang/utils/toTree'
6
+ import $n_trimString from '@netang/utils/trimString'
7
+ import $n_replaceAll from '@netang/utils/replaceAll'
8
+
9
+ // 地址数据缓存
10
+ let _areaData = null
11
+
12
+ /**
13
+ * 获取地区数据
14
+ */
15
+ function getData(level = 3, options) {
16
+ return _getData(() => import('../configs/area3'), level, options)
17
+ }
18
+ function _getData(areaData, level, options) {
19
+ return new Promise(function(resolve) {
20
+
21
+ // 执行
22
+ function run() {
23
+
24
+ const para = Object.assign({
25
+ // 忽略地区 id
26
+ ignore: [],
27
+ }, options)
28
+
29
+ // 克隆树数据
30
+ const treeData = $n_cloneDeep(_areaData)
31
+ const all = {}
32
+ const rows = []
33
+
34
+ // 是否有忽略省市区 id
35
+ const isIgnore = $n_isValidArray(para.ignore)
36
+ function checkIgnore(id) {
37
+ return isIgnore && $n_indexOf(para.ignore, id) > -1
38
+ }
39
+
40
+ // 省
41
+ for (const item1 of treeData) {
42
+
43
+ // 如果有忽略省
44
+ if (checkIgnore(item1[1])) {
45
+ continue
46
+ }
47
+
48
+ all[item1[1]] = {
49
+ id: item1[1],
50
+ pid: 0,
51
+ title: item1[0],
52
+ level: 1,
53
+ }
54
+
55
+ // 市
56
+ if (level > 1 && $n_isValidArray(item1[2])) {
57
+
58
+ for (let index2 = 0, len2 = item1[2].length; index2 < len2; index2++) {
59
+ const item2 = item1[2][index2]
60
+
61
+ // 如果有忽略市
62
+ if (checkIgnore(item2[1])) {
63
+ continue
64
+ }
65
+
66
+ all[item2[1]] = {
67
+ id: item2[1],
68
+ pid: item1[1],
69
+ title: item2[0],
70
+ level: 2,
71
+ }
72
+ item1[2][index2] = all[item2[1]]
73
+
74
+ // 区
75
+ if (level > 2 && $n_isValidArray(item2[2])) {
76
+ for (let index3 = 0, len3 = item2[2].length; index3 < len3; index3++) {
77
+ const item3 = item2[2][index3]
78
+
79
+ // 如果有忽略区
80
+ if (checkIgnore(item3[1])) {
81
+ continue
82
+ }
83
+
84
+ all[item3[1]] = {
85
+ id: item3[1],
86
+ pid: item2[1],
87
+ title: item3[0],
88
+ level: 3,
89
+ }
90
+ item2[2][index3] = all[item3[1]]
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ for (const key in all) {
98
+ rows.push(all[key])
99
+ }
100
+
101
+ resolve($n_toTree({
102
+ data: rows,
103
+ }))
104
+ }
105
+
106
+ if (_areaData) {
107
+ run()
108
+ return
109
+ }
110
+
111
+ areaData()
112
+ .then((res)=>{
113
+ _areaData = res.default
114
+ run()
115
+ })
116
+ })
117
+ }
118
+
119
+ /**
120
+ * 替换地址
121
+ */
122
+ function replaceArea(val) {
123
+ val = $n_trimString(val)
124
+ return val.replace(/直辖市/g, '')
125
+ .replace(/市/g, '')
126
+ .replace(/区/g, '')
127
+ .replace(/自治县/g, '')
128
+ .replace(/自治州/g, '')
129
+ .replace(/县/g, '')
130
+ }
131
+
132
+ /**
133
+ * 获取地区详情
134
+ */
135
+ async function getInfo(options) {
136
+
137
+ let {
138
+ // 地址数据
139
+ areaData,
140
+ // 级别
141
+ level,
142
+ // 地区编码
143
+ code,
144
+ // 省文字
145
+ provinceText,
146
+ // 市文字
147
+ cityText,
148
+ // 区文字
149
+ areaText,
150
+ // 详细区域文字
151
+ regionText,
152
+
153
+ } = Object.assign({
154
+ // 地址数据
155
+ areaData: null,
156
+ // 级别
157
+ level: 3,
158
+ // 地区编码
159
+ code: 0,
160
+ // 省文字
161
+ provinceText: '',
162
+ // 市文字
163
+ cityText: '',
164
+ // 区文字
165
+ areaText: '',
166
+ // 详细区域文字
167
+ regionText: '',
168
+ }, options)
169
+
170
+ if (! areaData) {
171
+ areaData = await getData(level)
172
+ }
173
+
174
+ const { attrs, nodes, tree } = areaData
175
+
176
+ // 先通过地区编码来查找
177
+ let data = $n_get(nodes, code)
178
+
179
+ // 如果没有找到, 则通过文字来查找
180
+ if (! data) {
181
+
182
+ function getData() {
183
+
184
+ // 获取省 start --------------------------------------------------
185
+ const isAreaText = provinceText && cityText
186
+ if (isAreaText || regionText) {
187
+
188
+ for (const item1 of tree) {
189
+
190
+ const {
191
+ text: text1,
192
+ children: children1,
193
+ } = item1
194
+
195
+ const _text1 = $n_replaceAll(text1, '省', '')
196
+
197
+ if (
198
+ isAreaText ?
199
+ (
200
+ provinceText === text1
201
+ || $n_replaceAll(provinceText, '省', '') === _text1
202
+ )
203
+ : regionText.indexOf(_text1) > -1
204
+ ) {
205
+
206
+ // 获取市 start --------------------------------------------------
207
+ if ($n_isValidArray(children1)) {
208
+
209
+ for (const item2 of children1) {
210
+
211
+ const {
212
+ text: text2,
213
+ children: children2,
214
+ } = item2
215
+
216
+ const _text2 = replaceArea(text2)
217
+
218
+ if (
219
+ isAreaText ?
220
+ (
221
+ cityText === text2
222
+ || replaceArea(cityText) === _text2
223
+ )
224
+ : regionText.indexOf(_text2) > -1
225
+ ) {
226
+ // 获取区 start --------------------------------------------------
227
+ if ($n_isValidArray(children2)) {
228
+
229
+ if (areaText || regionText) {
230
+
231
+ for (const item3 of children2) {
232
+
233
+ const {
234
+ text: text3,
235
+ } = item3
236
+ const _text3 = replaceArea(text3)
237
+
238
+ if (
239
+ areaText ?
240
+ (
241
+ areaText === text3
242
+ || replaceArea(areaText) === _text3
243
+ )
244
+ : regionText.indexOf(_text3) > -1
245
+ ) {
246
+ return item3
247
+ }
248
+ }
249
+ }
250
+
251
+ if (! data) {
252
+ return children2[0]
253
+ }
254
+ }
255
+ return false
256
+ // 获取市 end --------------------------------------------------
257
+ }
258
+ }
259
+ }
260
+ return false
261
+ // 获取市 end --------------------------------------------------
262
+ }
263
+ }
264
+ }
265
+ return false
266
+ }
267
+
268
+ data = getData()
269
+ if (! data) {
270
+ return false
271
+ }
272
+ }
273
+
274
+ // 获取区
275
+ const {
276
+ attr,
277
+ } = data
278
+
279
+ const res = Object.assign({}, attr)
280
+
281
+ let province
282
+ let city
283
+ let area
284
+
285
+ // 如果为区
286
+ if (level === 3) {
287
+
288
+ // 获取区
289
+ area = attr
290
+
291
+ // 获取市
292
+ city = attrs[area.pid]
293
+
294
+ // 获取省
295
+ province = attrs[city.pid]
296
+
297
+ // 如果为市
298
+ } else if (level === 2) {
299
+
300
+ // 获取市
301
+ city = attr
302
+
303
+ // 获取市下第一个区
304
+ area = nodes[city.id].children[0]
305
+
306
+ // 获取省
307
+ province = attrs[city.pid]
308
+
309
+ // 否则为省
310
+ } else {
311
+
312
+ // 获取省
313
+ province = attr
314
+
315
+ // 获取省下第一个市
316
+ city = nodes[province.id].children[0]
317
+
318
+ // 获取市下第一个区
319
+ area = nodes[city.id].children[0]
320
+ }
321
+
322
+ // 获取地区
323
+ res.region = [
324
+ province,
325
+ ]
326
+
327
+ // 获取地区 ids 数组
328
+ res.region_ids = [
329
+ province.id,
330
+ ]
331
+
332
+ // 获取地区文字
333
+ const texts = [
334
+ province.title,
335
+ ]
336
+
337
+ if (level >= 2) {
338
+ res.region.push(city)
339
+ res.region_ids.push(city.id)
340
+
341
+ if (city.title !== province.title) {
342
+ texts.push(city.title)
343
+ }
344
+
345
+ if (level === 3) {
346
+ res.region.push(area)
347
+ res.region_ids.push(area.id)
348
+
349
+ const _areaText = area.title.replace('市辖区', '')
350
+ if (texts[texts.length - 1] !== _areaText) {
351
+ texts.push(_areaText)
352
+ }
353
+ }
354
+ }
355
+
356
+ res.region_text = texts.join('')
357
+
358
+ // 返回数据示例
359
+ // level: 3
360
+ // pid: 140700
361
+ // region:
362
+ // [
363
+ // {
364
+ // level: 1
365
+ // pid: 0
366
+ // text: "山西省"
367
+ // value: 140000
368
+ // },
369
+ // {
370
+ // level: 2
371
+ // pid: 140000
372
+ // text: "晋中市"
373
+ // value: 140700
374
+ // },
375
+ // {
376
+ // level: 3
377
+ // pid: 140700
378
+ // text: "介休市"
379
+ // value: 140781
380
+ // }
381
+ // ]
382
+ // region_ids: [140000, 140700, 140781]
383
+ // region_text: "山西省晋中市介休市"
384
+ // text: "介休市"
385
+ // value: 140781
386
+
387
+ return res
388
+ }
389
+
390
+ /**
391
+ * 地区
392
+ */
393
+ const area = {
394
+ // 获取地区数据
395
+ getData,
396
+ // 获取地区详情
397
+ getInfo,
398
+ }
399
+
400
+ export default area