@netang/quasar 0.1.74 → 0.1.76

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.
@@ -87,6 +87,14 @@
87
87
  />
88
88
  </template>
89
89
 
90
+ <!-- 默认插槽 -->
91
+ <template
92
+ v-for="slotName in slotNames.normal"
93
+ v-slot:[slotName]
94
+ >
95
+ <slot :name="slotName" />
96
+ </template>
97
+
90
98
  <!-- 弹出层代理 -->
91
99
  <q-popup-proxy
92
100
  ref="popupRef"
@@ -141,9 +149,9 @@
141
149
  </n-data>
142
150
  </template>
143
151
 
144
- <!-- 插槽 -->
152
+ <!-- 表格插槽 -->
145
153
  <template
146
- v-for="slotName in slotNames"
154
+ v-for="slotName in slotNames.table"
147
155
  v-slot:[slotName]="props"
148
156
  >
149
157
  <q-td :props="props">
@@ -333,7 +341,27 @@ export default {
333
341
  * 插槽标识
334
342
  */
335
343
  const slotNames = computed(function() {
336
- return $n_isValidObject(slots) ? Object.keys(slots) : []
344
+
345
+ const table = []
346
+ const normal = []
347
+
348
+ // 如果有插槽
349
+ if ($n_isValidObject(slots)) {
350
+ for (const key in slots) {
351
+ if (key !== 'append' && key !== 'control') {
352
+ if (key.startsWith('table-')) {
353
+ table.push(key.replace('table-', ''))
354
+ } else {
355
+ normal.push(key)
356
+ }
357
+ }
358
+ }
359
+ }
360
+
361
+ return {
362
+ table,
363
+ normal,
364
+ }
337
365
  })
338
366
 
339
367
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.1.74",
3
+ "version": "0.1.76",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/sass/index.scss CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  @import "quasar/common";
4
4
  @import "quasar/btn";
5
- @import "quasar/dialog";
6
5
  @import "quasar/drawer";
7
6
  @import "quasar/field";
8
7
  @import "quasar/loading";
package/utils/getData.js CHANGED
@@ -1,73 +1,88 @@
1
- import { isRef } from 'vue'
2
-
3
- import $n_isNil from 'lodash/isNil'
4
- import $n_map from 'lodash/map'
5
-
6
- import $n_http from '@netang/utils/http'
7
-
8
- import $n_config from './config'
9
-
10
- /**
11
- * 获取公共数据
12
- * @param {String|Array} url 请求地址
13
- * @param pageStatus 页面状态
14
- * @param emptyDescription 空状态描述
15
- * @param refValue 请求成功后设置值
16
- * @returns
17
- */
18
- export default async function getData(url, pageStatus = null, emptyDescription = null, refValue = null) {
19
-
20
- const warn = $n_isNil(pageStatus) || ! isRef(pageStatus)
21
-
22
- // 如果是数组, 说明需要同时请求多个地址
23
- // --------------------------------------------------
24
- if (Array.isArray(url)) {
25
-
26
- const result = await $n_http($n_map(url, function (item) {
27
- return {
28
- url: $n_config('apiDataUrl') + item,
29
- warn,
30
- }
31
- }))
32
-
33
- const res = []
34
-
35
- for (const { status, data } of result) {
36
- if (! status) {
37
- if (! warn) {
38
- pageStatus.value = false
39
- }
40
- if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
41
- emptyDescription.value = data.msg
42
- }
43
- return false
44
- }
45
- res.push(data)
46
- }
47
-
48
- return res
49
- }
50
-
51
- // 单个请求
52
- // --------------------------------------------------
53
- const { status, data } = await $n_http({
54
- url: $n_config('apiDataUrl') + url,
55
- warn,
56
- })
57
- if (! status) {
58
- if (! warn) {
59
- pageStatus.value = false
60
- }
61
- if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
62
- emptyDescription.value = data.msg
63
- }
64
- return false
65
- }
66
-
67
- // 直接设置 value
68
- if (! $n_isNil(refValue) && isRef(refValue)) {
69
- refValue.value = data
70
- }
71
-
72
- return data
73
- }
1
+ import { isRef } from 'vue'
2
+
3
+ import $n_has from 'lodash/has'
4
+ import $n_isNil from 'lodash/isNil'
5
+ import $n_map from 'lodash/map'
6
+
7
+ import $n_http from '@netang/utils/http'
8
+ import $n_isValidObject from '@netang/utils/isValidObject'
9
+
10
+ import $n_config from './config'
11
+
12
+ /**
13
+ * 获取公共数据
14
+ * @param {String|Array} url 请求地址
15
+ * @param pageStatus 页面状态
16
+ * @param emptyDescription 空状态描述
17
+ * @param refValue 请求成功后设置值
18
+ * @returns
19
+ */
20
+ export default async function getData(url, pageStatus = null, emptyDescription = null, refValue = null) {
21
+
22
+ const warn = $n_isNil(pageStatus) || ! isRef(pageStatus)
23
+
24
+ // 获取单个请求配置
25
+ function getSingleHttpOptions(opt) {
26
+
27
+ // 如果是对象
28
+ if ($n_isValidObject(opt)) {
29
+ opt.url = $n_config('apiDataUrl') + opt.url
30
+ if (! $n_has(opt, 'warn')) {
31
+ opt.warn = warn
32
+ }
33
+ return opt
34
+ }
35
+
36
+ // 否则为字符串
37
+ return {
38
+ url: $n_config('apiDataUrl') + opt,
39
+ warn,
40
+ }
41
+ }
42
+
43
+ // 如果是数组, 说明需要同时请求多个地址
44
+ // --------------------------------------------------
45
+ if (Array.isArray(url)) {
46
+
47
+ const result = await $n_http($n_map(url, function (item) {
48
+ return getSingleHttpOptions(item)
49
+ }))
50
+
51
+ const res = []
52
+
53
+ for (const { status, data } of result) {
54
+ if (! status) {
55
+ if (! warn) {
56
+ pageStatus.value = false
57
+ }
58
+ if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
59
+ emptyDescription.value = data.msg
60
+ }
61
+ return false
62
+ }
63
+ res.push(data)
64
+ }
65
+
66
+ return res
67
+ }
68
+
69
+ // 单个请求
70
+ // --------------------------------------------------
71
+ const { status, data } = await $n_http(getSingleHttpOptions(url))
72
+ if (! status) {
73
+ if (! warn) {
74
+ pageStatus.value = false
75
+ }
76
+ if (! $n_isNil(emptyDescription) && isRef(emptyDescription)) {
77
+ emptyDescription.value = data.msg
78
+ }
79
+ return false
80
+ }
81
+
82
+ // 直接设置 value
83
+ if (! $n_isNil(refValue) && isRef(refValue)) {
84
+ refValue.value = data
85
+ }
86
+
87
+ return data
88
+ }
@@ -1,7 +0,0 @@
1
- /**
2
- * 对话框
3
- */
4
- .n-dialog {
5
-
6
- }
7
-