gyyg-components 0.3.20 → 0.3.21
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 +105 -105
- package/lib/gyyg-components.umd.js +105 -105
- package/lib/gyyg-components.umd.min.js +105 -105
- package/package.json +1 -1
- package/src/components/MecButtonGroup/MecButtonGroup.vue +0 -1
- package/src/components/MecCheckbox/MecCheckbox.vue +207 -157
- package/src/components/MecDatePicker/MecDatePicker.vue +4 -1
- package/src/components/MecRadio/MecRadio.vue +71 -58
- package/src/components/MecTable/MecTable.vue +0 -1
package/package.json
CHANGED
|
@@ -1,175 +1,225 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
<div class="checkbox-group">
|
|
3
|
+
<el-checkbox
|
|
4
|
+
:indeterminate="isIndeterminate"
|
|
5
|
+
v-if="isCheckAll"
|
|
6
|
+
v-model="checkAll"
|
|
7
|
+
@change="handleCheckAllChange"
|
|
8
|
+
>全选</el-checkbox
|
|
9
|
+
>
|
|
10
|
+
<div style="margin: 15px 0" v-if="isCheckAll"></div>
|
|
11
|
+
<el-checkbox-group
|
|
12
|
+
v-model="checkbox"
|
|
13
|
+
@change="handleCheckedCitiesChange"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
>
|
|
16
|
+
<div v-if="isHover">
|
|
17
|
+
<el-tooltip
|
|
18
|
+
v-for="(item, index) in option"
|
|
19
|
+
:key="index"
|
|
20
|
+
class="item"
|
|
21
|
+
effect="dark"
|
|
22
|
+
:content="item[contentFileld]"
|
|
23
|
+
placement="top-start"
|
|
24
|
+
>
|
|
25
|
+
<el-checkbox
|
|
26
|
+
:label="item[props.value]"
|
|
27
|
+
:disabled="item.disabled"
|
|
28
|
+
@change="(val) => checkBoxChange(val, item)"
|
|
29
|
+
>{{ item[props.label] }}</el-checkbox
|
|
30
|
+
>
|
|
31
|
+
</el-tooltip>
|
|
32
|
+
</div>
|
|
33
|
+
<div v-else>
|
|
34
|
+
<el-checkbox
|
|
35
|
+
v-for="(item, index) in option"
|
|
36
|
+
:label="item[props.value]"
|
|
37
|
+
:disabled="item.disabled"
|
|
38
|
+
:key="index"
|
|
39
|
+
@change="(val) => checkBoxChange(val, item)"
|
|
40
|
+
>{{ item[props.label] }}</el-checkbox
|
|
41
|
+
>
|
|
42
|
+
</div>
|
|
43
|
+
<el-input
|
|
44
|
+
v-if="showOther"
|
|
45
|
+
v-model="inputValue"
|
|
46
|
+
:disabled="inputDisabled"
|
|
47
|
+
placeholder="请输入其他"
|
|
48
|
+
@input="inputChange"
|
|
49
|
+
style="display: inline-block; margin-left: 10px"
|
|
50
|
+
/>
|
|
51
|
+
</el-checkbox-group>
|
|
52
|
+
</div>
|
|
25
53
|
</template>
|
|
26
54
|
<script>
|
|
27
55
|
export default {
|
|
28
|
-
|
|
56
|
+
name: "mec-checkbox",
|
|
57
|
+
props: {
|
|
58
|
+
value: {},
|
|
59
|
+
options: {},
|
|
29
60
|
props: {
|
|
30
|
-
|
|
31
|
-
options: {},
|
|
32
|
-
props: {
|
|
33
|
-
default() {
|
|
34
|
-
return {
|
|
35
|
-
label: 'name',
|
|
36
|
-
value: 'id'
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
isCheckAll: {
|
|
41
|
-
default() {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
showOther: {
|
|
46
|
-
default() {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
otherValue: {
|
|
51
|
-
default() {
|
|
52
|
-
return '';
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
checkText: {
|
|
56
|
-
default() {
|
|
57
|
-
return '其他'
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
disabled: {
|
|
61
|
-
default() {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
data() {
|
|
61
|
+
default() {
|
|
67
62
|
return {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
isIndeterminate: true,
|
|
71
|
-
option: [],
|
|
72
|
-
inputValue: '',
|
|
73
|
-
inputDisabled: true
|
|
63
|
+
label: "name",
|
|
64
|
+
value: "id",
|
|
74
65
|
};
|
|
66
|
+
},
|
|
75
67
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
immediate: true
|
|
82
|
-
},
|
|
83
|
-
options: {
|
|
84
|
-
handler: function (val) {
|
|
85
|
-
//判断options是否为promise
|
|
86
|
-
if (typeof val !== 'function' && val && !val.then) {
|
|
87
|
-
this.option = this.options;
|
|
88
|
-
let nameList = this.getNameListByIds(this.value, this.option)
|
|
89
|
-
this.inputDisabled = nameList.filter(item => {
|
|
90
|
-
return item.includes(this.checkText)
|
|
91
|
-
}).length == 0
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
deep: true,
|
|
95
|
-
immediate: true,
|
|
96
|
-
},
|
|
97
|
-
otherValue: {
|
|
98
|
-
handler(val) {
|
|
99
|
-
this.inputValue = val;
|
|
100
|
-
console.log(val, 'otherValue')
|
|
101
|
-
},
|
|
102
|
-
immediate: true
|
|
103
|
-
}
|
|
68
|
+
isCheckAll: {
|
|
69
|
+
default() {
|
|
70
|
+
return false;
|
|
71
|
+
},
|
|
104
72
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
73
|
+
showOther: {
|
|
74
|
+
default() {
|
|
75
|
+
return false;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
otherValue: {
|
|
79
|
+
default() {
|
|
80
|
+
return "";
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
checkText: {
|
|
84
|
+
default() {
|
|
85
|
+
return "其他";
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
disabled: {
|
|
89
|
+
default() {
|
|
90
|
+
return false;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
isHover: {
|
|
94
|
+
default() {
|
|
95
|
+
return false;
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
contentFileld: {
|
|
99
|
+
default() {
|
|
100
|
+
return "content";
|
|
101
|
+
},
|
|
130
102
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
103
|
+
},
|
|
104
|
+
data() {
|
|
105
|
+
return {
|
|
106
|
+
checkAll: false,
|
|
107
|
+
checkbox: [],
|
|
108
|
+
isIndeterminate: true,
|
|
109
|
+
option: [],
|
|
110
|
+
inputValue: "",
|
|
111
|
+
inputDisabled: true,
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
watch: {
|
|
115
|
+
value: {
|
|
116
|
+
handler(val) {
|
|
117
|
+
this.checkbox = [].concat(val);
|
|
118
|
+
},
|
|
119
|
+
immediate: true,
|
|
120
|
+
},
|
|
121
|
+
options: {
|
|
122
|
+
handler: function (val) {
|
|
123
|
+
//判断options是否为promise
|
|
124
|
+
if (typeof val !== "function" && val && !val.then) {
|
|
125
|
+
this.option = this.options;
|
|
126
|
+
let nameList = this.getNameListByIds(this.value, this.option);
|
|
127
|
+
this.inputDisabled =
|
|
128
|
+
nameList.filter((item) => {
|
|
129
|
+
return item.includes(this.checkText);
|
|
130
|
+
}).length == 0;
|
|
136
131
|
}
|
|
132
|
+
},
|
|
133
|
+
deep: true,
|
|
134
|
+
immediate: true,
|
|
135
|
+
},
|
|
136
|
+
otherValue: {
|
|
137
|
+
handler(val) {
|
|
138
|
+
this.inputValue = val;
|
|
139
|
+
console.log(val, "otherValue");
|
|
140
|
+
},
|
|
141
|
+
immediate: true,
|
|
137
142
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
inputChange(val) {
|
|
164
|
-
this.$emit('update:otherValue', val)
|
|
165
|
-
},
|
|
143
|
+
},
|
|
144
|
+
mounted() {
|
|
145
|
+
if (!Array.isArray(this.options) && this.options) {
|
|
146
|
+
if (this.options instanceof Promise) {
|
|
147
|
+
this.options.then((val) => {
|
|
148
|
+
this.option = val.data || val;
|
|
149
|
+
let nameList = this.getNameListByIds(this.value, this.option);
|
|
150
|
+
this.inputDisabled =
|
|
151
|
+
nameList.filter((item) => {
|
|
152
|
+
return item.includes(this.checkText);
|
|
153
|
+
}).length == 0;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (typeof this.options == "function") {
|
|
157
|
+
this.options().then((val) => {
|
|
158
|
+
this.option = val.data || val;
|
|
159
|
+
let nameList = this.getNameListByIds(this.value, this.option);
|
|
160
|
+
this.inputDisabled =
|
|
161
|
+
nameList.filter((item) => {
|
|
162
|
+
return item.includes(this.checkText);
|
|
163
|
+
}).length == 0;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
this.option = this.options;
|
|
166
168
|
}
|
|
169
|
+
},
|
|
170
|
+
computed: {
|
|
171
|
+
checkboxAll() {
|
|
172
|
+
return this.option.map((item) => {
|
|
173
|
+
return item[this.props.value];
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
methods: {
|
|
178
|
+
handleCheckAllChange(val) {
|
|
179
|
+
this.checkbox = val ? this.checkboxAll : [];
|
|
180
|
+
this.isIndeterminate = false;
|
|
181
|
+
},
|
|
182
|
+
handleCheckedCitiesChange(value) {
|
|
183
|
+
let checkedCount = value.length;
|
|
184
|
+
this.checkAll = checkedCount === this.checkboxAll.length;
|
|
185
|
+
this.isIndeterminate =
|
|
186
|
+
checkedCount > 0 && checkedCount < this.checkboxAll.length;
|
|
187
|
+
|
|
188
|
+
this.$emit("input", value);
|
|
189
|
+
this.$emit("update:value", value);
|
|
190
|
+
let nameList = this.getNameListByIds(value, this.option);
|
|
191
|
+
this.inputDisabled =
|
|
192
|
+
nameList.filter((item) => {
|
|
193
|
+
return item.includes(this.checkText);
|
|
194
|
+
}).length == 0;
|
|
195
|
+
},
|
|
196
|
+
// 根据 id 数组获取对应的 name 列表
|
|
197
|
+
getNameListByIds(ids, array) {
|
|
198
|
+
return ids
|
|
199
|
+
.map((id) => {
|
|
200
|
+
const reason = array.find((item) => item[this.props.value] === id);
|
|
201
|
+
return reason ? reason[this.props.label] : "";
|
|
202
|
+
})
|
|
203
|
+
.filter((name) => name); // 过滤掉空值
|
|
204
|
+
},
|
|
205
|
+
// 其他输入框输入
|
|
206
|
+
inputChange(val) {
|
|
207
|
+
this.$emit("update:otherValue", val);
|
|
208
|
+
},
|
|
209
|
+
checkBoxChange(val, item) {
|
|
210
|
+
if (val) {
|
|
211
|
+
this.$emit("checkBoxSelect", item);
|
|
212
|
+
} else {
|
|
213
|
+
this.$emit("checkBoxSelect", {});
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
},
|
|
167
217
|
};
|
|
168
218
|
</script>
|
|
169
219
|
<style lang="less" scoped>
|
|
170
220
|
.checkbox-group {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
221
|
+
/deep/ .el-checkbox__label {
|
|
222
|
+
font-weight: normal;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
175
225
|
</style>
|
|
@@ -12,20 +12,21 @@
|
|
|
12
12
|
:key="item[props.value]"
|
|
13
13
|
:value="item[props.value]"
|
|
14
14
|
:border="border"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
>{{ item[props.label] }}
|
|
16
|
+
</el-radio>
|
|
17
|
+
<el-input
|
|
18
18
|
v-if="showOther"
|
|
19
|
-
v-model="inputValue"
|
|
20
|
-
:disabled="inputDisabled"
|
|
21
|
-
placeholder="请输入"
|
|
22
|
-
style="display: inline-block; margin-top: 10px
|
|
23
|
-
|
|
19
|
+
v-model="inputValue"
|
|
20
|
+
:disabled="inputDisabled"
|
|
21
|
+
placeholder="请输入"
|
|
22
|
+
style="display: inline-block; margin-top: 10px"
|
|
23
|
+
/>
|
|
24
|
+
<!-- @input="inputChange" -->
|
|
24
25
|
</el-radio-group>
|
|
25
26
|
</template>
|
|
26
27
|
<script>
|
|
27
28
|
export default {
|
|
28
|
-
name:
|
|
29
|
+
name: "mec-radio",
|
|
29
30
|
props: {
|
|
30
31
|
value: {},
|
|
31
32
|
border: {
|
|
@@ -36,100 +37,112 @@ export default {
|
|
|
36
37
|
props: {
|
|
37
38
|
default() {
|
|
38
39
|
return {
|
|
39
|
-
label:
|
|
40
|
-
value:
|
|
41
|
-
}
|
|
40
|
+
label: "label",
|
|
41
|
+
value: "value",
|
|
42
|
+
};
|
|
42
43
|
},
|
|
43
44
|
},
|
|
44
45
|
showOther: {
|
|
45
46
|
type: Boolean,
|
|
46
|
-
default: false
|
|
47
|
+
default: false,
|
|
47
48
|
},
|
|
48
49
|
checkText: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
default() {
|
|
51
|
+
return "其他";
|
|
52
|
+
},
|
|
52
53
|
},
|
|
53
54
|
otherValue: {
|
|
54
|
-
default: ""
|
|
55
|
-
}
|
|
55
|
+
default: "",
|
|
56
|
+
},
|
|
56
57
|
},
|
|
57
58
|
data() {
|
|
58
59
|
return {
|
|
59
60
|
radio: this.value,
|
|
60
61
|
option: [],
|
|
61
|
-
inputValue:
|
|
62
|
-
inputDisabled: true
|
|
63
|
-
}
|
|
62
|
+
inputValue: "",
|
|
63
|
+
inputDisabled: true,
|
|
64
|
+
};
|
|
64
65
|
},
|
|
65
66
|
watch: {
|
|
66
67
|
value: {
|
|
67
68
|
handler(val) {
|
|
68
|
-
this.radio = val
|
|
69
|
+
this.radio = val;
|
|
69
70
|
},
|
|
70
|
-
immediate: true
|
|
71
|
+
immediate: true,
|
|
71
72
|
},
|
|
72
73
|
radio: {
|
|
73
74
|
handler(val) {
|
|
74
|
-
this.$emit(
|
|
75
|
-
this.$emit(
|
|
75
|
+
this.$emit("input", val);
|
|
76
|
+
this.$emit("update:value", val);
|
|
76
77
|
},
|
|
77
78
|
},
|
|
78
79
|
options: {
|
|
79
80
|
handler: function (val) {
|
|
80
81
|
if (!Array.isArray(this.options) && this.options) {
|
|
81
82
|
if (this.options instanceof Promise) {
|
|
82
|
-
this.options.then(val => {
|
|
83
|
+
this.options.then((val) => {
|
|
83
84
|
this.option = val.data || val;
|
|
85
|
+
let name = this.getNameById(this.value, this.option);
|
|
86
|
+
if (name.includes(this.checkText)) {
|
|
87
|
+
this.inputDisabled = false;
|
|
88
|
+
} else {
|
|
89
|
+
this.inputDisabled = true;
|
|
90
|
+
}
|
|
84
91
|
});
|
|
85
92
|
}
|
|
86
|
-
if (typeof this.options ==
|
|
87
|
-
this.options().then(val => {
|
|
93
|
+
if (typeof this.options == "function") {
|
|
94
|
+
this.options().then((val) => {
|
|
88
95
|
this.option = val.data || val;
|
|
96
|
+
let name = this.getNameById(this.value, this.option);
|
|
97
|
+
if (name.includes(this.checkText)) {
|
|
98
|
+
this.inputDisabled = false;
|
|
99
|
+
} else {
|
|
100
|
+
this.inputDisabled = true;
|
|
101
|
+
}
|
|
89
102
|
});
|
|
90
103
|
}
|
|
91
|
-
|
|
92
104
|
} else {
|
|
93
105
|
this.option = val;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
let name = this.getNameById(this.value, this.option);
|
|
107
|
+
if (name.includes(this.checkText)) {
|
|
108
|
+
this.inputDisabled = false;
|
|
109
|
+
} else {
|
|
110
|
+
this.inputDisabled = true;
|
|
111
|
+
}
|
|
100
112
|
}
|
|
101
113
|
},
|
|
102
114
|
deep: true,
|
|
103
115
|
immediate: true,
|
|
104
116
|
},
|
|
105
117
|
otherValue: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
118
|
+
handler(val) {
|
|
119
|
+
this.inputValue = val;
|
|
120
|
+
console.log(val, "otherValue");
|
|
121
|
+
},
|
|
122
|
+
immediate: true,
|
|
123
|
+
},
|
|
112
124
|
},
|
|
113
125
|
methods: {
|
|
114
126
|
handleChange(val) {
|
|
115
|
-
let info = this.option.filter(item => item[this.props.value] === val)
|
|
116
|
-
console.log(info,
|
|
117
|
-
let name = this.getNameById(val, this.option)
|
|
118
|
-
if(name.includes(this.checkText)) {
|
|
119
|
-
this.inputDisabled = false
|
|
127
|
+
let info = this.option.filter((item) => item[this.props.value] === val);
|
|
128
|
+
console.log(info, "info");
|
|
129
|
+
let name = this.getNameById(val, this.option);
|
|
130
|
+
if (name.includes(this.checkText)) {
|
|
131
|
+
this.inputDisabled = false;
|
|
120
132
|
} else {
|
|
121
|
-
this.inputDisabled = true
|
|
122
|
-
this.inputValue =
|
|
133
|
+
this.inputDisabled = true;
|
|
134
|
+
this.inputValue = "";
|
|
123
135
|
}
|
|
124
|
-
this.$emit(
|
|
136
|
+
this.$emit("change", val, info.length > 0 ? info[0] : {});
|
|
125
137
|
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
138
|
+
// 根据 id 数组获取对应的 name 列表
|
|
139
|
+
getNameById(id, array) {
|
|
140
|
+
console.log(id, array);
|
|
141
|
+
if (!id) return "";
|
|
142
|
+
return array[array.findIndex((item) => item[this.props.value] === id)][
|
|
143
|
+
this.props.label
|
|
144
|
+
];
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
135
148
|
</script>
|