<style scoped>
</style>
<template>
    <div class="toolbar-buttons-ct" v-show="showBtn">
      <el-button :disabled="!contentId" @click="publish('pub')">
        <i class="fa fa-share-square-o"></i>发布
      </el-button>
      <el-button :disabled="!contentId" @click="publish('topub')">
        <i class="fa fa-circle-o-notch"></i>待发布
      </el-button>
      <el-button :disabled="!contentId" @click="publish('offline')">
        <i class="fa fa-refresh"></i>下线
      </el-button>
    </div>
</template>
<script>
import util from '@src/common/util.js'
export default {
  name: 'ContentPublishButton',
  props: {
    contentId: {
      type: [String, Number]
    }
  },
  computed: {
    showBtn() {
      return !!(this.contentId && this.contentId.indexOf(',') > 0)
    }
  },
  methods: {
    async publish(type) {
      let resp = await axios.put(`/ui/contentcore/contentpublish/${this.contentId}/${type}`)
      util.showResponseMessage(resp.data)
      if (resp.data.status === 1) {
        this.$emit('refresh-content', this.contentId)
      }
    }
  }
}
</script>
