@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 CHANGED
@@ -1,13 +1,12 @@
1
1
  ## Installation
2
2
 
3
3
  ```bash
4
- npm install @netang/admin --save-dev
4
+ npm install @netang/quasar --save-dev
5
5
  ```
6
6
 
7
7
  Install mandatory peer dependencies
8
8
  ```bash
9
- npm install @netang/utils --save-dev
10
- npm install lodash --save-dev
9
+ npm install @netang/utils @netang/vue-utils @netang/node-utils quasar @quasar/extras lodash axios bignumber.js spark-md5 xregexp --save-dev
11
10
  ```
12
11
 
13
12
  ## License
@@ -2,6 +2,7 @@
2
2
  <q-dialog
3
3
  class="n-dialog-proxy"
4
4
  ref="dialogRef"
5
+ v-model="currentModelValue"
5
6
  v-bind="dialogProps"
6
7
  @hide="onDialogHide"
7
8
  >
@@ -23,9 +24,14 @@
23
24
  container
24
25
  >
25
26
  <q-page-container>
27
+ <slot
28
+ v-bind="props"
29
+ v-if="$slots.default"
30
+ />
26
31
  <component
27
32
  :is="comp"
28
33
  v-bind="props"
34
+ v-else
29
35
  />
30
36
  </q-page-container>
31
37
  </q-layout>
@@ -43,7 +49,7 @@
43
49
  </template>
44
50
 
45
51
  <script>
46
- import { ref, computed, defineAsyncComponent, provide } from 'vue'
52
+ import { ref, computed, defineAsyncComponent, provide, watch } from 'vue'
47
53
  import { useDialogPluginComponent, useQuasar } from 'quasar'
48
54
 
49
55
  import routers from '@/router/routers'
@@ -62,6 +68,11 @@ export default {
62
68
  * 声明属性
63
69
  */
64
70
  props: {
71
+ // 值
72
+ modelValue: {
73
+ type: Boolean,
74
+ default: true,
75
+ },
65
76
  // 对话框传参
66
77
  dialogProps: Object,
67
78
  // 组件标识
@@ -103,25 +114,41 @@ export default {
103
114
  },
104
115
  // 是否全屏
105
116
  fullscreen: Boolean,
117
+ // 页面容器
118
+ pageContainer: {
119
+ type: Boolean,
120
+ default: true,
121
+ },
106
122
  },
107
123
 
108
124
  /**
109
125
  * 声明事件
110
126
  */
111
127
  emits: [
128
+ 'update:modelValue',
112
129
  ...useDialogPluginComponent.emits
113
130
  ],
114
131
 
115
132
  /**
116
133
  * 组合式
117
134
  */
118
- setup(props) {
135
+ setup(props, { emit }) {
119
136
 
120
137
  // ==========【数据】============================================================================================
121
138
 
122
139
  // quasar 对象
123
140
  const $q = useQuasar()
124
141
 
142
+ const currentModelValue = ref(props.modelValue)
143
+
144
+ watch(()=>props.modelValue, function (val) {
145
+ currentModelValue.value = val
146
+ })
147
+
148
+ watch(currentModelValue, function (val) {
149
+ emit('update:modelValue', val)
150
+ })
151
+
125
152
  const {
126
153
  // 对话框节点
127
154
  dialogRef,
@@ -283,6 +310,7 @@ export default {
283
310
  // ==========【返回】=============================================================================================
284
311
 
285
312
  return {
313
+ currentModelValue,
286
314
  // 自定义样式
287
315
  customStyle,
288
316
  // 组件
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <q-drawer
3
- v-model="isShow"
3
+ v-model="currentModelValue"
4
4
  :side="side"
5
5
  :breakpoint="breakpoint"
6
6
  :width="currentWidth"
@@ -20,13 +20,13 @@
20
20
  </template>
21
21
 
22
22
  <script>
23
- import { ref, inject, nextTick } from 'vue'
23
+ import { ref, inject, nextTick, watch } from 'vue'
24
24
  import { useQuasar } from 'quasar'
25
25
  import { useRoute } from 'vue-router'
26
26
 
27
27
  import { layoutKey, emptyRenderFn } from 'quasar/src/utils/private/symbols.js'
28
28
 
29
- import { NLayoutKey } from '../../utils/symbols'
29
+ import { NPowerKey } from '../../utils/symbols'
30
30
 
31
31
  export default {
32
32
 
@@ -39,11 +39,15 @@ export default {
39
39
  * 声明属性
40
40
  */
41
41
  props: {
42
+ // 值
43
+ modelValue: Boolean,
44
+ // 位置
42
45
  side: {
43
46
  type: String,
44
47
  default: 'left',
45
48
  validator: v => [ 'left', 'right' ].includes(v)
46
49
  },
50
+ // 宽度
47
51
  width: {
48
52
  type: Number,
49
53
  default: 300
@@ -55,8 +59,6 @@ export default {
55
59
 
56
60
  // 【自定义属性】
57
61
  // --------------------------------------------------
58
- // 是否显示
59
- show: Boolean,
60
62
  // 手机端宽度(px / %)
61
63
  mobileWidth: {
62
64
  type: [String, Number],
@@ -82,38 +84,49 @@ export default {
82
84
  cache: [Boolean, String],
83
85
  },
84
86
 
87
+ /**
88
+ * 声明事件
89
+ */
90
+ emits: [
91
+ 'update:modelValue',
92
+ ],
93
+
85
94
  /**
86
95
  * 组合式
87
96
  */
88
- setup(props) {
97
+ setup(props, { emit }) {
89
98
 
90
- // ==========【注入】============================================================================================
99
+ // ==========【数据】============================================================================================
91
100
 
92
101
  // 获取 quasar 注入
93
- const $layout = inject(layoutKey, emptyRenderFn)
94
- if ($layout === emptyRenderFn) {
102
+ const $quasarLayout = inject(layoutKey, emptyRenderFn)
103
+ if ($quasarLayout === emptyRenderFn) {
95
104
  console.error('NDrawer needs to be child of QLayout')
96
105
  return emptyRenderFn
97
106
  }
98
107
 
99
- // 获取布局注入数据
100
- const $nLayout = inject(NLayoutKey)
101
-
102
- // ==========【数据】============================================================================================
103
-
104
108
  // quasar 对象
105
109
  const $q = useQuasar()
106
110
 
107
111
  // 获取当前路由
108
112
  const $route = useRoute()
109
113
 
110
- // 是否显示
111
- const isShow = ref($q.screen.width < props.breakpoint ? false : props.show)
114
+ // 获取权限注入数据
115
+ const $power = inject(NPowerKey)
112
116
 
113
- // 更新布局数据
114
- $nLayout.update(function(data) {
115
- data[props.side].data = isShow
116
- })
117
+ // 是否显示
118
+ let currentModelValue
119
+ if ($power) {
120
+ currentModelValue = $power[`${props.side}Drawer`].modelValue
121
+ if ($q.screen.width < props.breakpoint) {
122
+ currentModelValue.value = false
123
+ emit('update:modelValue', false)
124
+ } else {
125
+ currentModelValue.value = props.modelValue
126
+ }
127
+ } else {
128
+ currentModelValue = ref(props.modelValue)
129
+ }
117
130
 
118
131
  // 缓存名
119
132
  let cacheName = ''
@@ -160,11 +173,27 @@ export default {
160
173
 
161
174
  // 下次 DOM 更新
162
175
  nextTick(function() {
163
- if (isShow.value && $layout.totalWidth.value < props.breakpoint) {
164
- isShow.value = false
176
+ if (currentModelValue.value && $quasarLayout.totalWidth.value < props.breakpoint) {
177
+ currentModelValue.value = false
165
178
  }
166
179
  })
167
180
 
181
+ // ==========【监听数据】==========================================================================================
182
+
183
+ /**
184
+ * 监听声明值
185
+ */
186
+ watch(()=>props.modelValue, function (val) {
187
+ currentModelValue.value = val
188
+ })
189
+
190
+ /**
191
+ * 监听当前值
192
+ */
193
+ watch(currentModelValue, function (val) {
194
+ emit('update:modelValue', val)
195
+ })
196
+
168
197
  // ==========【方法】=============================================================================================
169
198
 
170
199
  /**
@@ -194,7 +223,7 @@ export default {
194
223
 
195
224
  // if (
196
225
  // // 如果显示
197
- // isShow.value
226
+ // currentModelValue.value
198
227
  // // 如果开启折叠
199
228
  // && props.dragCollapse
200
229
  // // 如果有最小宽度
@@ -204,7 +233,7 @@ export default {
204
233
  //
205
234
  // // 如果 拖拽宽度 < 折叠宽度
206
235
  // if (dragWidth < collapseWidth) {
207
- // isShow.value = false
236
+ // currentModelValue.value = false
208
237
  // }
209
238
  // }
210
239
 
@@ -222,7 +251,7 @@ export default {
222
251
 
223
252
  return {
224
253
  // 是否显示
225
- isShow,
254
+ currentModelValue,
226
255
  // 当前宽度
227
256
  currentWidth,
228
257
 
@@ -0,0 +1,23 @@
1
+ <template>
2
+ <div class="q-pa-lg flex flex-center absolute-full">
3
+ {{emptyDescription || '发生未知错误'}}
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+
10
+ /**
11
+ * 标识
12
+ */
13
+ name: 'NEmpty',
14
+
15
+ /**
16
+ * 声明属性
17
+ */
18
+ props: {
19
+ // 空状态描述
20
+ emptyDescription: String,
21
+ },
22
+ }
23
+ </script>
@@ -97,91 +97,22 @@
97
97
  </q-popup-proxy>
98
98
  </q-field>
99
99
 
100
- <q-dialog v-model="showDialog">
101
- <q-card>
102
- 123123123
103
- <!--<q-table-->
104
- <!-- ref="tableRef"-->
105
- <!-- class="n-table"-->
106
- <!-- style="min-width:500px;max-width:90vw;height: 300px;"-->
107
- <!-- v-model:pagination="tablePagination"-->
108
- <!-- v-model:selected="tableSelected"-->
109
- <!-- :row-key="tableRowKey"-->
110
- <!-- :rows="tableRows"-->
111
- <!-- :columns="tableColumns"-->
112
- <!-- :selection="tableSelection"-->
113
- <!-- :loading="tableLoading"-->
114
- <!-- :rows-per-page-options="tableRowsPerPageOptions"-->
115
- <!-- @row-click="tableRowClick"-->
116
- <!-- @row-dblclick="tableRowDblclick"-->
117
- <!-- @request="tableRequest"-->
118
- <!-- flat-->
119
- <!-- virtual-scroll-->
120
- <!-- dense-->
121
- <!--&gt;-->
122
- <!-- &lt;!&ndash; 图片 &ndash;&gt;-->
123
- <!-- <template-->
124
- <!-- v-for="imgName in tableImgNames"-->
125
- <!-- v-slot:[`body-cell-${imgName}`]="props"-->
126
- <!-- >-->
127
- <!-- <q-td :props="props">-->
128
- <!-- &lt;!&ndash; 缩略图 &ndash;&gt;-->
129
- <!-- <n-thumbnail-->
130
- <!-- :src="props.row[imgName]"-->
131
- <!-- preview-->
132
- <!-- />-->
133
- <!-- </q-td>-->
134
- <!-- </template>-->
135
-
136
- <!-- &lt;!&ndash; 插槽 &ndash;&gt;-->
137
- <!-- <template-->
138
- <!-- v-for="slotName in slotNames"-->
139
- <!-- v-slot:[slotName]="props"-->
140
- <!-- >-->
141
- <!-- <q-td :props="props">-->
142
- <!-- <slot-->
143
- <!-- :name="slotName"-->
144
- <!-- v-bind="props"-->
145
- <!-- />-->
146
- <!-- </q-td>-->
147
- <!-- </template>-->
148
-
149
- <!-- &lt;!&ndash; 合计 &ndash;&gt;-->
150
- <!-- &lt;!&ndash;<template v-slot:bottom-row="props" v-if="tableSummary">&ndash;&gt;-->
151
- <!-- &lt;!&ndash; <n-table-summary&ndash;&gt;-->
152
- <!-- &lt;!&ndash; :props="props"&ndash;&gt;-->
153
- <!-- &lt;!&ndash; :data="tableSummary"&ndash;&gt;-->
154
- <!-- &lt;!&ndash; :selection="tableSelection"&ndash;&gt;-->
155
- <!-- &lt;!&ndash; />&ndash;&gt;-->
156
- <!-- &lt;!&ndash;</template>&ndash;&gt;-->
157
-
158
- <!-- &lt;!&ndash; 翻页 &ndash;&gt;-->
159
- <!-- <template v-slot:pagination="props">-->
160
- <!-- <n-table-pagination-->
161
- <!-- :props="props"-->
162
- <!-- :table-refresh="tableRefresh"-->
163
- <!-- />-->
164
- <!-- </template>-->
165
- <!--</q-table>-->
166
- <!--<q-card-section>-->
167
- <!-- <div class="text-h6">Alert</div>-->
168
- <!--</q-card-section>-->
169
-
170
- <!--<q-card-section class="q-pt-none">-->
171
- <!-- Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum repellendus sit voluptate voluptas eveniet porro. Rerum blanditiis perferendis totam, ea at omnis vel numquam exercitationem aut, natus minima, porro labore.-->
172
- <!--</q-card-section>-->
173
-
174
- <!--<q-card-actions align="right">-->
175
- <!-- <q-btn flat label="OK" color="primary" v-close-popup />-->
176
- <!--</q-card-actions>-->
177
- </q-card>
178
- </q-dialog>
100
+ <n-dialog
101
+ title="选择商品"
102
+ v-model="showDialog"
103
+ >
104
+ <q-page>
105
+ <n-table
106
+ page-status
107
+ @load="onPopupShow"
108
+ />
109
+ </q-page>
110
+ </n-dialog>
179
111
  </template>
180
112
 
181
113
  <script>
182
- import { ref, reactive, computed, watch, nextTick, onMounted } from 'vue'
183
- import { date as quasarDate } from 'quasar'
184
- import NDialog from "../dialog";
114
+ import { ref, reactive, computed, provide, watch, nextTick, onMounted } from 'vue'
115
+ import { NFieldTableKey } from '../../utils/symbols'
185
116
 
186
117
  export default {
187
118
 
@@ -189,7 +120,7 @@ export default {
189
120
  * 标识
190
121
  */
191
122
  name: 'NFieldTable',
192
- components: {NDialog},
123
+
193
124
  /**
194
125
  * 声明属性
195
126
  */
@@ -267,10 +198,18 @@ export default {
267
198
  rowKey: props.rowKey,
268
199
  // 选择类型, 可选值 single multiple none
269
200
  selection: props.multiple ? 'multiple' : 'none',
270
- // 关闭宫格
271
- showGrid: false,
272
- // 关闭可见列
273
- showVisibleColumns: false,
201
+ // // 关闭宫格
202
+ // showGrid: false,
203
+ // // 关闭可见列
204
+ // showVisibleColumns: false,
205
+ })
206
+
207
+ // ==========【注入】============================================================================================
208
+
209
+ // 向后代注入数据
210
+ provide(NFieldTableKey, {
211
+ // 表格实例
212
+ $table,
274
213
  })
275
214
 
276
215
  // ==========【计算属性】=========================================================================================
@@ -285,6 +224,25 @@ export default {
285
224
  return []
286
225
  })
287
226
 
227
+ /**
228
+ * 获取表格列数据
229
+ */
230
+ // const tableColumns = computed(function () {
231
+ //
232
+ // // 获取原始表格列数据
233
+ // const rawTableColumns = props.route
234
+ // // 如果有路由组件路径
235
+ // ? utils.$table.config(props.route, 'columns')
236
+ // // 否则为自定义表格列数据
237
+ // : props.columns
238
+ //
239
+ // // 如果有原始表格列数据
240
+ // return utils.isValidArray(rawTableColumns)
241
+ // // 克隆原始表格列数据
242
+ // ? _.cloneDeep(rawTableColumns)
243
+ // : []
244
+ // })
245
+
288
246
  // ==========【监听数据】=========================================================================================
289
247
 
290
248
  /**
@@ -301,40 +259,54 @@ export default {
301
259
  */
302
260
  function getTableColumns() {
303
261
 
304
- const columns = []
305
-
306
262
  // 获取原始表格列数据
307
- let rawTableColumns = props.route
263
+ const rawTableColumns = props.route
308
264
  // 如果有路由组件路径
309
265
  ? utils.$table.config(props.route, 'columns')
310
266
  // 否则为自定义表格列数据
311
267
  : props.columns
312
268
 
313
269
  // 如果有原始表格列数据
314
- if (utils.isValidArray(rawTableColumns)) {
315
-
270
+ return utils.isValidArray(rawTableColumns)
316
271
  // 克隆原始表格列数据
317
- rawTableColumns = _.cloneDeep(rawTableColumns)
318
-
319
- // 快捷表格显示的属性名称数组
320
- utils.forEach(props.showKeys, function (key) {
321
- for (const item of rawTableColumns) {
322
- if (item.name === key) {
323
- // 删除搜索字段
324
- if (_.has(item, 'search')) {
325
- delete item.search
326
- }
327
- // 删除可见字段
328
- if (_.has(item, 'visible')) {
329
- delete item.visible
330
- }
331
- columns.push(item)
332
- }
333
- }
334
- })
335
- }
336
-
337
- return columns
272
+ ? _.cloneDeep(rawTableColumns)
273
+ // 否则为空
274
+ : []
275
+
276
+ // const columns = []
277
+ //
278
+ // // 获取原始表格列数据
279
+ // let rawTableColumns = props.route
280
+ // // 如果有路由组件路径
281
+ // ? utils.$table.config(props.route, 'columns')
282
+ // // 否则为自定义表格列数据
283
+ // : props.columns
284
+ //
285
+ // // 如果有原始表格列数据
286
+ // if (utils.isValidArray(rawTableColumns)) {
287
+ //
288
+ // // 克隆原始表格列数据
289
+ // rawTableColumns = _.cloneDeep(rawTableColumns)
290
+ //
291
+ // // 快捷表格显示的属性名称数组
292
+ // utils.forEach(props.showKeys, function (key) {
293
+ // for (const item of rawTableColumns) {
294
+ // if (item.name === key) {
295
+ // // 删除搜索字段
296
+ // if (_.has(item, 'search')) {
297
+ // delete item.search
298
+ // }
299
+ // // 删除可见字段
300
+ // if (_.has(item, 'visible')) {
301
+ // delete item.visible
302
+ // }
303
+ // columns.push(item)
304
+ // }
305
+ // }
306
+ // })
307
+ // }
308
+ //
309
+ // return columns
338
310
  }
339
311
 
340
312
  /**
@@ -394,9 +366,7 @@ export default {
394
366
  * 显示对话框
395
367
  */
396
368
  function onDialog() {
397
-
398
369
  showDialog.value = true
399
- console.log('ssss')
400
370
  }
401
371
 
402
372
  // ==========【生命周期】=========================================================================================
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <q-page
3
+ v-bind="$attrs"
4
+ >
5
+ <!-- 空数据 -->
6
+ <n-empty
7
+ :empty-description="emptyDescription"
8
+ v-if="pageStatus === false"
9
+ />
10
+
11
+ <!-- 插槽 -->
12
+ <slot v-else-if="pageStatus === true" />
13
+
14
+ <!-- 加载 -->
15
+ <q-inner-loading
16
+ :showing="pageLoading"
17
+ />
18
+ </q-page>
19
+ </template>
20
+
21
+ <script>
22
+ import { inject } from 'vue'
23
+ import { NPowerKey } from '../../utils/symbols'
24
+
25
+ export default {
26
+
27
+ /**
28
+ * 标识
29
+ */
30
+ name: 'NPowerPage',
31
+
32
+ /**
33
+ * 组合式
34
+ */
35
+ setup() {
36
+ // ==========【数据】============================================================================================
37
+
38
+ // 获取注入权限数据
39
+ const $power = inject(NPowerKey)
40
+
41
+ // ==========【返回】============================================================================================
42
+ return {
43
+ ...$power,
44
+ }
45
+ },
46
+ }
47
+ </script>