<template>
  <base-form slot="content" ref="ruleForm" :data="searchData">
    <div slot="footer">
      <el-button :loading="listLoading" icon="el-icon-search" class="xl-form-btn bgc1" @click="searchHandle">查询</el-button>
      <!-- <el-button :loading="listLoading" icon="el-icon-document" class="xl-form-btn bgc2" @click="toExportExcel">导出{{ this.$route.meta.title }}信息</el-button> -->
    </div>
  </base-form>
</template>
<script>
export default {
  props: {
    listLoading: Boolean
  },
  inject: ['parentData'],
  mixins,
  data() {
    return {
      searchData: []
    }
  },
  mounted () {
    this.getDef()
  },
  methods: {
    subwayLineChange (val) {
      this.getDef('change')
    },
    getDef (str) {
      let params = { ...this.$refs.ruleForm.baseForm }
      this.searchData = [
        { label: '发布时间', label2: '开始时间', label3: '结束时间', key: 'startEndTime', type: 'datePicker'},
        { label: '标题', key: 'title' },
        { label: '自定义标签', key: 'custom_tag' },
        { label: '分类', key: 'channels_type', type: 'select', options: this.$dictData.channels_type},
        { label: '状态', key: 'hide_status', type: 'select', options: this.$dictData.hide_status},
      ]
      this.setDefaultValue(params, 'searchData')
    },
    searchHandle() {
      const oldform = this.$refs.ruleForm.baseForm
      const newForm = { ...oldform }
      if (newForm.startEndTime) {
        newForm.start_at = newForm.startEndTime[0]
        newForm.end_at = newForm.startEndTime[1]
        delete newForm.startEndTime
      }
      this.$emit('change', newForm)
    }
  }
}
</script>
