dolphin-weex-ui 0.2.13 → 0.2.15
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/CHANGELOG.md +21 -0
- package/dist/index.native.js +3812 -1591
- package/dist/index.native.js.map +1 -1
- package/dist/index.web.js +4387 -1725
- package/dist/index.web.js.map +1 -1
- package/index.js +22 -0
- package/package.json +1 -1
- package/packages/dof-board/index.js +1 -0
- package/packages/dof-board/index.vue +63 -0
- package/packages/dof-card/index.js +1 -1
- package/packages/dof-card/index.vue +140 -411
- package/packages/dof-card-group/index.js +1 -0
- package/packages/dof-card-group/index.vue +18 -0
- package/packages/dof-card-item/index.js +1 -0
- package/packages/dof-card-item/index.vue +29 -0
- package/packages/dof-col/index.js +1 -0
- package/packages/dof-col/index.vue +23 -0
- package/packages/dof-icon-button/index.js +1 -0
- package/packages/dof-icon-button/index.vue +88 -0
- package/packages/dof-progress/index.vue +53 -56
- package/packages/dof-row/index.js +1 -0
- package/packages/dof-row/index.vue +21 -0
- package/packages/dof-slider/index.js +1 -0
- package/packages/dof-slider/index.vue +256 -0
- package/packages/dof-slider-scale/index.js +1 -0
- package/packages/dof-slider-scale/index.vue +52 -0
- package/packages/dof-step-action/index.js +1 -0
- package/packages/dof-step-action/index.vue +113 -0
- package/packages/dof-switch/index.vue +45 -7
- package/packages/dof-tag/index.js +1 -1
- package/packages/dof-tag/index.vue +60 -127
- package/packages/dof-tag-group/index.js +1 -0
- package/packages/dof-tag-group/index.vue +19 -0
- package/packages/dof-taged/index.js +1 -0
- package/packages/dof-taged/index.vue +140 -0
- package/packages/utils/direction.js +7 -0
- package/packages/utils/dom.js +11 -0
- package/packages/utils/math-extension.js +3 -0
- package/packages/utils/mix-child.js +57 -0
- package/packages/utils/mix-parent.js +14 -0
- package/packages/utils/mix-selectable-child.js +69 -0
- package/packages/utils/mix-selectable-parent.js +29 -0
- package/packages/utils/touch.js +76 -0
- package/packages/utils/transition.js +130 -0
- package/packages/utils/vue-extension.js +32 -0
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
<div class="dof-switch-wrapper">
|
|
3
|
+
<midea-apng-view
|
|
4
|
+
:src="loadingSrc"
|
|
5
|
+
class="dof-switch-loading"
|
|
6
|
+
resize="contain"
|
|
7
|
+
v-if="loading"
|
|
8
|
+
quality="original"
|
|
9
|
+
:auto="true"
|
|
10
|
+
:loop="true"
|
|
11
|
+
></midea-apng-view>
|
|
12
|
+
<div
|
|
13
|
+
v-else
|
|
14
|
+
ref="switch"
|
|
15
|
+
@click="changeHandler"
|
|
16
|
+
:class="[type === 'white' ? 'switch-white' : 'switch', checked && switchActiveClass]"
|
|
17
|
+
:style="mrSwitchStyle"
|
|
18
|
+
>
|
|
19
|
+
<div ref="switchDot" :style="dotStyle" :class="[type === 'white' ? 'switch-white-dot' : 'switch-dot']"></div>
|
|
20
|
+
</div>
|
|
9
21
|
</div>
|
|
10
22
|
</template>
|
|
11
23
|
|
|
12
24
|
<style scoped>
|
|
25
|
+
.dof-switch-wrapper {
|
|
26
|
+
width: 96px;
|
|
27
|
+
height: 48px;
|
|
28
|
+
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dof-switch-loading {
|
|
34
|
+
width: 32px;
|
|
35
|
+
height: 32px;
|
|
36
|
+
}
|
|
37
|
+
|
|
13
38
|
.switch {
|
|
14
39
|
width: 96px;
|
|
15
40
|
height: 48px;
|
|
@@ -117,9 +142,22 @@ module.exports = {
|
|
|
117
142
|
disabled: {
|
|
118
143
|
type: Boolean,
|
|
119
144
|
default: false
|
|
145
|
+
},
|
|
146
|
+
loading: {
|
|
147
|
+
type: Boolean,
|
|
148
|
+
default: false
|
|
149
|
+
},
|
|
150
|
+
isLightLoading: {
|
|
151
|
+
type: Boolean,
|
|
152
|
+
default: false
|
|
120
153
|
}
|
|
121
154
|
},
|
|
122
155
|
computed: {
|
|
156
|
+
loadingSrc() {
|
|
157
|
+
return this.isLightLoading
|
|
158
|
+
? 'http://dolphin-weex-dev.msmartlife.cn/static/component/loading/image/loading-white.png'
|
|
159
|
+
: 'http://dolphin-weex-dev.msmartlife.cn/static/component/loading/image/loading-gray.png'
|
|
160
|
+
},
|
|
123
161
|
switchActiveClass() {
|
|
124
162
|
const { type } = this
|
|
125
163
|
return `switch-active-${type}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './index.vue'
|
|
1
|
+
export { default } from './index.vue'
|
|
@@ -1,140 +1,73 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<text class="tag-text" :style="{color:fontColor}">{{value}}</text>
|
|
7
|
-
</div>
|
|
8
|
-
<image v-if="showImage"
|
|
9
|
-
:src="img"
|
|
10
|
-
@load="onLoad"
|
|
11
|
-
:aria-hidden="true"
|
|
12
|
-
:style="{ width: imgWidth+'px'}"
|
|
13
|
-
class="tag-image"></image>
|
|
14
|
-
<div class="tag-special tag-border"
|
|
15
|
-
:style="{borderColor:tagColor}"
|
|
16
|
-
:accessible="true"
|
|
17
|
-
:aria-label="value"
|
|
18
|
-
v-if="showSpecial">
|
|
19
|
-
<div class="tag-left" :style="{backgroundColor:tagColor}">
|
|
20
|
-
<image :src="specialIcon" class="left-image"></image>
|
|
21
|
-
</div>
|
|
22
|
-
<text class="tag-text" :style="{color:fontColor}">{{value}}</text>
|
|
23
|
-
</div>
|
|
2
|
+
<div :class="['dof-tag', isActive ? 'dof-tag--active' : 'dof-tag--normal']" @click="onClick">
|
|
3
|
+
<text :class="['dof-tag-text', isActive ? 'dof-tag-text--active' : 'dof-tag-text--normal']">
|
|
4
|
+
<slot></slot>
|
|
5
|
+
</text>
|
|
24
6
|
</div>
|
|
25
7
|
</template>
|
|
26
8
|
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
height: 24px;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
align-items: center;
|
|
32
|
-
/* hack高度不居中问题,后续版本升级去掉 */
|
|
33
|
-
padding-bottom: 2px;
|
|
34
|
-
}
|
|
9
|
+
<script>
|
|
10
|
+
import { mixSelectableChild } from '../utils//mix-selectable-child.js'
|
|
35
11
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
12
|
+
export default {
|
|
13
|
+
mixins: [mixSelectableChild('dof-tag-group')],
|
|
14
|
+
props: {
|
|
15
|
+
active: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
model: {
|
|
21
|
+
prop: 'active',
|
|
22
|
+
event: 'change'
|
|
23
|
+
},
|
|
24
|
+
computed: {
|
|
25
|
+
isActive() {
|
|
26
|
+
return this.active || this.isSelected
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
methods: {
|
|
30
|
+
onClick() {
|
|
31
|
+
this.$emit('change', !this.active)
|
|
32
|
+
if (this.parent) {
|
|
33
|
+
this.parent.triggerChange(this.value)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
41
36
|
}
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
<style scoped>
|
|
41
|
+
.dof-tag {
|
|
42
|
+
height: 72px;
|
|
43
|
+
border-radius: 36px;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
align-items: center;
|
|
46
|
+
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
.dof-tag--pad {
|
|
49
|
+
margin-right: 10px;
|
|
50
|
+
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
52
|
+
.dof-tag--normal {
|
|
53
|
+
background-color: #f2f2f2;
|
|
54
|
+
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
56
|
+
.dof-tag--active {
|
|
57
|
+
background-color: #267aff;
|
|
58
|
+
}
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
60
|
+
.dof-tag-text {
|
|
61
|
+
font-family: PingFangSC-Regular;
|
|
62
|
+
font-size: 28px;
|
|
63
|
+
font-weight: 400;
|
|
64
|
+
}
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
line-height: 22px;
|
|
72
|
-
padding-left: 6px;
|
|
73
|
-
padding-right: 6px;
|
|
74
|
-
}
|
|
75
|
-
</style>
|
|
66
|
+
.dof-tag-text--normal {
|
|
67
|
+
color: #666666;
|
|
68
|
+
}
|
|
76
69
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
type: String,
|
|
82
|
-
default: 'solid'
|
|
83
|
-
},
|
|
84
|
-
value: {
|
|
85
|
-
type: [String, Number],
|
|
86
|
-
default: '测试测试'
|
|
87
|
-
},
|
|
88
|
-
tagColor: {
|
|
89
|
-
type: String,
|
|
90
|
-
default: '#ff5000'
|
|
91
|
-
},
|
|
92
|
-
fontColor: {
|
|
93
|
-
type: String,
|
|
94
|
-
default: '#333333'
|
|
95
|
-
},
|
|
96
|
-
specialIcon: {
|
|
97
|
-
type: String,
|
|
98
|
-
default: ''
|
|
99
|
-
},
|
|
100
|
-
img: {
|
|
101
|
-
type: String,
|
|
102
|
-
default: ''
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
computed: {
|
|
106
|
-
showSolid () {
|
|
107
|
-
const { type, value } = this;
|
|
108
|
-
return type === 'solid' && value !== '';
|
|
109
|
-
},
|
|
110
|
-
showHollow () {
|
|
111
|
-
const { type, value } = this;
|
|
112
|
-
return type === 'hollow' && value !== '';
|
|
113
|
-
},
|
|
114
|
-
showSpecial () {
|
|
115
|
-
const { type, value, specialIcon } = this;
|
|
116
|
-
return type === 'special' && value !== '' && specialIcon !== '';
|
|
117
|
-
},
|
|
118
|
-
showImage () {
|
|
119
|
-
const { type, img } = this;
|
|
120
|
-
return type === 'image' && img !== '';
|
|
121
|
-
},
|
|
122
|
-
tagTextStyle () {
|
|
123
|
-
const { tagColor, showSolid } = this;
|
|
124
|
-
return showSolid ? { backgroundColor: tagColor } : { borderColor: tagColor };
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
data: () => ({
|
|
128
|
-
imgWidth: 90
|
|
129
|
-
}),
|
|
130
|
-
methods: {
|
|
131
|
-
onLoad (e) {
|
|
132
|
-
if (e.success && e.size && e.size.naturalWidth > 0) {
|
|
133
|
-
const width = e.size.naturalWidth;
|
|
134
|
-
const height = e.size.naturalHeight;
|
|
135
|
-
this.imgWidth = width * (24 / height);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
</script>
|
|
70
|
+
.dof-tag-text--active {
|
|
71
|
+
color: #ffffff;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './index.vue'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="dof-tag-group">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { mixSelectableParent } from '../utils/mix-selectable-parent.js'
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
mixins: [mixSelectableParent('dof-tag-group')]
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<style scoped>
|
|
16
|
+
.dof-tag-group {
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './index.vue';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div v-if="showSolid || showHollow"
|
|
4
|
+
:class="['tag-item','tag-border',showHollow && 'tag-hollow']"
|
|
5
|
+
:style="tagTextStyle">
|
|
6
|
+
<text class="tag-text" :style="{color:fontColor}">{{value}}</text>
|
|
7
|
+
</div>
|
|
8
|
+
<image v-if="showImage"
|
|
9
|
+
:src="img"
|
|
10
|
+
@load="onLoad"
|
|
11
|
+
:aria-hidden="true"
|
|
12
|
+
:style="{ width: imgWidth+'px'}"
|
|
13
|
+
class="tag-image"></image>
|
|
14
|
+
<div class="tag-special tag-border"
|
|
15
|
+
:style="{borderColor:tagColor}"
|
|
16
|
+
:accessible="true"
|
|
17
|
+
:aria-label="value"
|
|
18
|
+
v-if="showSpecial">
|
|
19
|
+
<div class="tag-left" :style="{backgroundColor:tagColor}">
|
|
20
|
+
<image :src="specialIcon" class="left-image"></image>
|
|
21
|
+
</div>
|
|
22
|
+
<text class="tag-text" :style="{color:fontColor}">{{value}}</text>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style scoped>
|
|
28
|
+
.tag-item {
|
|
29
|
+
height: 24px;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
align-items: center;
|
|
32
|
+
/* hack高度不居中问题,后续版本升级去掉 */
|
|
33
|
+
padding-bottom: 2px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.tag-border {
|
|
37
|
+
border-bottom-left-radius: 4px;
|
|
38
|
+
border-bottom-right-radius: 4px;
|
|
39
|
+
border-top-left-radius: 4px;
|
|
40
|
+
border-top-right-radius: 4px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.tag-hollow {
|
|
44
|
+
border-width: 1px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.tag-image {
|
|
48
|
+
height: 24px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.tag-special {
|
|
52
|
+
border-width: 1px;
|
|
53
|
+
flex-direction: row;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.left-image {
|
|
57
|
+
width: 20px;
|
|
58
|
+
height: 20px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.tag-left {
|
|
62
|
+
width: 24px;
|
|
63
|
+
height: 24px;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.tag-text {
|
|
69
|
+
font-size: 20px;
|
|
70
|
+
height: 22px;
|
|
71
|
+
line-height: 22px;
|
|
72
|
+
padding-left: 6px;
|
|
73
|
+
padding-right: 6px;
|
|
74
|
+
}
|
|
75
|
+
</style>
|
|
76
|
+
|
|
77
|
+
<script>
|
|
78
|
+
export default {
|
|
79
|
+
props: {
|
|
80
|
+
type: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: 'solid'
|
|
83
|
+
},
|
|
84
|
+
value: {
|
|
85
|
+
type: [String, Number],
|
|
86
|
+
default: '测试测试'
|
|
87
|
+
},
|
|
88
|
+
tagColor: {
|
|
89
|
+
type: String,
|
|
90
|
+
default: '#ff5000'
|
|
91
|
+
},
|
|
92
|
+
fontColor: {
|
|
93
|
+
type: String,
|
|
94
|
+
default: '#333333'
|
|
95
|
+
},
|
|
96
|
+
specialIcon: {
|
|
97
|
+
type: String,
|
|
98
|
+
default: ''
|
|
99
|
+
},
|
|
100
|
+
img: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: ''
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
computed: {
|
|
106
|
+
showSolid () {
|
|
107
|
+
const { type, value } = this;
|
|
108
|
+
return type === 'solid' && value !== '';
|
|
109
|
+
},
|
|
110
|
+
showHollow () {
|
|
111
|
+
const { type, value } = this;
|
|
112
|
+
return type === 'hollow' && value !== '';
|
|
113
|
+
},
|
|
114
|
+
showSpecial () {
|
|
115
|
+
const { type, value, specialIcon } = this;
|
|
116
|
+
return type === 'special' && value !== '' && specialIcon !== '';
|
|
117
|
+
},
|
|
118
|
+
showImage () {
|
|
119
|
+
const { type, img } = this;
|
|
120
|
+
return type === 'image' && img !== '';
|
|
121
|
+
},
|
|
122
|
+
tagTextStyle () {
|
|
123
|
+
const { tagColor, showSolid } = this;
|
|
124
|
+
return showSolid ? { backgroundColor: tagColor } : { borderColor: tagColor };
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
data: () => ({
|
|
128
|
+
imgWidth: 90
|
|
129
|
+
}),
|
|
130
|
+
methods: {
|
|
131
|
+
onLoad (e) {
|
|
132
|
+
if (e.success && e.size && e.size.naturalWidth > 0) {
|
|
133
|
+
const width = e.size.naturalWidth;
|
|
134
|
+
const height = e.size.naturalHeight;
|
|
135
|
+
this.imgWidth = width * (24 / height);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
</script>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const dom = weex.requireModule('dom')
|
|
2
|
+
|
|
3
|
+
export function getBoundingClientRect(element, func) {
|
|
4
|
+
dom.getComponentRect(element, func)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getBoundingClientRectAsync(element) {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
dom.getComponentRect(element, res => res.result && resolve(res.size))
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { sortComponent } from './vue-extension.js'
|
|
2
|
+
|
|
3
|
+
export function mixChild(key, options = {}) {
|
|
4
|
+
const indexKey = options.indexKey || 'index'
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
inject: {
|
|
8
|
+
[key]: {
|
|
9
|
+
default: null
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
computed: {
|
|
13
|
+
parent() {
|
|
14
|
+
if (this.disableBindingRelation) {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
return this[key]
|
|
18
|
+
},
|
|
19
|
+
[indexKey]() {
|
|
20
|
+
this.bindRelation()
|
|
21
|
+
if (this.parent) {
|
|
22
|
+
return this.parent.children.indexOf(this)
|
|
23
|
+
}
|
|
24
|
+
return null
|
|
25
|
+
},
|
|
26
|
+
isLast() {
|
|
27
|
+
if (this.parent) {
|
|
28
|
+
return this[indexKey] === this.parent.children.length - 1
|
|
29
|
+
}
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
watch: {
|
|
34
|
+
disableBindingRelation(val) {
|
|
35
|
+
if (!val) {
|
|
36
|
+
this.bindRelation()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
mounted() {
|
|
41
|
+
this.bindRelation()
|
|
42
|
+
},
|
|
43
|
+
beforeDestroy() {
|
|
44
|
+
if (this.parent) {
|
|
45
|
+
this.parent.children = this.parent.children.filter(x => x !== this)
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
methods: {
|
|
49
|
+
bindRelation() {
|
|
50
|
+
if (!this.parent || this.parent.children.indexOf(this) !== -1) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
this.parent.children = sortComponent([...this.parent.children, this], this.parent)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { sortComponent } from './vue-extension.js'
|
|
2
|
+
|
|
3
|
+
export function mixSelectableChild(key, options = {}) {
|
|
4
|
+
const indexKey = options.indexKey || 'index'
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
inject: {
|
|
8
|
+
[key]: {
|
|
9
|
+
default: null
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
props: {
|
|
13
|
+
value: {
|
|
14
|
+
type: [String, Number],
|
|
15
|
+
default: ''
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
computed: {
|
|
19
|
+
parent() {
|
|
20
|
+
if (this.disableBindingRelation) {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
return this[key]
|
|
24
|
+
},
|
|
25
|
+
[indexKey]() {
|
|
26
|
+
this.bindRelation()
|
|
27
|
+
if (this.parent) {
|
|
28
|
+
return this.parent.children.indexOf(this)
|
|
29
|
+
}
|
|
30
|
+
return null
|
|
31
|
+
},
|
|
32
|
+
isLast() {
|
|
33
|
+
if (this.parent) {
|
|
34
|
+
return this[indexKey] === this.parent.children.length - 1
|
|
35
|
+
}
|
|
36
|
+
return false
|
|
37
|
+
},
|
|
38
|
+
isSelected() {
|
|
39
|
+
if (!this.parent) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
return this.value == this.parent.value
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
watch: {
|
|
46
|
+
disableBindingRelation(val) {
|
|
47
|
+
if (!val) {
|
|
48
|
+
this.bindRelation()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
mounted() {
|
|
53
|
+
this.bindRelation()
|
|
54
|
+
},
|
|
55
|
+
beforeDestroy() {
|
|
56
|
+
if (this.parent) {
|
|
57
|
+
this.parent.children = this.parent.children.filter(x => x !== this)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
bindRelation() {
|
|
62
|
+
if (!this.parent || this.parent.children.indexOf(this) !== -1) {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
this.parent.children = sortComponent([...this.parent.children, this], this.parent)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function mixSelectableParent(key) {
|
|
2
|
+
return {
|
|
3
|
+
provide() {
|
|
4
|
+
return {
|
|
5
|
+
[key]: this
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
props: {
|
|
9
|
+
value: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
required: true
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
model: {
|
|
15
|
+
prop: 'value',
|
|
16
|
+
event: 'change'
|
|
17
|
+
},
|
|
18
|
+
data() {
|
|
19
|
+
return {
|
|
20
|
+
children: []
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
methods: {
|
|
24
|
+
triggerChange(value) {
|
|
25
|
+
this.$emit('change', value)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|