From a9c620e3ec4e5940eed7b9644047a080e2be373e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89?= <814457906@qq.com> Date: Fri, 1 Sep 2023 09:40:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/user/index.vue | 417 ++++++++++++++++++++++++++++++-- 1 file changed, 400 insertions(+), 17 deletions(-) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 4ce2497..212508f 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -384,6 +384,7 @@ multiple placeholder="请选择角色" @change="changeroleIds" + @remove-tag="remove" > + + + 请选择所属班级 + {{ tag.className }} + 选择所属班级 + + @@ -418,7 +452,98 @@ 取 消 + + + + + + + + + + + + + + + + 搜索 + 重置 + + + + + + + + + + + + + + + + + + import { listArea } from "@/api/system/area.js"; import kindergarlog from "../../assembly/kindergarlog.vue"; +import { listClassinfo } from "@/api/system/classinfo"; +import { getClassInfo } from "@/api/system/teacherInfo"; import { listUser, getUser, @@ -485,6 +612,40 @@ export default { return { // 遮罩层 loading: true, + dictValue1: "", + dictValue2: "", + dictValue3: "", + dictValue4: "", + classinfoList: [], + total2: 0, + innerVisible: false, + formkindergartenId: "", + classinfoList2: { + pageNum: 1, + pageSize: 10, + kindergartenId: null, + className: null, + classType: null + }, + classinfoName: [], + options: [ + { + classType: "", + label: "大班" + }, + { + classType: "", + label: "中班" + }, + { + classType: "", + label: "小班" + }, + { + classType: "", + label: "毕业" + } + ], //用户类型 memberGrades: [ { memberGrade: "COMMON", name: "普通" }, @@ -521,7 +682,10 @@ export default { //区域 areaList: [], // 表单参数 - form: {}, + form: { + classInfoList: [], + kindergartenId: null + }, defaultProps: { children: "children", label: "label" @@ -547,6 +711,8 @@ export default { name: "", code: "" }, + ClassType: "class_type", + statusitem: false, queryParams: { pageNum: 1, pageSize: 10, @@ -579,6 +745,9 @@ export default { trigger: "blur" } ], + classInfoList: [ + { required: true, message: "所属班级不能为空", trigger: "blur" } + ], nickName: [ { required: true, message: "用户昵称不能为空", trigger: "blur" } ], @@ -615,7 +784,16 @@ export default { this.$refs.tree.filter(val); } }, + computed: { + //传入的id 等于这个数组的id 的情况下为true 为蓝色按钮 + containsclass() { + return function(id) { + return this.form.classInfoList.find(e => e == id); + }; + } + }, created() { + this.info(); this.getList(); this.getTreeselect(); this.usermemberGrade(); @@ -625,8 +803,148 @@ export default { }); }, methods: { + innerVisibletrue2() { + if (this.form.kindergartenId == "" || !this.form.kindergartenId) { + this.$message.error("请先选择幼儿园"); + } else { + this.classinfoList2.kindergartenId = this.form.kindergartenId; + this.innerVisible = true; + this.getclassinfo(); + } + }, + //移除tage + handleClose(tag, index) { + this.form.classInfoList.splice(index, 1); + this.classinfoName.splice(index, 1); + }, + resetQuery3() { + this.classinfoList2 = { + pageNum: 1, + pageSize: 10, + kindergartenId: this.form.kindergartenId, + className: null, + classType: null, + classTeacher: null + }; + this.handleQuery2(); + }, + handleQuery2() { + listClassinfo(this.classinfoList2).then(response => { + this.classinfoList = response.rows; + this.total2 = response.total; + }); + }, + + innerVisiblecancel() { + this.innerVisible = false; + this.classinfoName = []; + }, + cancel3() { + // if (Array.isArray(this.classinfoName)) { + // this.classinfoName = this.classinfoName.join(","); + // } else { + // } + this.innerVisible = false; + this.innerVisible2 = false; + this.classinfoList2 = { + pageNum: 1, + pageSize: 10, + kindergartenId: null, + className: null, + classType: null + }; + // this.classinfoName = "请选择所属班级"; + // this.classinfoid = ""; + // if (this.classinfoName > 1) { + + // } else if (this.classinfoName.length == 1) { + // this.classinfoName = JSON.parse(this.classinfoName); + // } + }, + innerVisibleclick() { + if ( + this.form.kindergartenId == "" || + !this.form.kindergartenId || + this.form.kindergartenId == null + ) { + this.$message.error("请先选择幼儿园"); + } else { + this.classinfoList2.kindergartenId = this.form.kindergartenId; + this.innerVisible = true; + this.getclassinfo(); + } + }, + + info() { + tKindergartenInfo(this.ClassType).then(res => { + this.options[0].classType = res.data[0].dictValue; + this.options[1].classType = res.data[1].dictValue; + this.options[2].classType = res.data[2].dictValue; + this.options[3].classType = res.data[3].dictValue; + this.dictValue1 = res.data[0].dictValue; + this.dictValue2 = res.data[1].dictValue; + this.dictValue3 = res.data[2].dictValue; + this.dictValue4 = res.data[3].dictValue; + }); + }, + classinfoclick2(item) {}, + classinfoclick(item) { + if (this.form.classInfoList.findIndex(e => e == item.id) != -1) { + this.form.classInfoList = this.form.classInfoList.filter( + e => e != item.id + ); + this.classinfoName = this.classinfoName.filter(e => e.id != item.id); + } else { + this.form.classInfoList.push(item.id); + if (Array.isArray(this.classinfoName)) { + this.classinfoName.push(item); + } else { + this.classinfoName = this.classinfoName.split(","); + this.classinfoName.push(item); + } + } + }, + //选择班级 + getclassinfo() { + listClassinfo(this.classinfoList2).then(response => { + this.classinfoList = response.rows; + this.total2 = response.total; + }); + }, changeroleIds(row) { - this.kinshow = false; + var b = row.map(String); + if (b.length > 0) { + if (b.includes("6") == true) { + this.statusitem = true; + if (this.formkindergartenId) { + this.form.kindergartenId = this.formkindergartenId; + } + this.kinshow = true; + } else if (b.includes("10") == true) { + this.form.classInfoList = null; + // this.form.kindergartenId = null; + this.classinfoName = []; + this.form.kindergartenId; + this.kinshow = true; + this.statusitem = false; + } else if (b.includes("5") == true) { + this.form.classInfoList = null; + // this.form.kindergartenId = null; + this.classinfoName = []; + this.kinshow = true; + this.statusitem = false; + } else { + this.statusitem = false; + this.kinshow = false; + } + } else { + this.kinshow = false; + this.statusitem = false; + this.form.classInfoList = null; + this.form.kindergartenId = null; + this.classinfoName = []; + } + // this.kinshow = false; var obj = {}; this.roleOptions.forEach(el => { if (el.roleKey == "enchou") { @@ -636,15 +954,32 @@ export default { row.forEach(e => { if (e == obj.roleId) { this.kinshow = true; - this.form.kindergartenId = ""; - this.form.kindergartenName = "请选择幼儿园"; + // this.form.kindergartenId = ""; + // this.form.kindergartenName = "请选择幼儿园"; } }); }, + remove(e) { + // if (e) { + // if (e == 6) { + // this.form.classInfoList = null; + // // this.form.kindergartenId = null; + // this.classinfoName = []; + // } + // else if (e == 5 || e == 10) { + // // this.classinfoName= []; + // // this.form.classInfoList=null; + // // this.form.kindergartenId = null; + // } + // } + }, //幼儿园传值 - kinbatlist(e) { - this.kindergartenId = e; - this.form.kindergartenId = e; + kinbatlist(id, name) { + this.$set(this.form, "kindergartenId", id); + this.$set(this.form, "kindergartenName", name); + this.classinfoName = []; + this.form.classInfoList = []; + this.form.classinfoName = []; }, //字典用户类型 usermemberGrade() { @@ -721,7 +1056,7 @@ export default { // 表单重置 reset() { this.form = { - kindergartenId: undefined, + kindergartenId: null, userId: undefined, areaId: undefined, deptId: undefined, @@ -735,7 +1070,8 @@ export default { status: "0", remark: undefined, postIds: [], - roleIds: [] + roleIds: [], + classInfoList: [] }; this.resetForm("form"); }, @@ -772,6 +1108,7 @@ export default { /** 新增按钮操作 */ handleAdd() { this.kinshow = false; + this.statusitem = false; this.reset(); this.getTreeselect(); getUser().then(response => { @@ -785,15 +1122,42 @@ export default { /** 修改按钮操作 */ handleUpdate(row) { this.kinshow = false; + this.classinfoName = []; this.reset(); this.getTreeselect(); const userId = row.userId || this.ids; getUser(userId).then(response => { + response.data.classinfoName = response.data.classInfoList; + response.data.classInfoList + ? (response.data.classInfoList = response.data.classInfoList.map( + e => e.id + )) + : (response.data.classInfoList = []); this.form = response.data; + if (response.data.kindergartenId) { + this.formkindergartenId = response.data.kindergartenId; + } this.postOptions = response.posts; this.roleOptions = response.roles; this.form.postIds = response.postIds; this.form.roleIds = response.roleIds; + var b = this.form.roleIds.map(String); + response.data.classinfoName + ? (this.classinfoName = response.data.classinfoName) + : (this.classinfoName = []); + if (b.includes("6") == true) { + this.statusitem = true; + this.kinshow = true; + } else if (b.includes("10") == true) { + this.kinshow = true; + this.statusitem = false; + } else if (b.includes("5") == true) { + this.kinshow = true; + this.statusitem = false; + } else { + this.statusitem = false; + this.kinshow = false; + } this.title = "修改用户"; this.form.password = ""; var obj = {}; @@ -812,6 +1176,18 @@ export default { } this.open = true; }); + // .then((el) => { + // this.getclassinfo(); + // }) + // .then((val) => { + // getClassInfo({ + // id: row.id, + // }).then((res) => { + // this.form.classInfoList = res.data.map((e) => e.id); + // this.form.classInfoList.join(","); + // res.data.map((e) => this.classinfoName.push(e)); + // }); + // }); }, /** 重置密码按钮操作 */ handleResetPwd(row) { @@ -824,7 +1200,9 @@ export default { }) .then(({ value }) => { resetUserPwd(row.userId, value).then(response => { - this.$modal.msgSuccess("修改成功,新密码是:" + value); + if (response.code == 200) { + this.$modal.msgSuccess("修改成功,新密码是:" + value); + } }); }) .catch(() => {}); @@ -836,19 +1214,24 @@ export default { }, /** 提交按钮 */ submitForm: function() { + var b = this.form.roleIds.map(String); this.$refs["form"].validate(valid => { if (valid) { if (this.form.userId != undefined) { updateUser(this.form).then(response => { - this.$modal.msgSuccess("修改成功"); - this.open = false; - this.getList(); + if (response.code == 200) { + this.$modal.msgSuccess("修改成功"); + this.open = false; + this.getList(); + } }); } else { addUser(this.form).then(response => { - this.$modal.msgSuccess("新增成功"); - this.open = false; - this.getList(); + if (response.code == 200) { + this.$modal.msgSuccess("新增成功"); + this.open = false; + this.getList(); + } }); } }