@netang/quasar 0.0.30 → 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 +112 -0
- package/components/table/index.vue +22 -3
- package/components/table-column-fixed/index.vue +2 -1
- package/components/toolbar/index.vue +2 -0
- package/package.json +1 -1
- package/sass/quasar/table.scss +10 -0
- package/utils/$table.js +28 -5
- package/utils/price.js +13 -13
- 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>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 拆分器 -->
|
|
3
|
+
<q-splitter
|
|
4
|
+
v-model="currentValue"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
v-if="$slots.before && $slots.after"
|
|
7
|
+
>
|
|
8
|
+
<!-- 插槽 -->
|
|
9
|
+
<template
|
|
10
|
+
v-for="slotName in slotNames"
|
|
11
|
+
v-slot:[slotName]
|
|
12
|
+
>
|
|
13
|
+
<slot :name="slotName" />
|
|
14
|
+
</template>
|
|
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
|
+
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
import { computed, ref, watch } from 'vue'
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 标识
|
|
38
|
+
*/
|
|
39
|
+
name: 'NSplitter',
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 声明属性
|
|
43
|
+
*/
|
|
44
|
+
props: {
|
|
45
|
+
// 值
|
|
46
|
+
modelValue: {
|
|
47
|
+
type: Number,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 声明事件
|
|
54
|
+
*/
|
|
55
|
+
emits: [
|
|
56
|
+
'update:modelValue',
|
|
57
|
+
],
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 组合式
|
|
61
|
+
*/
|
|
62
|
+
setup(props, { emit, slots }) {
|
|
63
|
+
|
|
64
|
+
// ==========【计算属性】=========================================================================================
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 插槽标识
|
|
68
|
+
*/
|
|
69
|
+
const slotNames = computed(function() {
|
|
70
|
+
return utils.isValidObject(slots) ? Object.keys(slots) : []
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
// ==========【数据】============================================================================================
|
|
74
|
+
|
|
75
|
+
// 当前值
|
|
76
|
+
const currentValue = ref(props.modelValue)
|
|
77
|
+
|
|
78
|
+
// ==========【监听数据】=========================================================================================
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 监听声明值
|
|
82
|
+
*/
|
|
83
|
+
watch(()=>props.modelValue, function (val) {
|
|
84
|
+
|
|
85
|
+
// 如果值有变化
|
|
86
|
+
if (val !== currentValue.value) {
|
|
87
|
+
|
|
88
|
+
// 更新当前值
|
|
89
|
+
currentValue.value = val
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 监听值
|
|
95
|
+
*/
|
|
96
|
+
watch(currentValue, function (val) {
|
|
97
|
+
|
|
98
|
+
// 更新值
|
|
99
|
+
emit('update:modelValue', val)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// ==========【返回】=============================================================================================
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
// 插槽标识
|
|
106
|
+
slotNames,
|
|
107
|
+
// 当前值
|
|
108
|
+
currentValue,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
container
|
|
9
9
|
>
|
|
10
10
|
<!-- 头部 -->
|
|
11
|
-
<n-toolbar
|
|
11
|
+
<n-toolbar
|
|
12
|
+
:dense="dense"
|
|
13
|
+
header
|
|
14
|
+
/>
|
|
12
15
|
|
|
13
16
|
<!-- 左侧分类 -->
|
|
14
17
|
<n-drawer
|
|
15
18
|
:model-value="true"
|
|
16
|
-
side="
|
|
19
|
+
:side="treeSide"
|
|
17
20
|
:width="200"
|
|
18
21
|
:min-width="150"
|
|
19
22
|
bordered
|
|
@@ -75,6 +78,7 @@
|
|
|
75
78
|
@request="tableRequest"
|
|
76
79
|
flat
|
|
77
80
|
virtual-scroll
|
|
81
|
+
:dense="dense"
|
|
78
82
|
>
|
|
79
83
|
<!-- 图片 -->
|
|
80
84
|
<template
|
|
@@ -130,7 +134,7 @@
|
|
|
130
134
|
<!-- 右侧搜索 -->
|
|
131
135
|
<n-drawer
|
|
132
136
|
:model-value="true"
|
|
133
|
-
side="
|
|
137
|
+
:side="searchSide"
|
|
134
138
|
:min-width="320"
|
|
135
139
|
bordered
|
|
136
140
|
drag
|
|
@@ -187,6 +191,21 @@ export default {
|
|
|
187
191
|
treeFilter: Boolean,
|
|
188
192
|
// 不显示搜索
|
|
189
193
|
noSearch: Boolean,
|
|
194
|
+
// 树位置
|
|
195
|
+
treeSide: {
|
|
196
|
+
type: String,
|
|
197
|
+
default: 'left',
|
|
198
|
+
},
|
|
199
|
+
// 搜索位置
|
|
200
|
+
searchSide: {
|
|
201
|
+
type: String,
|
|
202
|
+
default: 'right',
|
|
203
|
+
},
|
|
204
|
+
// 紧凑模式
|
|
205
|
+
dense: {
|
|
206
|
+
type: Boolean,
|
|
207
|
+
default: true,
|
|
208
|
+
},
|
|
190
209
|
},
|
|
191
210
|
|
|
192
211
|
/**
|
package/package.json
CHANGED
package/sass/quasar/table.scss
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/price.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 换算金额
|
|
3
|
-
*/
|
|
4
|
-
utils.price = function(value, params) {
|
|
5
|
-
return utils.decimal(value, Object.assign({
|
|
6
|
-
// 最小值
|
|
7
|
-
min: 0,
|
|
8
|
-
// 小数点位数
|
|
9
|
-
decimalLength: 2,
|
|
10
|
-
// 是否开启人民币分转元(如值 189 -> 1.89)
|
|
11
|
-
centToYuan: utils.config('priceCent') === true,
|
|
12
|
-
}, params))
|
|
13
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 换算金额
|
|
3
|
+
*/
|
|
4
|
+
utils.price = function(value, params) {
|
|
5
|
+
return utils.decimal(value, Object.assign({
|
|
6
|
+
// 最小值
|
|
7
|
+
min: 0,
|
|
8
|
+
// 小数点位数
|
|
9
|
+
decimalLength: 2,
|
|
10
|
+
// 是否开启人民币分转元(如值 189 -> 1.89)
|
|
11
|
+
centToYuan: utils.config('priceCent') === true,
|
|
12
|
+
}, params))
|
|
13
|
+
}
|
package/utils/symbols.js
CHANGED