@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,202 @@
1
+ <template>
2
+ <div
3
+ class="n-dragger"
4
+ :class="{
5
+ dragging,
6
+ }"
7
+ >
8
+ <slot
9
+ :mousedown="mousedown"
10
+ :fromIndex="fromIndex"
11
+ :dragStart="dragStart"
12
+ :dragEnter="dragEnter"
13
+ :dragEnd="dragEnd"
14
+ />
15
+ </div>
16
+ </template>
17
+
18
+ <script>
19
+ import { ref, computed } from 'vue'
20
+
21
+ export default {
22
+
23
+ /**
24
+ * 标识
25
+ */
26
+ name: 'NDragger',
27
+
28
+ /**
29
+ * 声明属性
30
+ */
31
+ props: {
32
+ // 值
33
+ modelValue: Array,
34
+ // 是否开启拖拽
35
+ drag: {
36
+ type: Boolean,
37
+ default: true,
38
+ },
39
+ },
40
+
41
+ /**
42
+ * 声明事件
43
+ */
44
+ emits: [
45
+ 'update:modelValue',
46
+ ],
47
+
48
+ /**
49
+ * 组合式
50
+ */
51
+ setup(props, { emit }) {
52
+
53
+ // ==========【数据】=============================================================================================
54
+
55
+ // 是否拖拽中
56
+ const dragging = ref(false)
57
+
58
+ // 原始位置 index
59
+ const fromIndex = ref(null)
60
+
61
+ // 目标位置 index
62
+ const toIndex = ref(null)
63
+
64
+ // ==========【计算属性】=========================================================================================
65
+
66
+ /**
67
+ * 是否开启拖拽
68
+ */
69
+ const isDrag = computed(function() {
70
+ return props.drag
71
+ && utils.isValidArray(props.modelValue)
72
+ && props.modelValue.length > 1
73
+ })
74
+
75
+ // ==========【方法】=============================================================================================
76
+
77
+ /**
78
+ * 鼠标点击事件
79
+ */
80
+ function mousedown() {
81
+ // 如果开启拖拽
82
+ if (isDrag.value) {
83
+ // 设置拖拽中
84
+ dragging.value = true
85
+ }
86
+ }
87
+
88
+ /**
89
+ * 拖拽开始
90
+ * dragstart: 开始拖元素触发
91
+ * dragenter: 当元素拖进可drop元素(绑定drop事件的元素)时触发
92
+ * dragover: 当元素拖动到drop元素上时触发
93
+ * drop: 当元素放下到drop元素触发
94
+ * dragleave : 当元素离开drop元素时触发
95
+ * drag: 每次元素被拖动时会触发
96
+ * dragend: 放开拖动元素时触发
97
+ */
98
+ function dragStart(e, index) {
99
+
100
+ // 如果开启拖拽
101
+ if (isDrag.value) {
102
+
103
+ // 如果为火狐浏览器, 则必须要setData
104
+ // if (_.ua.firefox) {
105
+ // e.dataTransfer.setData('info', e.target.id)
106
+ // }
107
+
108
+ // 设置拖拽中
109
+ dragging.value = true
110
+
111
+ // 设置原始位置 index
112
+ fromIndex.value = index
113
+ }
114
+ }
115
+
116
+ /**
117
+ * 拖拽中
118
+ */
119
+ function dragEnter(e, index) {
120
+
121
+ // 如果开启拖拽
122
+ if (isDrag.value) {
123
+
124
+ // 设置目标位置 index
125
+ toIndex.value = index
126
+
127
+ // 如果拖拽中
128
+ if (dragging.value) {
129
+
130
+ // 为需要移动的元素设置 dragstart 事件
131
+ // e.dataTransfer.effectAllowed = 'move'
132
+
133
+ // 原始位置 index
134
+ const from = fromIndex.value
135
+ // 目标位置 index
136
+ const to = toIndex.value
137
+
138
+ // 如果原始位置 === 目标位置
139
+ if (from === to) {
140
+ // 则无任何操作
141
+ return
142
+ }
143
+
144
+ const val = [...props.modelValue]
145
+
146
+ // 如果当前元素在拖动目标位置的下方, 先将当前元素从数组拿出, 数组长度-1, 我们直接给数组拖动目标位置的地方新增一个和当前元素值一样的元素,
147
+ // 我们再把数组之前的那个拖动的元素删除掉, 所以要len+1
148
+ if (from > to) {
149
+ val.splice(to, 0, val[from])
150
+ val.splice(from + 1, 1)
151
+
152
+ } else {
153
+ // 如果当前元素在拖动目标位置的上方, 先将当前元素从数组拿出, 数组长度-1, 我们直接给数组拖动目标位置+1的地方新增一个和当前元素值一样的元素,
154
+ // 这时, 数组len不变, 我们再把数组之前的那个拖动的元素删除掉, 下标还是from
155
+ val.splice(to + 1, 0, val[from])
156
+ val.splice(from, 1)
157
+ }
158
+
159
+ fromIndex.value = to
160
+ toIndex.value = from
161
+
162
+ // 更新值
163
+ emit('update:modelValue', val)
164
+ }
165
+ }
166
+ }
167
+
168
+ /**
169
+ * 拖拽结束
170
+ */
171
+ function dragEnd() {
172
+
173
+ // 如果开启拖拽
174
+ if (isDrag.value) {
175
+ fromIndex.value = null
176
+ toIndex.value = null
177
+ dragging.value = false
178
+ }
179
+ }
180
+
181
+ // ==========【返回】=============================================================================================
182
+
183
+ return {
184
+ // 是否拖拽中
185
+ dragging,
186
+ // 原始位置 index
187
+ fromIndex,
188
+ // 目标位置 index
189
+ toIndex,
190
+
191
+ // 鼠标点击事件
192
+ mousedown,
193
+ // 拖拽开始
194
+ dragStart,
195
+ // 拖拽中
196
+ dragEnter,
197
+ // 拖拽结束
198
+ dragEnd,
199
+ }
200
+ },
201
+ }
202
+ </script>
@@ -0,0 +1,262 @@
1
+ <template>
2
+ <q-drawer
3
+ v-model="isShow"
4
+ :side="side"
5
+ :breakpoint="breakpoint"
6
+ :width="currentWidth"
7
+ v-bind="$attrs"
8
+ >
9
+ <!-- 插槽 -->
10
+ <slot />
11
+
12
+ <!-- 拖拽手柄 -->
13
+ <div
14
+ class="n-drawer__drag-handle"
15
+ :class="`n-drawer__drag-handle--${side}`"
16
+ v-touch-pan.horizontal.prevent.mouse.preserveCursor="onTouchPan"
17
+ v-if="! $q.platform.is.mobile && drag"
18
+ ></div>
19
+ </q-drawer>
20
+ </template>
21
+
22
+ <script>
23
+ import { ref, inject, nextTick } from 'vue'
24
+ import { useQuasar } from 'quasar'
25
+ import { useRoute } from 'vue-router'
26
+
27
+ import { layoutKey, emptyRenderFn } from 'quasar/src/utils/private/symbols.js'
28
+
29
+ import { NLayoutKey } from '../../utils/symbols'
30
+
31
+ export default {
32
+
33
+ /**
34
+ * 标识
35
+ */
36
+ name: 'NDrawer',
37
+
38
+ /**
39
+ * 声明属性
40
+ */
41
+ props: {
42
+ side: {
43
+ type: String,
44
+ default: 'left',
45
+ validator: v => [ 'left', 'right' ].includes(v)
46
+ },
47
+ width: {
48
+ type: Number,
49
+ default: 300
50
+ },
51
+ breakpoint: {
52
+ type: Number,
53
+ default: 1000,
54
+ },
55
+
56
+ // 【自定义属性】
57
+ // --------------------------------------------------
58
+ // 是否显示
59
+ show: Boolean,
60
+ // 手机端宽度(px / %)
61
+ mobileWidth: {
62
+ type: [String, Number],
63
+ default: '80%',
64
+ },
65
+ // 最小宽度
66
+ minWidth: {
67
+ type: Number,
68
+ default: 100,
69
+ },
70
+ // 最大宽度
71
+ maxWidth: Number,
72
+ // 是否可拖拽
73
+ drag: Boolean,
74
+ // 是否拖拽折叠
75
+ // dragCollapse: Boolean,
76
+ // 折叠宽度
77
+ // collapseWidth: {
78
+ // type: Number,
79
+ // default: 80,
80
+ // },
81
+ // 缓存名
82
+ cache: [Boolean, String],
83
+ },
84
+
85
+ /**
86
+ * 组合式
87
+ */
88
+ setup(props) {
89
+
90
+ // ==========【注入】============================================================================================
91
+
92
+ // 获取 quasar 注入
93
+ const $layout = inject(layoutKey, emptyRenderFn)
94
+ if ($layout === emptyRenderFn) {
95
+ console.error('NDrawer needs to be child of QLayout')
96
+ return emptyRenderFn
97
+ }
98
+
99
+ // 获取布局注入数据
100
+ const $nLayout = inject(NLayoutKey)
101
+
102
+ // ==========【数据】============================================================================================
103
+
104
+ // quasar 对象
105
+ const $q = useQuasar()
106
+
107
+ // 获取当前路由
108
+ const $route = useRoute()
109
+
110
+ // 是否显示
111
+ const isShow = ref($q.screen.width < props.breakpoint ? false : props.show)
112
+
113
+ // 更新布局数据
114
+ $nLayout.update(function(data) {
115
+ data[props.side].data = isShow
116
+ })
117
+
118
+ // 缓存名
119
+ let cacheName = ''
120
+
121
+ // 获取原始宽度
122
+ let originalWidth = props.width
123
+
124
+ // 如果是手机端
125
+ if ($q.platform.is.mobile) {
126
+
127
+ // 获取手机端百分比值
128
+ let res = utils.percentValue(props.mobileWidth, true)
129
+
130
+ // 如果是百分比值
131
+ if (! _.isNil(res)) {
132
+ // 原始尺寸 = 屏幕宽度 * 百分比
133
+ if (res) {
134
+ originalWidth = $q.screen.width * res
135
+ }
136
+
137
+ } else {
138
+ // 原始尺寸 = 屏幕宽度像素
139
+ res = utils.pxValue(props.mobileWidth)
140
+ if (res) {
141
+ originalWidth = res
142
+ }
143
+ }
144
+
145
+ // 否则如果开启拖拽 && 开启缓存
146
+ } else if (props.drag && props.cache) {
147
+
148
+ // 设置缓存名
149
+ cacheName = `drawer_${props.side}_${props.cache === true ? $route.fullPath : props.cache}`
150
+
151
+ // 从缓存获取宽度
152
+ const cache = utils.storage.get(cacheName)
153
+ if (cache) {
154
+ originalWidth = cache
155
+ }
156
+ }
157
+
158
+ // 当前宽度
159
+ const currentWidth = ref(originalWidth)
160
+
161
+ // 下次 DOM 更新
162
+ nextTick(function() {
163
+ if (isShow.value && $layout.totalWidth.value < props.breakpoint) {
164
+ isShow.value = false
165
+ }
166
+ })
167
+
168
+ // ==========【方法】=============================================================================================
169
+
170
+ /**
171
+ * 拖动事件
172
+ */
173
+ let initialWidth
174
+ function onTouchPan({ isFirst, offset: { x } }) {
175
+
176
+ // 设置初始宽度
177
+ if (isFirst === true) {
178
+ initialWidth = currentWidth.value
179
+ }
180
+
181
+ // 获取拖拽宽度
182
+ let dragWidth = initialWidth + (props.side === 'left' ? + x : - x)
183
+ let newWidth = dragWidth
184
+
185
+ // 如果宽度 < 最小宽度
186
+ if (props.minWidth && newWidth < props.minWidth) {
187
+ newWidth = props.minWidth
188
+ }
189
+
190
+ // 如果宽度 > 最大宽度
191
+ if (props.maxWidth && newWidth > props.maxWidth) {
192
+ newWidth = props.maxWidth
193
+ }
194
+
195
+ // if (
196
+ // // 如果显示
197
+ // isShow.value
198
+ // // 如果开启折叠
199
+ // && props.dragCollapse
200
+ // // 如果有最小宽度
201
+ // && props.minWidth
202
+ // ) {
203
+ // const collapseWidth = props.collapseWidth < props.minWidth ? props.collapseWidth : props.minWidth - 10
204
+ //
205
+ // // 如果 拖拽宽度 < 折叠宽度
206
+ // if (dragWidth < collapseWidth) {
207
+ // isShow.value = false
208
+ // }
209
+ // }
210
+
211
+ // 如果开启缓存
212
+ if (props.cache) {
213
+ // 设置缓存(永久缓存)
214
+ utils.storage.set(cacheName, newWidth, 0)
215
+ }
216
+
217
+ // 设置当前宽度
218
+ currentWidth.value = newWidth
219
+ }
220
+
221
+ // ==========【返回】=============================================================================================
222
+
223
+ return {
224
+ // 是否显示
225
+ isShow,
226
+ // 当前宽度
227
+ currentWidth,
228
+
229
+ // 拖动事件
230
+ onTouchPan,
231
+ }
232
+ },
233
+ }
234
+ </script>
235
+
236
+ <style lang="scss" scoped>
237
+ @import "@/assets/sass/var.scss";
238
+
239
+ .n-drawer {
240
+ // 拖拽手柄
241
+ &__drag-handle {
242
+ position: absolute;
243
+ top: 0;
244
+ bottom: 0;
245
+ width: 10px;
246
+ cursor: e-resize;
247
+ user-select: none;
248
+ z-index: 10;
249
+ right: 0;
250
+
251
+ // 左边侧滑菜单
252
+ &--left {
253
+ right: -5px;
254
+ }
255
+
256
+ // 右边侧滑菜单
257
+ &--right {
258
+ left: -5px;
259
+ }
260
+ }
261
+ }
262
+ </style>