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