@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
@@ -0,0 +1,100 @@
1
+ import { date } from 'quasar'
2
+
3
+ export const quickRange = ['最近7天', '最近30天', '本月', '上月', '最近2个月', '最近3个月', '最近6个月', '今年', '去年', '最近1年', '最近2年']
4
+
5
+ export function getQuickRange(index, showSecond) {
6
+
7
+ // 获取当前时间
8
+ const now = new Date()
9
+
10
+ const time = {
11
+ from: '00:00',
12
+ to: '23:59',
13
+ }
14
+ if (showSecond) {
15
+ time.from += ':00'
16
+ time.to += ':59'
17
+ }
18
+
19
+ // const quickRange = ['最近7天', '最近30天', '本周', '上周', '本月', '上月', '最近3个月', '最近6个月', '今年', '去年', '最近1年', '最近2年']
20
+ switch (index) {
21
+
22
+ // 最近7天
23
+ case 0:
24
+ // 最近30天
25
+ case 1:
26
+ return {
27
+ date: {
28
+ from: date.formatDate(date.subtractFromDate(now, { days: index === 0 ? 7 : 30 }), 'YYYY/MM/DD'),
29
+ to: date.formatDate(now, 'YYYY/MM/DD'),
30
+ },
31
+ time,
32
+ }
33
+
34
+ // 本月
35
+ case 2:
36
+ return {
37
+ date: {
38
+ from: date.formatDate(date.startOfDate(now, 'month'), 'YYYY/MM/DD'),
39
+ to: date.formatDate(date.endOfDate(now, 'month'), 'YYYY/MM/DD'),
40
+ },
41
+ time,
42
+ }
43
+
44
+ // 上月
45
+ case 3:
46
+ return {
47
+ date: {
48
+ from: date.formatDate(date.startOfDate(date.subtractFromDate(now, { month: 1 }), 'month'), 'YYYY/MM/DD'),
49
+ to: date.formatDate(date.endOfDate(date.subtractFromDate(now, { month: 1 }), 'month'), 'YYYY/MM/DD'),
50
+ },
51
+ time,
52
+ }
53
+
54
+ // 最近2个月
55
+ case 4:
56
+ // 最近3个月
57
+ case 5:
58
+ // 最近6个月
59
+ case 6:
60
+ return {
61
+ date: {
62
+ from: date.formatDate(date.subtractFromDate(now, { months: index === 4 ? 2 : (index === 5 ? 3 : 6) }), 'YYYY/MM/DD'),
63
+ to: date.formatDate(now, 'YYYY/MM/DD'),
64
+ },
65
+ time,
66
+ }
67
+
68
+ // 今年
69
+ case 7:
70
+ return {
71
+ date: {
72
+ from: date.formatDate(date.startOfDate(now, 'year'), 'YYYY/MM/DD'),
73
+ to: date.formatDate(date.endOfDate(now, 'year'), 'YYYY/MM/DD'),
74
+ },
75
+ time,
76
+ }
77
+
78
+ // 去年
79
+ case 8:
80
+ return {
81
+ date: {
82
+ from: date.formatDate(date.startOfDate(date.subtractFromDate(now, { year: 1 }), 'year'), 'YYYY/MM/DD'),
83
+ to: date.formatDate(date.endOfDate(date.subtractFromDate(now, { year: 1 }), 'year'), 'YYYY/MM/DD'),
84
+ },
85
+ time,
86
+ }
87
+
88
+ // 最近1年
89
+ case 9:
90
+ // 最近2年
91
+ case 10:
92
+ return {
93
+ date: {
94
+ from: date.formatDate(date.subtractFromDate(now, { year: index === 9 ? 1 : 2 }), 'YYYY/MM/DD'),
95
+ to: date.formatDate(now, 'YYYY/MM/DD'),
96
+ },
97
+ time,
98
+ }
99
+ }
100
+ }
@@ -0,0 +1,468 @@
1
+ <template>
2
+ <q-field
3
+ :class="fieldFocused ? 'q-field--float q-field--focused q-field--highlighted' : ''"
4
+ :model-value="modelValue"
5
+ :readonly="readonly"
6
+ @clear="onClear"
7
+ v-bind="$attrs"
8
+ >
9
+ <template v-slot:control>
10
+
11
+ <!--&lt;!&ndash; 显示值 &ndash;&gt;-->
12
+ <!--<div v-if="showValue">{{showValue}}</div>-->
13
+
14
+ <!--&lt;!&ndash; 显示占位符 &ndash;&gt;-->
15
+ <!--<div class="n-placeholder" v-else-if="placeholder">{{placeholder}}</div>-->
16
+ </template>
17
+
18
+ <template v-slot:append>
19
+ <q-icon
20
+ class="cursor-pointer"
21
+ name="search"
22
+ @click.prevent.stop="onDialog"
23
+ />
24
+ </template>
25
+
26
+ <q-popup-proxy
27
+ ref="popupRef"
28
+ @before-show="onPopupBeforeShow"
29
+ @show="onPopupShow"
30
+ @before-hide="onPopupBeforeHide"
31
+ @hide="onPopupHide"
32
+ v-if="! readonly"
33
+ >
34
+ <q-table
35
+ ref="tableRef"
36
+ class="n-table"
37
+ style="min-width:500px;max-width:90vw;height: 300px;"
38
+ v-model:pagination="tablePagination"
39
+ v-model:selected="tableSelected"
40
+ :row-key="tableRowKey"
41
+ :rows="tableRows"
42
+ :columns="tableColumns"
43
+ :selection="tableSelection"
44
+ :loading="tableLoading"
45
+ :rows-per-page-options="tableRowsPerPageOptions"
46
+ @row-click="tableRowClick"
47
+ @row-dblclick="tableRowDblclick"
48
+ @request="tableRequest"
49
+ flat
50
+ virtual-scroll
51
+ dense
52
+ >
53
+ <!-- 图片 -->
54
+ <template
55
+ v-for="imgName in tableImgNames"
56
+ v-slot:[`body-cell-${imgName}`]="props"
57
+ >
58
+ <q-td :props="props">
59
+ <!-- 缩略图 -->
60
+ <n-thumbnail
61
+ :src="props.row[imgName]"
62
+ preview
63
+ />
64
+ </q-td>
65
+ </template>
66
+
67
+ <!-- 插槽 -->
68
+ <template
69
+ v-for="slotName in slotNames"
70
+ v-slot:[slotName]="props"
71
+ >
72
+ <q-td :props="props">
73
+ <slot
74
+ :name="slotName"
75
+ v-bind="props"
76
+ />
77
+ </q-td>
78
+ </template>
79
+
80
+ <!-- 合计 -->
81
+ <!--<template v-slot:bottom-row="props" v-if="tableSummary">-->
82
+ <!-- <n-table-summary-->
83
+ <!-- :props="props"-->
84
+ <!-- :data="tableSummary"-->
85
+ <!-- :selection="tableSelection"-->
86
+ <!-- />-->
87
+ <!--</template>-->
88
+
89
+ <!-- 翻页 -->
90
+ <template v-slot:pagination="props">
91
+ <n-table-pagination
92
+ :props="props"
93
+ :table-refresh="tableRefresh"
94
+ />
95
+ </template>
96
+ </q-table>
97
+ </q-popup-proxy>
98
+ </q-field>
99
+
100
+ <q-dialog v-model="showDialog">
101
+ <q-card>
102
+ 123123123
103
+ <!--<q-table-->
104
+ <!-- ref="tableRef"-->
105
+ <!-- class="n-table"-->
106
+ <!-- style="min-width:500px;max-width:90vw;height: 300px;"-->
107
+ <!-- v-model:pagination="tablePagination"-->
108
+ <!-- v-model:selected="tableSelected"-->
109
+ <!-- :row-key="tableRowKey"-->
110
+ <!-- :rows="tableRows"-->
111
+ <!-- :columns="tableColumns"-->
112
+ <!-- :selection="tableSelection"-->
113
+ <!-- :loading="tableLoading"-->
114
+ <!-- :rows-per-page-options="tableRowsPerPageOptions"-->
115
+ <!-- @row-click="tableRowClick"-->
116
+ <!-- @row-dblclick="tableRowDblclick"-->
117
+ <!-- @request="tableRequest"-->
118
+ <!-- flat-->
119
+ <!-- virtual-scroll-->
120
+ <!-- dense-->
121
+ <!--&gt;-->
122
+ <!-- &lt;!&ndash; 图片 &ndash;&gt;-->
123
+ <!-- <template-->
124
+ <!-- v-for="imgName in tableImgNames"-->
125
+ <!-- v-slot:[`body-cell-${imgName}`]="props"-->
126
+ <!-- >-->
127
+ <!-- <q-td :props="props">-->
128
+ <!-- &lt;!&ndash; 缩略图 &ndash;&gt;-->
129
+ <!-- <n-thumbnail-->
130
+ <!-- :src="props.row[imgName]"-->
131
+ <!-- preview-->
132
+ <!-- />-->
133
+ <!-- </q-td>-->
134
+ <!-- </template>-->
135
+
136
+ <!-- &lt;!&ndash; 插槽 &ndash;&gt;-->
137
+ <!-- <template-->
138
+ <!-- v-for="slotName in slotNames"-->
139
+ <!-- v-slot:[slotName]="props"-->
140
+ <!-- >-->
141
+ <!-- <q-td :props="props">-->
142
+ <!-- <slot-->
143
+ <!-- :name="slotName"-->
144
+ <!-- v-bind="props"-->
145
+ <!-- />-->
146
+ <!-- </q-td>-->
147
+ <!-- </template>-->
148
+
149
+ <!-- &lt;!&ndash; 合计 &ndash;&gt;-->
150
+ <!-- &lt;!&ndash;<template v-slot:bottom-row="props" v-if="tableSummary">&ndash;&gt;-->
151
+ <!-- &lt;!&ndash; <n-table-summary&ndash;&gt;-->
152
+ <!-- &lt;!&ndash; :props="props"&ndash;&gt;-->
153
+ <!-- &lt;!&ndash; :data="tableSummary"&ndash;&gt;-->
154
+ <!-- &lt;!&ndash; :selection="tableSelection"&ndash;&gt;-->
155
+ <!-- &lt;!&ndash; />&ndash;&gt;-->
156
+ <!-- &lt;!&ndash;</template>&ndash;&gt;-->
157
+
158
+ <!-- &lt;!&ndash; 翻页 &ndash;&gt;-->
159
+ <!-- <template v-slot:pagination="props">-->
160
+ <!-- <n-table-pagination-->
161
+ <!-- :props="props"-->
162
+ <!-- :table-refresh="tableRefresh"-->
163
+ <!-- />-->
164
+ <!-- </template>-->
165
+ <!--</q-table>-->
166
+ <!--<q-card-section>-->
167
+ <!-- <div class="text-h6">Alert</div>-->
168
+ <!--</q-card-section>-->
169
+
170
+ <!--<q-card-section class="q-pt-none">-->
171
+ <!-- Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum repellendus sit voluptate voluptas eveniet porro. Rerum blanditiis perferendis totam, ea at omnis vel numquam exercitationem aut, natus minima, porro labore.-->
172
+ <!--</q-card-section>-->
173
+
174
+ <!--<q-card-actions align="right">-->
175
+ <!-- <q-btn flat label="OK" color="primary" v-close-popup />-->
176
+ <!--</q-card-actions>-->
177
+ </q-card>
178
+ </q-dialog>
179
+ </template>
180
+
181
+ <script>
182
+ import { ref, reactive, computed, watch, nextTick, onMounted } from 'vue'
183
+ import { date as quasarDate } from 'quasar'
184
+ import NDialog from "../dialog";
185
+
186
+ export default {
187
+
188
+ /**
189
+ * 标识
190
+ */
191
+ name: 'NFieldTable',
192
+ components: {NDialog},
193
+ /**
194
+ * 声明属性
195
+ */
196
+ props: {
197
+ // 值
198
+ modelValue: [String, Number],
199
+ // 占位符
200
+ placeholder: String,
201
+ // 是否只读
202
+ readonly: Boolean,
203
+
204
+ // 表格请求地址
205
+ url: String,
206
+ // 路由组件路径
207
+ route: String,
208
+ // 值属性名称
209
+ valueKey: {
210
+ type: String,
211
+ required: true,
212
+ },
213
+ // 快捷表格显示的属性名称数组
214
+ showKeys: {
215
+ type: Array,
216
+ required: true,
217
+ },
218
+ // 默认搜索属性名称
219
+ searchKey: String,
220
+
221
+ // 表格列数据
222
+ columns: Array,
223
+ // 表格行唯一键值
224
+ rowKey: {
225
+ type: String,
226
+ default: 'id',
227
+ },
228
+ // 是否多选
229
+ multiple: Boolean,
230
+ // 行数据
231
+ rows: Array,
232
+ },
233
+
234
+ /**
235
+ * 声明事件
236
+ */
237
+ emits: [
238
+ 'update:modelValue',
239
+ ],
240
+
241
+ /**
242
+ * 组合式
243
+ */
244
+ setup(props, { emit, slots }) {
245
+
246
+
247
+ // ==========【数据】============================================================================================
248
+
249
+ // 字段组件获取焦点
250
+ const fieldFocused = ref(false)
251
+
252
+ // 弹出层节点
253
+ const popupRef = ref(null)
254
+
255
+ // 是否显示对话框
256
+ const showDialog = ref(false)
257
+
258
+ // 表格是否已加载
259
+ let tableLoaded = false
260
+
261
+ // 创建表格
262
+ const $table = utils.$table.create({
263
+ url: props.route ? props.route : props.url,
264
+ // 获取表格列数据
265
+ columns: getTableColumns(),
266
+ // 表格行唯一键值
267
+ rowKey: props.rowKey,
268
+ // 选择类型, 可选值 single multiple none
269
+ selection: props.multiple ? 'multiple' : 'none',
270
+ // 关闭宫格
271
+ showGrid: false,
272
+ // 关闭可见列
273
+ showVisibleColumns: false,
274
+ })
275
+
276
+ // ==========【计算属性】=========================================================================================
277
+
278
+ /**
279
+ * 插槽标识
280
+ */
281
+ const slotNames = computed(function() {
282
+ if (utils.isValidObject(slots)) {
283
+ return Object.keys(slots)
284
+ }
285
+ return []
286
+ })
287
+
288
+ // ==========【监听数据】=========================================================================================
289
+
290
+ /**
291
+ * 获取快捷表格列数据
292
+ */
293
+ // watch([()=>props.modelValue, ()=>props.end, ()=>props.type], function() {
294
+ //
295
+ // })
296
+
297
+ // ==========【方法】=============================================================================================
298
+
299
+ /**
300
+ * 获取表格列数据
301
+ */
302
+ function getTableColumns() {
303
+
304
+ const columns = []
305
+
306
+ // 获取原始表格列数据
307
+ let rawTableColumns = props.route
308
+ // 如果有路由组件路径
309
+ ? utils.$table.config(props.route, 'columns')
310
+ // 否则为自定义表格列数据
311
+ : props.columns
312
+
313
+ // 如果有原始表格列数据
314
+ if (utils.isValidArray(rawTableColumns)) {
315
+
316
+ // 克隆原始表格列数据
317
+ rawTableColumns = _.cloneDeep(rawTableColumns)
318
+
319
+ // 快捷表格显示的属性名称数组
320
+ utils.forEach(props.showKeys, function (key) {
321
+ for (const item of rawTableColumns) {
322
+ if (item.name === key) {
323
+ // 删除搜索字段
324
+ if (_.has(item, 'search')) {
325
+ delete item.search
326
+ }
327
+ // 删除可见字段
328
+ if (_.has(item, 'visible')) {
329
+ delete item.visible
330
+ }
331
+ columns.push(item)
332
+ }
333
+ }
334
+ })
335
+ }
336
+
337
+ return columns
338
+ }
339
+
340
+ /**
341
+ * 取消
342
+ */
343
+ function onCancel() {
344
+ // 还原原始值
345
+ // onEmit('update:modelValue', oldModelValue)
346
+ }
347
+
348
+ /**
349
+ * 弹出层显示前回调
350
+ */
351
+ function onPopupBeforeShow() {
352
+
353
+ // 字段组件获取焦点
354
+ fieldFocused.value = true
355
+ }
356
+
357
+ /**
358
+ * 弹出层显示回调
359
+ */
360
+ function onPopupShow() {
361
+
362
+ // 表格重新加载
363
+ if (! tableLoaded) {
364
+ $table.tableReload()
365
+ tableLoaded = true
366
+ }
367
+ }
368
+
369
+ /**
370
+ * 弹出层隐藏前回调
371
+ */
372
+ function onPopupBeforeHide() {
373
+
374
+ // 字段组件失去焦点
375
+ fieldFocused.value = false
376
+ }
377
+
378
+ /**
379
+ * 弹出层隐藏后回调
380
+ */
381
+ function onPopupHide() {
382
+
383
+ }
384
+
385
+ /**
386
+ * 清空
387
+ */
388
+ function onClear() {
389
+ emit('update:modelValue', null)
390
+ popupRef.value.hide()
391
+ }
392
+
393
+ /**
394
+ * 显示对话框
395
+ */
396
+ function onDialog() {
397
+
398
+ showDialog.value = true
399
+ console.log('ssss')
400
+ }
401
+
402
+ // ==========【生命周期】=========================================================================================
403
+
404
+
405
+ // ==========【返回】=============================================================================================
406
+
407
+ return {
408
+ // 解构表格实例
409
+ ...$table,
410
+
411
+ // 字段组件获取焦点
412
+ fieldFocused,
413
+ // 弹出层节点
414
+ popupRef,
415
+ // 是否显示对话框
416
+ showDialog,
417
+
418
+ // 插槽 body 单元格标识
419
+ slotNames,
420
+
421
+ // 取消
422
+ onCancel,
423
+ // 弹出层显示前回调
424
+ onPopupBeforeShow,
425
+ // 弹出层显示回调
426
+ onPopupShow,
427
+ // 弹出层隐藏前回调
428
+ onPopupBeforeHide,
429
+ // 弹出层隐藏后回调
430
+ onPopupHide,
431
+ // 清空
432
+ onClear,
433
+
434
+ // 显示对话框
435
+ onDialog,
436
+ }
437
+ },
438
+ }
439
+ </script>
440
+
441
+ <style lang="scss" scoped>
442
+ @import "@/assets/sass/var.scss";
443
+
444
+ .date {
445
+
446
+ // 选择容器
447
+ &__select {
448
+ background-color: #ffffff;
449
+ }
450
+
451
+ // 时间容器
452
+ &__time {
453
+ + .date__settings {
454
+ // 等同 q-pt-sm
455
+ padding-top: map-get($space-sm, 'y');
456
+ }
457
+ }
458
+ }
459
+
460
+ /**
461
+ * 暗色
462
+ */
463
+ .body--dark {
464
+ .date__select {
465
+ background-color: $color-gray-86;
466
+ }
467
+ }
468
+ </style>