<template>
  <div>
    <div class="panel-fieldset">
      <h4 class="panel-legend">网站地图设置</h4>
      <el-form-item label="是否生成网站地图：">
        <el-switch v-model="extend.sitemapEnable" :disabled="disabled" active-value="Y" inactive-value="N"></el-switch>
      </el-form-item>
      <el-form-item label="网站地图页面更新频率：">
        <el-select v-model="extend.sitemapChangeFreq" class="form-item" :disabled="disabled">
          <el-option v-for="item in sitemapChangefreqSelection" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label=" ">
        <a href="javascript:void(0);" @click="exportIndexMap" :disabled="disabled">导出站点地图索引文件</a>
      </el-form-item>
    </div>

  </div>
</template>
<script>
export default {
  data() {
    return {
      sitemapChangefreqSelection: [] // 网站地图页面更新频率下拉框数据
    }
  },
  computed: {
    extend: {
      get() {
        return this.extends
      },
      set(val) {
        this.$emit('update:extends', val)
      }
    }
  },
  methods: {
    exportIndexMap() {
      window.open(`./ui/sitemap/exportsitemapindex?siteID=` + this.siteID)
    }
  },
  async created() {
    let res = await axios.get('/ui/platform/codes/SitemapChangefreq')
    this.sitemapChangefreqSelection = res.data.data
  },
  props: {
    extends: {
      type: Object,
      default: function() {
        return {
          sitemapEnable: 'N', // 是否生成网站地图
          sitemapChangeFreq: '' // 网站地图页面更新频率
        }
      }
    },
    siteID: {
      type: [String, Number]
    },
    disabled: {
      type: Boolean
    }
  }
}
</script>
