<template>
  <div>
    <el-form ref="searchForm" :model="searchForm" inline>
      <!-- <el-form-item label="筛选:" label-width="90px">
        <DMRadio v-model="searchForm.quickSearch" :list="quickList" all-text="全部" @change="$emit('search')" />
      </el-form-item>
      <el-form-item label="意向状态:" label-width="90px">
        <DMRadio v-model="searchForm.intentionState" :list="intentionOptions" all-text="全部" @change="$emit('search')" />
      </el-form-item> -->
      <el-row>
        <el-form-item>
          <el-input v-model="searchForm.name" style="width: 200px" placeholder="姓名/联系方式" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="成交时间">
          <el-date-picker v-model="dateRange" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="pickDateChange"></el-date-picker>
        </el-form-item>
        <el-form-item label="全款状态">
          <el-select v-model="searchForm.state" placeholder="请选择" style="width: 120px" clearable>
            <el-option key="true" label="全款" value="true" />
            <el-option key="false" label="未全款" value="false" />
          </el-select>
        </el-form-item>
        <el-form-item label="驾校" v-if="admin == 'true'">
          <el-select v-model="searchForm.signSchool" placeholder="请选择" style="width: 120px" clearable>
            <el-option v-for="dict in options.schoolOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
          </el-select>
        </el-form-item>
        <el-form-item label="跟进人员">
          <el-select v-model="searchForm.followUser2" placeholder="请选择" clearable>
            <el-option v-for="dict in options.userOptions" :key="dict.id" :label="dict.name" :value="dict.id" />
          </el-select>
        </el-form-item>

        <el-form-item label="线索来源">
          <el-select v-model="searchForm.source" placeholder="请选择" clearable>
            <el-option v-for="dict in options.sourceOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
          </el-select>
        </el-form-item>
        <el-form-item label="所属区域">
          <el-select v-model="searchForm.area" placeholder="请选择" clearable size="small">
            <el-option v-for="dict in options.areaOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
          </el-select>
        </el-form-item>

        <el-form-item label="回款状态" v-if="admin == 'true'">
          <el-select v-model="searchForm.moneyState" placeholder="请选择" clearable size="small">
            <el-option v-for="dict in options.moneyStateOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
          </el-select>
        </el-form-item>

        <el-form-item label="审核状态" v-if="admin == 'true'">
          <el-select v-model="searchForm.checkState" placeholder="请选择" clearable size="small">
            <el-option key="1" label="待审核" value="1" />
            <el-option key="2" label="已审核" value="2" />
            <el-option key="3" label="驳回" value="3" />
          </el-select>
        </el-form-item>
        <el-form-item label-width="0">
          <el-button type="primary" icon="el-icon-search" @click="$emit('search')">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import DMRadio from '@/components/DMRadio';
export default {
  components: {
    DMRadio
  },
  props: {
    admin: {
      type: Boolean,
      default: false
    },
    options: {
      type: Object,
      default: () => ({
        userOptions: [],
        schoolOptions: [],
        areaOptions: [],
        moneyStateOptions: []
      })
    }
  },
  data() {
    return {
      searchForm: {},
      quickList: [
        { value: 1, label: '我创建的' },
        { value: 2, label: '我的有效' },
        { value: 3, label: '有效线索' },
        { value: 4, label: '今日有效线索' },
        { value: 5, label: '今日跟踪' },
        { value: 6, label: '过期线索' },
        { value: 7, label: '相关线索' },
        { value: 8, label: '撞单线索' }
      ],
      intentionOptions: [],
      dateRange: []
    }

  },
  created() {

  },
  methods: {
    resetQuery() {
      this.searchForm = {
        createTime: [],
        state: undefined,
        percentageState: undefined,
        followUser2: undefined,
        dealState: undefined,
        dealDate: undefined,
        name: undefined,
        source: undefined
      };
      this.dateRange = []
      this.$emit('search')
    },
    pickDateChange() {
      this.addDateRange(this.searchForm, this.dateRange)
    }
  },
}
</script>

