用户启用禁用功能——单个和批量

el-switch:

        <el-switch
                  @change="switchChange1(scope.row)"
                  v-model="scope.row.IsAdmin"
                  class="ml-2"
                  style="--el-switch-on-color: #f69675; --el-switch-off-color: #e2e2e3"
                />&nbsp;&nbsp;&nbsp;<span v-if="scope.row.IsAdmin">启用</span
                ><span v-if="!scope.row.IsAdmin">已禁用</span>
              </template>
            </el-table-column>
            <el-table-column prop="updateTime" label="用户状态">
              <template #default="scope">
                <el-switch
                  @change="switchChange2(scope.row)"
                  :value ="scope.row.EntityState===1?true:false"
                  class="ml-2"
                  style="--el-switch-on-color: #13c75b; --el-switch-off-color: #e2e2e3"
                />&nbsp;&nbsp;&nbsp;<span
                  v-if="scope.row.EntityState===1"
                  >启用</span
                ><span v-if="scope.row.EntityState===3">已禁用</span>
              </template>
            </el-table-column>
          </el-table>
            <el-switch
                  @change="switchChange3"
                  v-model="isall"
                  class="ml-2"
                  style="--el-switch-on-color: #13c75b; --el-switch-off-color: #e2e2e3;margin-top:10px"
                />&nbsp;&nbsp;&nbsp;<span v-if="isall===false">用户状态批量启用</span><span v-if="isall">用户状态批量禁用</span>

数据初始化:

export default {
  data() {
    return {
      ids:[],//接口传递的参数
      isall:false,//控制批量
    };
  },

方法体:

switchChange1(val) {
      gruanUserAdministrator({
        id: val.Id,
        userBp: val.UserBP,
        isAdmin: val.IsAdmin,
        
      }).then((res) => {
        if (res.AntsCode === 200) {
          ElMessage({
            message: '操作成功',
            type: "success",
          });
        } else {
          ElMessage.error("操作失败");
        }
      });
    },
    switchChange2(val) {
    console.log('vvv',val.EntityState)
      if(val.EntityState ===1){
        this.isVisiable = false
        
      }else{
        this.isVisiable = true
       
      },

 switchChange3(){
      
      let data ={
        
        ids: this.ids,
        userBp: sessionStorage.getItem("UserBp") ,
        isVisiable: this.isall?true:false,
      }
      

效果:

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值