From 2be81744cfb167629303c44cab23ac66c3a26c62 Mon Sep 17 00:00:00 2001 From: SelfRidicule Date: Mon, 1 Apr 2024 15:54:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=8F=E8=BF=B0=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=9B=AD=E5=8C=BA=E7=AE=A1=E7=90=86=E5=91=98=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E7=95=8C=E9=9D=A2=E4=B8=AD=E2=80=9C=E6=89=80=E5=B1=9E?= =?UTF-8?q?=E7=A7=9F=E6=88=B7=E2=80=9D=E6=94=B9=E6=88=90=E2=80=9C=E6=89=80?= =?UTF-8?q?=E5=B1=9E=E5=9C=B0=E5=8C=BA=E2=80=9D=EF=BC=8C=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=85=E9=A1=BB=E9=80=89=E6=8B=A9=E6=89=80?= =?UTF-8?q?=E5=B1=9E=E5=9B=AD=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/modules/UserModal.vue | 246 ++++++++++++++++++++----- 1 file changed, 199 insertions(+), 47 deletions(-) diff --git a/src/views/system/modules/UserModal.vue b/src/views/system/modules/UserModal.vue index 27d42bf..72d4432 100644 --- a/src/views/system/modules/UserModal.vue +++ b/src/views/system/modules/UserModal.vue @@ -44,37 +44,44 @@ > - - - {{ item.text }} - - - - - {{ item.text }} - - - {{ action.roleName }} + + {{ action.roleName + }} + - - + + + {{ item.text }} + + + + + {{ item.text }} + + + + {{ item.text }} - + - + {{ item.username }} -{{ item.mobile }} @@ -135,25 +142,24 @@ export default { confirmLoading: false, roleAll: [], mdl: {}, - data: [], + searchUserList: [], customerList: [], deptCheck: true, spinning: false, tenantData: [], parkData: [], - form: this.$form.createForm(this) + form: this.$form.createForm(this), + selectRoleEnable: false, + tenantShow: false, + parkShow: false, + customerShow: false, + selectUserShow: false } }, beforeCreate() { }, created() { - getCustomerList().then(res => { - res.rows.forEach(r => { - this.customerList.push({ value: r.id, text: r.name }) - }) - }) - - // 租户 + // 地区 getTenantList().then(res => { if (res.code === 0) { res.rows.forEach(r => { @@ -161,23 +167,134 @@ export default { }) } }) - // 获取园区 - getParkList().then(res => { - if (res.code === 0) { - res.rows.forEach(r => { - this.parkData.push({ value: r.id, text: r.name }) - }) - } - }) this.loadRoleAll() }, methods: { + // 选择角色 + roleSelectChange(value) { + console.log('roleSelectChange', value) + // 清空数据 + this.searchUserList = [] + // 赋值 + this.mdl.roleIds = value + // 角色判断 + if (value.length > 0) { + this.selectRoleEnable = true + // 判断角色 + if (value[0] == 4) { // 企业:4 + this.tenantShow = true + this.parkShow = true + this.customerShow = true + + } else if (value[0] == 5) { // 园区:5 + this.tenantShow = true + this.parkShow = true + + } else { + this.tenantShow = false + this.parkShow = false + this.customerShow = false + this.selectUserShow = false + } + + } else { + this.selectRoleEnable = false + // + this.tenantShow = false + this.parkShow = false + this.customerShow = false + this.selectUserShow = false + } + }, + // 选择地区 -> 查询园区 + selectTenant(id) { + console.log('selectTenant', id) + getParkList({ + tenantId: id + }).then(res => { + this.parkData = res.rows.map(item => { + return { + value: item.id, + text: item.name + } + }) + }) + // 赋值 + this.mdl.tenantId = id + // 清空数据 + this.searchUserList = [] + // 隐藏用户搜索 + this.selectUserShow = false + // 清空园区、企业、用户 + this.mdl.parkId = null + this.mdl.customerId = null + this.mdl.staffId = null + this.form.setFieldsValue({ + parkId: null, + customerId: null, + staffId: null + }) + }, + // 选择园区 -> 查询企业 + selectPark(id) { + getCustomerList({ + parkId: id + }).then(res => { + this.customerList = res.data.map(item => { + return { + value: item.id, + text: item.name + } + }) + }) + // 赋值 + this.mdl.parkId = id + // 清空数据 + this.searchUserList = [] + // 清空企业、用户 + this.mdl.customerId = null + this.mdl.staffId = null + this.form.setFieldsValue({ + customerId: null, + staffId: null + }) + // 园区角色显示用户并且查询用户 + console.log('this.mdl.roleIds', this.mdl.roleIds) + if (this.mdl.roleIds[0] == 5) { + this.selectUserShow = true + } else { + // 隐藏用户搜索 + this.selectUserShow = false + } + }, + // 选择企业 + selectEnterprise(id) { + // 赋值 + this.mdl.customerId = id + // 显示搜索用户 + this.selectUserShow = true + // 清空数据 + this.searchUserList = [] + // 清空用户 + this.mdl.staffId = null + this.form.setFieldsValue({ + staffId: null + }) + }, handleSearch(value) { let param = { mobile: value + } + // 判断角色 + if (this.mdl.roleIds[0] == 4) { // 企业:4 + param.customerId = this.mdl.customerId + } else if (this.mdl.roleIds[0] == 5) { // 园区:5 + param.parkId = this.mdl.parkId + } else { + } getStaffList(param).then(res => { - this.data = res.rows + this.searchUserList = res.rows }) }, handleChange() { @@ -190,11 +307,12 @@ export default { this.$nextTick(() => { this.form.setFieldsValue(pick(this.mdl, 'id', 'username', 'nickname', 'status', 'mobile', 'roleIds', 'staffId', 'customerId', 'remark', 'deptId', 'parkId', 'tenantId')) }) - let param = {} - getStaffListByUser(param).then(res => { - this.data = res.rows - - }) + // 初始化显示 + this.selectRoleEnable = false + this.tenantShow = false + this.parkShow = false + this.customerShow = false + this.selectUserShow = false }, edit(record) { if (record.id > 0) { @@ -202,20 +320,54 @@ export default { this.spinning = true getUser(record.id).then(res => { this.mdl = Object.assign({}, res) + let copyMdl = JSON.parse(JSON.stringify(this.mdl)) this.visible = true this.$nextTick(() => { this.form.setFieldsValue(pick(this.mdl, 'id', 'username', 'nickname', 'status', 'mobile', 'roleIds', 'customerId', 'staffId', 'remark', 'deptId', 'parkId', 'tenantId')) this.spinning = false // this.form.setFieldsValue({ ...record }) - // 查询 选择用户 - getStaffListByUser({ - staffId: this.mdl.staffId - }).then(res => { - console.log('edit getStaffListByUser', res) - this.data = res.rows - }) }) + // 判断角色 + if (this.mdl.roleIds[0] == 4) { // 企业:4 + // 选择地区 -> 查询园区 + this.mdl = JSON.parse(JSON.stringify(copyMdl)) + this.selectTenant(copyMdl.tenantId) + // 选择园区 -> 查询企业 + this.mdl = JSON.parse(JSON.stringify(copyMdl)) + this.selectPark(copyMdl.parkId) + // 查询用户 + this.mdl = JSON.parse(JSON.stringify(copyMdl)) + this.handleSearch(copyMdl.staffPhone) + // 赋值 + this.mdl.customerId = copyMdl.customerId + this.mdl.staffId = copyMdl.staffId + // 显示 + this.tenantShow = true + this.parkShow = true + this.customerShow = true + this.selectUserShow = true + } else if (this.mdl.roleIds[0] == 5) { // 园区:5 + // 选择地区 -> 查询园区 + this.mdl = JSON.parse(JSON.stringify(copyMdl)) + this.selectTenant(copyMdl.tenantId) + // 查询用户 + this.mdl = JSON.parse(JSON.stringify(copyMdl)) + this.handleSearch(copyMdl.staffPhone) + // 赋值 + this.mdl.staffId = copyMdl.staffId + // 显示 + this.tenantShow = true + this.parkShow = true + this.customerShow = false + this.selectUserShow = true + + } else { + this.tenantShow = false + this.parkShow = false + this.customerShow = false + this.selectUserShow = false + } }) } },