<template>
    <el-dialog :title="title" visible :before-close="closeDialog" :close-on-click-modal="false" v-loading="loading">
        <el-timeline v-if="list.length">
            <el-timeline-item v-for="item in list" :timestamp="item.pickTime|parseTime" placement="top" :key="item.id">
                <div> {{item.deleted ? $t('已撤销') : $t('已提货')}} <el-button v-if="!item.deleted" size="mini" @click="deletePickup(item.id)" class="ml-10">{{$t('撤销')}}</el-button></div>
                <div>{{$t('提货箱数')}}：{{item.pickNum}}箱</div>
                <div>{{$t('操作人')}}：{{item.creator}}</div>
                <div v-if="item.deleted">{{$t('撤销人')}}：{{item.updater}}</div>
            </el-timeline-item>
        </el-timeline>
        <el-empty v-if="!loading && !list.length" :description="$t('暂无提货日志')"></el-empty>
    </el-dialog>
</template>
<script>
import {deletePickup, getAllPickUpListByOrderNo} from '@/api/ecw/orderPickup'
import {parseTime} from '@/utils/ruoyi'
export default {
    filters: {parseTime},
    props:{
        orderNo: String
    },
    data(){
        return {
            show: false,
            list:[],
            loading: false
        }
    },
    computed:{
        title(){
            return this.$t('提货日志') + '-' + this.orderNo
        }
    },
    created(){
        this.getList()
    },
    methods:{
        getList(){
            this.loading = true
            getAllPickUpListByOrderNo({orderNo: this.orderNo}).then(res => {
                this.list = res.data
            })
            .finally(() => {
                this.loading = false
            })
        },
        deletePickup(id){
            this.$confirm('确定要撤销此提货么？').then(res => {
                return deletePickup({id})
            }).then(res => {
                this.$message.success('操作成功')
                this.$emit('delete', id)
            })
        },
        closeDialog(){
            this.show = false
            this.$emit('close');
        }
    }
}
</script>