@netang/quasar 0.0.33 → 0.0.34
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.
- package/components/drawer/index.vue +20 -7
- package/components/splitter/index.vue +161 -19
- package/components/table/index.vue +75 -10
- package/package.json +1 -1
- package/utils/price.js +13 -13
|
@@ -109,7 +109,7 @@ export default {
|
|
|
109
109
|
const $q = useQuasar()
|
|
110
110
|
|
|
111
111
|
// 获取当前路由
|
|
112
|
-
|
|
112
|
+
let fullPath = ''
|
|
113
113
|
|
|
114
114
|
// 获取权限注入数据
|
|
115
115
|
const $power = inject(NPowerKey)
|
|
@@ -124,10 +124,18 @@ export default {
|
|
|
124
124
|
} else {
|
|
125
125
|
currentModelValue.value = props.modelValue
|
|
126
126
|
}
|
|
127
|
+
// 权限路由路径
|
|
128
|
+
fullPath = $power.routeFullPath
|
|
129
|
+
|
|
127
130
|
} else {
|
|
128
131
|
currentModelValue = ref(props.modelValue)
|
|
132
|
+
// 当前路由路径
|
|
133
|
+
fullPath = useRoute().fullPath
|
|
129
134
|
}
|
|
130
135
|
|
|
136
|
+
// 创建防抖睡眠方法
|
|
137
|
+
const sleep = utils.debounceSleep()
|
|
138
|
+
|
|
131
139
|
// 缓存名
|
|
132
140
|
let cacheName = ''
|
|
133
141
|
|
|
@@ -159,7 +167,7 @@ export default {
|
|
|
159
167
|
} else if (props.drag && props.cache) {
|
|
160
168
|
|
|
161
169
|
// 设置缓存名
|
|
162
|
-
cacheName = `drawer_${props.side}_${props.cache === true ?
|
|
170
|
+
cacheName = `drawer_${props.side}_${props.cache === true ? fullPath : props.cache}`
|
|
163
171
|
|
|
164
172
|
// 从缓存获取宽度
|
|
165
173
|
const cache = utils.storage.get(cacheName)
|
|
@@ -237,14 +245,19 @@ export default {
|
|
|
237
245
|
// }
|
|
238
246
|
// }
|
|
239
247
|
|
|
248
|
+
// 设置当前宽度
|
|
249
|
+
currentWidth.value = newWidth
|
|
250
|
+
|
|
240
251
|
// 如果开启缓存
|
|
241
252
|
if (props.cache) {
|
|
242
|
-
// 设置缓存(永久缓存)
|
|
243
|
-
utils.storage.set(cacheName, newWidth, 0)
|
|
244
|
-
}
|
|
245
253
|
|
|
246
|
-
|
|
247
|
-
|
|
254
|
+
// 延迟执行
|
|
255
|
+
sleep(500)
|
|
256
|
+
.then(function () {
|
|
257
|
+
// 设置缓存(永久缓存)
|
|
258
|
+
utils.storage.set(cacheName, newWidth, 0)
|
|
259
|
+
})
|
|
260
|
+
}
|
|
248
261
|
}
|
|
249
262
|
|
|
250
263
|
// ==========【返回】=============================================================================================
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<!-- 拆分器 -->
|
|
3
3
|
<q-splitter
|
|
4
|
+
class="n-splitter"
|
|
5
|
+
:class="currentClass"
|
|
4
6
|
v-model="currentValue"
|
|
5
7
|
v-bind="$attrs"
|
|
6
|
-
v-if="$slots.before && $slots.after"
|
|
7
8
|
>
|
|
8
9
|
<!-- 插槽 -->
|
|
9
10
|
<template
|
|
@@ -13,23 +14,11 @@
|
|
|
13
14
|
<slot :name="slotName" />
|
|
14
15
|
</template>
|
|
15
16
|
</q-splitter>
|
|
16
|
-
|
|
17
|
-
<!-- before 插槽 -->
|
|
18
|
-
<slot
|
|
19
|
-
name="before"
|
|
20
|
-
v-else-if="$slots.before"
|
|
21
|
-
/>
|
|
22
|
-
|
|
23
|
-
<!-- after 插槽 -->
|
|
24
|
-
<slot
|
|
25
|
-
name="after"
|
|
26
|
-
v-else-if="$slots.after"
|
|
27
|
-
/>
|
|
28
|
-
|
|
29
17
|
</template>
|
|
30
18
|
|
|
31
19
|
<script>
|
|
32
|
-
import { computed, ref, watch } from 'vue'
|
|
20
|
+
import { computed, ref, watch, inject } from 'vue'
|
|
21
|
+
import { NPowerKey } from '../../utils/symbols'
|
|
33
22
|
|
|
34
23
|
export default {
|
|
35
24
|
|
|
@@ -47,6 +36,21 @@ export default {
|
|
|
47
36
|
type: Number,
|
|
48
37
|
required: true,
|
|
49
38
|
},
|
|
39
|
+
// 显示前置插槽
|
|
40
|
+
showBefore: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true,
|
|
43
|
+
},
|
|
44
|
+
// 显示后置插槽
|
|
45
|
+
showAfter: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: true,
|
|
48
|
+
},
|
|
49
|
+
// 是否开启缓存
|
|
50
|
+
cache: {
|
|
51
|
+
type: [Boolean, String],
|
|
52
|
+
default: true,
|
|
53
|
+
},
|
|
50
54
|
},
|
|
51
55
|
|
|
52
56
|
/**
|
|
@@ -67,13 +71,81 @@ export default {
|
|
|
67
71
|
* 插槽标识
|
|
68
72
|
*/
|
|
69
73
|
const slotNames = computed(function() {
|
|
70
|
-
|
|
74
|
+
|
|
75
|
+
const keys = []
|
|
76
|
+
|
|
77
|
+
if (utils.isValidObject(slots)) {
|
|
78
|
+
for (const key in slots) {
|
|
79
|
+
if (key === 'before') {
|
|
80
|
+
if (props.showBefore) {
|
|
81
|
+
keys.push(key)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
} else if (key === 'after') {
|
|
85
|
+
if (props.showAfter) {
|
|
86
|
+
keys.push(key)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
} else {
|
|
90
|
+
keys.push(key)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return keys
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 当前样式
|
|
100
|
+
*/
|
|
101
|
+
const currentClass = computed(function () {
|
|
102
|
+
|
|
103
|
+
if (props.showBefore) {
|
|
104
|
+
if (! props.showAfter) {
|
|
105
|
+
return 'n-splitter--hide-before'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
} else if (props.showAfter) {
|
|
109
|
+
if (! props.showBefore) {
|
|
110
|
+
return 'n-splitter--hide-after'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
} else {
|
|
114
|
+
return 'n-splitter--hide'
|
|
115
|
+
}
|
|
71
116
|
})
|
|
72
117
|
|
|
73
118
|
// ==========【数据】============================================================================================
|
|
74
119
|
|
|
120
|
+
// 获取权限注入
|
|
121
|
+
const $power = inject(NPowerKey)
|
|
122
|
+
|
|
123
|
+
// 当前路由完整路径
|
|
124
|
+
const fullPath = $power ? $power.routeFullPath : utils.router.getRoute('fullPath')
|
|
125
|
+
|
|
126
|
+
// 缓存名
|
|
127
|
+
let cacheName = ''
|
|
128
|
+
|
|
129
|
+
// 初始值
|
|
130
|
+
let rawValue = props.modelValue
|
|
131
|
+
|
|
132
|
+
// 如果开启缓存
|
|
133
|
+
if (props.cache) {
|
|
134
|
+
// 设置缓存名
|
|
135
|
+
cacheName = `splitter_value_${props.cache === true ? fullPath : props.cache}`
|
|
136
|
+
|
|
137
|
+
// 从缓存获取初始值
|
|
138
|
+
const cache = utils.storage.get(cacheName)
|
|
139
|
+
if (cache) {
|
|
140
|
+
rawValue = cache
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
75
144
|
// 当前值
|
|
76
|
-
const currentValue = ref(
|
|
145
|
+
const currentValue = ref(rawValue)
|
|
146
|
+
|
|
147
|
+
// 创建防抖睡眠方法
|
|
148
|
+
const sleep = utils.debounceSleep()
|
|
77
149
|
|
|
78
150
|
// ==========【监听数据】=========================================================================================
|
|
79
151
|
|
|
@@ -81,10 +153,8 @@ export default {
|
|
|
81
153
|
* 监听声明值
|
|
82
154
|
*/
|
|
83
155
|
watch(()=>props.modelValue, function (val) {
|
|
84
|
-
|
|
85
156
|
// 如果值有变化
|
|
86
157
|
if (val !== currentValue.value) {
|
|
87
|
-
|
|
88
158
|
// 更新当前值
|
|
89
159
|
currentValue.value = val
|
|
90
160
|
}
|
|
@@ -97,6 +167,17 @@ export default {
|
|
|
97
167
|
|
|
98
168
|
// 更新值
|
|
99
169
|
emit('update:modelValue', val)
|
|
170
|
+
|
|
171
|
+
// 如果开启缓存
|
|
172
|
+
if (props.cache) {
|
|
173
|
+
|
|
174
|
+
// 延迟执行
|
|
175
|
+
sleep(500)
|
|
176
|
+
.then(function () {
|
|
177
|
+
// 设置缓存(永久缓存)
|
|
178
|
+
utils.storage.set(cacheName, val, 0)
|
|
179
|
+
})
|
|
180
|
+
}
|
|
100
181
|
})
|
|
101
182
|
|
|
102
183
|
// ==========【返回】=============================================================================================
|
|
@@ -106,7 +187,68 @@ export default {
|
|
|
106
187
|
slotNames,
|
|
107
188
|
// 当前值
|
|
108
189
|
currentValue,
|
|
190
|
+
// 当前样式
|
|
191
|
+
currentClass,
|
|
109
192
|
}
|
|
110
193
|
}
|
|
111
194
|
}
|
|
112
195
|
</script>
|
|
196
|
+
|
|
197
|
+
<style lang="scss">
|
|
198
|
+
@import "@/assets/sass/var.scss";
|
|
199
|
+
|
|
200
|
+
.n-splitter {
|
|
201
|
+
|
|
202
|
+
// 分离器激活背景色
|
|
203
|
+
&.q-splitter--active .q-splitter__separator ,
|
|
204
|
+
.q-splitter__separator:hover {
|
|
205
|
+
background-color: var(--q-primary);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 隐藏前置插槽
|
|
209
|
+
&--hide-before {
|
|
210
|
+
&.q-splitter--horizontal {
|
|
211
|
+
.q-splitter__before {
|
|
212
|
+
height: 100% !important;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
&.q-splitter--vertical {
|
|
216
|
+
.q-splitter__before {
|
|
217
|
+
width: 100% !important;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
.q-splitter__after,
|
|
221
|
+
.q-splitter__separator {
|
|
222
|
+
display: none !important;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// 隐藏后置插槽
|
|
227
|
+
&--hide-after {
|
|
228
|
+
&.q-splitter--horizontal {
|
|
229
|
+
.q-splitter__after {
|
|
230
|
+
height: 100% !important;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
&.q-splitter--vertical {
|
|
234
|
+
.q-splitter__after {
|
|
235
|
+
width: 100% !important;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
.q-splitter__before,
|
|
239
|
+
.q-splitter__separator {
|
|
240
|
+
display: none !important;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 隐藏前后置插槽
|
|
245
|
+
&--hide {
|
|
246
|
+
.q-splitter__before,
|
|
247
|
+
.q-splitter__after,
|
|
248
|
+
.q-splitter__separator {
|
|
249
|
+
display: none !important;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
</style>
|
|
254
|
+
|
|
@@ -11,18 +11,28 @@
|
|
|
11
11
|
<n-toolbar
|
|
12
12
|
:dense="dense"
|
|
13
13
|
header
|
|
14
|
-
|
|
14
|
+
>
|
|
15
|
+
<!-- 插槽 -->
|
|
16
|
+
<template
|
|
17
|
+
v-for="slotName in slotNames.toolbar"
|
|
18
|
+
v-slot:[slotName]
|
|
19
|
+
>
|
|
20
|
+
<slot :name="`toolbar-${slotName}`"/>
|
|
21
|
+
</template>
|
|
22
|
+
</n-toolbar>
|
|
15
23
|
|
|
16
24
|
<!-- 左侧分类 -->
|
|
25
|
+
<slot name="left-drawer" v-if="slotNames.leftDrawer" />
|
|
17
26
|
<n-drawer
|
|
18
|
-
:model-value="
|
|
27
|
+
:model-value="! hideLeftDrawer"
|
|
19
28
|
:side="treeSide"
|
|
20
29
|
:width="200"
|
|
21
30
|
:min-width="150"
|
|
22
31
|
bordered
|
|
23
32
|
drag
|
|
24
33
|
cache
|
|
25
|
-
v-
|
|
34
|
+
v-bind="leftDrawerProps"
|
|
35
|
+
v-else-if="treeNodes.length"
|
|
26
36
|
>
|
|
27
37
|
<q-scroll-area class="absolute-full">
|
|
28
38
|
|
|
@@ -50,6 +60,7 @@
|
|
|
50
60
|
v-model:selected="treeSelected"
|
|
51
61
|
no-selection-unset
|
|
52
62
|
default-expand-all
|
|
63
|
+
v-bind="treeProps"
|
|
53
64
|
/>
|
|
54
65
|
|
|
55
66
|
</q-scroll-area>
|
|
@@ -79,6 +90,7 @@
|
|
|
79
90
|
flat
|
|
80
91
|
virtual-scroll
|
|
81
92
|
:dense="dense"
|
|
93
|
+
v-bind="tableProps"
|
|
82
94
|
>
|
|
83
95
|
<!-- 图片 -->
|
|
84
96
|
<template
|
|
@@ -96,7 +108,7 @@
|
|
|
96
108
|
|
|
97
109
|
<!-- 插槽 -->
|
|
98
110
|
<template
|
|
99
|
-
v-for="slotName in slotNames"
|
|
111
|
+
v-for="slotName in slotNames.table"
|
|
100
112
|
v-slot:[slotName]="props"
|
|
101
113
|
>
|
|
102
114
|
<q-td :props="props">
|
|
@@ -132,14 +144,16 @@
|
|
|
132
144
|
</q-page-container>
|
|
133
145
|
|
|
134
146
|
<!-- 右侧搜索 -->
|
|
147
|
+
<slot name="right-drawer" v-if="slotNames.rightDrawer" />
|
|
135
148
|
<n-drawer
|
|
136
|
-
:model-value="
|
|
149
|
+
:model-value="! hideRightDrawer"
|
|
137
150
|
:side="searchSide"
|
|
138
151
|
:min-width="320"
|
|
139
152
|
bordered
|
|
140
153
|
drag
|
|
141
154
|
cache
|
|
142
|
-
v-
|
|
155
|
+
v-bind="rightDrawerProps"
|
|
156
|
+
v-else-if="! noSearch && tableSearchValue.length"
|
|
143
157
|
>
|
|
144
158
|
<!-- 搜索 -->
|
|
145
159
|
<n-search
|
|
@@ -147,8 +161,17 @@
|
|
|
147
161
|
:options="tableSearchOptions"
|
|
148
162
|
:on-search="tableReload"
|
|
149
163
|
:on-reset="tableSearchReset"
|
|
150
|
-
|
|
164
|
+
>
|
|
165
|
+
<!-- 插槽 -->
|
|
166
|
+
<template
|
|
167
|
+
v-for="slotName in slotNames.search"
|
|
168
|
+
v-slot:[slotName]
|
|
169
|
+
>
|
|
170
|
+
<slot :name="`search-${slotName}`"/>
|
|
171
|
+
</template>
|
|
172
|
+
</n-search>
|
|
151
173
|
</n-drawer>
|
|
174
|
+
|
|
152
175
|
</q-layout>
|
|
153
176
|
</template>
|
|
154
177
|
|
|
@@ -170,6 +193,10 @@ export default {
|
|
|
170
193
|
props: {
|
|
171
194
|
// 表格请求地址
|
|
172
195
|
url: String,
|
|
196
|
+
// 表格声明属性
|
|
197
|
+
tableProps: Object,
|
|
198
|
+
// 树声明属性
|
|
199
|
+
treeProps: Object,
|
|
173
200
|
// 树节点唯一键值
|
|
174
201
|
treeNodeKey: {
|
|
175
202
|
type: String,
|
|
@@ -189,13 +216,13 @@ export default {
|
|
|
189
216
|
treeNodeClick: Function,
|
|
190
217
|
// 显示树筛选
|
|
191
218
|
treeFilter: Boolean,
|
|
192
|
-
// 不显示搜索
|
|
193
|
-
noSearch: Boolean,
|
|
194
219
|
// 树位置
|
|
195
220
|
treeSide: {
|
|
196
221
|
type: String,
|
|
197
222
|
default: 'left',
|
|
198
223
|
},
|
|
224
|
+
// 不显示搜索
|
|
225
|
+
noSearch: Boolean,
|
|
199
226
|
// 搜索位置
|
|
200
227
|
searchSide: {
|
|
201
228
|
type: String,
|
|
@@ -206,6 +233,14 @@ export default {
|
|
|
206
233
|
type: Boolean,
|
|
207
234
|
default: true,
|
|
208
235
|
},
|
|
236
|
+
// 隐藏左边侧滑菜单
|
|
237
|
+
hideLeftDrawer: Boolean,
|
|
238
|
+
// 左边侧滑菜单声明属性
|
|
239
|
+
leftDrawerProps: Object,
|
|
240
|
+
// 隐藏右边侧滑菜单
|
|
241
|
+
hideRightDrawer: Boolean,
|
|
242
|
+
// 右边侧滑菜单声明属性
|
|
243
|
+
rightDrawerProps: Object,
|
|
209
244
|
},
|
|
210
245
|
|
|
211
246
|
/**
|
|
@@ -259,7 +294,37 @@ export default {
|
|
|
259
294
|
* 插槽标识
|
|
260
295
|
*/
|
|
261
296
|
const slotNames = computed(function() {
|
|
262
|
-
|
|
297
|
+
|
|
298
|
+
const toolbar = []
|
|
299
|
+
const search = []
|
|
300
|
+
const table = []
|
|
301
|
+
let leftDrawer = false
|
|
302
|
+
let rightDrawer = false
|
|
303
|
+
|
|
304
|
+
// 如果有插槽
|
|
305
|
+
if (utils.isValidObject(slots)) {
|
|
306
|
+
for (const key in slots) {
|
|
307
|
+
if (key.startsWith('toolbar-')) {
|
|
308
|
+
toolbar.push(key.replace('toolbar-', ''))
|
|
309
|
+
} else if (key.startsWith('search-')) {
|
|
310
|
+
search.push(key.replace('search-', ''))
|
|
311
|
+
} else if (key === 'left-drawer') {
|
|
312
|
+
leftDrawer = true
|
|
313
|
+
} else if (key === 'right-drawer') {
|
|
314
|
+
rightDrawer = true
|
|
315
|
+
} else {
|
|
316
|
+
table.push(key)
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
toolbar,
|
|
323
|
+
search,
|
|
324
|
+
table,
|
|
325
|
+
leftDrawer,
|
|
326
|
+
rightDrawer,
|
|
327
|
+
}
|
|
263
328
|
})
|
|
264
329
|
|
|
265
330
|
// ==========【监听数据】=========================================================================================
|
package/package.json
CHANGED
package/utils/price.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 换算金额
|
|
3
|
-
*/
|
|
4
|
-
utils.price = function(value, params) {
|
|
5
|
-
return utils.decimal(value, Object.assign({
|
|
6
|
-
// 最小值
|
|
7
|
-
min: 0,
|
|
8
|
-
// 小数点位数
|
|
9
|
-
decimalLength: 2,
|
|
10
|
-
// 是否开启人民币分转元(如值 189 -> 1.89)
|
|
11
|
-
centToYuan: utils.config('priceCent') === true,
|
|
12
|
-
}, params))
|
|
13
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 换算金额
|
|
3
|
+
*/
|
|
4
|
+
utils.price = function(value, params) {
|
|
5
|
+
return utils.decimal(value, Object.assign({
|
|
6
|
+
// 最小值
|
|
7
|
+
min: 0,
|
|
8
|
+
// 小数点位数
|
|
9
|
+
decimalLength: 2,
|
|
10
|
+
// 是否开启人民币分转元(如值 189 -> 1.89)
|
|
11
|
+
centToYuan: utils.config('priceCent') === true,
|
|
12
|
+
}, params))
|
|
13
|
+
}
|