<template>
    <fieldset>
        <legend>
            <el-tag type="info">条件筛选</el-tag>
        </legend>
        <el-form class="lv-form-inline" ref="searchForm" :model="searchKey" label-position="right" label-width="100px">
            <div class="search-form">
                <div class="form-left">
                    <el-row :gutter="10">
                        <el-col :xs="12" :sm="12" :md="12" :lg="6" :xl="6">
                            <el-input v-model="searchKey.shop" placeholder="请选择店铺" clearbale readonly :style="{width:'100%'}" @click="selectStore">
                                <template #append>
                                    <el-tooltip effect="dark" content="点这里，清除选择" placement="top-start">
                                        <div class="remove-a" @click="clearStore">清除</div>
                                    </el-tooltip>
                                </template>
                                <template #prepend>选择店铺</template>
                            </el-input>
                        </el-col>
                        <el-col :xs="12" :sm="12" :md="12" :lg="6" :xl="4">
                            <el-input v-model="searchKey.name" placeholder="订单编号" clearable :style="{ width: '100%' }" @keyup.enter="searchForm()">
                                <template #prepend>订单编号</template>
                            </el-input>
                        </el-col>
                        <el-col :xs="12" :sm="6" :md="6" :lg="6" :xl="4">
                            <el-date-picker v-model="searchKey.create" :style="{width: '100%'}" placeholder="请选择创建时间" start-placeholder="开始时间" end-placeholder="结束时间" type="daterange" range-separator="至" @change="searchForm" />
                        </el-col>
                    </el-row>
                </div>
                <div class="form-line"></div>
                <div class="form-right">
                    <el-button type="primary" icon="el-icon-search" @click="searchForm">搜索</el-button>
                </div>
            </div>
        </el-form>
    </fieldset>
    <storeData ref="storeData" :multiple="false" @success="handleStore"></storeData>
</template>

<script>
import storeData from '@/views/manage/components/store';
export default {
    components: {
        storeData
    },
    data(){
        return {
            searchKey:{}
        }
    },
    methods: {
        selectStore(){
            this.$nextTick(()=>{
                this.$refs.storeData.open()
            })
        },
        handleStore(data){
            this.searchKey.shop = data.shop_id;
            this.$emit("success",this.searchKey);
        },
        clearStore(){
            this.searchKey.shop = "";
            this.$emit("success",this.searchKey);
        },
        searchForm(){
            this.$emit("success",this.searchKey);
        }
    }
}
</script>