<template>
    <el-button @click="del" :disabled="this.selectedRows.length === 0" :type="buttonType"
      :priv="'com.zving.cms.Catalog.Content.Delete.'+catalogId">
      <i class="fa fa-remove"></i>删除
    </el-button>
</template>
<script>
import util from '@src/common/util.js'
export default {
  props: {
    selectedRows: {
      type: Array
    },
    buttonType: {
      type: String,
      default: ''
    },
    catalogId: {
      type: [Number, String]
    }
  },
  methods: {
    async del() {
      try {
        await this.$confirm('确定删除吗？删除后无法恢复。是否继续删除？', '删除确认', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
      } catch (e) {
        return
      }
      let rowIds = this.selectedRows.map(val => val.ID).join(',')
      let res = await axios.delete(`/ui/contentcore/contents/${rowIds}`, {
        timeout: 600000,
        params: {
          catalogID: this.catalogId
        }
      })
      if (res.data.status === 1) {
        await util.showProgress(res.data.taskID, res.data.message)
        this.$emit('refresh-content')
      } else {
        util.showErrorMessageBox(res.data.message)
      }
    }
  }

}
</script>
