<template>
  <div>
    <el-button-group>
      <el-button type="primary" size="small" @click="checkProducts('check')">审 核</el-button>
      <el-button type="primary" size="small" @click="checkProducts('uncheck')">反 审</el-button>
      <!-- <el-button type="primary" size="small">批量删除</el-button> -->
    </el-button-group>
  </div>
</template>

<script>
export default {
  props:['rows'],
  data () {
    return {}
  },
  methods:{
    checkProducts (type) {
      this.$emit('checkProducts',type)
      this.$confirm('确定执行当前页的批量操作吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if(this.rows.length === 0) return this.$message({
          message:'没有需要批量处理的数据',
          type:'warning'
        })
        this.onSubmit(type)
      }).catch(() => {
        this.$emit('cancel')    
      });
    },

    async onSubmit (type) {
      let arr = this.rows.map(e=>{return e.itemid})
      console.log(arr)
      const res = await this.$api.requested({
        "id": 20220923153902,
        "content": {
          "itemids": arr,
          "status": type === 'check'?1:0
        },
      })
      this.tool.showMessage(res,()=>{
        this.$emit('onSuccess')
      })
    }
  }
}

</script>
<style>
</style>