<template>
  <div class="panel-fieldset middle-label">
    <h4 class="panel-legend">评论配置</h4>
    <el-form-item label="是否允许评论">
      <el-switch v-model="extendsData.commentEnable" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
    </el-form-item>
    <el-form-item label="评论开始时间" v-show="extendsData.commentEnable==='Y'">
      <el-date-picker @change="inputChangeHandler" value-format="yyyy-MM-dd HH:mm:ss" v-model="extendsData.commentStartTime" id="commentStartTime" type="datetime" placeholder="选择日期时间" :picker-options="pickerOptions" :disabled="catalogId===0"></el-date-picker>
    </el-form-item>
    <el-form-item label="评论结束时间" v-show="extendsData.commentEnable==='Y'">
      <el-date-picker v-model="extendsData.commentEndTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" id="commentEndTime" placeholder="选择日期时间" :picker-options="pickerOptions" :disabled="catalogId===0||!extendsData.commentStartTime"></el-date-picker>
    </el-form-item>
    <el-form-item label="评论是否需要登录">
      <el-switch v-model="extendsData.commentLogin" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
    </el-form-item>
    <el-form-item label="评论是否需要审核">
      <el-switch v-model="extendsData.commentVerify" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
    </el-form-item>
    <el-form-item label="是否允许输入链接">
      <el-switch v-model="extendsData.commentUrlEnable" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
    </el-form-item>
    <el-form-item label="是否替换(链接/敏感词)">
      <el-switch v-model="extendsData.commentRLSWord" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
    </el-form-item>
    <el-form-item label="(链接/敏感词)替换为">
      <el-input v-model="extendsData.commentLinkSensitiveWord" :style="{width:'160px'}" :disabled="catalogId===0"></el-input>
    </el-form-item>
    <el-form-item label="表情评论是否限制IP">
      <el-switch v-model="extendsData.commentFaceLimit" active-value="Y" inactive-value="N" :disabled="catalogId===0"></el-switch>
    </el-form-item>
  </div>
</template>
<script>
export default {
  props: {
    extendsData: {
      type: Object,
      default: function() {
        return {
          commentEnable: 'Y', //  是否允许评论
          commentStartTime: '', //  评论开始时间
          commentEndTime: '', //  评论结束时间
          commentLogin: 'N', //  评论是否需要登录
          commentVerify: 'Y', //  评论是否需要审核
          commentUrlEnable: 'Y', //  是否允许输入链接
          commentRLSWord: 'N', //  是否替换
          commentLinkSensitiveWord: '****', //  链接、敏感词替换
          commentFaceLimit: 'Y', //  表情评论是否需要限制
          catalogBrowsePriv: ''
        }
      }
    },
    catalogId: [Number, String]
  },
  data() {
    return {
      pickerOptions: {
        //  今天之前的日期不能点击
        disabledDate(time) {
          let timeSpace = time.getTime() < Date.now()
          return timeSpace
        }
      }
    }
  },
  methods: {
    inputChangeHandler(val) {
      if (!val) {
        this.extendsData.commentEndTime = ''
      }
    }
  }
}
</script>
