<template>
  <div>
    <el-button :type="disabled?'':'primary'" size="small" @click="onshow" :disabled="disabled">{{$t(`批量下架`)}}</el-button>
  </div>
</template>

<script>
export default {
  name: "batchDown",
  props:["rowData","disabled"],
  methods:{
    onshow(){
      this.onBatchDown()
    },
    onBatchDown(){
      this.$confirm(this.$t('确定下架这些物料吗')+'?', this.$t('提示'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: 'warning'
      }).then(async () => {
        let row = []
        this.rowData.forEach(function (item,index) {
          row[index] = item.itemid
        })
        const res = await this.$api.requested({
          "id": 20220923154802,
          "content": {
            "itemids": row,
            "isonsale": 0
          },
        })
        this.tool.showMessage(res,()=>{
          this.$emit('batchUpSuccess')
        })
      }).catch(async () => {
        this.$message({
          type: 'info',
          message: this.$t('已取消批量下架')
        });
      });
    }
  }
}
</script>

<style scoped>

</style>
