天天看点

标记核心决策人

标记核心决策人

这个列表是有分页的,如何与后端接口传参,正确的设置核心决策人?

  主要问题场景:

    第一页选中前2个,第二页选中前2个,然后只将第一页取消勾选,此时第二页已勾选的人员怎么传递?

async handleSignOk() {
      const { relationList, isCoreList } = this // relationList 是列表数据 isCoreList 接口返回的已经是核心决策人list
      const bindIdList = []
      relationList.forEach(item => {
        if (item.coreType) bindIdList.push(item.id)
      })
      const unBindIdList = isCoreList.filter(item => !bindIdList.includes(item))
      if (bindIdList.length === 0 && unBindIdList.length === 0) return this.$vux.toast.text('请勾选核心决策人')
      const { success } = await setCoreApi({ bindIdList, unBindIdList })
      if (success) {
        this.refrash()
        this.isSign = false
        this.$refs.listScrollerRef.$el.scrollTop = 0
        this.$vux.toast.text('标记成功')
      }
    }      

核心思想:使用两个数组,一个是bindIdList(选中的),一个是unBindIdList(取消选中的)