gyyg-components 0.2.6 → 0.2.8
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 +955 -171
- package/lib/gyyg-components.umd.js +955 -171
- package/lib/gyyg-components.umd.min.js +955 -171
- package/package.json +2 -2
- package/src/App.vue +44 -51
- package/src/components/MECDefaultText/MECDefaultText.js +5 -0
- package/src/components/MECDefaultText/MECDefaultText.vue +9 -0
- package/src/components/MecCheckbox/MecCheckbox.js +5 -0
- package/src/components/MecCheckbox/MecCheckbox.vue +86 -0
- package/src/components/MecDatePicker/MecDatePicker.js +5 -0
- package/src/components/MecDatePicker/MecDatePicker.vue +94 -0
- package/src/components/MecDialog/MecDialog.js +5 -0
- package/src/components/MecDialog/MecDialog.vue +226 -0
- package/src/components/MecForm/MecForm.js +5 -0
- package/src/components/MecForm/MecForm.vue +77 -0
- package/src/components/MecInput/MecInput.vue +33 -6
- package/src/components/MecInputTable/MecInputTable.vue +4 -1
- package/src/components/MecPopoverButton/MecPopoverButton.vue +1 -0
- package/src/components/MecRadio/MecRadio.js +5 -0
- package/src/components/MecRadio/MecRadio.vue +62 -0
- package/src/components/MecSearchForm/MecSearchForm.js +5 -0
- package/src/components/MecSearchForm/MecSearchForm.vue +56 -0
- package/src/components/MecSelect/MecSelect.js +5 -0
- package/src/components/MecSelect/MecSelect.vue +114 -0
- package/src/components/MecTable/MecTable.vue +6 -2
- package/src/components/MecTabs/MecTabs.js +6 -0
- package/src/components/MecTabs/MecTabs.vue +66 -0
- package/src/directive/hasPermi.js +1 -4
- package/src/otherComponents/iconButton.vue +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gyyg-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "lib/gyyg-components.umd.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@vue/cli-plugin-babel": "~4.5.15",
|
|
21
21
|
"@vue/cli-plugin-eslint": "~4.5.15",
|
|
22
|
-
"@vue/cli-service": "
|
|
22
|
+
"@vue/cli-service": "^4.5.15",
|
|
23
23
|
"babel-eslint": "^10.1.0",
|
|
24
24
|
"eslint": "^6.7.2",
|
|
25
25
|
"eslint-plugin-vue": "^6.2.2",
|
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,66 +10,59 @@
|
|
|
10
10
|
@row-click="handleRowClick"
|
|
11
11
|
@page-size-change="handlePageSizeChange"
|
|
12
12
|
@page-change="handlePageChange"
|
|
13
|
-
@show="show"
|
|
14
|
-
></mec-input-table
|
|
15
|
-
|
|
13
|
+
@show="show"
|
|
14
|
+
></mec-input-table>-->
|
|
15
|
+
<!-- <mec-form :formData="formData" :showBtn="true" @submit="submit"></mec-form> -->
|
|
16
|
+
<mec-search-form :formGroups="formGroups"></mec-search-form>
|
|
16
17
|
|
|
18
|
+
</div>
|
|
17
19
|
</template>
|
|
18
20
|
|
|
19
21
|
<script>
|
|
20
|
-
|
|
21
22
|
export default {
|
|
22
23
|
data() {
|
|
24
|
+
const _this = this;
|
|
23
25
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{ name: '数据2', value: 'value2' },
|
|
41
|
-
{ name: '数据3', value: 'value3' },
|
|
42
|
-
],
|
|
43
|
-
columns: [
|
|
44
|
-
{
|
|
45
|
-
bind: 'name',
|
|
46
|
-
label: '姓名'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: '编码',
|
|
50
|
-
bind: 'value'
|
|
26
|
+
formGroups: {
|
|
27
|
+
abLifeSupport: {
|
|
28
|
+
componentName: 'mec-radio',
|
|
29
|
+
label: '生命支持',
|
|
30
|
+
labelWidth: "100px",
|
|
31
|
+
options: [
|
|
32
|
+
{
|
|
33
|
+
label: '是',
|
|
34
|
+
value: true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: '否',
|
|
38
|
+
value: false
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
value: '',
|
|
51
42
|
}
|
|
52
|
-
|
|
43
|
+
}
|
|
53
44
|
};
|
|
54
45
|
},
|
|
55
46
|
methods: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
},
|
|
48
|
+
// methods: {
|
|
49
|
+
// handleRowClick(row) {
|
|
50
|
+
// console.log('Row clicked:', row);
|
|
51
|
+
// },
|
|
52
|
+
// handlePageSizeChange(val) {
|
|
53
|
+
// console.log('Page size changed:', val);
|
|
54
|
+
// // 在这里处理 page-size-change 事件
|
|
55
|
+
// },
|
|
56
|
+
// handlePageChange(val) {
|
|
57
|
+
// console.log('Page changed:', val);
|
|
58
|
+
// },
|
|
59
|
+
// handleCurrentChange(val) {
|
|
60
|
+
// console.log('Current change:', val);
|
|
61
|
+
// },
|
|
62
|
+
// show() {
|
|
63
|
+
// console.log('显示');
|
|
64
|
+
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
74
67
|
};
|
|
75
68
|
</script>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="checkbox-group">
|
|
3
|
+
<el-checkbox
|
|
4
|
+
:indeterminate="isIndeterminate"
|
|
5
|
+
v-if="isCheckAll"
|
|
6
|
+
v-model="checkAll"
|
|
7
|
+
@change="handleCheckAllChange">全选</el-checkbox>
|
|
8
|
+
<div style="margin: 15px 0;" v-if="isCheckAll" ></div>
|
|
9
|
+
<el-checkbox-group v-model="checkbox" @change="handleCheckedCitiesChange">
|
|
10
|
+
<el-checkbox v-for="(item, index) in options"
|
|
11
|
+
:label="item[props.value]"
|
|
12
|
+
:disabled="item.disabled"
|
|
13
|
+
:key="index">{{ item[props.label] }}</el-checkbox>
|
|
14
|
+
</el-checkbox-group>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
<script>
|
|
18
|
+
const cityOptions = ['上海', '北京', '广州', '深圳'];
|
|
19
|
+
export default {
|
|
20
|
+
name: 'mec-checkbox',
|
|
21
|
+
props: {
|
|
22
|
+
value: {},
|
|
23
|
+
options: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default() {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
props: {
|
|
30
|
+
default() {
|
|
31
|
+
return {
|
|
32
|
+
label: 'label',
|
|
33
|
+
value: 'value'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
isCheckAll: {
|
|
38
|
+
default() {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
data() {
|
|
44
|
+
return {
|
|
45
|
+
checkAll: false,
|
|
46
|
+
checkbox: [],
|
|
47
|
+
isIndeterminate: true
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
watch: {
|
|
51
|
+
value: {
|
|
52
|
+
handler (val) {
|
|
53
|
+
this.checkbox = [].concat(val);
|
|
54
|
+
},
|
|
55
|
+
immediate: true
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
computed: {
|
|
59
|
+
checkboxAll () {
|
|
60
|
+
return this.options.map(item => {
|
|
61
|
+
return item[this.props.value]
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
methods: {
|
|
66
|
+
handleCheckAllChange(val) {
|
|
67
|
+
this.checkbox = val ? this.checkboxAll : [];
|
|
68
|
+
this.isIndeterminate = false;
|
|
69
|
+
},
|
|
70
|
+
handleCheckedCitiesChange(value) {
|
|
71
|
+
let checkedCount = value.length;
|
|
72
|
+
this.checkAll = checkedCount === this.checkboxAll.length;
|
|
73
|
+
this.isIndeterminate = checkedCount > 0 && checkedCount < this.checkboxAll.length;
|
|
74
|
+
this.$emit('input', value)
|
|
75
|
+
console.log(value)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
</script>
|
|
80
|
+
<style lang="less" scoped>
|
|
81
|
+
.checkbox-group {
|
|
82
|
+
/deep/ .el-checkbox__label {
|
|
83
|
+
font-weight: normal;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-date-picker
|
|
4
|
+
v-model="date"
|
|
5
|
+
:type="dateType"
|
|
6
|
+
:placeholder="placeholder"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
:readonly="readonly"
|
|
9
|
+
:size="size"
|
|
10
|
+
@change="change"
|
|
11
|
+
:picker-options="pickerOptions"
|
|
12
|
+
:start-placeholder="startPlaceholder"
|
|
13
|
+
:end-placeholder="endPlaceholder"
|
|
14
|
+
:range-separator="rangeSeparator"
|
|
15
|
+
:value-format="valueFormat"
|
|
16
|
+
style="width: 100%;">
|
|
17
|
+
</el-date-picker>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
<script>
|
|
21
|
+
export default {
|
|
22
|
+
name: 'mec-date-picker',
|
|
23
|
+
props: {
|
|
24
|
+
value: {},
|
|
25
|
+
dateType: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'date'
|
|
28
|
+
},
|
|
29
|
+
placeholder: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: '选择日期时间'
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
readonly: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
size: {
|
|
42
|
+
type: String,
|
|
43
|
+
},
|
|
44
|
+
pickerOptions: {
|
|
45
|
+
type: Object,
|
|
46
|
+
|
|
47
|
+
},
|
|
48
|
+
startPlaceholder: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: '开始日期'
|
|
51
|
+
},
|
|
52
|
+
endPlaceholder: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '结束日期'
|
|
55
|
+
|
|
56
|
+
},
|
|
57
|
+
rangeSeparator: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: '至'
|
|
60
|
+
},
|
|
61
|
+
valueFormat: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: 'yyyy-MM-dd'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
},
|
|
67
|
+
data() {
|
|
68
|
+
return {
|
|
69
|
+
date: ''
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
methods: {
|
|
73
|
+
change(val) {
|
|
74
|
+
this.$emit('change', val);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
watch: {
|
|
78
|
+
value: {
|
|
79
|
+
handler(val) {
|
|
80
|
+
this.date = val;
|
|
81
|
+
},
|
|
82
|
+
immediate: true
|
|
83
|
+
},
|
|
84
|
+
date: {
|
|
85
|
+
handler(val) {
|
|
86
|
+
this.$emit('input', val);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
<style lang="less" scoped>
|
|
94
|
+
</style>
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="base-dialog">
|
|
3
|
+
<el-dialog
|
|
4
|
+
:class="dialogClass"
|
|
5
|
+
v-el-drag-dialog="dragDialog"
|
|
6
|
+
:type="type"
|
|
7
|
+
:width="width"
|
|
8
|
+
:custom-class="customClass"
|
|
9
|
+
:fullscreen="fullscreen"
|
|
10
|
+
:title="title"
|
|
11
|
+
:close-on-click-modal="closeOnClickModal"
|
|
12
|
+
:append-to-body="appendToBody"
|
|
13
|
+
:visible.sync="visible"
|
|
14
|
+
:before-close="beforeClose"
|
|
15
|
+
:show-close="showClose"
|
|
16
|
+
v-if="visible"
|
|
17
|
+
@closed="closed"
|
|
18
|
+
@close="closeMethod"
|
|
19
|
+
:destroy-on-close="destroyOnClose"
|
|
20
|
+
:modal='modal'
|
|
21
|
+
>
|
|
22
|
+
<slot name="body" />
|
|
23
|
+
<div v-if="footer" slot="footer" class="dialog-footer">
|
|
24
|
+
<slot name="footer" />
|
|
25
|
+
</div>
|
|
26
|
+
</el-dialog>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import elDragDialog from "@/directive/el-drag-dialog"; // 引入拖拽指令
|
|
32
|
+
export default {
|
|
33
|
+
name: "mec-dialog",
|
|
34
|
+
directives: { elDragDialog },
|
|
35
|
+
props: {
|
|
36
|
+
appendToBody: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false,
|
|
39
|
+
}, // 是否嵌套
|
|
40
|
+
closeOnClickModal: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false,
|
|
43
|
+
}, // 是否可以点击关闭
|
|
44
|
+
footer: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true,
|
|
47
|
+
}, // 是否显示底部
|
|
48
|
+
title: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "",
|
|
51
|
+
}, // 对话框title
|
|
52
|
+
type: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "",
|
|
55
|
+
}, // 对话框类型:1.基础表单[base-dialog-form] 2.表格[base-dialog-table] 3.全屏 [base-dialog-fullscreen]
|
|
56
|
+
width: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "",
|
|
59
|
+
}, // 对话框宽度800px 或 50%
|
|
60
|
+
destroyOnClose: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true,
|
|
63
|
+
},
|
|
64
|
+
beforeClose: Function, // 关闭回调函数
|
|
65
|
+
dialogClass: {
|
|
66
|
+
//class
|
|
67
|
+
type: String,
|
|
68
|
+
default: "",
|
|
69
|
+
},
|
|
70
|
+
// 是否显示叉号
|
|
71
|
+
showClose: {
|
|
72
|
+
default: true,
|
|
73
|
+
type: Boolean
|
|
74
|
+
},
|
|
75
|
+
//是否需要遮罩层
|
|
76
|
+
modal:{
|
|
77
|
+
default: true,
|
|
78
|
+
type: Boolean
|
|
79
|
+
},
|
|
80
|
+
dragDialog: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
data() {
|
|
86
|
+
return {
|
|
87
|
+
visible: false,
|
|
88
|
+
fullscreen: false,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
computed: {
|
|
92
|
+
customClass() {
|
|
93
|
+
let className = "";
|
|
94
|
+
switch (this.type) {
|
|
95
|
+
case "form":
|
|
96
|
+
className = "base-dialog-form";
|
|
97
|
+
break;
|
|
98
|
+
case "table":
|
|
99
|
+
className = "base-dialog-table";
|
|
100
|
+
break;
|
|
101
|
+
case "fullscreen":
|
|
102
|
+
className = "base-dialog-fullscreen";
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
return className;
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
created() {
|
|
109
|
+
this.type === "fullscreen" && (this.fullscreen = true);
|
|
110
|
+
},
|
|
111
|
+
methods: {
|
|
112
|
+
open() {
|
|
113
|
+
this.visible = true;
|
|
114
|
+
},
|
|
115
|
+
close() {
|
|
116
|
+
this.visible = false;
|
|
117
|
+
},
|
|
118
|
+
closed() {
|
|
119
|
+
this.$emit("closed");
|
|
120
|
+
},
|
|
121
|
+
closeMethod() {
|
|
122
|
+
this.$emit("close");
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
</script>
|
|
127
|
+
|
|
128
|
+
<style lang="less" scoped>
|
|
129
|
+
.base-dialog {
|
|
130
|
+
text-align: left;
|
|
131
|
+
}
|
|
132
|
+
.el-dialog__wrapper {
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
display: flex;
|
|
135
|
+
justify-content: center;
|
|
136
|
+
align-items: center;
|
|
137
|
+
.el-dialog {
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
border-radius: 8px;
|
|
141
|
+
margin: 0;
|
|
142
|
+
margin-top: 0 !important;
|
|
143
|
+
.el-dialog__header {
|
|
144
|
+
text-align: left;
|
|
145
|
+
background-color: #efefef;
|
|
146
|
+
height: 48px;
|
|
147
|
+
line-height: 48px;
|
|
148
|
+
padding: 0 20px;
|
|
149
|
+
color: #fff;
|
|
150
|
+
border-top-left-radius: 8px;
|
|
151
|
+
border-top-right-radius: 8px;
|
|
152
|
+
font-weight: bold;
|
|
153
|
+
|
|
154
|
+
.el-dialog__title {
|
|
155
|
+
font-size: 16px;
|
|
156
|
+
// font-weight: bold;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.el-dialog__headerbtn {
|
|
160
|
+
top: 12px;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.el-dialog__body {
|
|
165
|
+
flex: 1;
|
|
166
|
+
overflow: auto;
|
|
167
|
+
padding: 20px;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.el-dialog__footer {
|
|
171
|
+
flex-shrink: 0;
|
|
172
|
+
box-sizing: content-box;
|
|
173
|
+
height: 32px;
|
|
174
|
+
padding: 10px;
|
|
175
|
+
border: none;
|
|
176
|
+
background-color: #efefef;
|
|
177
|
+
border-bottom-left-radius: 8px;
|
|
178
|
+
border-bottom-right-radius: 8px;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.base-dialog-form {
|
|
183
|
+
height: auto;
|
|
184
|
+
|
|
185
|
+
.el-dialog__body {
|
|
186
|
+
padding: 20px 20px 0 20px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.el-dialog__footer {
|
|
190
|
+
height: 32px;
|
|
191
|
+
border: none;
|
|
192
|
+
background-color: #efefef;
|
|
193
|
+
border-bottom-left-radius: 8px;
|
|
194
|
+
border-bottom-right-radius: 8px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.custom-table {
|
|
198
|
+
// 取消表格下边线
|
|
199
|
+
tbody tr:last-child td {
|
|
200
|
+
border-bottom: none !important;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.base-dialog-table {
|
|
206
|
+
height: 90vh;
|
|
207
|
+
margin-top: 5vh !important;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.base-dialog-fullscreen {
|
|
211
|
+
height: 100vh;
|
|
212
|
+
width: 100vw;
|
|
213
|
+
|
|
214
|
+
.el-dialog__body {
|
|
215
|
+
padding: 10px;
|
|
216
|
+
}
|
|
217
|
+
.el-dialog__footer {
|
|
218
|
+
padding: 10px;
|
|
219
|
+
border: none;
|
|
220
|
+
background-color: #efefef;
|
|
221
|
+
border-bottom-left-radius: 8px;
|
|
222
|
+
border-bottom-right-radius: 8px;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<template>
|
|
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="typeof item.displayWith !== 'function' || item.displayWith(formData, item)"
|
|
11
|
+
:span="item.col"
|
|
12
|
+
:style="item.style"
|
|
13
|
+
:key="index"
|
|
14
|
+
>
|
|
15
|
+
<el-form-item v-bind="item" :prop="getProp(item, index)" :rules="item.rules" :class="item.class">
|
|
16
|
+
<template slot="label">
|
|
17
|
+
<span v-if="item.label">
|
|
18
|
+
{{ item.label }}
|
|
19
|
+
<el-tooltip v-if="item.tooltip" class="item" effect="dark" :content="item.tooltip" placement="top">
|
|
20
|
+
<i class="el-icon-question"></i>
|
|
21
|
+
</el-tooltip>
|
|
22
|
+
</span>
|
|
23
|
+
</template>
|
|
24
|
+
<component
|
|
25
|
+
:is="item['componentName']"
|
|
26
|
+
v-model="item.value"
|
|
27
|
+
v-bind="item"
|
|
28
|
+
v-on="item.componentListeners"
|
|
29
|
+
></component>
|
|
30
|
+
</el-form-item>
|
|
31
|
+
</el-col>
|
|
32
|
+
</template>
|
|
33
|
+
</el-form>
|
|
34
|
+
</template>
|
|
35
|
+
<script>
|
|
36
|
+
export default {
|
|
37
|
+
name: 'mec-form',
|
|
38
|
+
props: {
|
|
39
|
+
formData: {
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
labelWidth: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: '150px',
|
|
45
|
+
},
|
|
46
|
+
labelPosition: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: 'right',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
data() {
|
|
52
|
+
return {
|
|
53
|
+
loading: false,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
computed: {},
|
|
57
|
+
methods: {
|
|
58
|
+
getProp(item, index) {
|
|
59
|
+
let propName = item.prop ? item.prop : index + ".value";
|
|
60
|
+
return propName;
|
|
61
|
+
},
|
|
62
|
+
validate() {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
this.$refs.formData.validate(valid => {
|
|
65
|
+
if (valid) {
|
|
66
|
+
resolve(true);
|
|
67
|
+
} else {
|
|
68
|
+
resolve(false);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
</script>
|
|
76
|
+
<style lang="less">
|
|
77
|
+
</style>
|