<template>
|
<zt-dialog ref="dialog" title="用户注册" @confirm="formSubmit" column="1" append-to-body>
|
<el-form :model="dataForm" ref="dataForm" :rules="dataRule" label-width="120px">
|
<zt-form-item prop="userName" :label="$t('user.username')" rules="required">
|
<el-input v-model="dataForm.userName" :placeholder="$t('user.username')"></el-input>
|
</zt-form-item>
|
<zt-form-item prop="nickName" :label="$t('user.realName')" rules="required">
|
<el-input v-model="dataForm.nickName" :placeholder="$t('user.realName')"></el-input>
|
</zt-form-item>
|
|
<zt-form-item prop="password" label="密码" rules="required">
|
<el-input v-model="dataForm.password" type="password" :placeholder="密码"></el-input>
|
</zt-form-item>
|
<zt-form-item prop="confirmPassword" label="确认密码" rules="required">
|
<el-input v-model="dataForm.confirmPassword" type="password" :placeholder="确认密码"></el-input>
|
</zt-form-item>
|
|
<zt-form-item prop="deptId" :label="$t('user.deptName')" rules="required">
|
<zt-combo-tree v-model="dataForm.deptId" :datas="deptList" @select="onDeptSelect"/>
|
</zt-form-item>
|
<!-- <zt-form-item prop="userCode" :label="$t('user.userCode')">-->
|
<!-- <el-input v-model="dataForm.userCode" :placeholder="$t('user.userCode')"></el-input>-->
|
<!-- </zt-form-item>-->
|
<!--
|
<zt-form-item prop="jobIdList" :label="$t('user.jobIdList')" class="role-list">
|
<zt-combo-tree v-model="dataForm.jobIdList" :datas="jobList" multiple :check-strictly="true"/>
|
</zt-form-item>
|
<zt-form-item prop="postIdList" :label="$t('user.postIdList')" class="role-list">
|
<zt-select v-model="dataForm.postIdList" :datas="postList" multiple :placeholder="$t('user.setPost')"></zt-select>
|
</zt-form-item>
|
-->
|
<zt-form-item prop="teamgroupIds" label="所属专业" class="role-list">
|
<team-group-selector v-model="dataForm.teamgroupIds" multiple leafOnly placeholder="所属专业"/>
|
</zt-form-item>
|
<zt-form-item prop="shipIds" v-if="true" :label="'负责'+keyword" class="role-list">
|
<local-ship-selector v-model="dataForm.shipIds" multiple :placeholder="'负责'+keyword"/>
|
</zt-form-item>
|
</el-form>
|
</zt-dialog>
|
</template>
|
|
<script>
|
|
export default {
|
data() {
|
return {
|
activeNames: ['1', '2'],
|
postList: [],
|
jobList: [],
|
deptList: [],
|
dataForm: {
|
userType: '0',
|
userName: '',
|
deptId: '',
|
deptName: '',
|
nickName: '',
|
// sex: 0,
|
// email: '',
|
// phonenumber: '',
|
password: '',
|
confirmPassword: '',
|
delFlag: 0,
|
tenantId: '1271368584383188993',
|
id: '10',
|
// createBy: '10',
|
// updateBy: '10',
|
passerror: 0,
|
teamgroupIds:'',
|
shipIds: '',
|
|
status: 0,
|
}
|
}
|
},
|
|
computed: {
|
keyword() {
|
return this.$store.state.word.jian || '';
|
},
|
dataRule() {
|
var validateConfirmPassword = (rule, value, callback) => {
|
if (this.dataForm.password !== value) {
|
return callback(new Error(this.$t('updatePassword.validate.confirmPassword')))
|
}
|
callback()
|
}
|
return {
|
password: [
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'}
|
],
|
confirmPassword: [
|
{required: true, message: this.$t('validate.required'), trigger: 'blur'},
|
{validator: validateConfirmPassword, trigger: 'blur'}
|
]
|
}
|
}
|
},
|
methods: {
|
init() {
|
console.log('init start')
|
this.getDeptList()
|
},
|
// 获取部门列表
|
async getDeptList() {
|
let res = await this.$http.get('/sys/dept/treeRegister')
|
console.log(res,'getDeptList')
|
if (res.success) {
|
this.deptList = res.data
|
}
|
},
|
// 获取岗位列表
|
async getPostList(deptId) {
|
let res = await this.$http.get('/sys/post/list?deptId=' + deptId)
|
if (res.success) {
|
this.postList = res.data
|
}
|
},
|
// 获取职位列表
|
async getJobList(companyId) {
|
let res = await this.$http.get('/sys/job/tree?companyId=' + companyId)
|
if (res.success) {
|
this.jobList = res.data
|
}
|
},
|
// 获取信息
|
async getInfo() {
|
// let res = await this.$http.get(`/sys/user/${this.dataForm.id}`)
|
// if (res.success) {
|
// this.dataForm = {
|
// ...this.dataForm,
|
// ...res.data
|
// }
|
// }
|
},
|
onDeptSelect(data, isChange) {
|
/*
|
if (data) {
|
this.getJobList(data.companyId)
|
this.getPostList(data.id)
|
} else {
|
this.jobIdList = []
|
this.postIdList = []
|
}
|
if (isChange) {
|
this.dataForm.jobIdList = []
|
this.dataForm.postIdList = []
|
}
|
*/
|
},
|
// 表单提交
|
async formSubmit() {
|
//this.dataForm.companyId = this.companyId
|
this.$refs.dataForm.validate((valid) => {
|
if (!valid) {
|
this.$alert('输入错误', '提示', {
|
confirmButtonText: '确定'
|
})
|
return false
|
}
|
})
|
if (this.dataForm.password !== this.dataForm.confirmPassword) {
|
this.$alert('密码输入不一致', '提示', {
|
confirmButtonText: '确定'
|
})
|
return false
|
}
|
|
|
//let res = await this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/userReg/test', this.dataForm)
|
|
console.log(this.dataForm, 'this.dataForm')
|
let res = await this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/userRegister', this.dataForm)
|
console.log(res, 'userReg')
|
if (res.success) {
|
if (res.data === 'OK') {
|
this.$alert('注册成功,等待管理员审核!', '提示', {
|
confirmButtonText: '确定'
|
})
|
//await this.$tip.success()
|
this.$refs.dialog.close()
|
this.$emit('refreshDataList')
|
}
|
else{
|
this.$alert(res.data , '提示', {
|
confirmButtonText: '确定'
|
})
|
}
|
}
|
}
|
}
|
}
|
</script>
|
|
// <style lang="scss">
|
// .mod-sys__user {
|
// .role-list {
|
// .el-select {
|
// width: 100%;
|
// }
|
// }
|
// }
|
|
// .avatar-uploader .el-upload {
|
// border: 1px dashed #d9d9d9;
|
// border-radius: 6px;
|
// cursor: pointer;
|
// position: relative;
|
// overflow: hidden;
|
// }
|
|
// .avatar-uploader .el-upload:hover {
|
// border-color: #409EFF;
|
// }
|
|
// .avatar-uploader-icon {
|
// font-size: 2.8px;
|
// color: #8c939d;
|
// width: 27.8px;
|
// height: 27.8px;
|
// line-height: 27.8px;
|
// text-align: center;
|
// }
|
|
// .avatar {
|
// width: 27.8px;
|
// height: 27.8px;
|
// display: block;
|
// }
|
// </style>
|