From 797cc9c1a5c90f413d46c5cb88e1ee5e3a84b071 Mon Sep 17 00:00:00 2001
From: “dzb” <2632970487@qq.com>
Date: 星期二, 04 十月 2022 11:51:05 +0800
Subject: [PATCH] 修改用户只能分配单一角色
---
src/views/systemSetting/baseSetting/department/createUser/index.vue | 280 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 185 insertions(+), 95 deletions(-)
diff --git a/src/views/systemSetting/baseSetting/department/createUser/index.vue b/src/views/systemSetting/baseSetting/department/createUser/index.vue
index 82c27d4..26eaf15 100644
--- a/src/views/systemSetting/baseSetting/department/createUser/index.vue
+++ b/src/views/systemSetting/baseSetting/department/createUser/index.vue
@@ -1,11 +1,5 @@
<template>
<div class="createUser">
- <header>
- <div class="headerTitle">鏂板閮ㄩ棬淇℃伅</div>
- <div class="headerTip">
- <label>x</label>
- </div>
- </header>
<main>
<div class="mainContent">
<el-form ref="user" label-width="140px" autoComplete="on" :model="depart" :rules="createDepartRules"
@@ -17,40 +11,52 @@
<!-- 涓婄骇閮ㄩ棬 -->
<el-form-item class="optionItems" label="涓婄骇閮ㄩ棬:" prop="parentId">
<el-select v-model="depart.parentId" placeholder="璇疯緭鍏ヤ笂绾ч儴闂�">
- <el-option v-for="item in typeList" :key="item.name" :label="item.name" :value="item.value"
- :disabled="item.disabled">
+ <el-option v-for="item in departList" :key="item.departName" :label="item.departName"
+ :value="item.id" :disabled="item.disabled">
</el-option>
</el-select>
</el-form-item>
<!-- 閮ㄩ棬绫诲瀷 -->
<el-form-item class="optionItem" label="閮ㄩ棬绫诲瀷:" prop="departType">
- <el-select v-model="depart.departType" placeholder="璇烽�夋嫨閮ㄩ棬绫诲瀷">
- <el-option v-for="item in typeList" :key="item.name" :label="item.name" :value="item.value"
- :disabled="item.disabled">
- </el-option>
- </el-select>
+ <el-input v-model="depart.departType" placeholder="璇烽�夋嫨閮ㄩ棬绫诲瀷"></el-input>
</el-form-item>
<!--娣诲姞浜哄憳 -->
- <el-form-item class="optionItem" label="娣诲姞浜哄憳:">
+ <el-form-item class="optionItem add" label="娣诲姞浜哄憳:">
<ul class="addPerson">
<li><i class="el-icon-user-solid"></i></li>
<li><i class="el-icon-user-solid"></i></li>
<li><i class="el-icon-user-solid"></i></li>
- <li><i class="el-icon-plus"></i></li>
+ <li><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 :max="3" v-model="checkedUser" @change="handleCheckedUserChange">
+ <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>
</el-form-item>
<!-- 閮ㄩ棬鎻忚堪 -->
<el-form-item class="optionItem" label="閮ㄩ棬鎻忚堪:" prop="departDes">
- <el-input v-model="depart.departDes" placeholder="璇疯緭鍏ラ儴闂ㄦ弿杩�"></el-input>
+ <el-input type="textarea" v-model="depart.departDes" placeholder="璇疯緭鍏ラ儴闂ㄦ弿杩�"></el-input>
</el-form-item>
</el-form>
</div>
</main>
<footer>
<div class="optionBtn">
- <el-button>鍙栨秷</el-button>
- <el-button type="primary" class="btn submit" @click="handleUser">纭畾</el-button>
- </div>
+ <el-button>鍙栨秷</el-button>
+ <el-button type="primary" class="btn submit" @click="handleUser">纭畾</el-button>
+ </div>
</footer>
</div>
</template>
@@ -59,37 +65,27 @@
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 validateTruename = (rule, value, callback) => {
- if (!value) {
- callback(new Error("璇峰~鍐欑敤鎴峰鍚�"));
- } else {
- const rep = /^[\u4E00-\u9FA5]{2,4}$/;
- if (!rep.test(value)) {
- callback("璇疯緭鍏ユ纭殑鐢ㄦ埛濮撳悕");
- }
+ callback();
}
};
const validatePhone = (rule, value, callback) => {
if (!value) {
- callback(new Error("璇峰~鍐欐墜鏈哄彿鐮�"));
+ callback();
} else {
- const rep = /(^1[3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/
- if (!rep.test(value)) {
- callback("璇疯緭鍏ユ纭殑鎵嬫満鍙风爜");
- }
+ // const rep = /(^1[3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/
+ // if (!rep.test(value)) {
+ // callback("璇疯緭鍏ユ纭殑鎵嬫満鍙风爜");
+ // }
+ callback();
}
};
return {
@@ -104,47 +100,99 @@
{ required: true, trigger: "blur", validator: validateNickname },
],
parentId: [
- { required: true, trigger: "blur", validator: validatePass },
+ { required: false, trigger: "blur", validator: validatePass },
],
departType: [
- { required: true, trigger: "blur", validator: validateTruename },
+ { required: false, trigger: "blur", validator: validatePhone },
],
departDes: [
- { required: true, trigger: "blur" },
+ { required: false, trigger: "blur" },
],
},
- roleList: [
- { name: '瑙掕壊1', value: 1 }, { name: '瑙掕壊2', value: 2 }
- ],
- typeList: []
+ userList: [],
+ departList: [],
+ checkedUser: [],
+ openUser: false,
}
},
created() {
const that = this;
- // 鑾峰彇瑙掕壊鍒楄〃
- // 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.getDepartTree();
+ // 鑾峰彇鐢ㄦ埛鍒楄〃
+ this.getUserList();
},
methods: {
handleUser() {
- const { depart } = this;
- console.log(depart);
- this.$axios.post('/sccg/depart/create', {
- departName: depart.departName,
- parentId: depart.parentId, departType: depart.departType, departDes: depart.departDes
- }).then(res => {
- if (res.code === 200) {
- this.refresh();
+ this.$refs.user.validate((valid) => {
+ if (valid) {
+ const { depart, checkedUser } = this;
+ console.log(depart);
+ console.log(checkedUser);
+ this.$axios.post('/sccg/depart/create', {
+ departName: depart.departName,
+ parentId: depart.parentId, departType: depart.departType, departDes: depart.departDes
+ }).then(res => {
+ if (res.code === 200) {
+ this.$message({
+ message:res.message,
+ type:'success'
+ })
+ this.refresh();
+ }else if(res.code ===2001){
+ this.$message({
+ message:res.message,
+ type:'error'
+ })
+ this.refresh();
+ }
+ })
+ } else {
+ return false;
}
})
- }
+ },
+ // 鑾峰彇閮ㄩ棬鏍戝舰缁撴瀯鍥�
+ getDepartTree() {
+ this.$axios({
+ method: 'get',
+ url: 'sccg/depart/tree',
+ })
+ .then(res => {
+ res.data.unshift({ id: 0, departName: '椤剁骇鑿滃崟' })
+ this.departList = res.data;
+ })
+ },
+ // 鑾峰彇鎵�鏈夌敤鎴蜂俊鎭�
+ getUserList() {
+ const that = this;
+ const { currentPage, pageSize, search } = this;
+ // 鑾峰彇鎵�鏈夌敤鎴蜂俊鎭�佺敤鎴锋煡璇�(鏆傛椂鏀寔鐢佃瘽鍙风爜)
+ this.$axios.get(`sccg/admin/list`).then(res => {
+ if (res.code === 200) {
+ console.log(res)
+ this.userList = res.data.records;
+ console.log(this.userList);
+ }
+ })
+ },
+ handleCheckedUserChange(value) {
+ // console.log(value);
+ if (value.length > 3) {
+ console.log(this.checkedUser);
+ this.$message({
+ type: 'warning',
+ message: '鏈�澶氬彧鑳芥坊鍔犱笁涓垚鍛�'
+ })
+ }
+ // let checkedCount = value.length;
+ // this.checkAll = checkedCount === this.cities.length;
+ // this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
+ },
+ addUser() {
+ console.log(this.checkedUser);
+ this.openUser = false;
+ },
},
props: ['refresh']
}
@@ -154,30 +202,7 @@
border-radius: 1px;
background-color: #09152f;
- header {
- display: flex;
- justify-content: space-between;
- 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;
text-align: left;
padding: 0 55px;
background-color: #09152f;
@@ -186,7 +211,8 @@
.mainContent {
display: flex;
justify-content: center;
- margin-top: 50px;
+ padding-top: 50px;
+
&::v-deep .el-form-item__label {
color: #4b9bb7;
}
@@ -195,11 +221,18 @@
background-color: #09152f;
border: 1px solid #17324c;
}
- .addPerson{
+
+ &::v-deep .el-textarea__inner {
+ background-color: #09152f;
+ border: 1px solid #17324c;
+ }
+
+ .addPerson {
display: flex;
list-style: none;
- padding:0;
- li{
+ padding: 0;
+
+ li {
background-color: #cccccc;
width: 36px;
height: 36px;
@@ -210,6 +243,7 @@
margin-left: 10px;
}
}
+
.el-form-item__content {
width: 400px;
@@ -232,9 +266,65 @@
}
}
+
+ .add {
+ position: relative;
+
+ .card {
+ position: absolute;
+ z-index: 2000;
+ right: 0;
+
+ .box-card {
+ max-height: 200px;
+ overflow: hidden;
+ background-color: #09152f;
+ 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;
+ }
+ }
+ }
+ }
}
- footer{
- border: 1px solid #fff;
+
+ footer {
+ border-top: 1px solid #fff;
height: 80px;
display: flex;
align-items: center;
--
Gitblit v1.8.0