<template>
  <div>
    <el-form-item label="官方微博发布平台">
      <el-select v-model="extend.weiboPlatform" clearable class="form-item" :disabled="disabled">
        <el-option v-for="item in weiboPlatformSelection" :key="item.key" :label="item.name" :value="item.key"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="微博内容提取位置">
      <el-select v-model="extend.getVContentPosition" clearable class="form-item" :disabled="disabled">
        <el-option v-for="item in getVContentPositionSelection" :key="item.value" :label="item.label" :value="item.value"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="开启前台文章转图">
      <el-switch v-model="extend.isArticleToImageUsable" :disabled="disabled" active-value="Y" inactive-value="N"></el-switch>
    </el-form-item>
    <el-form-item label="文章转图需要登录">
      <el-switch v-model="extend.articleToImageNeedLogin" :disabled="disabled" active-value="Y" inactive-value="N"></el-switch>
    </el-form-item>
  </div>
</template>
<script>
export default {
  data() {
    return {
      weiboPlatformSelection: [], // 微博内容提取位置下拉框数据
      getVContentPositionSelection: [] // 微博内容提取位置下拉框数据
    }
  },
  computed: {
    extend: {
      get() {
        return this.extends
      },
      set(val) {
        this.$emit('update:extends', val)
      }
    }
  },
  async created() {
    let getPlatform = await axios.get('/ui/weibosend')
    this.weiboPlatformSelection = getPlatform.data.data
    let getVContent = await axios.get('/ui/platform/codes/VContentPositionCode')
    this.getVContentPositionSelection = getVContent.data.data
  },
  props: {
    extends: {
      type: Object,
      default: function () {
        return {
          weiboPlatform: '', // 官方微博发布平台
          getVContentPosition: '', // 微博内容提取位置
          isArticleToImageUsable: 'N', // 开启前台文章转图
          articleToImageNeedLogin: 'N' // 文章转图需要登录}
        }
      }
    },
    disabled: {
      type: Boolean
    }
  }
}
</script>
