zoukankan      html  css  js  c++  java
  • 2021年5月30日

    时间:1.6个小时左右

    代码:100行左右

    博客:1

    学习内容:添加删除权限

    emoveRightById(scope.row,item2.id)
    removeRightById(scope.row,item3.id)
    ```
    async removeRightById(role,rightId){
        //弹窗提示用户是否要删除
        const confirmResult = await this.$confirm('请问是否要删除该权限','删除提示',{
            confirmButtonText:'确认删除',
            cancelButtonText:'取消',
            type:'warning'
        }).catch(err=>err)
        //如果用户点击确认,则confirmResult 为'confirm'
        //如果用户点击取消, 则confirmResult获取的就是catch的错误消息'cancel'
        if(confirmResult != "confirm"){
            return this.$message.info("已经取消删除")
        }
    
        //用户点击了确定表示真的要删除
        //当发送delete请求之后,返回的数据就是最新的角色权限信息
        const {data:res} = await this.$http.delete(`roles/${role.id}/rights/${rightId}`)
        if (res.meta.status !== 200)
            return this.$message.error('删除角色权限失败')
    
        //无需再重新加载所有权限
        //只需要对现有的角色权限进行更新即可
        role.children = res.data
        // this.getRoleList();
    
    }
    <el-button size="mini" type="warning" icon="el-icon-setting" @click="showSetRightDialog">分配权限</el-button>
    在showSetRightDialog函数中请求权限树数据并显示对话框
    ```
    async showSetRightDialog() {
        //当点击分配权限按钮时,展示对应的对话框
        this.setRightDialogVisible = true;
        //获取所有权限的数据
        const {data:res} = await this.$http.get('rights/tree')
        //如果返回状态为异常状态则报错并返回
        if (res.meta.status !== 200)
            return this.$message.error('获取权限树失败')
        //如果返回状态正常,将请求的数据保存在data中
        this.rightsList = res.data
    }
    <!-- 分配权限对话框 -->
    <el-dialog title="分配权限" :visible.sync="setRightDialogVisible" width="50%">
        <span>这是一段信息</span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="setRightDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="setRightDialogVisible = false">确 定</el-button>
        </span>
    </el-dialog>
  • 相关阅读:
    Ubuntu10.04搭建linux-0.11编译环境(1.bochs安装和使用)
    Linux 0.11内核编译和bochs上的实验环境的搭建
    64位Linux的内核和用户地址空间
    2012年计算机考研大纲——操作系统
    【27.34%】【codeforces 611D】New Year and Ancient Prophecy
    【14.94%】【codeforces 611E】New Year and Three Musketeers
    【53.57%】【codeforces 610C】Harmony Analysis
    【42.49%】【hdu 1542】Atlantis(线段树扫描线简析)
    【49.23%】【hdu 1828】Picture
    【20.51%】【codeforces 610D】Vika and Segments
  • 原文地址:https://www.cnblogs.com/j-y-s/p/14903364.html
Copyright © 2011-2022 走看看