<template>
  <div>
    <div class="panel-fieldset">
      <h4 class="panel-legend">定时任务</h4>
      <el-form-item label="定时全量发布启用状态">
        <el-switch v-model="extendsData.cronPublishEnable" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
      </el-form-item>
      <el-form-item label="定时全量发布起始时间">
        <el-date-picker id="cronPublishStartTime" value-format="yyyy-MM-dd HH:mm:ss" :disabled="extendsData.cronPublishEnable==='N' || catalogId===0" v-model="extendsData.cronPublishStartTime" type="datetime" placeholder="选择日期时间" :picker-options="pickerOptions"></el-date-picker>
      </el-form-item>
      <el-form-item label="定时发布执行周期">
        <label>每隔</label>
        <el-input v-model="extendsData.cronPublishPeriod" :style="{width:'40px'}" :disabled="extendsData.cronPublishEnable==='N'||catalogId===0"></el-input>
        <el-select v-model="extendsData.cronPublishPeriodType" :style="{width:'100px'}" :disabled="extendsData.cronPublishEnable==='N'||catalogId===0">
          <el-option
            v-for="item in cronPublishPeriodTypes"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="启用定时下线">
        <el-switch v-model="extendsData.offLineEnable" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
      </el-form-item>
      <el-form-item label="归档期限">
        <el-input-number v-model="extendsData.archiveTimeType" :min="0" :max="999" :step="1" :disabled="catalogId===0 || extendsData.offLineEnable === 'N'"></el-input-number> 月
      </el-form-item>
    </div>
    <div class="panel-fieldset long-label">
      <h4 class="panel-legend">发布配置</h4>
      <el-form-item label="发布时内容和模板未修改也重新生成文件">
        <el-switch v-model="extendsData.alwaysGenerateFile" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
      </el-form-item>
    </div>
    <div class="panel-fieldset short-label">
      <h4 class="panel-legend">栏目资源水印图片设置</h4>
      <el-form-item label="水印图片">
        <water-path
           :path.sync="extendsData.waterImagePath"
           :catalog-id="catalogId"
           :disabled="catalogId === 0"
         ></water-path>
      </el-form-item>
      <el-form-item label="水印位置">
         <water-position-picker :position.sync="extendsData.waterImagePosition" :disabled="catalogId===0"></water-position-picker>
      </el-form-item>
    </div>
    <div class="panel-fieldset short-label">
      <h4 class="panel-legend">全文检索设置</h4>
      <el-form-item label="是否开启检索">
        <el-switch v-model="extendsData.indexEnable" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
      </el-form-item>
    </div>
    <div class="panel-fieldset">
      <h4 class="panel-legend">关键字和相关内容设置</h4>
      <el-form-item label="自动计算关键字">
        <el-switch v-model="extendsData.autoKeyword" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
      </el-form-item>
      <el-form-item label="自动计算相关内容">
        <el-switch v-model="extendsData.autoRelaContent" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
      </el-form-item>
      <el-form-item label="自动计算相关内容选项">
        <el-select clearable v-model="extendsData.autoRelaType" placeholder="请选择" :style="{width:'150px'}" :disabled="catalogId===0">
          <el-option
            v-for="item in autorelaTypes"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
    </div>
  </div>
</template>
<script>
import WaterPath from './WaterPath.vue'
import WaterPositionPicker from './WaterPositionPicker.vue'
export default {
  components: {
    'water-path': WaterPath,
    'water-position-picker': WaterPositionPicker
  },
  props: {
    extendsData: {
      type: Object,
      default: function() {
        return {
          cronPublishEnable: 'N',
          cronPublishStartTime: '',
          cronPublishPeriodType: 'Hour',
          cronPublishPeriod: 24,
          offLineEnable: 'N',
          archiveTimeType: 999,
          alwaysGenerateFile: 'N',
          waterImagePath: '',
          waterImagePosition: 0,
          prefix: '',
          indexEnable: 'Y',
          autoKeyword: 'N',
          autoRelaContent: 'N',
          autoRelaType: 'Self'
        }
      }
    },
    catalogId: [Number, String]
  },
  data() {
    return {
      pickerOptions: {
        //  今天之前的日期不能点击
        disabledDate(time) {
          let timeSpace = time.getTime() < Date.now()
          return timeSpace
        }
      },
      cronPublishPeriodTypes: [
        { value: 'Hour', label: '小时' },
        { value: 'Day', label: '天' },
        { value: 'Month', label: '月' }
      ], //  定时发布执行周期选项
      submitLoading: false,
      autorelaTypes: [{value: 'Self', label: '本栏目关联'}, {value: 'Parent', label: '父栏目关联'}, {value: 'Site', label: '全站相关'}]// 自动计算相关内容选项
    }
  },
  methods: {
  }
}
</script>
