| | |
| | | <template> |
| | | <div class="updateUser"> |
| | | <!-- <header> |
| | | <div class="updateUser"> |
| | | <!-- <header> |
| | | <div class="headerTitle">{{updateFlag ? '修改用户部门信息' :'查看用户信息'}}</div> |
| | | </header> --> |
| | | <main> |
| | | <div class="mainContent"> |
| | | <el-form ref="user" label-width="140px" autoComplete="on" :model="user" :rules="createUserRules" |
| | | label-position="right"> |
| | | <!-- 部门id |
| | | <main> |
| | | <div class="mainContent"> |
| | | <el-form |
| | | ref="user" |
| | | label-width="140px" |
| | | autoComplete="on" |
| | | :model="user" |
| | | :rules="createUserRules" |
| | | label-position="right" |
| | | > |
| | | <!-- 部门id |
| | | <el-form-item class="optionItem" label="部门id:" prop="id"> |
| | | <el-input v-model="user.id" placeholder="请输入部门名称" :disabled="!updateFlag"></el-input> |
| | | </el-form-item> --> |
| | | <!-- 部门名称 --> |
| | | <el-form-item class="optionItem" label="部门名称:" prop="departName"> |
| | | <el-input v-model="user.departName" placeholder="请输入部门名称" :disabled="!updateFlag"></el-input> |
| | | </el-form-item> |
| | | <!-- 上级部门 --> |
| | | <el-form-item class="optionItems" label="上级部门:" prop="parentId"> |
| | | <el-select v-model="user.parentId" placeholder="请选择上级部门" disabled> |
| | | <el-option v-for="item in departList" :key="item.departName" :label="item.departName" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- 部门类型 --> |
| | | <el-form-item class="optionItem" label="部门类型:" prop="departType"> |
| | | <el-select v-model="user.departType" placeholder="请选择部门类型" :disabled="!updateFlag"> |
| | | <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- 部门描述 --> |
| | | <el-form-item class="optionItem" label="部门描述:" prop="departDes"> |
| | | <el-input v-model="user.departDes" placeholder="请输入部门描述" :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> |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <!-- 部门名称 --> |
| | | <el-form-item class="optionItem" label="部门名称:" prop="departName"> |
| | | <el-input |
| | | v-model="user.departName" |
| | | placeholder="请输入部门名称" |
| | | :disabled="!updateFlag" |
| | | ></el-input> |
| | | </el-form-item> |
| | | <!-- 上级部门 --> |
| | | <el-form-item class="optionItems" label="上级部门:" prop="parentId"> |
| | | <el-select v-model="user.parentId" placeholder="请选择上级部门"> |
| | | <el-option |
| | | v-for="item in departList" |
| | | :key="item.departName" |
| | | :label="item.departName" |
| | | :value="item.id" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- 部门类型 --> |
| | | <el-form-item class="optionItem" label="部门类型:" prop="departType"> |
| | | <el-select |
| | | v-model="user.departType" |
| | | placeholder="请选择部门类型" |
| | | :disabled="!updateFlag" |
| | | > |
| | | <el-option |
| | | v-for="item in typeList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!--添加人员 --> |
| | | <el-form-item class="optionItem add" label="添加人员:"> |
| | | <ul class="addPerson"> |
| | | <li |
| | | v-for="(item, index) in checkedList" |
| | | :key="index" |
| | | @click="setLeader(index)" |
| | | > |
| | | <div class="li-item"> |
| | | <div class="li-icon"> |
| | | <i |
| | | :class="[ |
| | | 'el-icon-user-solid', |
| | | item.leader ? 'leader' : '', |
| | | ]" |
| | | ></i> |
| | | </div> |
| | | <label |
| | | style="font-size: 12px" |
| | | :class="[item.leader ? 'leader' : '']" |
| | | >{{ item.username }}</label |
| | | > |
| | | </div> |
| | | </li> |
| | | <li class="li-btn" v-if="updateFlag"> |
| | | <i class="el-icon-plus" @click="openUser = true"></i> |
| | | </li> |
| | | </ul> |
| | | <div class="card" v-if="openUser"> |
| | | <el-card class="box-card"> |
| | | <div slot="header" class="myclear"> |
| | | <span>工作人员</span> |
| | | <div @click="addUser">确认</div> |
| | | </div> |
| | | <div class="scrollWrap"> |
| | | <el-checkbox-group v-model="checkedUser"> |
| | | <el-checkbox |
| | | v-for="user in userList" |
| | | :label="user.id" |
| | | :key="user.id" |
| | | > |
| | | {{ user.username }} |
| | | </el-checkbox> |
| | | </el-checkbox-group> |
| | | </div> |
| | | <div class="hidebar"></div> |
| | | </el-card> |
| | | </div> |
| | | </main> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item style="margin-top: -40px"> |
| | | <label style="color: #ff0000ab" |
| | | >红色代表部门领导,点击头像可设置部门领导</label |
| | | > |
| | | </el-form-item> |
| | | <!-- 部门描述 --> |
| | | <el-form-item class="optionItem" label="部门描述:" prop="departDes"> |
| | | <el-input |
| | | type="textarea" |
| | | :rows="4" |
| | | v-model="user.departDes" |
| | | placeholder="请输入部门描述" |
| | | :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> |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | </main> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import {getTypeList} from '@/utils/helper' |
| | | import { getTypeList } from "@/utils/helper"; |
| | | export default { |
| | | data() { |
| | | const validateNickname = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写部门名称")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validateId = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写部门id")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | } |
| | | const validatePass = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(); |
| | | } else { |
| | | callback(); |
| | | // const rep = /^\w+$/; |
| | | // if (!rep.test(value)) { |
| | | // callback(new Error("密码只能是以数字、26个英文字母或者下划线组成的字符串")); |
| | | // } |
| | | } |
| | | }; |
| | | const validatePhone = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(); |
| | | } else { |
| | | callback(); |
| | | // const rep = /(^1[3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/ |
| | | // if (!rep.test(value)) { |
| | | // callback("请输入正确的手机号码"); |
| | | // } |
| | | } |
| | | }; |
| | | return { |
| | | user: { |
| | | id: '', |
| | | departName: '', |
| | | parentId: '', |
| | | departDes: '', |
| | | departType: '', |
| | | }, |
| | | createUserRules: { |
| | | id: [ |
| | | { required: true, trigger: "blur", validator: validateId }, |
| | | ], |
| | | departName: [ |
| | | { required: true, trigger: "blur", validator: validateNickname }, |
| | | ], |
| | | parentId: [ |
| | | { required: false, trigger: "blur", validator: validatePass }, |
| | | ], |
| | | departDes: [ |
| | | { required: false, trigger: "blur" }, |
| | | ], |
| | | departType: [ |
| | | { required: false, trigger: "blur" }, |
| | | ], |
| | | }, |
| | | departList: [ |
| | | |
| | | ], |
| | | typeList: [] |
| | | } |
| | | }, |
| | | created() { |
| | | const that = this; |
| | | this.user = JSON.parse(JSON.stringify(that.userInfo)); |
| | | this.$axios.get('sccg/depart/page').then(res => { |
| | | that.departList = res.data.records; |
| | | }); |
| | | // 获取部门类型 |
| | | this.getDepartType(); |
| | | }, |
| | | methods: { |
| | | handleUser() { |
| | | this.$refs['user'].validate((valid) => { |
| | | if (valid) { |
| | | const { user } = this; |
| | | console.log(user) |
| | | this.$axios.post('sccg/depart/update', { |
| | | id: user.id, |
| | | departName: user.departName, |
| | | parentId: user.parentId, |
| | | departDes: user.departDes |
| | | }).then(res => { |
| | | console.log(res); |
| | | this.$message({ |
| | | message:res.message, |
| | | type:res.code === 200 ? 'success' : 'warning', |
| | | }) |
| | | this.$emit('changeDialog', { flag: false }); |
| | | this.getUserList(); |
| | | }) |
| | | } else { |
| | | return false; |
| | | } |
| | | data() { |
| | | const validateNickname = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写部门名称")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validateId = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写部门id")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validatePass = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(); |
| | | } else { |
| | | callback(); |
| | | // const rep = /^\w+$/; |
| | | // if (!rep.test(value)) { |
| | | // callback(new Error("密码只能是以数字、26个英文字母或者下划线组成的字符串")); |
| | | // } |
| | | } |
| | | }; |
| | | const validatePhone = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(); |
| | | } else { |
| | | callback(); |
| | | // const rep = /(^1[3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/ |
| | | // if (!rep.test(value)) { |
| | | // callback("请输入正确的手机号码"); |
| | | // } |
| | | } |
| | | }; |
| | | return { |
| | | user: { |
| | | id: "", |
| | | departName: "", |
| | | parentId: "", |
| | | departDes: "", |
| | | departType: "", |
| | | }, |
| | | createUserRules: { |
| | | id: [{ required: true, trigger: "blur", validator: validateId }], |
| | | departName: [ |
| | | { required: true, trigger: "blur", validator: validateNickname }, |
| | | ], |
| | | parentId: [ |
| | | { required: false, trigger: "blur", validator: validatePass }, |
| | | ], |
| | | departDes: [{ required: false, trigger: "blur" }], |
| | | departType: [{ required: false, trigger: "blur" }], |
| | | }, |
| | | userList: [], |
| | | departList: [], |
| | | typeList: [], |
| | | checkedUser: [], |
| | | checkedList: [], |
| | | openUser: false, |
| | | }; |
| | | }, |
| | | created() { |
| | | const that = this; |
| | | this.user = JSON.parse(JSON.stringify(that.userInfo)); |
| | | this.checkedList = this.checkedUser = this.user.userInfoDTOS; |
| | | this.$axios({ |
| | | method: "get", |
| | | url: "sccg/depart/tree", |
| | | }).then((res) => { |
| | | that.departList = res.data; |
| | | }); |
| | | this.getUserList(); |
| | | // 获取部门类型 |
| | | this.getDepartType(); |
| | | }, |
| | | methods: { |
| | | handleUser() { |
| | | this.$refs["user"].validate((valid) => { |
| | | if (valid) { |
| | | const { user } = this; |
| | | console.log(user); |
| | | this.$axios |
| | | .post("sccg/depart/update", { |
| | | id: user.id, |
| | | departName: user.departName, |
| | | parentId: user.parentId, |
| | | departDes: user.departDes, |
| | | }) |
| | | }, |
| | | // 获取部门类型 |
| | | async getDepartType(){ |
| | | this.typeList = await getTypeList(1,'08') |
| | | .then((res) => { |
| | | console.log(res); |
| | | this.$message({ |
| | | message: res.message, |
| | | type: res.code === 200 ? "success" : "warning", |
| | | }); |
| | | this.$emit("changeDialog", { flag: false }); |
| | | this.getUserList(); |
| | | }); |
| | | } else { |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | props: ['userInfo', 'updateFlag', 'getUserList', 'changeDialog'] |
| | | } |
| | | // 获取部门类型 |
| | | async getDepartType() { |
| | | this.typeList = await getTypeList(1, "08"); |
| | | }, |
| | | |
| | | // 设置领导 |
| | | setLeader(idx) { |
| | | this.checkedList.forEach((item, index) => { |
| | | item.leader = index === idx; |
| | | }); |
| | | }, |
| | | |
| | | // 获取所有用户信息 |
| | | getUserList() { |
| | | // 获取所有用户信息、用户查询(暂时支持电话号码) |
| | | this.$axios.get(`sccg/admin/list`).then((res) => { |
| | | if (res.code === 200) { |
| | | this.userList = res.data.records; |
| | | } |
| | | }); |
| | | }, |
| | | addUser() { |
| | | console.log(this.checkedUser); |
| | | console.log(this.userList); |
| | | this.checkedList = []; |
| | | this.userList.forEach((item) => { |
| | | this.checkedUser.forEach((child) => { |
| | | if (item.id == child) { |
| | | this.checkedList.push({ |
| | | id: item.id, |
| | | username: item.username, |
| | | isLeader: 0, |
| | | checked: false, |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | this.checkedList[0].isLeader = 1; |
| | | this.checkedList[0].checked = true; |
| | | this.openUser = false; |
| | | }, |
| | | }, |
| | | props: ["userInfo", "updateFlag", "changeDialog"], |
| | | }; |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | .updateUser { |
| | | border-radius: 1px; |
| | | border-radius: 1px; |
| | | background-color: #09152f; |
| | | |
| | | main { |
| | | // border: 1px solid #fff; |
| | | text-align: left; |
| | | padding: 0 55px; |
| | | background-color: #09152f; |
| | | padding-bottom: 50px; |
| | | |
| | | main { |
| | | // border: 1px solid #fff; |
| | | text-align: left; |
| | | padding: 0 55px; |
| | | background-color: #09152f; |
| | | padding-bottom: 50px; |
| | | // .mainTitle { |
| | | // color: #4b9bb7; |
| | | // font-weight: 600; |
| | | // line-height: 100px; |
| | | // font-size: 14px; |
| | | // } |
| | | |
| | | // .mainTitle { |
| | | // color: #4b9bb7; |
| | | // font-weight: 600; |
| | | // line-height: 100px; |
| | | // font-size: 14px; |
| | | // } |
| | | .mainContent { |
| | | display: flex; |
| | | justify-content: center; |
| | | padding-top: 50px; |
| | | |
| | | .mainContent { |
| | | display: flex; |
| | | justify-content: center; |
| | | padding-top: 50px; |
| | | .el-form-item__content { |
| | | width: 400px; |
| | | |
| | | .el-form-item__content { |
| | | width: 400px; |
| | | |
| | | .el-select { |
| | | width: 100%; |
| | | } |
| | | } |
| | | |
| | | .optionHandleSp { |
| | | display: flex; |
| | | |
| | | .areaNumber, |
| | | .moreNumber { |
| | | flex: 1; |
| | | } |
| | | |
| | | .telNumber { |
| | | flex: 2; |
| | | } |
| | | } |
| | | |
| | | .optionBtn { |
| | | display: flex; |
| | | margin-top: 20px; |
| | | |
| | | .btn { |
| | | padding: 12px 50px; |
| | | } |
| | | } |
| | | |
| | | .el-select { |
| | | width: 100%; |
| | | } |
| | | } |
| | | |
| | | .optionHandleSp { |
| | | display: flex; |
| | | |
| | | .areaNumber, |
| | | .moreNumber { |
| | | flex: 1; |
| | | } |
| | | |
| | | .telNumber { |
| | | flex: 2; |
| | | } |
| | | } |
| | | |
| | | .optionBtn { |
| | | display: flex; |
| | | margin-top: 20px; |
| | | |
| | | .btn { |
| | | padding: 12px 50px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | .updateUser::v-deep .el-form-item__label { |
| | | color: #4b9bb7; |
| | | color: #4b9bb7; |
| | | } |
| | | |
| | | .updateUser::v-deep .el-input__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | } |
| | | |
| | | .addPerson { |
| | | display: flex; |
| | | list-style: none; |
| | | padding: 0; |
| | | flex-wrap: wrap; |
| | | max-width: 280px; |
| | | li { |
| | | color: #fff; |
| | | text-align: center; |
| | | font-size: 30px; |
| | | margin-left: 10px; |
| | | } |
| | | } |
| | | .li-icon { |
| | | background-color: #cccccc; |
| | | width: 36px; |
| | | height: 36px; |
| | | border-radius: 50%; |
| | | margin: 0 auto; |
| | | } |
| | | .li-btn { |
| | | background-color: #cccccc; |
| | | width: 36px; |
| | | height: 36px; |
| | | border-radius: 50%; |
| | | } |
| | | |
| | | .card { |
| | | position: absolute; |
| | | z-index: 2000; |
| | | right: 0; |
| | | |
| | | .box-card { |
| | | max-height: 200px; |
| | | overflow: hidden; |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | position: relative; |
| | | max-width: 220px; |
| | | |
| | | .scrollWrap { |
| | | overflow: scroll; |
| | | height: 160px; |
| | | position: relative; |
| | | color: #4b9bb7; |
| | | |
| | | .el-checkbox-group { |
| | | display: flex; |
| | | flex-direction: column; |
| | | |
| | | .el-checkbox { |
| | | line-height: 20px; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .myclear { |
| | | width: 100%; |
| | | line-height: 20px; |
| | | color: #4b9bb7; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | } |
| | | |
| | | .hidebar { |
| | | position: absolute; |
| | | top: 77px; |
| | | right: 20px; |
| | | width: 20px; |
| | | height: 160px; |
| | | background-color: #09152f; |
| | | } |
| | | |
| | | .item { |
| | | line-height: 40px; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .leader { |
| | | color: red; |
| | | } |
| | | .el-input { |
| | | width: 280px !important; |
| | | } |
| | | </style> |