<template>
    <div>
      <el-dialog title="导出" :visible.sync="searchDialog" :modal-append-to-body="false" append-to-body :close-on-click-modal="false">
        <el-form :model="searchForm">
          <el-form-item label="请选择日期:" label-width="120px">
            <div class="block">
              <el-date-picker style="width: 2rem;" @change='changeDate' size="large" v-model="date" type="daterange" align="center" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" >
              </el-date-picker>
            </div>
          </el-form-item>
          <el-form-item label="请选择门店:" label-width="120px">
            <div class="block">
              <selec @selecData="selecData"/>
            </div>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button size="mini" type="primary" plain @click="searchDialog = false">取 消</el-button>
          <el-button type="primary" size="mini" @click="search ">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </template>
  
  <script>
  import selec from "@/components/store/select/index";
  export default {
    components:{
      selec
    },
    data() {
      return {
          searchDialog:false,
          storeIds:[],
          searchForm:{},
          date:[new Date(),new Date()]
      }
    },
    methods: {
      selecData(v){
        this.storeIds = v
      },
      show(){
          this.searchDialog = true
          this.date = [new Date(),new Date()]
      },
      search(){
        if(!this.date){
          this.$message.warning({ message: "请选择正确日期" });
        }else{
          if(!this.storeIds.length){
            this.$message.warning({ message: "请选择门店" });
          }else{
            this.searchDialog = false
            let date1 = this.formatTime(this.date[0], "YYYY-MM-DD 00:00:00");
            let date2 = this.formatTime(this.date[1], "YYYY-MM-DD 23:59:59");
            let params = {
              storeIds:this.storeIds,
              startTime:date1,
              endTime:date2
            }
            this.$emit('confirmExport',params)
          }
        }
      },
      changeDate(date){
          if(!date){
              this.date = []
          }
      }
    },
  }
  </script>
  <style scoped>
  
  </style>