<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: '咨询客户', key: 'nickname' },
        { label: '置业经理', key: 'sale_id', type: 'selectRemote',
          remoteParams: { skey: 'sale_name', api: `user.admsaleuserlist`, opKey: 'sale_name', opVal: 'id' }
        },
        { label: '点击类型', key: 'click_type', type: 'select', options: this.$dictData.contact_click_type},
        // { label: '目标类型', key: 'target_type', type: 'select', options: this.$dictData.contact_target_type},
        { label: '点击时间', label2: '开始时间', label3: '结束时间', key: 'startEndTime', type: 'datePicker', rules: 1},
      ]
      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>
