gyyg-components 0.2.6 → 0.2.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 +332 -154
- package/lib/gyyg-components.umd.js +332 -154
- package/lib/gyyg-components.umd.min.js +332 -154
- package/package.json +1 -1
- package/src/App.vue +109 -42
- package/src/components/MecInputTable/MecInputTable.vue +4 -1
- package/src/components/MecSearchForm/MecSearchForm.js +5 -0
- package/src/components/MecSearchForm/MecSearchForm.vue +55 -0
- package/src/components/MecSelect/MecSelect.js +5 -0
- package/src/components/MecSelect/MecSelect.vue +92 -0
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="app">
|
|
3
|
-
<mec-input-table
|
|
3
|
+
<!-- <mec-input-table
|
|
4
4
|
:tableData="tableData"
|
|
5
5
|
:columns="columns"
|
|
6
6
|
:height="height"
|
|
@@ -10,8 +10,13 @@
|
|
|
10
10
|
@row-click="handleRowClick"
|
|
11
11
|
@page-size-change="handlePageSizeChange"
|
|
12
12
|
@page-change="handlePageChange"
|
|
13
|
-
@show="show"
|
|
14
|
-
></mec-input-table
|
|
13
|
+
@show="show"
|
|
14
|
+
></mec-input-table>-->
|
|
15
|
+
<mec-search-form
|
|
16
|
+
:formGroups="formGroups"
|
|
17
|
+
>
|
|
18
|
+
|
|
19
|
+
</mec-search-form>
|
|
15
20
|
</div>
|
|
16
21
|
|
|
17
22
|
</template>
|
|
@@ -20,56 +25,118 @@
|
|
|
20
25
|
|
|
21
26
|
export default {
|
|
22
27
|
data() {
|
|
28
|
+
const _this = this
|
|
23
29
|
return {
|
|
24
|
-
|
|
25
|
-
inputPlaceholder: '请输入',
|
|
26
|
-
clearable: true,
|
|
27
|
-
disabled: false,
|
|
28
|
-
tablePlaceholder: '请输入'
|
|
29
|
-
},
|
|
30
|
-
showSearch: true,
|
|
31
|
-
showSelection: true,
|
|
32
|
-
height: '200',
|
|
33
|
-
page: {
|
|
34
|
-
currentPage: 1,
|
|
35
|
-
total: 100,
|
|
36
|
-
pageSize: 20,
|
|
37
|
-
},
|
|
38
|
-
tableData: [
|
|
39
|
-
{ name: '数据1', value: 'value1' },
|
|
40
|
-
{ name: '数据2', value: 'value2' },
|
|
41
|
-
{ name: '数据3', value: 'value3' },
|
|
42
|
-
],
|
|
43
|
-
columns: [
|
|
30
|
+
formGroups: [
|
|
44
31
|
{
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
componentName: 'mec-select',
|
|
33
|
+
value: '',
|
|
34
|
+
prop: 'a',
|
|
35
|
+
componentProps: {
|
|
36
|
+
options: [
|
|
37
|
+
{ id: 'option1', name: '选项1' },
|
|
38
|
+
{ id: 'option2', name: '选项2' },
|
|
39
|
+
{ id: 'option3', name: '选项3' }
|
|
40
|
+
],
|
|
41
|
+
placeholder: '请选择一个选项',
|
|
42
|
+
clearable: true,
|
|
43
|
+
filterable: true,
|
|
44
|
+
props: {
|
|
45
|
+
label: 'name',
|
|
46
|
+
value: 'id'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
componentListeners: {
|
|
50
|
+
change: (val) => {
|
|
51
|
+
this.formGroups[0].value = val
|
|
52
|
+
console.log(this.formGroups[0].value);
|
|
53
|
+
},
|
|
54
|
+
clear: () => {
|
|
55
|
+
console.log(_this);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
},
|
|
48
59
|
{
|
|
49
|
-
label: '
|
|
50
|
-
|
|
60
|
+
label: '选择项',
|
|
61
|
+
componentName: 'MecInputTable',
|
|
62
|
+
value: '',
|
|
63
|
+
prop: 'b',
|
|
64
|
+
componentProps: {
|
|
65
|
+
tableData: [
|
|
66
|
+
{ name: 'John', age: 30, address: 'New York' },
|
|
67
|
+
{ name: 'Tom', age: 25, address: 'London' },
|
|
68
|
+
{ name: 'Jerry', age: 35, address: 'Paris' }
|
|
69
|
+
],
|
|
70
|
+
columns: [
|
|
71
|
+
{ label: '姓名', bind: 'name' },
|
|
72
|
+
{ label: '年龄', bind: 'age' },
|
|
73
|
+
{ label: '地址', bind: 'address' }
|
|
74
|
+
],
|
|
75
|
+
inputInfo: {
|
|
76
|
+
inputPlaceholder: '点击选择',
|
|
77
|
+
tablePlaceholder: '请输入',
|
|
78
|
+
},
|
|
79
|
+
showSearch: true,
|
|
80
|
+
page: {
|
|
81
|
+
currentPage: 1,
|
|
82
|
+
pageSize: 10,
|
|
83
|
+
total: 3
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
componentListeners: {
|
|
87
|
+
'row-click': (row) => {
|
|
88
|
+
_this.formGroups[1].value = row.name
|
|
89
|
+
console.log('Row clicked:', row);
|
|
90
|
+
},
|
|
91
|
+
'size-change': (val) => {
|
|
92
|
+
console.log('Page size changed:', val);
|
|
93
|
+
},
|
|
94
|
+
'current-change': (val) => {
|
|
95
|
+
console.log('Page changed:', val);
|
|
96
|
+
},
|
|
97
|
+
'show': () => {
|
|
98
|
+
console.log('Dropdown shown');
|
|
99
|
+
},
|
|
100
|
+
'input': (val) => {
|
|
101
|
+
console.log('Input changed:', val);
|
|
102
|
+
},
|
|
103
|
+
'search': (val) => {
|
|
104
|
+
console.log('Search:', val);
|
|
105
|
+
},
|
|
106
|
+
'refresh': () => {
|
|
107
|
+
console.log('Refreshed');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
51
110
|
}
|
|
52
111
|
]
|
|
53
112
|
};
|
|
54
113
|
},
|
|
55
114
|
methods: {
|
|
56
|
-
|
|
57
|
-
console.log('
|
|
58
|
-
},
|
|
59
|
-
handlePageSizeChange(val) {
|
|
60
|
-
console.log('Page size changed:', val);
|
|
61
|
-
// 在这里处理 page-size-change 事件
|
|
62
|
-
},
|
|
63
|
-
handlePageChange(val) {
|
|
64
|
-
console.log('Page changed:', val);
|
|
115
|
+
handleSelectChange(val) {
|
|
116
|
+
console.log('Selected value changed:', val);
|
|
65
117
|
},
|
|
66
|
-
|
|
67
|
-
console.log('
|
|
68
|
-
},
|
|
69
|
-
show() {
|
|
70
|
-
console.log('显示');
|
|
71
|
-
|
|
118
|
+
handleSelectClear() {
|
|
119
|
+
console.log('Selection cleared');
|
|
72
120
|
}
|
|
73
121
|
}
|
|
122
|
+
// methods: {
|
|
123
|
+
// handleRowClick(row) {
|
|
124
|
+
// console.log('Row clicked:', row);
|
|
125
|
+
// },
|
|
126
|
+
// handlePageSizeChange(val) {
|
|
127
|
+
// console.log('Page size changed:', val);
|
|
128
|
+
// // 在这里处理 page-size-change 事件
|
|
129
|
+
// },
|
|
130
|
+
// handlePageChange(val) {
|
|
131
|
+
// console.log('Page changed:', val);
|
|
132
|
+
// },
|
|
133
|
+
// handleCurrentChange(val) {
|
|
134
|
+
// console.log('Current change:', val);
|
|
135
|
+
// },
|
|
136
|
+
// show() {
|
|
137
|
+
// console.log('显示');
|
|
138
|
+
|
|
139
|
+
// }
|
|
140
|
+
// }
|
|
74
141
|
};
|
|
75
142
|
</script>
|
|
@@ -76,6 +76,9 @@ export default {
|
|
|
76
76
|
toggleRow: {
|
|
77
77
|
type: Boolean,
|
|
78
78
|
default: true
|
|
79
|
+
},
|
|
80
|
+
value: {
|
|
81
|
+
default: ''
|
|
79
82
|
}
|
|
80
83
|
},
|
|
81
84
|
data() {
|
|
@@ -119,7 +122,7 @@ export default {
|
|
|
119
122
|
|
|
120
123
|
},
|
|
121
124
|
watch: {
|
|
122
|
-
|
|
125
|
+
value: {
|
|
123
126
|
handler(val) {
|
|
124
127
|
this.inputValue = val
|
|
125
128
|
},
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-form ref="form" :model="formModel" :inline="true">
|
|
4
|
+
<template v-for="(item, index) in formGroups">
|
|
5
|
+
<el-form-item
|
|
6
|
+
:key="index"
|
|
7
|
+
:label="item.label ? item.label : null"
|
|
8
|
+
:label-width="item.label?item.labelWidth:'0px'"
|
|
9
|
+
:rules="item.rules"
|
|
10
|
+
:prop="getProp(item,index)"
|
|
11
|
+
>
|
|
12
|
+
<component :is="item['componentName']"
|
|
13
|
+
v-model="item.value"
|
|
14
|
+
v-bind="item.componentProps"
|
|
15
|
+
v-on="item.componentListeners"
|
|
16
|
+
></component>
|
|
17
|
+
</el-form-item>
|
|
18
|
+
|
|
19
|
+
</template>
|
|
20
|
+
<el-button type="primary" @click="search">查询</el-button>
|
|
21
|
+
</el-form>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
<script>
|
|
25
|
+
export default {
|
|
26
|
+
name: 'MecSearchForm',
|
|
27
|
+
props: {
|
|
28
|
+
formGroups: {
|
|
29
|
+
type: Array,
|
|
30
|
+
default: () => []
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
data() {
|
|
34
|
+
return {
|
|
35
|
+
formModel: this.createFormModel(this.formGroups)
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
methods: {
|
|
39
|
+
createFormModel(formGroups) {
|
|
40
|
+
const model = {};
|
|
41
|
+
formGroups.forEach(item => {
|
|
42
|
+
model[item.prop] = item.value;
|
|
43
|
+
});
|
|
44
|
+
return model;
|
|
45
|
+
},
|
|
46
|
+
getProp (item, index) {
|
|
47
|
+
let propName = item.prop ? item.prop : index + ".value";
|
|
48
|
+
return propName;
|
|
49
|
+
},
|
|
50
|
+
search() {
|
|
51
|
+
console.log(this.formGroups)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-select
|
|
3
|
+
v-model="selected"
|
|
4
|
+
@clear="clear"
|
|
5
|
+
@change="handleChange"
|
|
6
|
+
:placeholder="placeholder"
|
|
7
|
+
:multiple="multiple || false"
|
|
8
|
+
:clearable="clearable"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
:size="size"
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
:filterable="filterable"
|
|
13
|
+
>
|
|
14
|
+
<el-option
|
|
15
|
+
v-for="item in options"
|
|
16
|
+
:key="item[props.value]"
|
|
17
|
+
:label="item[props.label]"
|
|
18
|
+
:value="item[props.value]"
|
|
19
|
+
:disabled="item.disabled"
|
|
20
|
+
></el-option>
|
|
21
|
+
</el-select>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
export default {
|
|
26
|
+
name: "MecSelect",
|
|
27
|
+
props: {
|
|
28
|
+
value: {
|
|
29
|
+
default: null,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
options: {
|
|
33
|
+
type: Array,
|
|
34
|
+
required: true,
|
|
35
|
+
default: () => [],
|
|
36
|
+
},
|
|
37
|
+
multiple: {
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
props: {
|
|
41
|
+
default() {
|
|
42
|
+
return {
|
|
43
|
+
label: "label",
|
|
44
|
+
value: "value",
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
placeholder: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "请选择",
|
|
51
|
+
},
|
|
52
|
+
clearable: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
},
|
|
55
|
+
disabled: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
defalut: false,
|
|
58
|
+
},
|
|
59
|
+
size: String,
|
|
60
|
+
filterable: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
defalut: false,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
data() {
|
|
66
|
+
return {
|
|
67
|
+
selected: this.value,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
watch: {
|
|
71
|
+
value: {
|
|
72
|
+
handler(val) {
|
|
73
|
+
this.selected = val;
|
|
74
|
+
},
|
|
75
|
+
immediate: true,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
methods: {
|
|
79
|
+
handleChange(val) {
|
|
80
|
+
this.$emit("change", val);
|
|
81
|
+
},
|
|
82
|
+
clear() {
|
|
83
|
+
this.selected = '';
|
|
84
|
+
this.$emit('clear')
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<style scoped>
|
|
91
|
+
/* 你可以在这里添加自定义样式 */
|
|
92
|
+
</style>
|