dialogReg.vue
5.55 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<template>
<el-dialog
center
title="用户注册"
:visible.sync="dialogVisible"
:before-close="handleClose"
width="680px"
:close-on-click-modal="false"
custom-class="reg-dialog"
>
<el-form
ref="regForm"
:model="regForm"
label-width="120px"
class="reg-dialog-form"
:rules="rules"
>
<el-form-item label="用户名:" prop="userName">
<el-input v-model="regForm.userName" requred maxlength="10" clearable placeholder="请输入用户名" :show-word-limit="true"></el-input>
</el-form-item>
<el-form-item label="密码:" prop="password">
<el-input type="password" v-model="regForm.password" placeholder="请输入密码" clearable maxlength="12" :show-word-limit="true" :show-password="true"></el-input>
</el-form-item>
<el-form-item label="确认密码:" prop="confirm">
<el-input type="password" v-model="regForm.confirm" placeholder="请再输入一次密码" clearable maxlength="12" :show-word-limit="true" :show-password="true"></el-input>
</el-form-item>
<el-form-item flex="main:left cross:center"></el-form-item>
</el-form>
<div slot="footer">
<el-button @click="submit" type="primary" :loading="$store.state.d2admin.loading.value" class="button-submit">提交</el-button>
<el-button @click="handleClose" type="plain" class="button-submit">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { Reg } from '@/api/sys.account'
import notice from '@/common/notice'
export default {
name: 'DialogReg',
props: {
isVisible: {
type: Boolean,
default: false
}
},
computed: {
dialogVisible() {
return this.isVisible
}
},
data() {
return {
company: [],
regForm: {
userName: '',
password: '',
confirm: ''
},
rules: Object.freeze({
userName: [
{ required: true, message: '用户名不能为空', trigger: ['blur'] }
],
password: [
{ required: true,
validator: (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入密码'))
} else {
if (this.regForm.confirm !== '') {
this.$refs.regForm.validateField('confirm')
}
callback()
}
},
trigger: 'blur'
}
],
confirm: [
{ required: true,
validator: (rule, value, callback) => {
if (value === '') {
callback(new Error('请再次输入密码'))
} else if (value !== this.regForm.password) {
callback(new Error('两次输入密码不一致!'))
} else {
callback()
}
},
trigger: 'blur'
}
],
// userName: [
// { required: true, message: '姓名不能为空', trigger: ['blur'] }
// ],
mobile: [
{ required: true,
validator: (rule, value, callback) => {
if (value === '') {
callback(new Error('联系方式不能为空'))
} else {
if (/^1\d{10}$/.test(value)) {
callback()
} else {
return callback(new Error('联系方式错误'))
}
}
},
trigger: ['blur'] }
],
companyName: [
{ required: true, message: '所属公司不能为空', trigger: ['blur'] }
],
departName: [
{ required: true, message: '部门不能为空', trigger: ['blur'] }
],
postCode: [
{ required: true, message: '职务不能为空', trigger: ['blur'] }
],
stationCode: [
{ required: true, message: '所属站点不能为空', trigger: ['blur'] }
]
})
}
},
methods: {
handleClose() {
this.$refs.regForm.resetFields()
this.$event.$emit('e-reg-dialog', false)
},
// 提交注册数据
submit() {
this.$refs.regForm.validate(vaild => {
if (vaild) {
var __p = this.regForm
Reg(__p).then(res => {
const { operateStatus } = res
if (operateStatus) {
notice.okTips('注册信息已提交,请等待管理员审核')
this.handleClose()
} else {
notice.errorTips('注册失败!')
}
})
}
})
}
},
mounted() {
}
}
</script>
<style lang="scss">
$login-dialog-lable-width: 90px;
$login-dialog-font: 13px;
.reg-dialog {
background: #fff;
box-shadow: 0 8px 20px 0 rgba(0, 0, 0, 0.06);
border-radius: 9px;
.reg-dialog-form {
width: 600px;
.el-form-item {
margin-bottom: 20px;
.el-input__inner {
height: 35px;
line-height: 35px;
border-radius: 2px;
}
}
}
.el-dialog__title {
font-size: 20px;
color: #333;
}
.el-dialog__body {
display: flex;
justify-content: center;
padding: 25px 25px 0 30px;
.el-form-item__label {
// width: $login-dialog-lable-width !important;
// text-align: right;
font-size: $login-dialog-font;
}
// .el-form-item__content {
// margin-left: $login-dialog-lable-width;
// font-size: $login-dialog-font;
// }
}
.el-dialog__footer {
padding-top:0;
display: flex;
justify-content: flex-end;
// padding: 0 0 38px 0 !important;
}
.sigle-select {
width: 100%;
}
}
</style>