@netang/quasar 0.0.21 → 0.0.23

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.
@@ -1,37 +1,24 @@
1
1
  <template>
2
- <n-layout
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
- ref="tableToolbarRef"
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
- >
25
- </n-toolbar>
11
+ <n-toolbar header />
12
+
26
13
  <!-- 左侧分类 -->
27
14
  <n-drawer
15
+ :model-value="true"
28
16
  side="left"
29
17
  :width="200"
30
18
  :min-width="150"
31
19
  bordered
32
- show
33
20
  drag
34
- :cache="currentUrl"
21
+ cache
35
22
  v-if="treeNodes.length"
36
23
  >
37
24
  <q-scroll-area class="absolute-full">
@@ -69,7 +56,6 @@
69
56
  <q-page-container>
70
57
  <q-page>
71
58
  <q-table
72
- ref="tableRef"
73
59
  class="n-table absolute-full"
74
60
  :class="{
75
61
  'n-table--last-fixed': showTableFixed,
@@ -85,7 +71,7 @@
85
71
  :rows-per-page-options="tableRowsPerPageOptions"
86
72
  :grid="tableGrid"
87
73
  @row-click="tableRowClick"
88
- @row-dblclick="tableRowDblclick"
74
+ @row-dblclick="currentTableRowDblclick"
89
75
  @request="tableRequest"
90
76
  flat
91
77
  virtual-scroll
@@ -121,7 +107,6 @@
121
107
  <template v-slot:body-cell-settings="props">
122
108
  <n-table-column-fixed
123
109
  :props="props"
124
- :role-btn-lists="tableFixedRoleBtnLists"
125
110
  />
126
111
  </template>
127
112
 
@@ -129,8 +114,6 @@
129
114
  <template v-slot:bottom-row="props" v-if="tableSummary">
130
115
  <n-table-summary
131
116
  :props="props"
132
- :data="tableSummary"
133
- :selection="tableSelection"
134
117
  />
135
118
  </template>
136
119
 
@@ -138,7 +121,6 @@
138
121
  <template v-slot:pagination="props">
139
122
  <n-table-pagination
140
123
  :props="props"
141
- :table-refresh="tableRefresh"
142
124
  />
143
125
  </template>
144
126
  </q-table>
@@ -147,12 +129,12 @@
147
129
 
148
130
  <!-- 右侧搜索 -->
149
131
  <n-drawer
132
+ :model-value="true"
150
133
  side="right"
151
134
  :min-width="320"
152
135
  bordered
153
136
  drag
154
- :cache="currentUrl"
155
- show
137
+ cache
156
138
  v-if="! noSearch && tableSearchValue.length"
157
139
  >
158
140
  <!-- 搜索 -->
@@ -163,14 +145,13 @@
163
145
  :on-reset="tableSearchReset"
164
146
  />
165
147
  </n-drawer>
166
- </n-layout>
148
+ </q-layout>
167
149
  </template>
168
150
 
169
151
  <script>
170
- import { ref, onMounted, watch, computed, inject } from 'vue'
171
- import { useRoute } from 'vue-router'
152
+ import { ref, watch, computed, inject } from 'vue'
172
153
 
173
- import { NFieldTableKey } from '../../utils/symbols'
154
+ import { NDialogKey, NTableKey } from '../../utils/symbols'
174
155
 
175
156
  export default {
176
157
 
@@ -185,10 +166,6 @@ export default {
185
166
  props: {
186
167
  // 表格请求地址
187
168
  url: String,
188
- // 表格参数
189
- tableParams: Object,
190
- // 权限按钮列表
191
- roleBtnLists: Array,
192
169
  // 树节点唯一键值
193
170
  treeNodeKey: {
194
171
  type: String,
@@ -208,44 +185,45 @@ export default {
208
185
  treeNodeClick: Function,
209
186
  // 显示树筛选
210
187
  treeFilter: Boolean,
211
- // 页面状态
212
- pageStatus: {
213
- type: Boolean,
214
- default: null,
215
- },
216
- // 空状态描述
217
- emptyDescription: {
218
- type: String,
219
- default: '发生未知错误',
220
- },
221
- // 工具栏声明属性
222
- toolbarProps: Object,
223
188
  // 不显示搜索
224
189
  noSearch: Boolean,
225
- // 表格加载回调
226
- load: Function,
227
190
  },
228
191
 
229
- /**
230
- * 声明事件
231
- */
232
- emits: [
233
- // 表格加载回调
234
- 'load',
235
- ],
236
-
237
192
  /**
238
193
  * 组合式
239
194
  */
240
- setup(props, { emit, slots }) {
195
+ setup(props, { slots }) {
241
196
 
242
- // ==========【注入】============================================================================================
197
+ // ==========【数据】============================================================================================
243
198
 
244
- // 获取文本框表格注入
245
- const $fieldTable = inject(NFieldTableKey)
246
- const inFieldTable = !! $fieldTable
199
+ // 获取表格注入
200
+ const $table = inject(NTableKey)
247
201
 
248
- // ==========【数据】============================================================================================
202
+ // 获取对话框注入
203
+ const $dialog = inject(NDialogKey)
204
+ const inDialog = !! $dialog
205
+
206
+ // 当前双击表格行
207
+ let currentTableRowDblclick
208
+
209
+ // 如果在对话框内部
210
+ if (inDialog) {
211
+ // 提交表格已选数据给对话框
212
+ $dialog.submit(() => $table.tableSelected.value)
213
+
214
+ // 对话框中的表格双击表格行
215
+ currentTableRowDblclick = function (e, row) {
216
+ // 如果不是多选
217
+ if ($table.tableSelection !== 'multiple') {
218
+ $table.tableSelected.value = [ row ]
219
+ $dialog.confirm()
220
+ }
221
+ }
222
+
223
+ } else {
224
+ // 表格实例中的双击表格行
225
+ currentTableRowDblclick = $table.tableRowDblclick
226
+ }
249
227
 
250
228
  // 树节点
251
229
  const treeRef = ref(null)
@@ -256,35 +234,13 @@ export default {
256
234
  // 树选择数据
257
235
  const treeSelected = ref('')
258
236
 
259
- // 当前请求地址
260
- const currentUrl = ref(props.url ? props.url : useRoute().fullPath)
261
-
262
- // 表格参数
263
- const tableParams = Object.assign({}, props.tableParams, {
264
- // 请求地址
265
- url: currentUrl.value,
266
- // 权限按钮列表
267
- roleBtnLists: computed(()=>props.roleBtnLists),
268
- })
269
-
270
- // 如果不显示搜索
271
- if (props.noSearch) {
272
- tableParams.search = false
273
- }
274
-
275
- // 创建表格
276
- const $table = inFieldTable ? $fieldTable.$table : utils.$table.create(tableParams)
277
-
278
237
  // ==========【计算属性】==========================================================================================
279
238
 
280
239
  /**
281
240
  * 插槽标识
282
241
  */
283
242
  const slotNames = computed(function() {
284
- if (utils.isValidObject(slots)) {
285
- return Object.keys(slots)
286
- }
287
- return []
243
+ return utils.isValidObject(slots) ? Object.keys(slots) : []
288
244
  })
289
245
 
290
246
  // ==========【监听数据】=========================================================================================
@@ -320,18 +276,6 @@ export default {
320
276
  })
321
277
  }
322
278
 
323
- // ==========【生命周期】=========================================================================================
324
-
325
- /**
326
- * 实例被挂载后调用
327
- */
328
- onMounted( async function() {
329
-
330
- // 表格加载回调
331
- emit('load', { $table })
332
- await utils.runAsync(props.load)({ $table })
333
- })
334
-
335
279
  // ==========【返回】=============================================================================================
336
280
 
337
281
  return {
@@ -345,11 +289,11 @@ export default {
345
289
  // 树选择数据
346
290
  treeSelected,
347
291
 
348
- // 当前请求地址
349
- currentUrl,
350
-
351
292
  // 插槽 body 单元格标识
352
293
  slotNames,
294
+
295
+ // 当前双击表格行
296
+ currentTableRowDblclick,
353
297
  }
354
298
  },
355
299
  }
@@ -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 roleBtnLists"
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
- import { NLayoutKey } from '../../utils/symbols'
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 $nLayout = inject(NLayoutKey)
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
- $nLayout.data.role?.click(item, [ props.props.row ])
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
  },
@@ -1,11 +1,12 @@
1
1
  <template>
2
2
  <div>
3
3
  <!-- 页码 -->
4
- <span class="q-table__bottom-item">{{props.pagination.page}} / {{Math.ceil(props.pagination.rowsNumber / props.pagination.rowsPerPage)}}</span>
4
+ <span class="q-table__bottom-item">{{props.pagination.page}} / {{props.pagesNumber}}</span>
5
5
 
6
6
  <!-- 第一页 -->
7
7
  <q-btn
8
8
  v-if="props.pagesNumber > 2"
9
+ :class="{ dense }"
9
10
  icon="first_page"
10
11
  color="grey-8"
11
12
  round
@@ -17,6 +18,7 @@
17
18
 
18
19
  <!-- 上页 -->
19
20
  <q-btn
21
+ :class="{ dense }"
20
22
  icon="chevron_left"
21
23
  color="grey-8"
22
24
  round
@@ -28,6 +30,7 @@
28
30
 
29
31
  <!-- 下页 -->
30
32
  <q-btn
33
+ :class="{ dense }"
31
34
  icon="chevron_right"
32
35
  color="grey-8"
33
36
  round
@@ -39,6 +42,7 @@
39
42
 
40
43
  <!-- 最后一页 -->
41
44
  <q-btn
45
+ :class="{ dense }"
42
46
  v-if="props.pagesNumber > 2"
43
47
  icon="last_page"
44
48
  color="grey-8"
@@ -51,18 +55,58 @@
51
55
 
52
56
  <!-- 刷新 -->
53
57
  <q-btn
58
+ :class="{ dense }"
54
59
  icon="refresh"
55
60
  color="grey-8"
56
61
  round
57
62
  dense
58
63
  flat
59
64
  @click="tableRefresh"
60
- v-if="tableRefresh"
65
+ v-if="! noRefresh && hasRefresh"
61
66
  />
67
+
68
+ <!-- 当前页面工具栏无权限按钮时显示 -->
69
+ <template v-if="! noPower && ! toolbarPowerBtns.length">
70
+
71
+ <!-- 左边侧滑菜单切换按钮-->
72
+ <q-btn
73
+ :class="{ dense }"
74
+ :icon="leftDrawer.icon"
75
+ dense
76
+ round
77
+ flat
78
+ @click="leftDrawer.toggle"
79
+ v-if="leftDrawer.showButton()"
80
+ />
81
+
82
+ <!-- 表格筛选可见列按钮 -->
83
+ <table-visible-columns-button
84
+ :class="{ dense }"
85
+ v-if="hasTable"
86
+ />
87
+
88
+ <!-- 右边侧滑菜单切换按钮-->
89
+ <q-btn
90
+ :class="{ dense }"
91
+ :icon="rightDrawer.icon"
92
+ dense
93
+ round
94
+ flat
95
+ @click="rightDrawer.toggle"
96
+ v-if="rightDrawer.showButton()"
97
+ />
98
+
99
+ </template>
100
+
62
101
  </div>
63
102
  </template>
64
103
 
65
104
  <script>
105
+ import { inject } from 'vue'
106
+
107
+ import TableVisibleColumnsButton from '../private/table-visible-columns-button'
108
+ import { NPowerKey, NTableKey } from '../../utils/symbols'
109
+
66
110
  export default {
67
111
 
68
112
  /**
@@ -70,14 +114,80 @@ export default {
70
114
  */
71
115
  name: 'NTablePagination',
72
116
 
117
+ /**
118
+ * 容器
119
+ */
120
+ components: {
121
+ TableVisibleColumnsButton,
122
+ },
123
+
73
124
  /**
74
125
  * 声明属性
75
126
  */
76
127
  props: {
77
128
  // 传值
78
129
  props: Object,
79
- // 表格刷新
80
- tableRefresh: Function,
130
+ // 是否关闭权限
131
+ noPower: Boolean,
132
+ // 是否关闭刷新按钮
133
+ noRefresh: Boolean,
134
+ // 紧凑模式
135
+ dense: Boolean,
136
+ },
137
+
138
+ /**
139
+ * 组合式
140
+ */
141
+ setup() {
142
+
143
+ // ==========【数据】============================================================================================
144
+
145
+ // 获取权限注入
146
+ const $power = inject(NPowerKey)
147
+ const {
148
+ // 左边侧滑菜单数据
149
+ leftDrawer,
150
+ // 右边侧滑菜单数据
151
+ rightDrawer,
152
+ // 当前页面工具栏权限按钮
153
+ toolbarPowerBtns,
154
+ } = $power
155
+
156
+ // 获取表格注入
157
+ const $table = inject(NTableKey)
158
+ const hasTable = !! $table
159
+
160
+ const {
161
+ // 表格刷新
162
+ tableRefresh,
163
+ } = $table
164
+
165
+ // ==========【返回】=============================================================================================
166
+
167
+
168
+ return {
169
+ // 是否有表格
170
+ hasTable,
171
+ // 是否有刷新按钮
172
+ hasRefresh: hasTable && !! $table.routeFullPath,
173
+ // 表格刷新
174
+ tableRefresh,
175
+ // 当前页面工具栏权限按钮
176
+ toolbarPowerBtns,
177
+ // 左边侧滑菜单数据
178
+ leftDrawer,
179
+ // 右边侧滑菜单数据
180
+ rightDrawer,
181
+ }
81
182
  },
82
183
  }
83
184
  </script>
185
+
186
+ <style lang="scss" scoped>
187
+ @import "@/assets/sass/var.scss";
188
+
189
+ // 紧凑模式
190
+ .dense {
191
+ font-size: 12px;
192
+ }
193
+ </style>
@@ -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
  }