<template>
    <el-timeline>
        <template v-for="item in list">
            <el-timeline-item :key="item.id" :timestamp="item.send_time" placement="top">
                <el-card>
                    <h4>{{item.message_content}}</h4>
                    <p>
                        <el-tag type="success">已发送</el-tag>
                        {{item.create_user_id}} 发送于 {{item.send_time}}
                    </p>
                </el-card>
            </el-timeline-item>
        </template>
    </el-timeline>
</template>

<script>
import { getJobMessages } from '@/api/job'
import { dateFormat } from '@/utils/tool'

export default {
    props: ['jobId'],
    data () {
        return {
            list: []
        }
    },
    mounted () {
        this.getList();
    },
    methods: {
        getList() {
            getJobMessages(this.jobId, {
                page: 1,
                size: 10000,
                sort: 'create_time desc'
            }).then(res => {
                const list = res && res.data || [];
                list.map(item => {
                    item.send_time = dateFormat('YYYY-mm-dd HH:MM:SS', new Date(item.send_time));
                });
                this.list = list;
            })
        }
    }
}
</script>