@netang/quasar 0.0.20 → 0.0.22
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/README.md +2 -3
- package/components/dialog/index.vue +30 -2
- package/components/drawer/index.vue +54 -25
- package/components/empty/index.vue +23 -0
- package/components/field-table/index.vue +85 -115
- package/components/power-page/index.vue +47 -0
- package/components/private/table-visible-columns-button/index.vue +105 -0
- package/components/table/index.vue +31 -85
- package/components/table-column-fixed/index.vue +20 -10
- package/components/table-pagination/index.vue +83 -3
- package/components/table-summary/index.vue +14 -2
- package/components/toolbar/index.vue +44 -311
- package/components/uploader/index.vue +6 -8
- package/components/uploader-query/index.vue +1 -3
- package/package.json +1 -1
- package/store/index.js +14 -0
- package/utils/$form.js +52 -0
- package/utils/{$role.js → $power.js} +313 -106
- package/utils/$table.js +69 -88
- package/utils/$tree.js +56 -32
- package/utils/http.js +5 -5
- package/utils/symbols.js +4 -0
- package/components/layout/index.vue +0 -119
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<container
|
|
3
3
|
:header="header"
|
|
4
|
+
v-if="toolbarPowerBtns.length"
|
|
4
5
|
>
|
|
5
6
|
<q-toolbar>
|
|
6
7
|
|
|
7
|
-
<!--
|
|
8
|
+
<!-- 左边侧滑菜单切换按钮-->
|
|
8
9
|
<q-btn
|
|
9
|
-
:icon="
|
|
10
|
+
:icon="leftDrawer.icon"
|
|
10
11
|
dense
|
|
11
12
|
round
|
|
12
13
|
flat
|
|
13
|
-
@click="
|
|
14
|
-
v-if="
|
|
14
|
+
@click="leftDrawer.toggle"
|
|
15
|
+
v-if="leftDrawer.showButton()"
|
|
15
16
|
/>
|
|
16
17
|
|
|
17
18
|
<!-- 左边插槽 -->
|
|
18
19
|
<slot name="left" />
|
|
19
20
|
|
|
20
|
-
<!--
|
|
21
|
+
<!-- 中间权限按钮 -->
|
|
21
22
|
<q-toolbar-title>
|
|
22
|
-
<q-scroll-area style="height:50px;"
|
|
23
|
+
<q-scroll-area style="height:50px;">
|
|
23
24
|
<div class="n-toolbar__body">
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<!-- 插槽 -->
|
|
41
|
-
<slot />
|
|
26
|
+
<!-- 权限按钮 -->
|
|
27
|
+
<template v-for="item in toolbarPowerBtns">
|
|
28
|
+
<q-btn
|
|
29
|
+
class="n-button-icon"
|
|
30
|
+
:color="item.color"
|
|
31
|
+
:outline="item.color === 'default'"
|
|
32
|
+
:label="item.title"
|
|
33
|
+
:icon="item.icon"
|
|
34
|
+
v-if="! item.hidden"
|
|
35
|
+
v-show="item.show"
|
|
36
|
+
@click="powerBtnClick(item, tableSelected)"
|
|
37
|
+
unelevated
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
<!-- 中间权限按钮插槽 -->
|
|
42
|
+
<slot />
|
|
44
43
|
</div>
|
|
45
44
|
</q-scroll-area>
|
|
46
45
|
</q-toolbar-title>
|
|
@@ -48,77 +47,30 @@
|
|
|
48
47
|
<!-- 右边插槽 -->
|
|
49
48
|
<slot name="right" />
|
|
50
49
|
|
|
51
|
-
<!--
|
|
52
|
-
<
|
|
53
|
-
icon="checklist"
|
|
54
|
-
dense
|
|
55
|
-
round
|
|
56
|
-
flat
|
|
57
|
-
v-if="tableColumns"
|
|
58
|
-
>
|
|
59
|
-
<q-menu
|
|
60
|
-
self="top middle"
|
|
61
|
-
:offset="[0, 8]"
|
|
62
|
-
>
|
|
63
|
-
<q-list style="min-width: 250px" dense bordered>
|
|
64
|
-
|
|
65
|
-
<!-- 表格宫格 -->
|
|
66
|
-
<template v-if="tableGrid !== null">
|
|
67
|
-
<q-item
|
|
68
|
-
clickable
|
|
69
|
-
@click="onTableGrid"
|
|
70
|
-
>
|
|
71
|
-
<q-item-section>宫格模式</q-item-section>
|
|
72
|
-
<q-item-section side>
|
|
73
|
-
<q-icon
|
|
74
|
-
size="xs"
|
|
75
|
-
name="check"
|
|
76
|
-
v-show="tableGrid"
|
|
77
|
-
/>
|
|
78
|
-
</q-item-section>
|
|
79
|
-
</q-item>
|
|
80
|
-
<q-separator />
|
|
81
|
-
</template>
|
|
50
|
+
<!-- 表格筛选可见列按钮 -->
|
|
51
|
+
<table-visible-columns-button v-if="hasTable" />
|
|
82
52
|
|
|
83
|
-
|
|
84
|
-
<q-item
|
|
85
|
-
v-for="item in tableColumns"
|
|
86
|
-
clickable
|
|
87
|
-
@click="onTableVisible(item)"
|
|
88
|
-
>
|
|
89
|
-
<q-item-section>{{item.label}}</q-item-section>
|
|
90
|
-
<q-item-section side>
|
|
91
|
-
<q-icon
|
|
92
|
-
size="xs"
|
|
93
|
-
name="check"
|
|
94
|
-
v-show="utils.indexOf(tableVisibleColumns, item.name) > -1"
|
|
95
|
-
/>
|
|
96
|
-
</q-item-section>
|
|
97
|
-
</q-item>
|
|
98
|
-
</q-list>
|
|
99
|
-
</q-menu>
|
|
100
|
-
</q-btn>
|
|
101
|
-
|
|
102
|
-
<!-- 右边按钮-->
|
|
53
|
+
<!-- 右边侧滑菜单切换按钮-->
|
|
103
54
|
<q-btn
|
|
104
|
-
:icon="
|
|
55
|
+
:icon="rightDrawer.icon"
|
|
105
56
|
dense
|
|
106
57
|
round
|
|
107
58
|
flat
|
|
108
|
-
@click="
|
|
109
|
-
v-if="
|
|
59
|
+
@click="rightDrawer.toggle"
|
|
60
|
+
v-if="rightDrawer.showButton()"
|
|
110
61
|
/>
|
|
62
|
+
|
|
111
63
|
</q-toolbar>
|
|
112
64
|
</container>
|
|
113
65
|
</template>
|
|
114
66
|
|
|
115
67
|
<script>
|
|
116
|
-
import { inject
|
|
117
|
-
import { useRoute } from 'vue-router'
|
|
118
|
-
import { useQuasar } from 'quasar'
|
|
68
|
+
import { inject } from 'vue'
|
|
119
69
|
|
|
120
70
|
import Container from './container'
|
|
121
|
-
import
|
|
71
|
+
import TableVisibleColumnsButton from '../private/table-visible-columns-button'
|
|
72
|
+
|
|
73
|
+
import { NPowerKey, NTableKey } from '../../utils/symbols'
|
|
122
74
|
|
|
123
75
|
export default {
|
|
124
76
|
|
|
@@ -132,252 +84,37 @@ export default {
|
|
|
132
84
|
*/
|
|
133
85
|
components: {
|
|
134
86
|
Container,
|
|
87
|
+
TableVisibleColumnsButton,
|
|
135
88
|
},
|
|
136
89
|
|
|
137
90
|
/**
|
|
138
91
|
* 声明属性
|
|
139
92
|
*/
|
|
140
93
|
props: {
|
|
141
|
-
// 值(权限按钮列表)
|
|
142
|
-
modelValue: Array,
|
|
143
|
-
// 表格宫格
|
|
144
|
-
tableGrid: {
|
|
145
|
-
type: Boolean,
|
|
146
|
-
default: null,
|
|
147
|
-
},
|
|
148
|
-
// 表格可见列
|
|
149
|
-
tableVisibleColumns: Array,
|
|
150
|
-
|
|
151
|
-
// 传参
|
|
152
|
-
query: Object,
|
|
153
|
-
// 表格列
|
|
154
|
-
tableColumns: Array,
|
|
155
|
-
// 表格选中数据
|
|
156
|
-
tableSelected: Array,
|
|
157
|
-
// 表格刷新
|
|
158
|
-
tableRefresh: Function,
|
|
159
|
-
// 表单节点
|
|
160
|
-
formRef: Function,
|
|
161
|
-
// 表单数据
|
|
162
|
-
formData: Object,
|
|
163
|
-
// 重置表单
|
|
164
|
-
resetForm: Function,
|
|
165
|
-
// 请求前执行
|
|
166
|
-
requestBefore: Function,
|
|
167
|
-
// 请求成功执行
|
|
168
|
-
requestSuccess: Function,
|
|
169
|
-
// 请求失败执行
|
|
170
|
-
requestFail: Function,
|
|
171
|
-
// 请求后执行
|
|
172
|
-
requestAfter: Function,
|
|
173
|
-
// 左边图标
|
|
174
|
-
leftIcon: {
|
|
175
|
-
type: String,
|
|
176
|
-
default: 'format_list_bulleted',
|
|
177
|
-
},
|
|
178
|
-
// 默认隐藏左边(宽屏不显示, 小屏自动显示)
|
|
179
|
-
hiddenLeft: Boolean,
|
|
180
|
-
// 左边图标
|
|
181
|
-
rightIcon: {
|
|
182
|
-
type: String,
|
|
183
|
-
default: 'search',
|
|
184
|
-
},
|
|
185
|
-
// 是否请求权限按钮数据
|
|
186
|
-
getRoleBtn: {
|
|
187
|
-
type: Boolean,
|
|
188
|
-
default: true,
|
|
189
|
-
},
|
|
190
|
-
// 是否隐藏右边(宽屏不显示, 小屏自动显示)
|
|
191
|
-
hiddenRight: Boolean,
|
|
192
94
|
// 是否头部
|
|
193
95
|
header: Boolean,
|
|
194
96
|
},
|
|
195
97
|
|
|
196
|
-
/**
|
|
197
|
-
* 声明事件
|
|
198
|
-
*/
|
|
199
|
-
emits: [
|
|
200
|
-
'update:modelValue',
|
|
201
|
-
'update:tableVisibleColumns',
|
|
202
|
-
],
|
|
203
|
-
|
|
204
98
|
/**
|
|
205
99
|
* 组合式
|
|
206
100
|
*/
|
|
207
|
-
setup(
|
|
208
|
-
|
|
209
|
-
// ==========【注入】============================================================================================
|
|
210
|
-
|
|
211
|
-
// 获取布局注入数据
|
|
212
|
-
const $nLayout = inject(NLayoutKey)
|
|
213
|
-
|
|
214
|
-
// 是否在对话框中
|
|
215
|
-
const inDialog = ref(!! utils.$dialog.inject())
|
|
101
|
+
setup() {
|
|
216
102
|
|
|
217
103
|
// ==========【数据】============================================================================================
|
|
218
104
|
|
|
219
|
-
//
|
|
220
|
-
const $
|
|
221
|
-
|
|
222
|
-
// 当前路由地址
|
|
223
|
-
const $route = useRoute()
|
|
224
|
-
|
|
225
|
-
// ==========【计算属性】=========================================================================================
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* 当前权限按钮
|
|
229
|
-
*/
|
|
230
|
-
const currentRoleBtnLists = computed(function() {
|
|
231
|
-
|
|
232
|
-
if (utils.isValidArray(props.modelValue)) {
|
|
233
|
-
|
|
234
|
-
const lists = _.filter(utils.$role.formatRoleBtnLists(props.modelValue), e => e.type > 2)
|
|
235
|
-
|
|
236
|
-
// 格式化权限按钮列表
|
|
237
|
-
utils.forEach(lists, function(item) {
|
|
238
|
-
|
|
239
|
-
if (! item.hidden) {
|
|
240
|
-
|
|
241
|
-
// 如果是单条数据显示
|
|
242
|
-
const isSingle = item.show === 'single'
|
|
243
|
-
|
|
244
|
-
// 如果是单条 || 多条显示
|
|
245
|
-
if (isSingle || item.show === 'multi') {
|
|
246
|
-
|
|
247
|
-
// 初始为不显示
|
|
248
|
-
item.show = false
|
|
249
|
-
|
|
250
|
-
// 如果有数据
|
|
251
|
-
if (utils.isValidArray(props.tableSelected)) {
|
|
105
|
+
// 获取权限注入数据
|
|
106
|
+
const $power = inject(NPowerKey)
|
|
252
107
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
item.show = props.tableSelected.length === 1
|
|
256
|
-
|
|
257
|
-
// 否则是多个显示
|
|
258
|
-
} else {
|
|
259
|
-
item.show = props.tableSelected.length >= 1
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// 如果是手机模式
|
|
265
|
-
if ($q.platform.is.mobile) {
|
|
266
|
-
item.icon = undefined
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
return lists
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return []
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* 权限传参
|
|
279
|
-
*/
|
|
280
|
-
const roleQuery = computed(function () {
|
|
281
|
-
|
|
282
|
-
const query = {}
|
|
283
|
-
|
|
284
|
-
// 合并路由传参
|
|
285
|
-
if (utils.isValidObject($route.query)) {
|
|
286
|
-
Object.assign(query, $route.query)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// 合并声明传参
|
|
290
|
-
if (utils.isValidObject(props.query)) {
|
|
291
|
-
Object.assign(query, props.query)
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return utils.numberDeep(query)
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
// ==========【方法】=============================================================================================
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* 按钮点击
|
|
301
|
-
*/
|
|
302
|
-
async function onClick({ data }, tableSelected) {
|
|
303
|
-
|
|
304
|
-
// 角色请求
|
|
305
|
-
await utils.$role.request({
|
|
306
|
-
// 按钮数据
|
|
307
|
-
data,
|
|
308
|
-
// 传参
|
|
309
|
-
query: roleQuery.value,
|
|
310
|
-
// 表格选中数据
|
|
311
|
-
tableSelected,
|
|
312
|
-
// 表格刷新
|
|
313
|
-
tableRefresh: props.tableRefresh,
|
|
314
|
-
// 检查是否正在上传文件
|
|
315
|
-
checkUploading: $nLayout.checkUploading,
|
|
316
|
-
// 表单节点
|
|
317
|
-
formRef: props.formRef,
|
|
318
|
-
// 表单数据
|
|
319
|
-
formData: props.formData,
|
|
320
|
-
// 重置表单
|
|
321
|
-
resetForm: props.resetForm,
|
|
322
|
-
// 请求前执行
|
|
323
|
-
requestBefore: props.requestBefore,
|
|
324
|
-
// 请求数据执行
|
|
325
|
-
requestData: props.requestData,
|
|
326
|
-
// 请求成功执行
|
|
327
|
-
requestSuccess: props.requestSuccess,
|
|
328
|
-
// 请求后执行
|
|
329
|
-
requestAfter: props.requestAfter,
|
|
330
|
-
})
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// 更新布局数据
|
|
334
|
-
$nLayout.update(function(data) {
|
|
335
|
-
Object.assign(data.role, {
|
|
336
|
-
click: onClick,
|
|
337
|
-
})
|
|
338
|
-
})
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* 表格宫格点击
|
|
343
|
-
*/
|
|
344
|
-
function onTableGrid() {
|
|
345
|
-
emit('update:tableGrid', ! props.tableGrid)
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* 表格可见列点击
|
|
350
|
-
*/
|
|
351
|
-
function onTableVisible(item) {
|
|
352
|
-
|
|
353
|
-
const columns = [...props.tableVisibleColumns]
|
|
354
|
-
|
|
355
|
-
const index = utils.indexOf(props.tableVisibleColumns, item.name)
|
|
356
|
-
if (index > -1) {
|
|
357
|
-
columns.splice(index, 1)
|
|
358
|
-
} else {
|
|
359
|
-
columns.push(item.name)
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
emit('update:tableVisibleColumns', columns)
|
|
363
|
-
}
|
|
108
|
+
// 获取表格注入数据
|
|
109
|
+
const $table = inject(NTableKey)
|
|
364
110
|
|
|
365
111
|
// ==========【返回】=============================================================================================
|
|
366
112
|
|
|
367
113
|
return {
|
|
368
|
-
//
|
|
369
|
-
|
|
370
|
-
//
|
|
371
|
-
|
|
372
|
-
// 当前权限按钮
|
|
373
|
-
currentRoleBtnLists,
|
|
374
|
-
|
|
375
|
-
// 按钮点击
|
|
376
|
-
onClick,
|
|
377
|
-
// 表格宫格点击
|
|
378
|
-
onTableGrid,
|
|
379
|
-
// 表格可见列点击
|
|
380
|
-
onTableVisible,
|
|
114
|
+
// 解构权限实例
|
|
115
|
+
...$power,
|
|
116
|
+
// 是否有表格
|
|
117
|
+
hasTable: !! $table,
|
|
381
118
|
}
|
|
382
119
|
},
|
|
383
120
|
}
|
|
@@ -388,10 +125,6 @@ export default {
|
|
|
388
125
|
|
|
389
126
|
.n-toolbar {
|
|
390
127
|
&__body {
|
|
391
|
-
//height: 50px;
|
|
392
|
-
//display: flex;
|
|
393
|
-
//align-items: center;
|
|
394
|
-
|
|
395
128
|
.q-btn {
|
|
396
129
|
margin-top: 7px;
|
|
397
130
|
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
22
|
<script>
|
|
23
|
-
import {onMounted, ref, provide, inject} from 'vue'
|
|
24
|
-
import { NUploaderKey, NLayoutKey } from '../../utils/symbols'
|
|
23
|
+
import { onMounted, ref, provide, inject } from 'vue'
|
|
24
|
+
import { NPowerKey, NUploaderKey, NLayoutKey } from '../../utils/symbols'
|
|
25
25
|
|
|
26
26
|
export default {
|
|
27
27
|
|
|
@@ -75,13 +75,11 @@ export default {
|
|
|
75
75
|
*/
|
|
76
76
|
setup(props, { emit }) {
|
|
77
77
|
|
|
78
|
-
// ==========【注入】============================================================================================
|
|
79
|
-
|
|
80
|
-
// 获取布局注入数据
|
|
81
|
-
const $nLayout = inject(NLayoutKey)
|
|
82
|
-
|
|
83
78
|
// ==========【数据】============================================================================================
|
|
84
79
|
|
|
80
|
+
// 获取权限注入数据
|
|
81
|
+
const $power = inject(NPowerKey)
|
|
82
|
+
|
|
85
83
|
// 页面状态
|
|
86
84
|
const pageStatus = ref(false)
|
|
87
85
|
|
|
@@ -111,7 +109,7 @@ export default {
|
|
|
111
109
|
})
|
|
112
110
|
|
|
113
111
|
// 更新布局数据
|
|
114
|
-
$
|
|
112
|
+
$power.update(function(data) {
|
|
115
113
|
data.uploader.push(uploader)
|
|
116
114
|
})
|
|
117
115
|
|
|
@@ -395,9 +395,7 @@ export default {
|
|
|
395
395
|
// quasar 对象
|
|
396
396
|
const $q = useQuasar()
|
|
397
397
|
|
|
398
|
-
//
|
|
399
|
-
|
|
400
|
-
// 获取布局注入数据
|
|
398
|
+
// 获取上传器注入数据
|
|
401
399
|
const {
|
|
402
400
|
// 声明属性
|
|
403
401
|
props: uploaderProps,
|
package/package.json
CHANGED
package/store/index.js
CHANGED
|
@@ -5,6 +5,20 @@ import { initAuthStore } from '../utils/useAuth'
|
|
|
5
5
|
* 公共变量
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
// 权限数据
|
|
9
|
+
export const statePower = ref({
|
|
10
|
+
// 角色权限版本
|
|
11
|
+
v: null,
|
|
12
|
+
// all id
|
|
13
|
+
all: {},
|
|
14
|
+
// 页面
|
|
15
|
+
urls: {},
|
|
16
|
+
// 按钮
|
|
17
|
+
btns: {},
|
|
18
|
+
// 菜单
|
|
19
|
+
menus: [],
|
|
20
|
+
})
|
|
21
|
+
|
|
8
22
|
// 角色数据
|
|
9
23
|
export const stateRole = ref({
|
|
10
24
|
// 角色权限版本
|
package/utils/$form.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ref, provide, inject } from 'vue'
|
|
2
|
+
|
|
3
|
+
import { NPowerKey, NFormKey } from './symbols'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 创建表单
|
|
7
|
+
*/
|
|
8
|
+
function create(params) {
|
|
9
|
+
|
|
10
|
+
// ==========【数据】=================================================================================================
|
|
11
|
+
|
|
12
|
+
// 获取参数
|
|
13
|
+
const o = Object.assign({
|
|
14
|
+
// 表单数据
|
|
15
|
+
formData: {},
|
|
16
|
+
// 重置表单
|
|
17
|
+
resetForm: null,
|
|
18
|
+
}, params)
|
|
19
|
+
|
|
20
|
+
// 获取权限注入
|
|
21
|
+
const $power = _.has(params, '$power') ? params.$power : inject(NPowerKey)
|
|
22
|
+
|
|
23
|
+
// ==========【返回】=================================================================================================
|
|
24
|
+
|
|
25
|
+
const resForm = {
|
|
26
|
+
// 表单节点
|
|
27
|
+
formRef: ref(null),
|
|
28
|
+
// 原始表单数据
|
|
29
|
+
rawFormData: o.formData,
|
|
30
|
+
// 表单数据
|
|
31
|
+
formData: ref(o.formData),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if ($power) {
|
|
35
|
+
$power.update(function(data, _data) {
|
|
36
|
+
_data.$form = resForm
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 提供可以被后代组件注入的值
|
|
41
|
+
provide(NFormKey, resForm)
|
|
42
|
+
|
|
43
|
+
return resForm
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 业务表单
|
|
48
|
+
*/
|
|
49
|
+
utils.$form = {
|
|
50
|
+
// 创建表单
|
|
51
|
+
create,
|
|
52
|
+
}
|