<template>
    <el-dialog :title="title" visible :before-close="closeDialog" :close-on-click-modal="false">
        <el-collapse v-model="activeNames">
            <template v-for="item in list">
            <el-collapse-item :key="item.orderNo" :title="item.orderNo" :name="item.orderNo">
                <el-timeline :reverse="reverse">
                    <el-timeline-item
                    v-for="(activity, index) in item.logs"
                    :key="index"
                    :timestamp="activity.createTime|parseTime">
                    {{activity.titleZh}}
                    </el-timeline-item>
                </el-timeline>
            </el-collapse-item>
            </template>
            <div class="empty-placeholder" v-if="status == 'finished' && !list.length">
                {{$t('暂无数据')}}
            </div>
        </el-collapse>
    </el-dialog>
</template>
<script>
import {getMergeLogByMergedOrderNo} from '@/api/ecw/order'
import {parseTime} from '@/utils/ruoyi'
export default {
    props:{
        orderNo: String
    },
    data(){
        return {
            show: false,
            list:[],
            activeNames:[],
            status: null
        }
    },
    filters: {parseTime},
    computed:{
        title(){
            return this.$t('合单日志') + ' - ' + this.orderNo 
        }
    },
    created(){
        this.status = 'loading'
        getMergeLogByMergedOrderNo({mergedOrderNo: this.orderNo}).then(res => {
            for(let orderNo in res.data){
                this.list.push({
                    orderNo,
                    logs: res.data[orderNo]
                })
            }
            if(!this.list.length){
                this.empty = true
            }
        }).finally(res => {
            this.status = 'finished'
        })
    },
    methods:{
        closeDialog(){
            this.show = false
            this.$emit('close');
        }
    }
}
</script>