<template>
    <view class="flex direction-column height-100pre width-100per">
        <uni-search-bar placeholder="单号、型号" style="width: 100%;"></uni-search-bar>
        <view class="flex padding-lr child-gap">
            <uni-datetime-picker type="date" placeholder="开始时间"></uni-datetime-picker>
            <uni-datetime-picker type="date" placeholder="结束时间"></uni-datetime-picker>
        </view>
        <view class="grow-1 height-0 scroll padding">
            <view class="dispatch-row" v-for="(item, index) in list" key="number">
                <view class="dispatch-row-title">{{item.title}}</view>
                <view class="dispatch-row-cells child-gap">
                    <view class="dispatch-row-cell width-40per">{{item.number}}</view>
                    <view class="dispatch-row-cell grow-1">{{item.spec}}</view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    import extend from '../../utils/extend';
    import request from '../../utils/request';
    export default {
        name: "page-dispatch",
        props: {
            url: {
                type: String,
                default: ''
            },
            method: {
                type: String,
                default: 'get'
            }
        },
        data() {
            return {
                list: [{
                    title: '劳伦斯',
                    number: 'C25412555',
                    spec: '左扶1+右扶1+脚踏'
                }, {
                    title: '劳伦斯ds',
                    number: 'C254125ert',
                    spec: '左扶1+右扶1+脚踏'
                }, {
                    title: '劳ddsds',
                    number: 'CD212244',
                    spec: '左扶1+右扶1+脚踏'
                }, {
                    title: '劳gs',
                    number: 'CD21552244',
                    spec: '左扶1+右扶1+脚踏'
                }, {
                    title: '劳bdf',
                    number: 'CS21552244',
                    spec: '左扶1+右扶1+脚踏'
                }, {
                    title: 'hhhbdf',
                    number: 'GCS21552244',
                    spec: '左扶1+右扶1+脚踏'
                }, {
                    title: 'hhdggbdf',
                    number: 'GC232244',
                    spec: '左扶1+右扶1+脚踏'
                }, {
                    title: 'haadggbdf',
                    number: 'GV3224de4',
                    spec: '左扶1+右扶1+脚踏'
                }]
            };
        },
        created(){
            this.load();
        },
        methods: {
            async load(){
                if (extend.isEmptyString(this.url)) {
                    return;
                }
                uni.showLoading();
                let res = await request.sendToken({
                    url: this.url,
                    method: this.method
                });
                uni.hideLoading();
                console.log(res);
                if (res.success) {} else {
                    uni.showModal({
                        title: '错误',
                        content: res.message
                    });
                }
            }
        }
    }
</script>

<style lang="scss">
    .dispatch-row {
        position: relative;
        padding: 10upx 0;
        
        .dispatch-row-title {
            font-size: 32upx;
            padding: 10upx 0;
        }
        
        .dispatch-row-cells {
            position: relative;
            display: flex;
            font-size: 24upx;
            color: #666666;
        }
        
        .dispatch-row-cell {
            flex-shrink: 0;
        }
    }
</style>