<template>
    <el-dialog title="批量提货" visible :before-close="closeDialog" :close-on-click-modal="false">
        <el-form :model="form">                
            <el-tabs v-model="current" type="card">
                <el-tab-pane label="全部提货" name="createOrderPickupBatch">
                    <el-form-item label="订单号/提单号" required>
                        <el-input v-model="form.orderId" placeholder="例：NA2200001L"></el-input>
                        <div>注：单号之间使用逗号或空格隔开</div>
                    </el-form-item>
                    <el-form-item label="提货时间">
                        <el-date-picker v-model="form.pickTime" placeholder="" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                    </el-form-item>
                </el-tab-pane>
                <el-tab-pane label="分批提货" name="createOrderPickupSplitBatch">
                    // TODO
                </el-tab-pane>
            </el-tabs>
            <el-form-item label="">
                <el-button type="primary" @click="submit">提交</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>
<script>
import {createOrderPickupBatch, createOrderPickupSplitBatch} from '@/api/ecw/order'
export default {
    props:{
        
    },
    data(){
        return {
            current: 'createOrderPickupBatch',
            show: false,
            form:{
                orderId: '',
                pickTime: '',
                pickType: 1
            },
        }
    },
    computed:{
        
    },
    created(){
        
    },
    methods:{
        submit(){
            if(this.form.orderId == '' || this.form.pickTime==''){
                return this.$message.error('请填写订单号和提货时间')
            }
            let orderIdArr = this.form.orderId.replace(/,/g, ' ').split(' ').filter(item => item !='')
            let data = []
            for(let orderId of orderIdArr){
                data.push({
                    pickType: 1,
                    orderId,
                    pickTime: this.form.pickTime
                })
            }

            ({createOrderPickupBatch, createOrderPickupSplitBatch}[this.current])(data).then(res => {
                this.$message.success("操作成功");
                this.form.orderId = ''
            })
        },
        closeDialog(){
            this.show = false
            this.$emit('close');
        }
    }
}
</script>