-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathu-form.vue
98 lines (89 loc) · 2.06 KB
/
u-form.vue
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
<template>
<div class="u-form">
<!-- 标题区 -->
<slot name="head">
<div v-if="title" class="title">
<slot name="title">{{ title }}</slot>
</div>
</slot>
<!-- 内容区 -->
<div class="u-form-body"><slot></slot></div>
<!-- 操作区 -->
<slot name="foot">
<div class="u-form-foot u-form-ops" v-if="okButton || cancelButton">
<u-button v-if="cancelButton" @click="$emit('cancel')">{{ cancelButton }}</u-button>
<u-button v-if="okButton" @click="$emit('save')" type="primary">{{
okButton
}}</u-button>
</div>
</slot>
</div>
</template>
<script>
export default {
name: 'u-form',
props: {
title: String,
labelWidth: String,
contentWidth: String,
okButton: { type: String, default: '确定' },
cancelButton: { type: String, default: '取消' }
},
provide() {
return {
uForm: this
}
}
}
</script>
<style lang="scss" scoped>
$margin-l: 32px;
$margin-m: 16px;
$margin-s: 8px;
.u-form {
width: 100%;
height: 100%;
.title {
font-size: 18px;
font-weight: bold;
margin-bottom: 40px;
}
&-row {
margin-bottom: $margin-m;
position: relative;
}
&-ops {
margin-top: 30px;
padding-top: $margin-l;
text-align: center;
.u-button {
margin: 0 10px;
vertical-align: middle;
}
}
&-label {
display: inline-block;
width: 20%;
text-align: right;
margin-right: $margin-s;
vertical-align: top;
line-height: 36px;
}
&-value {
display: inline-block;
width: 70%;
text-align: left;
min-height: 36px;
}
&-tip {
font-size: 12px;
color: #888;
}
&-error {
font-size: 12px;
color: $danger-color;
position: absolute;
bottom: -20px;
}
}
</style>