| | |
| | | <div class="mainContent"> |
| | | <el-form ref="user" label-width="140px" autoComplete="on" :model="user" :rules="createUserRules" |
| | | label-position="right"> |
| | | <!-- 用户名称 --> |
| | | <!-- 用户名称 |
| | | <el-form-item class="optionItem" label="用户名称:" prop="nickName"> |
| | | <el-input v-model="user.nickName" placeholder="填写用户名称"></el-input> |
| | | </el-form-item> |
| | | </el-form-item> --> |
| | | <!-- 用户密码 --> |
| | | <el-form-item class="optionItems" label="用户密码:" prop="password"> |
| | | <el-input v-model="user.password" type="password" placeholder="请输入用户密码"></el-input> |
| | |
| | | <el-input v-model="user.username" placeholder="请填写用户姓名"></el-input> |
| | | </el-form-item> |
| | | <!-- 性别 --> |
| | | <!-- <el-form-item class="optionItem" label="性别:" prop="gender"> |
| | | <el-radio-group v-model="user.gender"> |
| | | <el-form-item class="optionItem" label="性别:" prop="sex"> |
| | | <el-radio-group v-model="user.sex"> |
| | | <el-radio :label="1">男</el-radio> |
| | | <el-radio :label="2">女</el-radio> |
| | | <el-radio :label="0">女</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> --> |
| | | </el-form-item> |
| | | <!-- 是否党员 --> |
| | | <el-form-item class="optionItem" label="是否党员:" prop="isDy"> |
| | | <el-radio-group v-model="user.isDy"> |
| | |
| | | </el-form-item> |
| | | <!-- 所属部门 --> |
| | | <el-form-item class="optionItem" label="所属部门:" prop="departmentId"> |
| | | <el-select v-model="user.departmentId" placeholder="请选择所属部门"> |
| | | <el-select v-model="user.departmentId" placeholder="请选择所属部门" @change="getDepartName"> |
| | | <el-option v-for="item in departList" :key="item.name" :label="item.departName" |
| | | :value="item.id"> |
| | | </el-option> |
| | |
| | | <div class="optionBtn"> |
| | | <el-button type="primary" class="btn submit" @click.native.prevent="handleUser">提交 |
| | | </el-button> |
| | | <el-button class="btn reset">重置</el-button> |
| | | <el-button class="btn reset" @click.native.prevent="resetForm">重置</el-button> |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | <script> |
| | | export default { |
| | | data() { |
| | | const validateNickname = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("用户名称不能为空")); |
| | | }else{ |
| | | callback(); |
| | | } |
| | | }; |
| | | // const validateNickname = (rule, value, callback) => { |
| | | // if (!value) { |
| | | // callback(new Error("用户名称不能为空")); |
| | | // }else{ |
| | | // callback(); |
| | | // } |
| | | // }; |
| | | const validatePass = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("用户密码不能为空")); |
| | |
| | | // }; |
| | | return { |
| | | user: { |
| | | nickName: '', |
| | | // nickName: '', |
| | | password: '', |
| | | username: '', |
| | | gender: 1, |
| | | sex: 1, |
| | | isDy: 0, |
| | | mobile: '', |
| | | email: '', |
| | |
| | | ip: '', |
| | | }, |
| | | createUserRules: { |
| | | nickName: [ |
| | | { required: true, trigger: "blur", validator: validateNickname }, |
| | | ], |
| | | // nickName: [ |
| | | // { required: true, trigger: "blur", validator: validateNickname }, |
| | | // ], |
| | | password: [ |
| | | { required: true, trigger: "blur", validator: validatePass }, |
| | | ], |
| | | username: [ |
| | | { required: true, trigger: "blur", validator: validateTruename }, |
| | | ], |
| | | gender: [ |
| | | sex: [ |
| | | { required: true, trigger: "blur" }, |
| | | ], |
| | | isDy: [ |
| | |
| | | }) |
| | | }, |
| | | methods: { |
| | | // 提交注册 |
| | | handleUser() { |
| | | this.$refs['user'].validate((valid) => { |
| | | console.log(valid); |
| | |
| | | jsDy: user.isDy, |
| | | jobTitle: user.jobTitle, |
| | | mobile: user.mobile, |
| | | nickName: user.nickName, |
| | | // nickName: user.nickName, |
| | | password: user.password, |
| | | userType: user.userType, |
| | | username: user.username, |
| | | departName:user.departName, |
| | | }).then(res => { |
| | | if (res.code === 200) { |
| | | console.log(1); |
| | | this.$message({ |
| | | type:'success', |
| | | message:res.message, |
| | | }) |
| | | this.$emit('sendDialog', { flag: false }); |
| | | }else if(res.code === 500 && res.message === "操作失败"){ |
| | | this.$message({ |
| | | type:'warning', |
| | | message:'该用户已注册' |
| | | }) |
| | | } |
| | | }) |
| | | }else{ |
| | |
| | | .then(res => { |
| | | this.roleList = res.data; |
| | | }) |
| | | }, |
| | | // 重置表单 |
| | | resetForm(){ |
| | | this.$refs['user'].resetFields(); |
| | | }, |
| | | // 获得部门名称 |
| | | getDepartName(data){ |
| | | this.departList.forEach(item=>{ |
| | | if(item.id === data){ |
| | | this.user.departName = item.departName |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | props: ['sendDialog'] |