gyyg-components 0.3.18 → 0.3.20
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 +312 -100
- package/lib/gyyg-components.umd.js +312 -100
- package/lib/gyyg-components.umd.min.js +312 -100
- package/package.json +1 -1
- package/src/components/MecDrawer/MecDrawer.js +5 -0
- package/src/components/MecDrawer/MecDrawer.vue +94 -0
- package/src/components/MecForm/MecForm.vue +118 -88
- package/src/components/MecInput/MecInput.vue +2 -0
- package/src/components/MecPopoverButton/MecPopoverButton.vue +4 -0
- package/src/components/MecRadio/MecRadio.vue +52 -3
- package/src/components/MecSelect/MecSelect.vue +20 -21
- package/src/components/MecSelectAndButton/MecSelectAndButton.js +5 -0
- package/src/components/MecSelectAndButton/MecSelectAndButton.vue +167 -0
- package/src/components/MecTable/MecTable.vue +9 -5
package/package.json
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-drawer :visible.sync="searchDrawerVisible" direction="rtl" :before-close="handleBeforeClose" :modal="true"
|
|
4
|
+
icon="el-icon-search" :size="width">
|
|
5
|
+
<!-- 标题区域 -->
|
|
6
|
+
<div slot="title" class="drawer-title">
|
|
7
|
+
<i class="el-icon-search" style="margin-right: 8px; color: #409EFF;font-size: 20px;"></i>
|
|
8
|
+
<span>{{title}}</span>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<!-- 内容区域:通过默认插槽自定义内容 -->
|
|
12
|
+
<div class="drawer-content">
|
|
13
|
+
<slot name="body"></slot>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<!-- 底部区域:通过具名插槽自定义内容(固定在底部) -->
|
|
17
|
+
<div class="searchBoxFooter">
|
|
18
|
+
<slot name="footer"></slot>
|
|
19
|
+
</div>
|
|
20
|
+
</el-drawer>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
name: 'SearchDrawer',
|
|
28
|
+
props: {
|
|
29
|
+
width: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: '20%'
|
|
32
|
+
},
|
|
33
|
+
title: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: '筛选'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
searchDrawerVisible: false
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
methods: {
|
|
44
|
+
open() {
|
|
45
|
+
this.searchDrawerVisible = true;
|
|
46
|
+
},
|
|
47
|
+
close() {
|
|
48
|
+
this.searchDrawerVisible = false
|
|
49
|
+
},
|
|
50
|
+
handleBeforeClose(done) {
|
|
51
|
+
this.searchDrawerVisible = false;
|
|
52
|
+
done();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<style scoped>
|
|
59
|
+
::v-deep .el-drawer__header {
|
|
60
|
+
align-items: center;
|
|
61
|
+
color: #72767b;
|
|
62
|
+
display: flex;
|
|
63
|
+
margin-bottom: 32px;
|
|
64
|
+
padding: 10px 20px;
|
|
65
|
+
background-color: #efefef !important;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.drawer-title {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: baseline;
|
|
71
|
+
font-size: 18px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.drawer-content {
|
|
75
|
+
height: calc(100% - 120px);
|
|
76
|
+
padding: 0 20px;
|
|
77
|
+
overflow-y: auto;
|
|
78
|
+
box-sizing: border-box;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.searchBoxFooter {
|
|
82
|
+
position: absolute;
|
|
83
|
+
bottom: 0;
|
|
84
|
+
right: 0;
|
|
85
|
+
width: 100%;
|
|
86
|
+
padding: 6px 15px;
|
|
87
|
+
background-color: #efefef;
|
|
88
|
+
border-top: 1px solid #e8e8e8;
|
|
89
|
+
display: flex;
|
|
90
|
+
justify-content: flex-end;
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
z-index: 10;
|
|
93
|
+
}
|
|
94
|
+
</style>
|
|
@@ -1,100 +1,130 @@
|
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
2
|
+
<el-form
|
|
3
|
+
ref="formData"
|
|
4
|
+
:model="formData"
|
|
5
|
+
:label-width="labelWidth"
|
|
6
|
+
:label-position="labelPosition"
|
|
7
|
+
>
|
|
8
|
+
<template v-for="(item, index) in formData">
|
|
9
|
+
<el-col
|
|
10
|
+
v-if="
|
|
11
|
+
typeof item.displayWith !== 'function' ||
|
|
12
|
+
item.displayWith(formData, item)
|
|
13
|
+
"
|
|
14
|
+
:span="item.col"
|
|
15
|
+
:style="item.style"
|
|
16
|
+
:key="index"
|
|
17
|
+
>
|
|
18
|
+
<el-form-item
|
|
19
|
+
v-bind="item"
|
|
20
|
+
:prop="getProp(item, index)"
|
|
21
|
+
:rules="item.rules"
|
|
22
|
+
:class="item.class"
|
|
23
|
+
:label-width="item.labelWidth"
|
|
24
|
+
>
|
|
25
|
+
<template slot="label">
|
|
26
|
+
<span v-if="item.label">
|
|
27
|
+
<span :style="'color:' + item.labelColor">{{ item.label }}</span>
|
|
28
|
+
<el-tooltip
|
|
29
|
+
v-if="item.tooltip"
|
|
30
|
+
class="item"
|
|
31
|
+
effect="dark"
|
|
32
|
+
:content="item.tooltip"
|
|
33
|
+
placement="top"
|
|
34
|
+
>
|
|
35
|
+
<i class="el-icon-question"></i>
|
|
36
|
+
</el-tooltip>
|
|
37
|
+
</span>
|
|
38
|
+
</template>
|
|
39
|
+
<component
|
|
40
|
+
:is="item['componentName']"
|
|
41
|
+
v-model="item.value"
|
|
42
|
+
:value.sync="item.value"
|
|
43
|
+
:otherValue.sync="item.otherValue"
|
|
44
|
+
:delIdList.sync="item.delIdList"
|
|
45
|
+
v-bind="item"
|
|
46
|
+
v-on="item.componentListeners"
|
|
47
|
+
:ref="item.componentRef"
|
|
48
|
+
></component>
|
|
49
|
+
</el-form-item>
|
|
50
|
+
</el-col>
|
|
51
|
+
</template>
|
|
52
|
+
</el-form>
|
|
40
53
|
</template>
|
|
41
54
|
<script>
|
|
42
55
|
export default {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
56
|
+
name: "mec-form",
|
|
57
|
+
props: {
|
|
58
|
+
formData: {
|
|
59
|
+
required: true,
|
|
60
|
+
},
|
|
61
|
+
labelWidth: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: "150px",
|
|
64
|
+
},
|
|
65
|
+
labelPosition: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: "right",
|
|
68
|
+
},
|
|
69
|
+
showErrMsg: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
data() {
|
|
75
|
+
return {
|
|
76
|
+
loading: false,
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
computed: {},
|
|
80
|
+
methods: {
|
|
81
|
+
getProp(item, index) {
|
|
82
|
+
let propName = item.prop ? item.prop : index + ".value";
|
|
83
|
+
return propName;
|
|
84
|
+
},
|
|
85
|
+
validate() {
|
|
86
|
+
return new Promise((resolve) => {
|
|
87
|
+
this.$refs.formData.validate((valid, info) => {
|
|
88
|
+
if (valid) {
|
|
89
|
+
if (this.showErrMsg) {
|
|
90
|
+
resolve({ valid: true, errorMsg: [] });
|
|
91
|
+
} else {
|
|
92
|
+
resolve(true);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
let errorMsg = [];
|
|
96
|
+
for (let key in info) {
|
|
97
|
+
console.log(info[key]);
|
|
98
|
+
errorMsg.push(info[key][0].message);
|
|
99
|
+
}
|
|
100
|
+
if (this.showErrMsg) {
|
|
101
|
+
resolve({ valid: false, errorMsg: errorMsg });
|
|
102
|
+
} else {
|
|
103
|
+
resolve(false);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
clearValidate() {
|
|
110
|
+
this.$refs.formData.clearValidate();
|
|
111
|
+
},
|
|
112
|
+
},
|
|
83
113
|
};
|
|
84
114
|
</script>
|
|
85
115
|
<style lang="less" scoped>
|
|
116
|
+
|
|
86
117
|
::v-deep.el-form::after {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
118
|
+
content: "";
|
|
119
|
+
display: table;
|
|
120
|
+
clear: both;
|
|
90
121
|
}
|
|
91
122
|
::v-deep.el-form--label-top {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
123
|
+
.el-col {
|
|
124
|
+
padding-right: 15px;
|
|
125
|
+
}
|
|
126
|
+
.el-form-item {
|
|
127
|
+
margin-bottom: 12px;
|
|
128
|
+
}
|
|
98
129
|
}
|
|
99
|
-
|
|
100
130
|
</style>
|
|
@@ -150,6 +150,8 @@
|
|
|
150
150
|
if (value.split('.').length > 2) {
|
|
151
151
|
value = value.replace(/\.+$/, '');
|
|
152
152
|
}
|
|
153
|
+
} else if (this.inputType === 'englishAndNumber') {
|
|
154
|
+
value = value.replace(/[^a-zA-Z0-9\s]/g, '');
|
|
153
155
|
}
|
|
154
156
|
this.inputValue = value
|
|
155
157
|
this.$emit('input', value);
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
placement="bottom-end"
|
|
10
10
|
@click="clickEvent"
|
|
11
11
|
@command="changeItem"
|
|
12
|
+
@visible-change="visibleChange"
|
|
12
13
|
>
|
|
13
14
|
<span v-if="btnInfo.splitButton"><i :class="btnInfo.icon" style="margin-right: 5px;"></i>{{ btnInfo.text}}</span>
|
|
14
15
|
<el-button :type="btnInfo.type" v-else>
|
|
@@ -39,6 +40,9 @@ export default {
|
|
|
39
40
|
},
|
|
40
41
|
changeItem(value) {
|
|
41
42
|
this.btnInfo.callback(value)
|
|
43
|
+
},
|
|
44
|
+
visibleChange(value) {
|
|
45
|
+
this.$emit('visibleChange', value)
|
|
42
46
|
|
|
43
47
|
}
|
|
44
48
|
}
|
|
@@ -12,7 +12,15 @@
|
|
|
12
12
|
:key="item[props.value]"
|
|
13
13
|
:value="item[props.value]"
|
|
14
14
|
:border="border"
|
|
15
|
-
>{{ item[props.label] }}
|
|
15
|
+
>{{ item[props.label] }}
|
|
16
|
+
</el-radio>
|
|
17
|
+
<el-input
|
|
18
|
+
v-if="showOther"
|
|
19
|
+
v-model="inputValue"
|
|
20
|
+
:disabled="inputDisabled"
|
|
21
|
+
placeholder="请输入"
|
|
22
|
+
style="display: inline-block; margin-top: 10px;" />
|
|
23
|
+
<!-- @input="inputChange" -->
|
|
16
24
|
</el-radio-group>
|
|
17
25
|
</template>
|
|
18
26
|
<script>
|
|
@@ -33,11 +41,25 @@ export default {
|
|
|
33
41
|
}
|
|
34
42
|
},
|
|
35
43
|
},
|
|
44
|
+
showOther: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false
|
|
47
|
+
},
|
|
48
|
+
checkText: {
|
|
49
|
+
default() {
|
|
50
|
+
return '其他'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
otherValue: {
|
|
54
|
+
default: ""
|
|
55
|
+
}
|
|
36
56
|
},
|
|
37
57
|
data() {
|
|
38
58
|
return {
|
|
39
59
|
radio: this.value,
|
|
40
|
-
option: []
|
|
60
|
+
option: [],
|
|
61
|
+
inputValue: '',
|
|
62
|
+
inputDisabled: true
|
|
41
63
|
}
|
|
42
64
|
},
|
|
43
65
|
watch: {
|
|
@@ -68,18 +90,45 @@ export default {
|
|
|
68
90
|
}
|
|
69
91
|
|
|
70
92
|
} else {
|
|
71
|
-
this.option =
|
|
93
|
+
this.option = val;
|
|
94
|
+
}
|
|
95
|
+
let name = this.getNameById(this.value, this.option)
|
|
96
|
+
if(name.includes(this.checkText)) {
|
|
97
|
+
this.inputDisabled = false
|
|
98
|
+
} else {
|
|
99
|
+
this.inputDisabled = true
|
|
72
100
|
}
|
|
73
101
|
},
|
|
74
102
|
deep: true,
|
|
75
103
|
immediate: true,
|
|
76
104
|
},
|
|
105
|
+
otherValue: {
|
|
106
|
+
handler(val) {
|
|
107
|
+
this.inputValue = val;
|
|
108
|
+
console.log(val, 'otherValue')
|
|
109
|
+
},
|
|
110
|
+
immediate: true
|
|
111
|
+
}
|
|
77
112
|
},
|
|
78
113
|
methods: {
|
|
79
114
|
handleChange(val) {
|
|
80
115
|
let info = this.option.filter(item => item[this.props.value] === val)
|
|
116
|
+
console.log(info, 'info')
|
|
117
|
+
let name = this.getNameById(val, this.option)
|
|
118
|
+
if(name.includes(this.checkText)) {
|
|
119
|
+
this.inputDisabled = false
|
|
120
|
+
} else {
|
|
121
|
+
this.inputDisabled = true
|
|
122
|
+
this.inputValue = ''
|
|
123
|
+
}
|
|
81
124
|
this.$emit('change', val, info.length > 0 ? info[0] : {})
|
|
82
125
|
},
|
|
126
|
+
// 根据 id 数组获取对应的 name 列表
|
|
127
|
+
getNameById(id, array) {
|
|
128
|
+
console.log(id, array)
|
|
129
|
+
if(!id) return ''
|
|
130
|
+
return array[array.findIndex(item => item[this.props.value] === id)][this.props.label]
|
|
131
|
+
},
|
|
83
132
|
}
|
|
84
133
|
|
|
85
134
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<el-select
|
|
3
3
|
v-model="selected"
|
|
4
|
-
|
|
4
|
+
@clear="clear"
|
|
5
5
|
@change="handleChange"
|
|
6
6
|
:placeholder="placeholder"
|
|
7
7
|
:multiple="multiple || false"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
v-bind="$attrs"
|
|
12
12
|
:filterable="filterable"
|
|
13
13
|
:value="selected"
|
|
14
|
-
style="width: 100
|
|
14
|
+
style="width: 100%"
|
|
15
15
|
>
|
|
16
16
|
<el-option
|
|
17
17
|
v-for="item in option"
|
|
@@ -64,8 +64,8 @@ export default {
|
|
|
64
64
|
},
|
|
65
65
|
data() {
|
|
66
66
|
return {
|
|
67
|
-
selected:
|
|
68
|
-
option:[]
|
|
67
|
+
selected: "",
|
|
68
|
+
option: [],
|
|
69
69
|
};
|
|
70
70
|
},
|
|
71
71
|
watch: {
|
|
@@ -76,39 +76,38 @@ export default {
|
|
|
76
76
|
immediate: true,
|
|
77
77
|
},
|
|
78
78
|
options: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if(this.options instanceof
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
handler: function () {
|
|
80
|
+
if (!Array.isArray(this.options) && this.options) {
|
|
81
|
+
if (this.options instanceof Promise) {
|
|
82
|
+
this.options.then((val) => {
|
|
83
|
+
this.option = val.data || val;
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
if(typeof this.options ==
|
|
87
|
-
this.options().then(val => {
|
|
86
|
+
if (typeof this.options == "function") {
|
|
87
|
+
this.options().then((val) => {
|
|
88
88
|
this.option = val.data || val;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
|
|
92
91
|
} else {
|
|
93
92
|
this.option = this.options;
|
|
94
93
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
},
|
|
95
|
+
deep: true,
|
|
96
|
+
immediate: true,
|
|
97
|
+
},
|
|
99
98
|
},
|
|
100
99
|
methods: {
|
|
101
100
|
handleChange(val) {
|
|
102
101
|
this.selected = val;
|
|
103
|
-
|
|
102
|
+
let info = this.option.filter((item) => item[this.props.value] == val);
|
|
104
103
|
this.$emit("input", this.selected);
|
|
105
|
-
this.$emit(
|
|
104
|
+
this.$emit("update:value", val);
|
|
106
105
|
this.$emit("change", val, info.length > 0 ? info[0] : {});
|
|
107
106
|
},
|
|
108
107
|
clear() {
|
|
109
|
-
this.selected =
|
|
110
|
-
this.$emit(
|
|
111
|
-
}
|
|
108
|
+
this.selected = "";
|
|
109
|
+
this.$emit("clear");
|
|
110
|
+
},
|
|
112
111
|
},
|
|
113
112
|
};
|
|
114
113
|
</script>
|