// 计皮作业
<template>
    <div class="sale">
        <div class="top">
            <el-date-picker
            v-model="startTime"
            type="date"
            placeholder="选择日期"
            style="width:200px"
            >
            </el-date-picker>
            <span class="text">至</span>
            <el-date-picker
            v-model="endTime"
            type="date"
            placeholder="选择日期"
            style="width:200px"
            >
            </el-date-picker>
            <el-select v-model="condition1" placeholder="请选择筛选条件"  style="width:150px" clearable>
                <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                </el-option>
            </el-select>
            <el-input
                placeholder="请输入内容"
                v-model="input1"
                style="width:200px"
                clearable
            >
            </el-input>
            <el-select v-model="condition2" placeholder="请选择筛选条件" style="width:150px" clearable>
                <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
                </el-option>
            </el-select>
            <el-input
                placeholder="请输入内容"
                v-model="input2"
                style="width:200px"
                clearable
            >
            </el-input>
            <el-button type="primary" class="btn" @click="onclick">
                <i class="el-icon-search"></i>查询
            </el-button>
        </div>
        <div class="tab">
            <dilTable v-bind.sync="option" max-height="300"></dilTable>
        </div>
    </div>
</template>
<script>
import { sjTime } from "@/utils/sharedJsFile";
export default {
    data(){
        return{
            condition1:null,
            condition2:null,
            input1:null,
            input2:null,
            options:[
                {
                label:"车牌号",
                value:"capacityNumber"
                },
                {
                label:"物资",
                value:"materialName"
                },
                {
                label:"发货单位",
                value:"shipperName"
                },
                {
                label:"收货单位",
                value:"consigneeCompanyName"
                },
                
            ],
            inputText:'',
            option: {       
                // 表格请求数据的地址
                requestUrl: "/api/v1/tms/getAllJiPiResult?apiId=211&orderType=2",
            },
            startTime:'',
            endTime:''
        }
    },
    methods:{
        async onclick(){
            let startTime = null;
            let endTime = null;
            if (this.startTime && this.endTime) {
                startTime = sjTime(this.startTime);
                endTime = sjTime(this.endTime);
            }
            console.log("进入了查询")
            console.log(startTime)
            console.log(endTime)
            let option = {       
                requestQuery:{}
            }
            option.requestQuery[this.condition1]=[];
            option.requestQuery[this.condition2]=[];
            if(this.condition1 == this.condition2){
                option.requestQuery[this.condition1]=[this.input1,this.input2]
            }else{
                option.requestQuery[this.condition1]=[this.input1]
                option.requestQuery[this.condition2]=[this.input2]
            }
            option.requestUrl = "/api/v1/tms/getAllJiPiResult?apiId=211&orderType=2"
            +"&startTime="+startTime+"&endTime="+endTime+"&i="+new Date();
            await this.setOption("option",option)
        },
        setOption(prop,option){
            return new Promise((resolve,reject)=>{
            this.$set(this,prop,option)
            this.$forceUpdate();
            resolve("更新表格数据成功!");
            });
        },
    }
}
</script>
<style lang="scss" scoped>
    .sale{
        .top{
            padding: 1.25rem 0.375rem;
			.el-input {
			width: 20%;
			margin-right: 1.25rem;
			}
        }
    }
</style>