@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,179 @@
1
+ <template>
2
+ <q-input
3
+ v-model="currentValue"
4
+ @blur="onBlur"
5
+ v-bind="$attrs"
6
+ >
7
+ <template
8
+ v-for="slotName in slotNames"
9
+ v-slot:[slotName]
10
+ >
11
+ <slot :name="slotName" />
12
+ </template>
13
+ </q-input>
14
+ </template>
15
+
16
+ <script>
17
+ import { computed, ref, watch } from 'vue'
18
+
19
+ /**
20
+ * 金额(元)
21
+ */
22
+ export default {
23
+
24
+ /**
25
+ * 标识
26
+ */
27
+ name: 'NInputPrice',
28
+
29
+ /**
30
+ * 声明属性
31
+ */
32
+ props: {
33
+ // 值
34
+ modelValue: [String, Number],
35
+ // 最小值(元)
36
+ min: {
37
+ type: Number,
38
+ default: 1,
39
+ },
40
+ // 最大值(元)
41
+ max: Number,
42
+ },
43
+
44
+ /**
45
+ * 声明事件
46
+ */
47
+ emits: [
48
+ 'update:modelValue',
49
+ ],
50
+
51
+ /**
52
+ * 组合式
53
+ */
54
+ setup(props, { emit, slots }) {
55
+
56
+ // ==========【数据】============================================================================================
57
+
58
+ // 当前值
59
+ const currentValue = ref(props.modelValue)
60
+
61
+ // ==========【计算属性】==========================================================================================
62
+
63
+ /**
64
+ * 插槽标识数组
65
+ */
66
+ const slotNames = computed(function() {
67
+ if (utils.isValidObject(slots)) {
68
+ return Object.keys(slots)
69
+ }
70
+ return []
71
+ })
72
+
73
+ // ==========【监听数据】=========================================================================================
74
+
75
+ /**
76
+ * 监听声明值
77
+ */
78
+ watch(()=>props.modelValue, function(val) {
79
+ currentValue.value = val
80
+ })
81
+
82
+ // ==========【方法】=============================================================================================
83
+
84
+ /**
85
+ * 提交值
86
+ */
87
+ function emitModelValue(newVal) {
88
+ // 更新值
89
+ emit('update:modelValue', newVal)
90
+ }
91
+
92
+ /**
93
+ * 失去焦点触发
94
+ */
95
+ function onBlur() {
96
+
97
+ if (utils.isValidValue(currentValue.value)) {
98
+
99
+ let val = new BigNumber(currentValue.value)
100
+
101
+ if (val.isFinite()) {
102
+
103
+ // 值是否有更新
104
+ let isChange = false
105
+
106
+ if (
107
+ // 如果值 > 0
108
+ val.isGreaterThan(0)
109
+ // 如果值精度 > 2
110
+ && val.decimalPlaces() > 2
111
+ ) {
112
+ // 值有更新
113
+ isChange = true
114
+
115
+ // 将元向下舍入 2 位精度(如 68.345 -> 68.34)
116
+ val = val.decimalPlaces(2, BigNumber.ROUND_DOWN)
117
+ }
118
+
119
+ // 如果值 >= 最大值
120
+ if (Number.isFinite(props.max)) {
121
+ if (val.isGreaterThanOrEqualTo(props.max)) {
122
+
123
+ // 更新当前值
124
+ currentValue.value = props.max
125
+
126
+ // 提交值
127
+ emitModelValue(currentValue.value)
128
+ return
129
+ }
130
+ }
131
+
132
+ // 如果值 <= 最小值
133
+ if (Number.isFinite(props.min)) {
134
+ if (val.isLessThanOrEqualTo(props.min)) {
135
+
136
+ // 更新当前值
137
+ currentValue.value = props.min
138
+
139
+ // 提交值
140
+ emitModelValue(currentValue.value)
141
+ return
142
+ }
143
+ }
144
+
145
+ // 获取最新值
146
+ val = val.toNumber()
147
+
148
+ if (isChange) {
149
+ // 更新当前值
150
+ currentValue.value = val
151
+ }
152
+
153
+ // 提交值
154
+ emitModelValue(val)
155
+ return
156
+ }
157
+ }
158
+
159
+ // 更新当前值
160
+ currentValue.value = ''
161
+
162
+ // 提交值
163
+ emitModelValue(currentValue.value)
164
+ }
165
+
166
+ // ==========【返回】=============================================================================================
167
+
168
+ return {
169
+ // 当前值
170
+ currentValue,
171
+ // 插槽标识数组
172
+ slotNames,
173
+
174
+ // 失去焦点触发
175
+ onBlur,
176
+ }
177
+ },
178
+ }
179
+ </script>
@@ -0,0 +1,119 @@
1
+ <template>
2
+ <q-layout
3
+ v-bind="$attrs"
4
+ >
5
+ <!-- 错误提示 -->
6
+ <q-page-container v-if="pageStatus === false">
7
+ <q-page class="q-pa-lg flex flex-center">
8
+ {{emptyDescription}}
9
+ </q-page>
10
+ </q-page-container>
11
+
12
+ <!-- 插槽 -->
13
+ <slot :data="data" v-else-if="pageStatus === true" />
14
+ </q-layout>
15
+
16
+ <!-- 加载 -->
17
+ <q-inner-loading
18
+ :showing="pageLoading"
19
+ />
20
+ </template>
21
+
22
+ <script>
23
+ import { provide } from 'vue'
24
+ import { NLayoutKey } from '../../utils/symbols'
25
+
26
+ export default {
27
+
28
+ /**
29
+ * 标识
30
+ */
31
+ name: 'NLayout',
32
+
33
+ /**
34
+ * 声明属性
35
+ */
36
+ props: {
37
+ // 页面加载
38
+ pageLoading: Boolean,
39
+ // 页面状态
40
+ pageStatus: {
41
+ type: Boolean,
42
+ default: null,
43
+ },
44
+ // 空状态描述
45
+ emptyDescription: {
46
+ type: String,
47
+ default: '发生未知错误',
48
+ },
49
+ },
50
+
51
+ /**
52
+ * 组合式
53
+ */
54
+ setup() {
55
+
56
+ // ==========【注入】============================================================================================
57
+
58
+ // 布局数据
59
+ const data = {
60
+ // 左边侧滑菜单数据
61
+ left: {
62
+ // 是否显示
63
+ data: null,
64
+ },
65
+ // 右边侧滑菜单数据
66
+ right: {
67
+ // 是否显示
68
+ data: null,
69
+ },
70
+ // 权限数据
71
+ role: {},
72
+ // 表格数据
73
+ table: {},
74
+ // 上传器
75
+ uploader: [],
76
+ }
77
+ data.left.show = function() {
78
+ return data.left.data !== null ? data.left.data.value : false
79
+ }
80
+ data.left.toggle = function () {
81
+ if (data.left.data !== null) {
82
+ data.left.data.value = ! data.left.data.value
83
+ }
84
+ }
85
+ data.right.show = function() {
86
+ return data.right.data !== null ? data.right.data.value : false
87
+ }
88
+ data.right.toggle = function () {
89
+ if (data.right.data !== null) {
90
+ data.right.data.value = ! data.right.data.value
91
+ }
92
+ }
93
+
94
+ // 向后代注入数据
95
+ provide(NLayoutKey, {
96
+ // 注入数据
97
+ data,
98
+ // 更新注入数据
99
+ update(cb) {
100
+ cb(data)
101
+ },
102
+ // 检查是否上传中
103
+ checkUploading() {
104
+ for (const uploader of data.uploader) {
105
+ if (uploader.checkUploading()) {
106
+ return true
107
+ }
108
+ }
109
+ return false
110
+ },
111
+ })
112
+
113
+ return {
114
+ // 布局数据
115
+ data,
116
+ }
117
+ },
118
+ }
119
+ </script>
@@ -0,0 +1,137 @@
1
+ <template>
2
+ <q-list
3
+ :dark="dark"
4
+ >
5
+ <n-list-menu-item
6
+ :data="data"
7
+ @item-click="onItemClick"
8
+ />
9
+ </q-list>
10
+ </template>
11
+
12
+ <script>
13
+ import { watch } from 'vue'
14
+
15
+ export default {
16
+
17
+ /**
18
+ * 标识
19
+ */
20
+ name: 'NListMenu',
21
+
22
+ /**
23
+ * 声明属性
24
+ */
25
+ props: {
26
+ // 数据
27
+ data: Array,
28
+ // 是否暗色
29
+ dark: Boolean,
30
+ // 激活 key
31
+ activeKey: {
32
+ type: String,
33
+ default: 'id',
34
+ },
35
+ // 激活值
36
+ activeValue: [String, Number],
37
+ },
38
+
39
+ /**
40
+ * 声明事件
41
+ */
42
+ emits: [
43
+ // 单个元素点击
44
+ 'itemClick',
45
+ ],
46
+
47
+ /**
48
+ * 组合式
49
+ */
50
+ setup(props, { emit }) {
51
+
52
+ // ==========【方法】============================================================================================
53
+
54
+ /**
55
+ * 单个元素点击
56
+ */
57
+ function onItemClick(item) {
58
+ emit('itemClick', item)
59
+ }
60
+
61
+ /**
62
+ * 设置激活状态
63
+ */
64
+ function setActive() {
65
+
66
+ const parentAll = {}
67
+
68
+ // 获取父节点
69
+ function getParent({ attr }) {
70
+ if (
71
+ // 如果不是根节点
72
+ attr.pid
73
+ // 有父节点
74
+ && _.has(parentAll, attr.pid)
75
+ ) {
76
+ const parentItem = parentAll[attr.pid]
77
+
78
+ // 设为展开
79
+ parentItem.expanded = true
80
+
81
+ getParent(parentItem)
82
+ }
83
+ }
84
+
85
+ // 获取子节点
86
+ function getChildren(data) {
87
+
88
+ for (const item of data) {
89
+
90
+ // 设为折叠
91
+ item.expanded = false
92
+
93
+ // 如果是父节点
94
+ if (item.children.length) {
95
+ parentAll[item.id] = item
96
+ getChildren(item.children)
97
+
98
+ // 否则如果是匹配的子节点
99
+ } else if (props.activeValue && item.attr[props.activeKey] === props.activeValue) {
100
+
101
+ // 设为展开
102
+ item.expanded = true
103
+
104
+ getParent(item)
105
+ }
106
+ }
107
+ }
108
+
109
+ getChildren(props.data)
110
+ }
111
+
112
+ // ==========【监听数据】=========================================================================================
113
+
114
+ /**
115
+ * 监听声明值
116
+ */
117
+ watch([()=>props.data, ()=>props.activeValue], function() {
118
+
119
+ // 设置激活状态
120
+ if (utils.isValidArray(props.data)) {
121
+ setActive()
122
+ }
123
+
124
+ }, {
125
+ // 立即执行
126
+ immediate: true,
127
+ })
128
+
129
+ // ==========【返回】=========================================================================================
130
+
131
+ return {
132
+ // 单个元素点击
133
+ onItemClick,
134
+ }
135
+ }
136
+ }
137
+ </script>
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <template v-for="item in data">
3
+
4
+ <!-- 如果有子菜单 -->
5
+ <q-expansion-item
6
+ :label="item.label"
7
+ :group="`group-${level}`"
8
+ v-model="item.expanded"
9
+ :icon="item.attr.icon"
10
+ v-if="item.children.length"
11
+ >
12
+ <n-list-menu-item
13
+ :data="item.children"
14
+ :level="level + 1"
15
+ @item-click="onItemClick"
16
+ />
17
+ </q-expansion-item>
18
+
19
+ <!-- 否则为单独的菜单 -->
20
+ <q-item
21
+ :active="item.expanded"
22
+ active-class="text-white"
23
+ @click="onItemClick(item)"
24
+ clickable
25
+ v-else
26
+ >
27
+ <q-item-section>
28
+ <q-item-label>{{item.label}}</q-item-label>
29
+ </q-item-section>
30
+ </q-item>
31
+
32
+ </template>
33
+ </template>
34
+
35
+ <script>
36
+ export default {
37
+
38
+ /**
39
+ * 标识
40
+ */
41
+ name: 'NListMenuItem',
42
+
43
+ /**
44
+ * 声明属性
45
+ */
46
+ props: {
47
+ // 数据
48
+ data: Array,
49
+ // 层级
50
+ level: {
51
+ type: Number,
52
+ default: 1,
53
+ },
54
+ },
55
+
56
+ /**
57
+ * 声明事件
58
+ */
59
+ emits: [
60
+ // 单个元素点击
61
+ 'itemClick',
62
+ ],
63
+
64
+ /**
65
+ * 组合式
66
+ */
67
+ setup(props, { emit }) {
68
+
69
+ // ==========【返回】=========================================================================================
70
+
71
+ return {
72
+ // 单个元素点击
73
+ onItemClick(item) {
74
+ emit('itemClick', item)
75
+ },
76
+ }
77
+ }
78
+ }
79
+ </script>