@netang/quasar 0.0.31 → 0.0.32
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/render/index.vue +106 -0
- package/components/splitter/index.vue +20 -36
- package/package.json +1 -1
- package/utils/$table.js +28 -5
- package/utils/symbols.js +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot
|
|
3
|
+
:query="query"
|
|
4
|
+
v-bind="props"
|
|
5
|
+
v-if="$slots.default"
|
|
6
|
+
/>
|
|
7
|
+
<component
|
|
8
|
+
:is="comp"
|
|
9
|
+
:query="query"
|
|
10
|
+
v-bind="props"
|
|
11
|
+
v-else
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { computed, defineAsyncComponent, provide } from 'vue'
|
|
17
|
+
|
|
18
|
+
import routers from '@/router/routers'
|
|
19
|
+
import components from './components'
|
|
20
|
+
|
|
21
|
+
import { NRenderKey } from '../../utils/symbols'
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 标识
|
|
27
|
+
*/
|
|
28
|
+
name: 'NRender',
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 声明属性
|
|
32
|
+
*/
|
|
33
|
+
props: {
|
|
34
|
+
// 组件标识
|
|
35
|
+
name: String,
|
|
36
|
+
// 组件路径
|
|
37
|
+
path: String,
|
|
38
|
+
// 参数
|
|
39
|
+
query: Object,
|
|
40
|
+
// 组件传参
|
|
41
|
+
props: Object,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 组合式
|
|
46
|
+
*/
|
|
47
|
+
setup(props) {
|
|
48
|
+
|
|
49
|
+
// ==========【计算属性】=========================================================================================
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 获取当前组件
|
|
53
|
+
*/
|
|
54
|
+
const comp = computed(function () {
|
|
55
|
+
|
|
56
|
+
// 组件
|
|
57
|
+
let comp
|
|
58
|
+
|
|
59
|
+
// 如果是路由路径
|
|
60
|
+
if (props.path) {
|
|
61
|
+
// 获取路由组件
|
|
62
|
+
comp = _.get(routers, `${utils.slash(props.path, 'start', false)}.component`)
|
|
63
|
+
|
|
64
|
+
// 如果有组件标识
|
|
65
|
+
} else if (props.name && _.has(components, props.name)) {
|
|
66
|
+
// 获取自定义组件
|
|
67
|
+
comp = components[props.name]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 如果没有组件
|
|
71
|
+
if (! comp) {
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 如果是方法, 则说明是异步组件
|
|
76
|
+
if (_.isFunction(comp)) {
|
|
77
|
+
return defineAsyncComponent(comp)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 返回组件
|
|
81
|
+
return comp
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// ==========【注入】============================================================================================
|
|
85
|
+
|
|
86
|
+
// 向后代注入数据
|
|
87
|
+
provide(NRenderKey, {
|
|
88
|
+
// 组件标识
|
|
89
|
+
name: props.name,
|
|
90
|
+
// 路由路径
|
|
91
|
+
path: utils.isValidString(props.path) ? utils.slash(props.path, 'start', true) : '',
|
|
92
|
+
// 参数
|
|
93
|
+
query: utils.isValidObject(props.query) ? props.query : {},
|
|
94
|
+
// 组件传参
|
|
95
|
+
props: props.props,
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// ==========【返回】=============================================================================================
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
// 组件
|
|
102
|
+
comp,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
</script>
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- 默认插槽 -->
|
|
3
|
-
<slot
|
|
4
|
-
:name="currentSlot.defaultName"
|
|
5
|
-
v-if="!! currentSlot.defaultName"
|
|
6
|
-
/>
|
|
7
|
-
|
|
8
2
|
<!-- 拆分器 -->
|
|
9
3
|
<q-splitter
|
|
10
4
|
v-model="currentValue"
|
|
11
5
|
v-bind="$attrs"
|
|
12
|
-
v-
|
|
6
|
+
v-if="$slots.before && $slots.after"
|
|
13
7
|
>
|
|
14
8
|
<!-- 插槽 -->
|
|
15
9
|
<template
|
|
16
|
-
v-for="slotName in
|
|
10
|
+
v-for="slotName in slotNames"
|
|
17
11
|
v-slot:[slotName]
|
|
18
12
|
>
|
|
19
13
|
<slot :name="slotName" />
|
|
20
14
|
</template>
|
|
21
15
|
</q-splitter>
|
|
16
|
+
|
|
17
|
+
<!-- before 插槽 -->
|
|
18
|
+
<slot
|
|
19
|
+
name="before"
|
|
20
|
+
v-else-if="$slots.before"
|
|
21
|
+
/>
|
|
22
|
+
|
|
23
|
+
<!-- after 插槽 -->
|
|
24
|
+
<slot
|
|
25
|
+
name="after"
|
|
26
|
+
v-else-if="$slots.after"
|
|
27
|
+
/>
|
|
28
|
+
|
|
22
29
|
</template>
|
|
23
30
|
|
|
24
31
|
<script>
|
|
@@ -57,33 +64,10 @@ export default {
|
|
|
57
64
|
// ==========【计算属性】=========================================================================================
|
|
58
65
|
|
|
59
66
|
/**
|
|
60
|
-
*
|
|
67
|
+
* 插槽标识
|
|
61
68
|
*/
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
let keys = []
|
|
65
|
-
let defaultName = ''
|
|
66
|
-
|
|
67
|
-
if (utils.isValidObject(slots)) {
|
|
68
|
-
|
|
69
|
-
keys = Object.keys(slots)
|
|
70
|
-
|
|
71
|
-
const hasBefore = _.has(slots, 'before')
|
|
72
|
-
const hasAfter = _.has(slots, 'after')
|
|
73
|
-
|
|
74
|
-
if (hasBefore) {
|
|
75
|
-
if (! hasAfter) {
|
|
76
|
-
defaultName = 'before'
|
|
77
|
-
}
|
|
78
|
-
} else if (hasAfter && ! hasBefore) {
|
|
79
|
-
defaultName = 'after'
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
keys,
|
|
85
|
-
defaultName,
|
|
86
|
-
}
|
|
69
|
+
const slotNames = computed(function() {
|
|
70
|
+
return utils.isValidObject(slots) ? Object.keys(slots) : []
|
|
87
71
|
})
|
|
88
72
|
|
|
89
73
|
// ==========【数据】============================================================================================
|
|
@@ -118,8 +102,8 @@ export default {
|
|
|
118
102
|
// ==========【返回】=============================================================================================
|
|
119
103
|
|
|
120
104
|
return {
|
|
121
|
-
//
|
|
122
|
-
|
|
105
|
+
// 插槽标识
|
|
106
|
+
slotNames,
|
|
123
107
|
// 当前值
|
|
124
108
|
currentValue,
|
|
125
109
|
}
|
package/package.json
CHANGED
package/utils/$table.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
setItemValue,
|
|
10
10
|
} from './$search'
|
|
11
11
|
|
|
12
|
-
import { NPowerKey, NTableKey
|
|
12
|
+
import { NPowerKey, NTableKey } from './symbols'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* 创建表格
|
|
@@ -67,8 +67,6 @@ function create(params) {
|
|
|
67
67
|
request: null,
|
|
68
68
|
// 格式化单条数据
|
|
69
69
|
formatRow: null,
|
|
70
|
-
// 格式化参数
|
|
71
|
-
// formatQuery: null,
|
|
72
70
|
// http 设置
|
|
73
71
|
httpSettings: {},
|
|
74
72
|
// 是否开启初始搜素
|
|
@@ -85,6 +83,11 @@ function create(params) {
|
|
|
85
83
|
cache: true,
|
|
86
84
|
// 刷新后清空已选数据
|
|
87
85
|
refreshResetSelected: true,
|
|
86
|
+
|
|
87
|
+
// 单击表格行事件
|
|
88
|
+
rowClick: null,
|
|
89
|
+
// 双击表格行事件
|
|
90
|
+
rowDblClick: null,
|
|
88
91
|
}, params)
|
|
89
92
|
|
|
90
93
|
// 获取权限注入
|
|
@@ -732,7 +735,7 @@ function create(params) {
|
|
|
732
735
|
/**
|
|
733
736
|
* 单击表格行
|
|
734
737
|
*/
|
|
735
|
-
function
|
|
738
|
+
function _tableRowClick(e, row) {
|
|
736
739
|
|
|
737
740
|
// 如果选择类型为无
|
|
738
741
|
if (o.selection === 'none') {
|
|
@@ -763,11 +766,21 @@ function create(params) {
|
|
|
763
766
|
tableSelected.value.splice(itemIndex, 1)
|
|
764
767
|
}
|
|
765
768
|
}
|
|
769
|
+
function tableRowClick(...e) {
|
|
770
|
+
|
|
771
|
+
// 单击表格行
|
|
772
|
+
_tableRowClick(...e)
|
|
773
|
+
|
|
774
|
+
// 如果有自定义单击事件
|
|
775
|
+
if (_.isFunction(o.rowClick)) {
|
|
776
|
+
o.rowClick(...e)
|
|
777
|
+
}
|
|
778
|
+
}
|
|
766
779
|
|
|
767
780
|
/**
|
|
768
781
|
* 双击表格行
|
|
769
782
|
*/
|
|
770
|
-
function
|
|
783
|
+
function _tableRowDblclick(e, row) {
|
|
771
784
|
|
|
772
785
|
// 如果选择类型为无
|
|
773
786
|
if (o.selection === 'none') {
|
|
@@ -784,6 +797,16 @@ function create(params) {
|
|
|
784
797
|
$power.powerBtnClick(tableDbClickPowerBtn.value, [ row ])
|
|
785
798
|
}
|
|
786
799
|
}
|
|
800
|
+
function tableRowDblclick(...e) {
|
|
801
|
+
|
|
802
|
+
// 双击表格行
|
|
803
|
+
_tableRowDblclick(...e)
|
|
804
|
+
|
|
805
|
+
// 如果有自定义双击表格行事件
|
|
806
|
+
if (_.isFunction(o.tableRowDblclick)) {
|
|
807
|
+
o.tableRowDblclick(...e)
|
|
808
|
+
}
|
|
809
|
+
}
|
|
787
810
|
|
|
788
811
|
/**
|
|
789
812
|
* 设置表格搜索参数
|
package/utils/symbols.js
CHANGED