<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 :span="this.$store.state.global.ismobile?12:4">
                            <el-input v-model="searchKey.agent" placeholder="所属代理" clearable readonly :style="{ width: '100%' }" @click="selectUser">
                                <template #append>
                                    <el-tooltip
                                        effect="dark"
                                        content="点这里，清除选择"
                                        placement="top-start"
                                    >
                                    <div class="remove-a" @click="clearUser">清除</div>
                                    </el-tooltip>
                                </template>
                                <template #prepend>所属代理</template>
                            </el-input>
                        </el-col>
                        <el-col :span="this.$store.state.global.ismobile?12:4">
                            <el-input v-model="searchKey.name" placeholder="店铺名称" clearable :style="{ width: '100%' }" @keyup.enter="searchForm()">
                                <template #prepend>店铺名称</template>
                            </el-input>
                        </el-col>
                        <el-col :span="this.$store.state.global.ismobile?12:4">
                            <el-input v-model="searchKey.account" placeholder="来客账户ID" clearable :style="{ width: '100%' }" @keyup.enter="searchForm()">
                                <template #prepend>来客账户ID</template>
                            </el-input>
                        </el-col>
                        <el-col :span="this.$store.state.global.ismobile?12:4">
                            <el-select v-model="searchKey.status" clearable placeholder="请选择状态" @change="searchForm" :style="{width: '100%'}" class="diy-select">
                                <el-option value="1" label="冻结"></el-option>
                                <el-option value="2" label="正常"></el-option>
                                <template #prefix>状态</template>
                            </el-select>
                        </el-col>
                        <el-col :span="this.$store.state.global.ismobile?12: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>
    <agentData ref="agentData" :multiple="false" @success="handleSuccess"></agentData>
</template>

<script>
import agentData from "@/views/manage/components/agent";
export default {
    components: {
        agentData
    },
    data(){
        return {
            searchKey:{}
        }
    },
    methods: {
        handleSuccess(data){
            this.searchKey.agent = data.user_id;
            this.$emit("success",this.searchKey);
        },
        clearUser(){
            this.searchKey.agent = "";
        },
        selectUser(){
            this.$nextTick(() => {
                this.$refs.agentData.open()
            })
        },
        searchForm(){
            this.$emit("success",this.searchKey);
        }
    }
}
</script>