<template>
  <!-- <el-button  @click="saveContent" :loading="loading" :priv="`com.zving.cms.Catalog.Content.Add.${catalogId}`"> -->
  <el-button  @click="saveContent" :loading="loading" :priv="`${content.ID === 0 ?`com.zving.cms.Catalog.Content.Add.${catalogId}`:`com.zving.cms.Catalog.Content.Edit.${catalogId}`}`" :disabled="content.isLock=='Y'&&content.lockUser!=userName">
    <i class="fa fa-floppy-o"></i>保存
  </el-button>
</template>
<script>
export default {
  props: {
    content: {
      type: Object
    },
    contentRule: {
      type: Object
    },
    catalogId: {
      type: [Number, String],
      default: 0
    }
  },
  data() {
    return {
      loading: false,
      // 需要格式化的Key
      formatItem: ['props', 'extend', 'attributes', 'detailTemplate'],
      userName: localStorage.userName,
      isOpenNewPage: true
    }
  },
  methods: {
    async saveContent() {
      this.loading = true
      try {
        if (this.content && this.content.contentTypeID !== 'Article') {
          this.isOpenNewPage = false
        }
        await Window.saveContent(this.isOpenNewPage)
        this.$emit('refresh-content')
      } catch (e) {
        this.loading = false
      }
      this.loading = false
    }
  }
}
</script>
