other.vue
4.82 KB
1
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
40
41
42
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<style>
.custom-form {
background: #cfc;
}
.custom-title {
background: #ccf;
}
.custom-content {
background: #fcc;
}
</style>
<template>
<div>
<pre>{{ model }}</pre>
<eg-table :value="[this.model]" :list="option.list" :tableProps="{ border: true }">
<el-table-column type="selection"></el-table-column>
<template #value-location-locationMin="{ value }">
<el-tag size="mini">{{ value }}</el-tag>
</template>
<template #value-location-district-province="{ value }">
<el-tag type="success" size="mini">{{ value }}</el-tag>
</template>
<template #location-district-city>
<el-table-column label="城市测试" prop="location-district-city">
<el-tag type="danger" size="mini" slot-scope="{ row: { location: { district: { city } = {} } = {} } }">{{ city }}</el-tag>
</el-table-column>
</template>
</eg-table>
<!-- <p>这是一个非markdown页面</p>
<pre>{{ model }}</pre>
<el-button size="mini" @click="handleGetValue">校验</el-button>
<eg-form ref="form" v-model="model" :list="option.list" @validate="onValidate" label-width="80px" :span="6" type="div"></eg-form> -->
<eg-form
ref="form" v-model="model" :list="option.list" @validate="onValidate" :span="4"
form-class="custom-form" title-class="custom-title" content-class="custom-content" item-class="custom-item"
></eg-form>
</div>
</template>
<script>
import EgForm from './form-new';
import EgTable from './table-new';
export default {
name: 'other',
components: { EgForm, EgTable },
data() {
return {
model: {
name: 'name',
location: {
areaName: 'hahhhahaa',
},
},
option: {
list: [
{
group: { title: '基础信息', span: 12 },
list: [
{ type: 'el-input', label: '名称', key: 'name' },
{ type: 'el-input-number', label: '年龄', key: 'age' },
],
},
{
group: { title: '', span: 12 },
},
{
group: { title: '住址', key: 'location', span: 24 },
list: [
{ type: 'el-input', label: '地址简称', key: 'locationMin' },
{
group: { key: 'district' },
list: [
{ type: 'el-input', label: '省', key: 'province', rules: [{ required: true, message: '请输入省' }] },
{ type: 'el-input', label: '市', key: 'city' },
],
},
{
group: { title: '小区信息' },
list: [
{ type: 'el-input', label: '小区名', key: 'areaName' },
{ type: 'el-input', label: '门牌号', key: 'homeNum' },
{
group: { title: 'A栋' },
list: [
{ type: 'el-input-number', label: '人数', key: 'anumber',
props: { 'controls-position': 'right' },
on: {
change(value) {
console.log(value);
}
}
},
],
},
{
group: { title: 'B栋', key: 'bside' },
list: [
{ type: 'el-input-number', label: '人数', key: 'bnumber',
on({ model, update }) {
return {
change(value) {
if (value === 18 && model.age === 18) {
console.log(model)
update({ 'location.areaName': 'hehe', name: 'aaa', 'text.0': 'abc', 'ttt.0': 'abc' });
}
}
}
}
},
],
}
],
}
],
},
{ type: 'el-input', label: '身高', key: 'height', props: { type: 'textarea', min: 3 }, style: { width: '100%' }, span: 24 },
{ type: 'el-input', label: '体重', key: 'weight' },
]
}
}
},
mounted() {
setTimeout(() => {
this.model = {
age: 7,
name: '1',
location: {
locationMin: 'a',
district: {
province: 'p',
city: 'c'
},
areaName: 'a',
homeNum: 'n',
anumber: '1',
bside: {
bnumber: '2'
}
},
height: '3',
weight: '4'
}
}, 3000);
},
methods: {
onValidate(isValidated, model) {
console.log(isValidated, model);
},
handleGetValue() {
this.$refs.form.validate();
}
}
}
</script>