gyyg-components 0.3.6 → 0.3.7
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/lib/gyyg-components.common.js +138 -104
- package/lib/gyyg-components.umd.js +138 -104
- package/lib/gyyg-components.umd.min.js +138 -104
- package/package.json +1 -1
- package/src/components/MECDescriptions/MECDescriptions.vue +1 -1
- package/src/components/MecButtonGroup/MecButtonGroup.vue +35 -9
- package/src/components/MecRadio/MecRadio.vue +63 -40
- package/src/components/MecSelect/MecSelect.vue +2 -1
- package/src/components/MecTags/MecTags.vue +144 -9
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
:span="item.span || 1"
|
|
25
25
|
:contentClassName="direction == 'vertical' ? 'vertical-content' : item.contentClassName || ''"
|
|
26
26
|
:labelStyle="direction == 'horizontal' ? { width: labelWidth + 'px', textAlign: 'right' } : {}"
|
|
27
|
-
:contentStyle="
|
|
27
|
+
:contentStyle="direction == 'horizontal' ? { width: 'calc(100% - (' + labelWidth + 'px))' }: {}"
|
|
28
28
|
:labelClassName="direction == 'vertical' ? 'vertical-label' : item.labelClassName || ''"
|
|
29
29
|
>
|
|
30
30
|
<div v-if="item.type === 'img'">
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="showTags ? 'has-tags' : ''">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
|
|
4
|
+
<div
|
|
5
|
+
class="btn-group"
|
|
6
|
+
ref="btnGroup"
|
|
7
|
+
>
|
|
9
8
|
<div
|
|
10
9
|
v-for="btn in btnList"
|
|
11
10
|
:key="btn.id"
|
|
@@ -64,6 +63,12 @@
|
|
|
64
63
|
|
|
65
64
|
</div>
|
|
66
65
|
</div>
|
|
66
|
+
<mec-tags
|
|
67
|
+
v-if="showTags"
|
|
68
|
+
:tagsList="tagsData"
|
|
69
|
+
@tagClose="tagClose"
|
|
70
|
+
:btnWidth="btnWidth"
|
|
71
|
+
></mec-tags>
|
|
67
72
|
|
|
68
73
|
</div>
|
|
69
74
|
</template>
|
|
@@ -86,7 +91,8 @@ export default {
|
|
|
86
91
|
},
|
|
87
92
|
data() {
|
|
88
93
|
return {
|
|
89
|
-
tagsData: null
|
|
94
|
+
tagsData: null,
|
|
95
|
+
btnWidth: 0
|
|
90
96
|
}
|
|
91
97
|
},
|
|
92
98
|
watch: {
|
|
@@ -96,8 +102,25 @@ export default {
|
|
|
96
102
|
},
|
|
97
103
|
deep: true,
|
|
98
104
|
immediate: true
|
|
105
|
+
},
|
|
106
|
+
btnList: {
|
|
107
|
+
handler(val) {
|
|
108
|
+
if (this.$refs.btnGroup) {
|
|
109
|
+
this.btnWidth = this.$refs.btnGroup.offsetWidth
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
deep: true,
|
|
114
|
+
immediate: true
|
|
99
115
|
}
|
|
100
116
|
},
|
|
117
|
+
mounted() {
|
|
118
|
+
this.$nextTick(() => {
|
|
119
|
+
this.btnWidth = this.$refs.btnGroup.offsetWidth
|
|
120
|
+
console.log('width: calc(100% - (' + this.btnWidth + ' px))')
|
|
121
|
+
})
|
|
122
|
+
},
|
|
123
|
+
|
|
101
124
|
methods: {
|
|
102
125
|
// 按钮点击事件
|
|
103
126
|
btnClick(btn) {
|
|
@@ -105,12 +128,17 @@ export default {
|
|
|
105
128
|
if (btn.trigger) {
|
|
106
129
|
btn.trigger()
|
|
107
130
|
}
|
|
131
|
+
},
|
|
132
|
+
tagClose(key, tag) {
|
|
133
|
+
this.$emit('tagClose', key, tag);
|
|
108
134
|
}
|
|
109
135
|
},
|
|
110
136
|
}
|
|
111
137
|
</script>
|
|
112
138
|
<style lang="less" scoped>
|
|
113
139
|
/deep/ .el-button {
|
|
140
|
+
font-weight: normal;
|
|
141
|
+
|
|
114
142
|
&:not(:disabled):hover {
|
|
115
143
|
transform: translateY(-1px);
|
|
116
144
|
}
|
|
@@ -119,7 +147,6 @@ export default {
|
|
|
119
147
|
.btn-group {
|
|
120
148
|
display: flex;
|
|
121
149
|
align-items: center;
|
|
122
|
-
flex-wrap: wrap;
|
|
123
150
|
|
|
124
151
|
&>div {
|
|
125
152
|
margin-left: 5px;
|
|
@@ -136,7 +163,6 @@ export default {
|
|
|
136
163
|
.has-tags {
|
|
137
164
|
display: flex;
|
|
138
165
|
align-content: center;
|
|
139
|
-
justify-content: space-between;
|
|
140
166
|
}
|
|
141
167
|
|
|
142
168
|
/deep/ .el-badge__content.is-fixed {
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
<el-radio-group
|
|
3
|
+
v-model="radio"
|
|
4
|
+
:value="radio"
|
|
5
|
+
@change="handleChange"
|
|
6
|
+
v-bind="$attrs"
|
|
7
|
+
class="radio-group"
|
|
8
|
+
>
|
|
9
|
+
<el-radio
|
|
10
|
+
v-for="item in option"
|
|
11
|
+
:label="item[props.value]"
|
|
12
|
+
:key="item[props.value]"
|
|
13
|
+
:value="item[props.value]"
|
|
14
|
+
:border="border"
|
|
15
|
+
>{{ item[props.label] }}</el-radio>
|
|
16
|
+
</el-radio-group>
|
|
17
17
|
</template>
|
|
18
18
|
<script>
|
|
19
19
|
export default {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
name: 'mec-radio',
|
|
21
|
+
props: {
|
|
22
22
|
value: {},
|
|
23
23
|
border: {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: false,
|
|
26
26
|
},
|
|
27
27
|
options: {},
|
|
28
28
|
props: {
|
|
@@ -34,30 +34,53 @@ export default {
|
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
radio: this.value,
|
|
40
|
+
option: []
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
watch: {
|
|
44
|
+
value: {
|
|
45
|
+
handler(val) {
|
|
46
|
+
this.radio = val
|
|
47
|
+
},
|
|
48
|
+
immediate: true
|
|
41
49
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
radio: {
|
|
51
|
+
handler(val) {
|
|
52
|
+
this.$emit('input', val)
|
|
53
|
+
this.$emit('update:value', val)
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
options: {
|
|
57
|
+
handler: function (val) {
|
|
58
|
+
if (!Array.isArray(this.options) && this.options) {
|
|
59
|
+
if (this.options instanceof Promise) {
|
|
60
|
+
this.options.then(val => {
|
|
61
|
+
this.option = val.data || val;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (typeof this.options == 'function') {
|
|
65
|
+
this.options().then(val => {
|
|
66
|
+
this.option = val.data || val;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
} else {
|
|
71
|
+
this.option = this.options;
|
|
54
72
|
}
|
|
73
|
+
},
|
|
74
|
+
deep: true,
|
|
75
|
+
immediate: true,
|
|
55
76
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
},
|
|
78
|
+
methods: {
|
|
79
|
+
handleChange(val) {
|
|
80
|
+
let info = this.option.filter(item => item[this.props.value] === val)
|
|
81
|
+
this.$emit('change', val, info.length > 0 ? info[0] : {})
|
|
82
|
+
},
|
|
83
|
+
}
|
|
61
84
|
|
|
62
85
|
}
|
|
63
86
|
</script>
|
|
@@ -100,9 +100,10 @@ export default {
|
|
|
100
100
|
methods: {
|
|
101
101
|
handleChange(val) {
|
|
102
102
|
this.selected = val;
|
|
103
|
+
let info = this.option.filter(item => item[this.props.value] == val)
|
|
103
104
|
this.$emit("input", this.selected);
|
|
104
105
|
this.$emit('update:value', val)
|
|
105
|
-
this.$emit("change", val);
|
|
106
|
+
this.$emit("change", val, info.length > 0 ? info[0] : {});
|
|
106
107
|
},
|
|
107
108
|
clear() {
|
|
108
109
|
this.selected = '';
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="mec-tags"
|
|
4
|
+
:style="{ width: `calc(100% - ${btnWidth}px)` }"
|
|
5
|
+
ref="tagsContainer"
|
|
6
|
+
>
|
|
7
|
+
<el-button
|
|
8
|
+
icon="el-icon-arrow-left"
|
|
9
|
+
circle
|
|
10
|
+
v-show="showArrow"
|
|
11
|
+
@click="scrollLeft"
|
|
12
|
+
></el-button>
|
|
13
|
+
<div
|
|
14
|
+
class="tags-box"
|
|
15
|
+
ref="tagsBox"
|
|
8
16
|
>
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
<el-tag
|
|
18
|
+
v-for="(tag, index) in tagsData"
|
|
19
|
+
:key="index"
|
|
20
|
+
closable
|
|
21
|
+
:type="tag.type || ''"
|
|
22
|
+
@close="handleClose(index, tag)"
|
|
23
|
+
>
|
|
24
|
+
{{ tag.label }}: {{ tag.value }}
|
|
25
|
+
</el-tag>
|
|
26
|
+
</div>
|
|
27
|
+
<el-button
|
|
28
|
+
style="margin-left: 3px"
|
|
29
|
+
icon="el-icon-arrow-right"
|
|
30
|
+
circle
|
|
31
|
+
v-show="showArrow"
|
|
32
|
+
@click="scrollRight"
|
|
33
|
+
></el-button>
|
|
11
34
|
</div>
|
|
12
35
|
</template>
|
|
13
36
|
<script>
|
|
@@ -15,9 +38,121 @@ export default {
|
|
|
15
38
|
name: 'MecTags',
|
|
16
39
|
props: {
|
|
17
40
|
tagsList: {
|
|
18
|
-
|
|
41
|
+
type: [Array, Object],
|
|
42
|
+
},
|
|
43
|
+
btnWidth: {
|
|
44
|
+
// type: Number,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
data() {
|
|
48
|
+
return {
|
|
49
|
+
tagsData: [],
|
|
50
|
+
tagsContainerWidth: 0,
|
|
51
|
+
showArrow: false,
|
|
19
52
|
}
|
|
20
53
|
},
|
|
54
|
+
watch: {
|
|
55
|
+
tagsList: {
|
|
56
|
+
handler(val) {
|
|
57
|
+
console.log(val)
|
|
58
|
+
this.tagsData = []
|
|
59
|
+
this.tagsData = [...val] ;
|
|
60
|
+
if(this.tagsData.length > 0) {
|
|
61
|
+
this.$nextTick(() => {
|
|
62
|
+
this.updateTagsContainerWidth();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
deep: true,
|
|
67
|
+
immediate: true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
mounted() {
|
|
71
|
+
this.updateTagsContainerWidth();
|
|
72
|
+
window.addEventListener('resize', this.updateTagsContainerWidth);
|
|
73
|
+
},
|
|
74
|
+
beforeDestroy() {
|
|
75
|
+
window.removeEventListener('resize', this.updateTagsContainerWidth);
|
|
76
|
+
},
|
|
77
|
+
methods: {
|
|
78
|
+
handleClose(index, tag) {
|
|
79
|
+
this.tagsData.splice(index, 1);
|
|
80
|
+
this.$emit('tagClose', tag.key, tag);
|
|
81
|
+
},
|
|
82
|
+
scrollLeft() {
|
|
83
|
+
const tagsBox = this.$refs.tagsBox;
|
|
84
|
+
tagsBox.scrollBy({
|
|
85
|
+
left: -150,
|
|
86
|
+
behavior: 'smooth'
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
scrollRight() {
|
|
90
|
+
const tagsBox = this.$refs.tagsBox;
|
|
91
|
+
tagsBox.scrollBy({
|
|
92
|
+
left: 150,
|
|
93
|
+
behavior: 'smooth'
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
updateTagsContainerWidth() {
|
|
98
|
+
this.tagsContainerWidth = this.$refs.tagsContainer.offsetWidth;
|
|
99
|
+
const boxWidth = this.$refs.tagsBox.scrollWidth;
|
|
100
|
+
if (boxWidth > this.tagsContainerWidth) {
|
|
101
|
+
this.showArrow = true;
|
|
102
|
+
} else {
|
|
103
|
+
this.showArrow = false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
21
107
|
}
|
|
22
108
|
|
|
23
109
|
</script>
|
|
110
|
+
<style lang="less" scoped>
|
|
111
|
+
.mec-tags {
|
|
112
|
+
height: 40px;
|
|
113
|
+
margin-left: 10px;
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
|
|
117
|
+
/deep/ .el-tag {
|
|
118
|
+
margin-right: 10px;
|
|
119
|
+
margin-bottom: 10px;
|
|
120
|
+
margin-bottom: 5px;
|
|
121
|
+
margin-top: 5px;
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
height: 30px;
|
|
124
|
+
line-height: 30px;
|
|
125
|
+
padding: 0 5px;
|
|
126
|
+
color: #1890ff;
|
|
127
|
+
|
|
128
|
+
.el-icon-close {
|
|
129
|
+
right: 0;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/deep/ .el-button.is-circle {
|
|
134
|
+
padding: 0;
|
|
135
|
+
width: 24px;
|
|
136
|
+
height: 24px;
|
|
137
|
+
line-height: 24px;
|
|
138
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
139
|
+
margin-right: 3px;
|
|
140
|
+
flex-grow: 0;
|
|
141
|
+
flex-shrink: 0;
|
|
142
|
+
|
|
143
|
+
&:hover,
|
|
144
|
+
&:focus {
|
|
145
|
+
background: #1890ff;
|
|
146
|
+
border-color: #1890ff;
|
|
147
|
+
color: #fff;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.tags-box {
|
|
153
|
+
display: flex;
|
|
154
|
+
overflow-x: auto;
|
|
155
|
+
scroll-behavior: smooth;
|
|
156
|
+
scrollbar-width: none;
|
|
157
|
+
}
|
|
158
|
+
</style>
|