TaskHistory.vue 942 字节
<template>
  <el-dialog :title="'任务历史记录'" :visible.sync="visible">
    <el-table :data="history">
      <el-table-column prop="executedAt" label="执行时间"></el-table-column>
      <el-table-column prop="status" label="状态"></el-table-column>
      <el-table-column prop="result" label="执行结果"></el-table-column>
    </el-table>
    <span slot="footer">
      <el-button @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import api from '../../../api/task/index';

export default {
  props: ['taskId', 'visible'],
  data() {
    return {
      history: []
    };
  },
  watch: {
    taskId: async function(newVal) {
      if (newVal) {
        try {
          const res = await api.getExecutionHistory(newVal);
          this.history = res.data.data;
        } catch (e) {
          this.$message.error('加载历史记录失败');
        }
      }
    }
  }
};
</script>