| | |
| | | <template> |
| | | <div class="updateUser"> |
| | | <header> |
| | | <div class="headerTitle">{{updateFlag ? '修改角色信息' :'查看角色信息'}}</div> |
| | | </header> |
| | | <main> |
| | | <div class="mainContent"> |
| | | <el-form ref="user" label-width="140px" autoComplete="on" :model="role" :rules="createRoleRules" |
| | |
| | | <el-input v-model="role.name" placeholder="请填写角色名称" :disabled="!updateFlag"></el-input> |
| | | </el-form-item> |
| | | <!-- 角色类型 --> |
| | | <el-form-item class="optionItems" label="角色类型:" prop="status"> |
| | | <el-select v-model="role.status" placeholder="请选择角色类型" :disabled="!updateFlag"> |
| | | <el-option v-for="item in typeList" :key="item.name" :label="item.name" :value="item.value" |
| | | :disabled="item.disabled"> |
| | | <el-form-item class="optionItems" label="角色类型:" prop="sort"> |
| | | <!-- <el-input v-model="role.sort" placeholder="请选择角色类型" :disabled="!updateFlag"></el-input> --> |
| | | <el-select v-model="role.sort" placeholder="请选择角色类型"> |
| | | <!-- v-for="item in roleList" :key="item.id" :label="item.departName" |
| | | :value="item.id" --> |
| | | <el-option :value="treeId" :label="treeLabel"> |
| | | <el-tree :data="roleList" :props="defaultProps" @node-click="handleNodeClick"></el-tree> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- 角色描述 --> |
| | | <el-form-item class="optionItem" label="角色描述:" prop="description"> |
| | | <el-input v-model="role.description" placeholder="请输入描述内容200字以内" :disabled="!updateFlag"></el-input> |
| | | <el-input type="textarea" v-model="role.description" placeholder="请输入描述内容200字以内" |
| | | :disabled="!updateFlag"></el-input> |
| | | </el-form-item> |
| | | <el-form-item v-if="updateFlag"> |
| | | <div class="optionBtn"> |
| | | <el-button type="primary" class="btn submit" @click.native.prevent="handleUser">确认</el-button> |
| | | <el-button type="primary" class="btn submit" @click.native.prevent="handleUser">确认 |
| | | </el-button> |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | data() { |
| | | const validateNickname = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写用户名称")); |
| | | callback(new Error("请填写角色名称")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validatePass = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写登录密码")); |
| | | callback(); |
| | | } else { |
| | | const rep = /^\w+$/; |
| | | if (!rep.test(value)) { |
| | | callback(new Error("密码只能是以数字、26个英文字母或者下划线组成的字符串")); |
| | | } |
| | | // const rep = /^\w+$/; |
| | | // if (!rep.test(value)) { |
| | | // callback(new Error("密码只能是以数字、26个英文字母或者下划线组成的字符串")); |
| | | // } |
| | | callback(); |
| | | } |
| | | }; |
| | | const validateTruename = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写用户姓名")); |
| | | if (value) { |
| | | callback(); |
| | | } else { |
| | | const rep = /^[\u4E00-\u9FA5]{2,4}$/; |
| | | if (!rep.test(value)) { |
| | | callback("请输入正确的用户姓名"); |
| | | } |
| | | // const rep = /^[\u4E00-\u9FA5]{2,4}$/; |
| | | // if (!rep.test(value)) { |
| | | // callback("请输入正确的用户姓名"); |
| | | // } |
| | | callback(); |
| | | } |
| | | }; |
| | | return { |
| | | role: { |
| | | id:'', |
| | | name: '', |
| | | status: '', |
| | | sort: '', |
| | | description: '', |
| | | }, |
| | | createRoleRules: { |
| | | name: [ |
| | | { required: true, trigger: "blur", validator: validateNickname }, |
| | | ], |
| | | status: [ |
| | | sort: [ |
| | | { required: false, trigger: "blur", validator: validatePass }, |
| | | ], |
| | | description: [ |
| | | { required: false, trigger: "blur", validator: validateTruename }, |
| | | ], |
| | | }, |
| | | roleList: [ |
| | | { name: '角色1', value: 1 }, { name: '角色2', value: 2 } |
| | | ], |
| | | typeList: [] |
| | | roleList: [], |
| | | defaultProps: { |
| | | children: 'children', |
| | | label: 'title' |
| | | }, |
| | | treeLabel:'', |
| | | treeId:23 |
| | | } |
| | | }, |
| | | created() { |
| | | const that = this; |
| | | this.userInfo.status ? this.userInfo.status = 1: this.userInfo.status = 0; |
| | | this.userInfo.status ? this.userInfo.status = 1 : this.userInfo.status = 0; |
| | | this.role = JSON.parse(JSON.stringify(that.userInfo)); |
| | | // 获取角色列表 |
| | | // this.$axios.get('') |
| | | // 获取用户类型列表 |
| | | // this.$axios.get('sccg/admin/list',{userType:0}).then(res=>{ |
| | | // console.log(res); |
| | | // }) |
| | | // 获取全部部门列表 |
| | | this.$axios.get('sccg/depart/page').then(res => { |
| | | that.typeList = res.data.records; |
| | | }) |
| | | this.getMenuList(); |
| | | }, |
| | | methods: { |
| | | handleUser() { |
| | | const { role } = this; |
| | | this.$axios.post('/sccg/role/update/'+role.id, { |
| | | id:role.id, |
| | | status: role.status, |
| | | description:role.description, |
| | | name:role.name |
| | | }).then(res => { |
| | | this.$emit('changeDialog',{dialogUpdate:false}); |
| | | this.getUserList(); |
| | | this.$refs.user.validate((valid) => { |
| | | if (valid) { |
| | | const { role } = this; |
| | | console.log(role); |
| | | this.$axios.post('/sccg/role/update/' + role.id, { |
| | | id: role.id, |
| | | status: role.status, |
| | | description: role.description, |
| | | name: role.name, |
| | | sort: 0 |
| | | }).then(res => { |
| | | this.$emit('changeDialog', { dialogUpdate: false }); |
| | | this.getUserList(); |
| | | }) |
| | | } else { |
| | | return false; |
| | | } |
| | | }) |
| | | }, |
| | | // 获取系统菜单 |
| | | getMenuList() { |
| | | this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/menu/treeList', |
| | | }) |
| | | .then(res => { |
| | | this.roleList = res.data; |
| | | console.log(res); |
| | | }) |
| | | }, |
| | | // 点击树节点 |
| | | handleNodeClick({title,id}) { |
| | | // console.log(obj); |
| | | this.role.sort = title; |
| | | this.treeLabel = title; |
| | | this.treeId = id; |
| | | |
| | | } |
| | | }, |
| | | props: ['userInfo', 'updateFlag','getUserList','changeDialog'] |
| | | props: ['userInfo', 'updateFlag', 'getUserList', 'changeDialog'] |
| | | } |
| | | </script> |
| | | <style lang="scss" scoped> |
| | |
| | | border-radius: 1px; |
| | | background-color: #09152f; |
| | | |
| | | header { |
| | | display: flex; |
| | | justify-content: center; |
| | | height: 60px; |
| | | line-height: 60px; |
| | | padding: 0 20px; |
| | | border: 1px solid #fff; |
| | | .headerTitle { |
| | | color: #4b9bb7; |
| | | font-weight: 600; |
| | | } |
| | | |
| | | .headerTip span { |
| | | color: #ff3b6c; |
| | | } |
| | | |
| | | .headerTip label { |
| | | color: #4b9bb7; |
| | | } |
| | | } |
| | | |
| | | main { |
| | | border: 1px solid #fff; |
| | | // border: 1px solid #fff; |
| | | text-align: left; |
| | | padding: 0 55px; |
| | | background-color: #09152f; |
| | | padding-bottom: 50px; |
| | | |
| | | .mainContent { |
| | | display: flex; |
| | | justify-content: center; |
| | | margin-top: 50px ; |
| | | padding-top: 50px; |
| | | |
| | | .el-form-item__content { |
| | | width: 400px; |
| | | |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | &::v-deep .el-textarea__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | } |
| | | |
| | | ::v-deep .el-form-item__label { |
| | | color: #4b9bb7; |
| | | } |
| | | |
| | | ::v-deep .el-input__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | } |
| | | } |
| | | |
| | | .updateUser::v-deep .el-form-item__label { |
| | | color: #4b9bb7; |
| | | } |
| | | |
| | | .updateUser::v-deep .el-input__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | } |
| | | </style> |