<!--
 * @Descripttion: 系统计划任务配置
 * @version: 1.0
 * @Author: sakuya
 * @Date: 2021年7月7日09:28:32
 * @LastEditors:
 * @LastEditTime:
-->

<template>
<el-drawer title="计划任务日志" v-model="Visible" :size="780" direction="rtl" destroy-on-close>
	<el-container>
		<el-main  style="padding:0 20px;">
			<scTable ref="table" :apiObj="list.apiObj" :column="list.column" :params="search" stripe>
				<el-table-column type="selection" width="50"></el-table-column>
				<template #return_code="scope">
					<span v-if="scope.row.return_code==0" style="color: #67C23A;"><el-icon><el-icon-success-filled /></el-icon></span>
					<span v-else style="color: #F56C6C;"><el-icon><el-icon-circle-close-filled /></el-icon></span>
				</template>
				<template #logs="scope">
					<el-button @click="show(scope.row)" type="text">日志</el-button>
				</template>
				<template #create_time="scope">
					<div v-time="scope.row.create_time"></div>
				</template>
			</scTable>
		</el-main>
	</el-container>

	<el-drawer title="日志" v-model="logsVisible" :size="500" direction="rtl" destroy-on-close>
		<el-main  style="padding:0 20px 20px 20px;">
			<pre style="font-size: 12px;color: #999;padding:20px;background: #333;font-family: consolas;line-height: 1.5;overflow: auto;">{{logDetail}}</pre>
		</el-main>
	</el-drawer>
</el-drawer>
</template>

<script>
export default {
	data() {
		return {
			Visible: false,
			logsVisible: false,
			crontab: {},
			logDetail: '',
			list: {
				apiObj: this.$API.system.crontab.log,
				column: [
					{ label: '执行时间', prop: 'running_time', width: 100 },
					{ label: '执行结果', prop: 'return_code', width: 100, align: 'center' },
					{ label: '参数', prop: 'parameter', width: 100, align: 'center' },
					{ label: '时间', prop: 'create_time', width: 200 },
					{ label: '执行日志', prop: 'logs', align: 'center' }
				]
			},
			search: {crontab_id: 0}
		}
	},
	mounted() {
	},
	methods: {
		open() {
			this.Visible = true
			return this
		},
		show(item){
			this.logDetail = item.exception
			this.logsVisible = true;
		},
		setData(row){
			this.crontab = row
			this.search.crontab_id = row.id
		}
	}
}
</script>

<style>
</style>
