From 7759b52788c81e0724350642ed62d40b467c365b Mon Sep 17 00:00:00 2001 From: liangjin <liangjin@finlean.com> Date: Fri, 23 Apr 2021 15:13:36 +0800 Subject: [PATCH] 账号权限修复 --- src/views/mine/account/account-add.vue | 292 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 149 insertions(+), 143 deletions(-) diff --git a/src/views/mine/account/account-add.vue b/src/views/mine/account/account-add.vue index f788336..33bd59d 100644 --- a/src/views/mine/account/account-add.vue +++ b/src/views/mine/account/account-add.vue @@ -3,7 +3,7 @@ * @Date: 2019-08-20 18:12:00 * @LastEditors: 小明丶 * @LastEditTime: 2020-11-17 09:39:52 - * @Description: + * @Description: --> <template> <div class="account-add h-100-g"> @@ -21,16 +21,16 @@ <v-cell v-model="form.email" max="50" label="联系邮箱" placeholder="请输入邮箱地址"></v-cell> </div> - <div class="cell-group"> + <div v-if="orgType !== 4" class="cell-group"> <v-cell label="权限分配" :readonly="true"></v-cell> <van-checkbox-group class="van-check-box" v-model="form.menuPower"> <div v-for="(item, index) in powerInfo" :key="index"> <v-cell :label="item.powerName" v-if="item.powerId !==100005"> <van-checkbox - slot="v-cell-right" - :key="item.powerId" - :name="item.powerId" - :checked-color="$store.state.backColor" + slot="v-cell-right" + :key="item.powerId" + :name="item.powerId" + :checked-color="$store.state.backColor" /> </v-cell> </div> @@ -51,149 +51,155 @@ </template> <script> -import { mapState } from "vuex"; -export default { - name: "account-add", - data() { - return { - form: { - name: "", - mblNo: "", - email: "", - name: "", - menuPower: [], - powerInfoVos: [] //权限列表 - }, - rule:[ - {key:"name",message:"请输入账户名称",type:"isEmpty"}, - {key:"name",message:"请输入正确的账户名称",rule:/^[\u4e00-\u9fa50-9a-zA-Z]{1,6}$/}, - {key:"mblNo",message:"请输入手机号",type:"isEmpty"}, - {key:"mblNo",message:"请输入正确的手机号",type:"isTel"}, - {key:"email",message:"请输入联系邮箱",type:"isEmpty"}, - {key:"email",message:"请输入正确的联系邮箱",type:"isEmail"}, - ], - isFreeze: false - }; - }, - computed: { - ...mapState(["userinfo"]), - // 判断是新增 还是 详情 - isAdd() { - return this.$route.query.isAdd == "1"; - }, - //权限列表 - powerInfo() { - return this.form.powerInfoVos || []; - }, - id() { - return this.$route.query.id || ""; - } - }, - created() { - this.form.powerInfoVos = this.userinfo.powerInfoVos; - if (!this.isAdd) { - this.init(); - } - }, - methods: { - //获取用户详情 - init() { - this.$api.getUserDetail(this.id).then(({ body }) => { - let {powerInfoVos} = body; - if (body.supStatus && body.status) { - this.isFreeze = true; - } else { - this.isFreeze = false; - } - let powerInfo = this.userinfo.powerInfoVos; - if (powerInfoVos.length) { - powerInfo.forEach(item => { - let index = powerInfoVos.findIndex(child => { - return item.powerId === child.powerId; - }); - if(index!==-1){ - this.form.menuPower.push(item.powerId) - } - }); - } + import { mapState } from "vuex"; + export default { + name: "account-add", + data() { + return { + orgType:"", + form: { + name: "", + mblNo: "", + email: "", + name: "", + menuPower: [], + powerInfoVos: [] //权限列表 + }, + rule:[ + {key:"name",message:"请输入账户名称",type:"isEmpty"}, + {key:"name",message:"请输入正确的账户名称",rule:/^[\u4e00-\u9fa50-9a-zA-Z]{1,6}$/}, + {key:"mblNo",message:"请输入手机号",type:"isEmpty"}, + {key:"mblNo",message:"请输入正确的手机号",type:"isTel"}, + {key:"email",message:"请输入联系邮箱",type:"isEmpty"}, + {key:"email",message:"请输入正确的联系邮箱",type:"isEmail"}, + ], + isFreeze: false + }; + }, + computed: { + ...mapState(["userinfo"]), + // 判断是新增 还是 详情 + isAdd() { + return this.$route.query.isAdd == "1"; + }, + //权限列表 + powerInfo() { + return this.form.powerInfoVos || []; + }, + id() { + return this.$route.query.id || ""; + } + }, + created() { + this.orgType = this.userinfo.orgType; + console.log("orgType:"+this.orgType); + this.form.powerInfoVos = this.userinfo.powerInfoVos; + if (!this.isAdd) { + this.init(); + } + }, + methods: { + //获取用户详情 + init() { + this.$api.getUserDetail(this.id).then(({ body }) => { + let {powerInfoVos} = body; + if (body.supStatus && body.status) { + this.isFreeze = true; + } else { + this.isFreeze = false; + } + let powerInfo = this.userinfo.powerInfoVos; + if (powerInfoVos.length) { + powerInfo.forEach(item => { + let index = powerInfoVos.findIndex(child => { + return item.powerId === child.powerId; + }); + if(index!==-1){ + this.form.menuPower.push(item.powerId) + } + }); + } - this.form = { - ...this.form, - ...body - }; - this.form.powerInfoVos = this.userinfo.powerInfoVos;; - }) - .catch(err => {}); - }, - // 验证form参数 - validatorForm(){ - return this.$validator(this.form,this.rule).check(item=>{ - this.$notify(item.message) - }) - }, - // 新增 - add() { - if(!this.validatorForm()) return - this.$api.userAdd(this.form).then(res => { - this.$notify("添加成功"); - setTimeout(() => this.$router.go(-1), 1000); - }).catch(err => {}); - }, - //更新 - update() { - if(!this.validatorForm()) return - this.$api.userUpdate(this.form).then(res => { - this.$notify("保存成功"); - }) - .catch(err => {}); - }, - //冻结账号 - freeze() { - this.$dialog.confirm({ - message: `请问是否确认${this.isFreeze ? "冻结" : "启用"}该账户?` - }).then(() => { - this.$api.userFreezeMgr(this.id).then(() => { - let text = this.isFreeze ? "冻结成功" : "启用成功"; - this.$notify(text); - this.isFreeze = !this.isFreeze; - }); - }) - .catch(() => { - // on cancel - }); - } - } -}; + this.form = { + ...this.form, + ...body + }; + this.form.powerInfoVos = this.userinfo.powerInfoVos;; + }) + .catch(err => {}); + }, + // 验证form参数 + validatorForm(){ + return this.$validator(this.form,this.rule).check(item=>{ + this.$notify(item.message) + }) + }, + // 新增 + add() { + if(this.orgType == 4){ + this.form.menuPower = [100001, 100006] + } + if(!this.validatorForm()) return + this.$api.userAdd(this.form).then(res => { + this.$notify("添加成功"); + setTimeout(() => this.$router.go(-1), 1000); + }).catch(err => {}); + }, + //更新 + update() { + if(!this.validatorForm()) return + this.$api.userUpdate(this.form).then(res => { + this.$notify("保存成功"); + }) + .catch(err => {}); + }, + //冻结账号 + freeze() { + this.$dialog.confirm({ + message: `请问是否确认${this.isFreeze ? "冻结" : "启用"}该账户?` + }).then(() => { + this.$api.userFreezeMgr(this.id).then(() => { + let text = this.isFreeze ? "冻结成功" : "启用成功"; + this.$notify(text); + this.isFreeze = !this.isFreeze; + }); + }) + .catch(() => { + // on cancel + }); + } + } + }; </script> <style scoped lang="less"> -.account-add { - background-color: @c-bg-f5; - padding-top: 44px; + .account-add { + background-color: @c-bg-f5; + padding-top: 44px; - .tip { - margin: 10px 0 15px 21px; - font-size: @font-12; - color: @c-text-999; + .tip { + margin: 10px 0 15px 21px; + font-size: @font-12; + color: @c-text-999; + } } -} -.cell-group { - margin: 10px 8px 0; -} + .cell-group { + margin: 10px 8px 0; + } -.btn { - width: 340px; - height: 44px; - border: none; - font-size: @font-16; - border-radius: 22px; - background-color: @c-bg-default; - color: @c-text-fff; -} + .btn { + width: 340px; + height: 44px; + border: none; + font-size: @font-16; + border-radius: 22px; + background-color: @c-bg-default; + color: @c-text-fff; + } -.footer { - margin-top: 60px; - padding-bottom: 30px; -} -</style> \ No newline at end of file + .footer { + margin-top: 60px; + padding-bottom: 30px; + } +</style> -- Gitblit v1.8.0