@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.
- package/components/field-table/index.vue +31 -3
- package/package.json +1 -1
- package/sass/index.scss +0 -1
- package/utils/getData.js +88 -73
- package/sass/quasar/dialog.scss +0 -7
|
@@ -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
|
-
|
|
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
package/sass/index.scss
CHANGED
package/utils/getData.js
CHANGED
|
@@ -1,73 +1,88 @@
|
|
|
1
|
-
import { isRef } from 'vue'
|
|
2
|
-
|
|
3
|
-
import $
|
|
4
|
-
import $
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import $
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
}
|