JS实现全选,取消全选,正常选择


//点击选择方法
onUserIdsChange(selVal) {
if (this.form.groupUserIds.includes(-1) && !this.isSelectAll) {
// 全选
this.nickNames = []
this.isSelectAll = true
this.form.groupUserIds = []
this.groupUserOption.forEach(item => {
item.value != -1 && this.form.groupUserIds.push(item.value)
if(this.form.groupUserIds.length !== 0 && item.subscribe !== true){
this.onShow = true
this.nickNames.push(item.label)
}
})
this.groupUserOption[0].label = '取消全选'

    } else if (this.isSelectAll && this.form.groupUserIds.includes(-1)) {
     **// 取消全选**
      this.isSelectAll = false
      this.groupUserOption[0].label = '全选'
      this.form.groupUserIds = []
      this.onShow = false
      this.nickNames = []
    } else {
      **// 正常选择**
      this.nickNames = []
      this.form.groupUserIds = selVal
      if(this.form.groupUserIds.length === this.groupUserOption.length - 1){
        this.groupUserOption[0].label = '取消全选'
      }else{
        this.groupUserOption[0].label = '全选'
      }
      if(this.form.groupUserIds.length !== 0){
       this.groupUserOption.forEach(item2 => {
         this.form.groupUserIds.forEach(item => {
           if(item2.value === item && item2.subscribe !== true){
            this.onShow = true
            this.nickNames.push(item2.label)
          }else if(item2.value === item && item2.subscribe === true){
            this.onShow = false
          }
         })
       })
      }
      else{
        this.onShow = false
        this.nickNames = []
      }
    }
  }
},
优质内容筛选与推荐>>
1、opencv VideoCapture.read()读取错误
2、弹出对话框MessageDlg
3、Visual Studio 2013常用快捷键
4、基础知识
5、新浪微博问题


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号