点击启动,其他按钮(修改,删除)状态为禁用状态

效果:

点击启用按钮,状态变为已禁用,修改与删除变为灰色禁用状态

// 状态部分
 <el-table-column label="状态" prop="state" width="120">
            <template slot-scope="scope">
              {{ scope.row.state === 0 ? '已禁用' : '已启动' }}
            </template>
 </el-table-column>

//开关:启动或者禁用部分

 <el-table-column label="操作" width="250">
            <template slot-scope="scope">
              <el-button type="text" @click="hDisable(scope)">
                <template>
                  {{ scope.row.state === 1 ? '禁用' : '启动' }}
                </template>
              </el-button>
              <el-button type="text" @click="hEdit(scope.row)" 
:disabled="scope.row.state === 0">修改</el-button>
              <el-button type="text" @click="hDel(scope.row)" 
:disabled="scope.row.state === 0">删除</el-button>
            </template>
          </el-table-column>

 // script中的点击开关部分
methods:{
 async hDisable(data) {
      try {
        this.state = data.row.state === 1 ? 0 : 1  // 每次点击就是将状态转换为相反的状态
        await changeState({ state: this.state, id: data.row.id })  // 状态改变的接口
        this.loadDirectorys()
      } catch (e) {
        console.log(e)
      }
    }
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值