@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
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 表格筛选可见列按钮-->
|
|
3
|
+
<q-btn
|
|
4
|
+
icon="checklist"
|
|
5
|
+
dense
|
|
6
|
+
round
|
|
7
|
+
flat
|
|
8
|
+
v-if="tableColumns.length"
|
|
9
|
+
>
|
|
10
|
+
<q-menu
|
|
11
|
+
self="top middle"
|
|
12
|
+
:offset="[0, 8]"
|
|
13
|
+
>
|
|
14
|
+
<q-list style="min-width: 250px" dense bordered>
|
|
15
|
+
|
|
16
|
+
<!-- 表格宫格 -->
|
|
17
|
+
<template v-if="tableGrid !== null">
|
|
18
|
+
<q-item
|
|
19
|
+
clickable
|
|
20
|
+
@click="tableGrid = ! tableGrid"
|
|
21
|
+
>
|
|
22
|
+
<q-item-section>宫格模式</q-item-section>
|
|
23
|
+
<q-item-section side>
|
|
24
|
+
<q-icon
|
|
25
|
+
size="xs"
|
|
26
|
+
name="check"
|
|
27
|
+
v-show="tableGrid"
|
|
28
|
+
/>
|
|
29
|
+
</q-item-section>
|
|
30
|
+
</q-item>
|
|
31
|
+
<q-separator />
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<!-- 筛选表格列 -->
|
|
35
|
+
<q-item
|
|
36
|
+
v-for="item in tableColumns"
|
|
37
|
+
clickable
|
|
38
|
+
@click="onTableVisible(item)"
|
|
39
|
+
>
|
|
40
|
+
<q-item-section>{{item.label}}</q-item-section>
|
|
41
|
+
<q-item-section side>
|
|
42
|
+
<q-icon
|
|
43
|
+
size="xs"
|
|
44
|
+
name="check"
|
|
45
|
+
v-show="utils.indexOf(tableVisibleColumns, item.name) > -1"
|
|
46
|
+
/>
|
|
47
|
+
</q-item-section>
|
|
48
|
+
</q-item>
|
|
49
|
+
</q-list>
|
|
50
|
+
</q-menu>
|
|
51
|
+
</q-btn>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
import { inject } from 'vue'
|
|
56
|
+
|
|
57
|
+
import { NTableKey } from '../../../utils/symbols'
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 组合式
|
|
63
|
+
*/
|
|
64
|
+
setup() {
|
|
65
|
+
|
|
66
|
+
// ==========【方法】=============================================================================================
|
|
67
|
+
|
|
68
|
+
// 获取表格注入数据
|
|
69
|
+
const {
|
|
70
|
+
// 表格列数据(对象数组)
|
|
71
|
+
tableColumns,
|
|
72
|
+
// 表格可见列
|
|
73
|
+
tableVisibleColumns,
|
|
74
|
+
// 表格宫格
|
|
75
|
+
tableGrid,
|
|
76
|
+
} = inject(NTableKey)
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 表格可见列点击
|
|
80
|
+
*/
|
|
81
|
+
function onTableVisible(item) {
|
|
82
|
+
const index = utils.indexOf(tableVisibleColumns.value, item.name)
|
|
83
|
+
if (index > -1) {
|
|
84
|
+
tableVisibleColumns.value.splice(index, 1)
|
|
85
|
+
} else {
|
|
86
|
+
tableVisibleColumns.value.push(item.name)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ==========【返回】=============================================================================================
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
// 表格列数据(对象数组)
|
|
94
|
+
tableColumns,
|
|
95
|
+
// 表格可见列
|
|
96
|
+
tableVisibleColumns,
|
|
97
|
+
// 表格宫格
|
|
98
|
+
tableGrid,
|
|
99
|
+
|
|
100
|
+
// 表格可见列点击
|
|
101
|
+
onTableVisible,
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
@@ -1,36 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<q-layout
|
|
3
3
|
class="absolute-full"
|
|
4
4
|
:class="{
|
|
5
5
|
'n-table--grid': tableGrid,
|
|
6
6
|
}"
|
|
7
7
|
view="lHr LpR lff"
|
|
8
8
|
container
|
|
9
|
-
:page-status="pageStatus"
|
|
10
|
-
:empty-description="emptyDescription"
|
|
11
9
|
>
|
|
12
10
|
<!-- 头部 -->
|
|
13
|
-
<n-toolbar
|
|
14
|
-
|
|
15
|
-
:model-value="roleBtnLists"
|
|
16
|
-
v-model:table-grid="tableGrid"
|
|
17
|
-
v-model:table-visible-columns="tableVisibleColumns"
|
|
18
|
-
:query="tableQuery"
|
|
19
|
-
:table-columns="tableColumns"
|
|
20
|
-
:table-selected="tableSelected"
|
|
21
|
-
:table-refresh="tableRefresh"
|
|
22
|
-
v-bind="toolbarProps"
|
|
23
|
-
header
|
|
24
|
-
/>
|
|
11
|
+
<n-toolbar header />
|
|
12
|
+
|
|
25
13
|
<!-- 左侧分类 -->
|
|
26
14
|
<n-drawer
|
|
15
|
+
:model-value="true"
|
|
27
16
|
side="left"
|
|
28
17
|
:width="200"
|
|
29
18
|
:min-width="150"
|
|
30
19
|
bordered
|
|
31
|
-
show
|
|
32
20
|
drag
|
|
33
|
-
|
|
21
|
+
cache
|
|
34
22
|
v-if="treeNodes.length"
|
|
35
23
|
>
|
|
36
24
|
<q-scroll-area class="absolute-full">
|
|
@@ -120,7 +108,6 @@
|
|
|
120
108
|
<template v-slot:body-cell-settings="props">
|
|
121
109
|
<n-table-column-fixed
|
|
122
110
|
:props="props"
|
|
123
|
-
:role-btn-lists="tableFixedRoleBtnLists"
|
|
124
111
|
/>
|
|
125
112
|
</template>
|
|
126
113
|
|
|
@@ -128,8 +115,6 @@
|
|
|
128
115
|
<template v-slot:bottom-row="props" v-if="tableSummary">
|
|
129
116
|
<n-table-summary
|
|
130
117
|
:props="props"
|
|
131
|
-
:data="tableSummary"
|
|
132
|
-
:selection="tableSelection"
|
|
133
118
|
/>
|
|
134
119
|
</template>
|
|
135
120
|
|
|
@@ -137,7 +122,6 @@
|
|
|
137
122
|
<template v-slot:pagination="props">
|
|
138
123
|
<n-table-pagination
|
|
139
124
|
:props="props"
|
|
140
|
-
:table-refresh="tableRefresh"
|
|
141
125
|
/>
|
|
142
126
|
</template>
|
|
143
127
|
</q-table>
|
|
@@ -146,12 +130,12 @@
|
|
|
146
130
|
|
|
147
131
|
<!-- 右侧搜索 -->
|
|
148
132
|
<n-drawer
|
|
133
|
+
:model-value="true"
|
|
149
134
|
side="right"
|
|
150
135
|
:min-width="320"
|
|
151
136
|
bordered
|
|
152
137
|
drag
|
|
153
|
-
|
|
154
|
-
show
|
|
138
|
+
cache
|
|
155
139
|
v-if="! noSearch && tableSearchValue.length"
|
|
156
140
|
>
|
|
157
141
|
<!-- 搜索 -->
|
|
@@ -162,12 +146,13 @@
|
|
|
162
146
|
:on-reset="tableSearchReset"
|
|
163
147
|
/>
|
|
164
148
|
</n-drawer>
|
|
165
|
-
</
|
|
149
|
+
</q-layout>
|
|
166
150
|
</template>
|
|
167
151
|
|
|
168
152
|
<script>
|
|
169
|
-
import { ref,
|
|
170
|
-
|
|
153
|
+
import { ref, watch, computed, inject } from 'vue'
|
|
154
|
+
|
|
155
|
+
import { NPowerKey, NTableKey } from '../../utils/symbols'
|
|
171
156
|
|
|
172
157
|
export default {
|
|
173
158
|
|
|
@@ -182,10 +167,6 @@ export default {
|
|
|
182
167
|
props: {
|
|
183
168
|
// 表格请求地址
|
|
184
169
|
url: String,
|
|
185
|
-
// 表格参数
|
|
186
|
-
tableParams: Object,
|
|
187
|
-
// 权限按钮列表
|
|
188
|
-
roleBtnLists: Array,
|
|
189
170
|
// 树节点唯一键值
|
|
190
171
|
treeNodeKey: {
|
|
191
172
|
type: String,
|
|
@@ -205,39 +186,22 @@ export default {
|
|
|
205
186
|
treeNodeClick: Function,
|
|
206
187
|
// 显示树筛选
|
|
207
188
|
treeFilter: Boolean,
|
|
208
|
-
// 页面状态
|
|
209
|
-
pageStatus: {
|
|
210
|
-
type: Boolean,
|
|
211
|
-
default: null,
|
|
212
|
-
},
|
|
213
|
-
// 空状态描述
|
|
214
|
-
emptyDescription: {
|
|
215
|
-
type: String,
|
|
216
|
-
default: '发生未知错误',
|
|
217
|
-
},
|
|
218
|
-
// 工具栏声明属性
|
|
219
|
-
toolbarProps: Object,
|
|
220
189
|
// 不显示搜索
|
|
221
190
|
noSearch: Boolean,
|
|
222
|
-
// 表格加载回调
|
|
223
|
-
load: Function,
|
|
224
191
|
},
|
|
225
192
|
|
|
226
|
-
/**
|
|
227
|
-
* 声明事件
|
|
228
|
-
*/
|
|
229
|
-
emits: [
|
|
230
|
-
// 表格加载回调
|
|
231
|
-
'load',
|
|
232
|
-
],
|
|
233
|
-
|
|
234
193
|
/**
|
|
235
194
|
* 组合式
|
|
236
195
|
*/
|
|
237
|
-
setup(props, {
|
|
196
|
+
setup(props, { slots }) {
|
|
238
197
|
|
|
239
198
|
// ==========【数据】============================================================================================
|
|
240
199
|
|
|
200
|
+
// 获取权限注入
|
|
201
|
+
const $power = inject(NPowerKey)
|
|
202
|
+
|
|
203
|
+
const $table = inject(NTableKey)
|
|
204
|
+
|
|
241
205
|
// 树节点
|
|
242
206
|
const treeRef = ref(null)
|
|
243
207
|
|
|
@@ -248,23 +212,18 @@ export default {
|
|
|
248
212
|
const treeSelected = ref('')
|
|
249
213
|
|
|
250
214
|
// 当前请求地址
|
|
251
|
-
const currentUrl = ref(props.url ? props.url : useRoute().fullPath)
|
|
252
|
-
|
|
253
|
-
// 表格参数
|
|
254
|
-
const tableParams = Object.assign({}, props.tableParams, {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
//
|
|
262
|
-
|
|
263
|
-
tableParams.search = false
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// 创建表格
|
|
267
|
-
const $table = utils.$table.create(tableParams)
|
|
215
|
+
// const currentUrl = ref(props.url ? props.url : useRoute().fullPath)
|
|
216
|
+
|
|
217
|
+
// // 表格参数
|
|
218
|
+
// const tableParams = Object.assign({}, props.tableParams, {
|
|
219
|
+
// // 请求地址
|
|
220
|
+
// url: currentUrl.value,
|
|
221
|
+
// })
|
|
222
|
+
//
|
|
223
|
+
// // 如果不显示搜索
|
|
224
|
+
// if (props.noSearch) {
|
|
225
|
+
// tableParams.search = false
|
|
226
|
+
// }
|
|
268
227
|
|
|
269
228
|
// ==========【计算属性】==========================================================================================
|
|
270
229
|
|
|
@@ -311,21 +270,11 @@ export default {
|
|
|
311
270
|
})
|
|
312
271
|
}
|
|
313
272
|
|
|
314
|
-
// ==========【生命周期】=========================================================================================
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* 实例被挂载后调用
|
|
318
|
-
*/
|
|
319
|
-
onMounted( async function() {
|
|
320
|
-
|
|
321
|
-
// 表格加载回调
|
|
322
|
-
emit('load', { $table })
|
|
323
|
-
await utils.runAsync(props.load)({ $table })
|
|
324
|
-
})
|
|
325
|
-
|
|
326
273
|
// ==========【返回】=============================================================================================
|
|
327
274
|
|
|
328
275
|
return {
|
|
276
|
+
// 解构权限实例
|
|
277
|
+
...$power,
|
|
329
278
|
// 解构表格实例
|
|
330
279
|
...$table,
|
|
331
280
|
|
|
@@ -336,9 +285,6 @@ export default {
|
|
|
336
285
|
// 树选择数据
|
|
337
286
|
treeSelected,
|
|
338
287
|
|
|
339
|
-
// 当前请求地址
|
|
340
|
-
currentUrl,
|
|
341
|
-
|
|
342
288
|
// 插槽 body 单元格标识
|
|
343
289
|
slotNames,
|
|
344
290
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<q-td :props="props">
|
|
3
|
-
<div class="q-gutter-sm">
|
|
3
|
+
<div class="q-gutter-sm" v-if="tableFixedPowerBtns.length">
|
|
4
4
|
<q-btn
|
|
5
|
-
v-for="item in
|
|
5
|
+
v-for="item in tableFixedPowerBtns"
|
|
6
6
|
:key="`btn-item-${item.id}`"
|
|
7
7
|
class="n-button-icon"
|
|
8
8
|
:icon="item.icon"
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
<script>
|
|
21
21
|
import { inject } from 'vue'
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
import { NPowerKey, NTableKey } from '../../utils/symbols'
|
|
23
24
|
|
|
24
25
|
export default {
|
|
25
26
|
|
|
@@ -34,8 +35,6 @@ export default {
|
|
|
34
35
|
props: {
|
|
35
36
|
// 传值
|
|
36
37
|
props: Object,
|
|
37
|
-
// 权限按钮列表
|
|
38
|
-
roleBtnLists: Array,
|
|
39
38
|
},
|
|
40
39
|
|
|
41
40
|
/**
|
|
@@ -43,10 +42,19 @@ export default {
|
|
|
43
42
|
*/
|
|
44
43
|
setup(props) {
|
|
45
44
|
|
|
46
|
-
//
|
|
45
|
+
// ==========【数据】============================================================================================
|
|
46
|
+
|
|
47
|
+
// 获取权限注入
|
|
48
|
+
const {
|
|
49
|
+
// 权限按钮点击
|
|
50
|
+
powerBtnClick,
|
|
51
|
+
} = inject(NPowerKey)
|
|
47
52
|
|
|
48
|
-
//
|
|
49
|
-
const
|
|
53
|
+
// 获取表格注入
|
|
54
|
+
const {
|
|
55
|
+
// 固定在右边的权限按钮列表
|
|
56
|
+
tableFixedPowerBtns,
|
|
57
|
+
} = inject(NTableKey)
|
|
50
58
|
|
|
51
59
|
// ==========【方法】=============================================================================================
|
|
52
60
|
|
|
@@ -54,13 +62,15 @@ export default {
|
|
|
54
62
|
* 点击
|
|
55
63
|
*/
|
|
56
64
|
function onClick(item) {
|
|
57
|
-
|
|
65
|
+
powerBtnClick(item, [ props.props.row ])
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
// ==========【返回】=============================================================================================
|
|
61
69
|
|
|
62
70
|
return {
|
|
63
|
-
//
|
|
71
|
+
// 固定在右边的权限按钮列表
|
|
72
|
+
tableFixedPowerBtns,
|
|
73
|
+
// 权限按钮点击
|
|
64
74
|
onClick,
|
|
65
75
|
}
|
|
66
76
|
},
|
|
@@ -57,12 +57,46 @@
|
|
|
57
57
|
dense
|
|
58
58
|
flat
|
|
59
59
|
@click="tableRefresh"
|
|
60
|
-
v-if="
|
|
60
|
+
v-if="hasTable"
|
|
61
61
|
/>
|
|
62
|
+
|
|
63
|
+
<!-- 当前页面工具栏无权限按钮时显示 -->
|
|
64
|
+
<template v-if="! toolbarPowerBtns.length">
|
|
65
|
+
|
|
66
|
+
<!-- 左边侧滑菜单切换按钮-->
|
|
67
|
+
<q-btn
|
|
68
|
+
:icon="leftDrawer.icon"
|
|
69
|
+
dense
|
|
70
|
+
round
|
|
71
|
+
flat
|
|
72
|
+
@click="leftDrawer.toggle"
|
|
73
|
+
v-if="leftDrawer.showButton()"
|
|
74
|
+
/>
|
|
75
|
+
|
|
76
|
+
<!-- 表格筛选可见列按钮 -->
|
|
77
|
+
<table-visible-columns-button v-if="hasTable" />
|
|
78
|
+
|
|
79
|
+
<!-- 右边侧滑菜单切换按钮-->
|
|
80
|
+
<q-btn
|
|
81
|
+
:icon="rightDrawer.icon"
|
|
82
|
+
dense
|
|
83
|
+
round
|
|
84
|
+
flat
|
|
85
|
+
@click="rightDrawer.toggle"
|
|
86
|
+
v-if="rightDrawer.showButton()"
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
</template>
|
|
90
|
+
|
|
62
91
|
</div>
|
|
63
92
|
</template>
|
|
64
93
|
|
|
65
94
|
<script>
|
|
95
|
+
import { inject } from 'vue'
|
|
96
|
+
|
|
97
|
+
import TableVisibleColumnsButton from '../private/table-visible-columns-button'
|
|
98
|
+
import { NPowerKey, NTableKey } from '../../utils/symbols'
|
|
99
|
+
|
|
66
100
|
export default {
|
|
67
101
|
|
|
68
102
|
/**
|
|
@@ -70,14 +104,60 @@ export default {
|
|
|
70
104
|
*/
|
|
71
105
|
name: 'NTablePagination',
|
|
72
106
|
|
|
107
|
+
/**
|
|
108
|
+
* 容器
|
|
109
|
+
*/
|
|
110
|
+
components: {
|
|
111
|
+
TableVisibleColumnsButton,
|
|
112
|
+
},
|
|
113
|
+
|
|
73
114
|
/**
|
|
74
115
|
* 声明属性
|
|
75
116
|
*/
|
|
76
117
|
props: {
|
|
77
118
|
// 传值
|
|
78
119
|
props: Object,
|
|
79
|
-
|
|
80
|
-
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 组合式
|
|
124
|
+
*/
|
|
125
|
+
setup() {
|
|
126
|
+
|
|
127
|
+
// ==========【数据】============================================================================================
|
|
128
|
+
|
|
129
|
+
// 获取权限注入
|
|
130
|
+
const $power = inject(NPowerKey)
|
|
131
|
+
const {
|
|
132
|
+
// 左边侧滑菜单数据
|
|
133
|
+
leftDrawer,
|
|
134
|
+
// 右边侧滑菜单数据
|
|
135
|
+
rightDrawer,
|
|
136
|
+
// 当前页面工具栏权限按钮
|
|
137
|
+
toolbarPowerBtns,
|
|
138
|
+
} = $power
|
|
139
|
+
|
|
140
|
+
// 获取表格注入
|
|
141
|
+
const $table = inject(NTableKey)
|
|
142
|
+
const {
|
|
143
|
+
// 表格刷新
|
|
144
|
+
tableRefresh,
|
|
145
|
+
} = $table
|
|
146
|
+
|
|
147
|
+
// ==========【返回】=============================================================================================
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
// 是否有表格
|
|
151
|
+
hasTable: !! $table,
|
|
152
|
+
// 表格刷新
|
|
153
|
+
tableRefresh,
|
|
154
|
+
// 当前页面工具栏权限按钮
|
|
155
|
+
toolbarPowerBtns,
|
|
156
|
+
// 左边侧滑菜单数据
|
|
157
|
+
leftDrawer,
|
|
158
|
+
// 右边侧滑菜单数据
|
|
159
|
+
rightDrawer,
|
|
160
|
+
}
|
|
81
161
|
},
|
|
82
162
|
}
|
|
83
163
|
</script>
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
|
-
import { computed } from 'vue'
|
|
17
|
+
import { computed, inject } from 'vue'
|
|
18
|
+
|
|
19
|
+
import { NTableKey } from '../../utils/symbols'
|
|
18
20
|
|
|
19
21
|
export default {
|
|
20
22
|
|
|
@@ -40,13 +42,21 @@ export default {
|
|
|
40
42
|
*/
|
|
41
43
|
setup(props) {
|
|
42
44
|
|
|
45
|
+
// ==========【数据】============================================================================================
|
|
46
|
+
|
|
47
|
+
// 获取表格注入
|
|
48
|
+
const {
|
|
49
|
+
// 表格选择类型
|
|
50
|
+
tableSelection,
|
|
51
|
+
} = inject(NTableKey)
|
|
52
|
+
|
|
43
53
|
// ==========【计算属性】============================================================================================
|
|
44
54
|
|
|
45
55
|
const columns = computed(function () {
|
|
46
56
|
|
|
47
57
|
const lists = []
|
|
48
58
|
|
|
49
|
-
if (
|
|
59
|
+
if (tableSelection.value !== 'none') {
|
|
50
60
|
lists.push({
|
|
51
61
|
css: 'q-table--col-auto-width text-center',
|
|
52
62
|
name: '',
|
|
@@ -85,6 +95,8 @@ export default {
|
|
|
85
95
|
return {
|
|
86
96
|
// 栏目
|
|
87
97
|
columns,
|
|
98
|
+
// 表格选择类型
|
|
99
|
+
tableSelection,
|
|
88
100
|
}
|
|
89
101
|
},
|
|
90
102
|
}
|