log.vue 7.4 KB
Newer Older
sunhongwei's avatar
sunhongwei committed
1 2 3 4
<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
Marcus's avatar
Marcus committed
5 6
      <el-form-item :label="$t('处理器的名字')" prop="handlerName">
        <el-input v-model="queryParams.handlerName" :placeholder="$t('请输入处理器的名字')" clearable @keyup.enter.native="handleQuery"/>
sunhongwei's avatar
sunhongwei committed
7
      </el-form-item>
Marcus's avatar
Marcus committed
8 9
      <el-form-item :label="$t('开始执行时间')" prop="beginTime">
        <el-date-picker clearable v-model="queryParams.beginTime" type="date" value-format="yyyy-MM-dd" :placeholder="$t('选择开始执行时间')" />
sunhongwei's avatar
sunhongwei committed
10
      </el-form-item>
Marcus's avatar
Marcus committed
11 12
      <el-form-item :label="$t('结束执行时间')" prop="endTime">
        <el-date-picker clearable v-model="queryParams.endTime" type="date" value-format="yyyy-MM-dd" :placeholder="$t('选择结束执行时间')" />
sunhongwei's avatar
sunhongwei committed
13
      </el-form-item>
Marcus's avatar
Marcus committed
14 15
      <el-form-item :label="$t('任务状态')" prop="status">
        <el-select v-model="queryParams.status" :placeholder="$t('请选择任务状态')" clearable>
sunhongwei's avatar
sunhongwei committed
16 17 18 19 20
          <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_JOB_LOG_STATUS)"
                     :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item>
      <el-form-item>
Marcus's avatar
Marcus committed
21 22
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{ $t('重置') }}</el-button>
sunhongwei's avatar
sunhongwei committed
23 24 25 26 27 28
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
Marcus's avatar
Marcus committed
29
                   v-hasPermi="['infra:job:export']">{{ $t('导出') }}</el-button>
sunhongwei's avatar
sunhongwei committed
30 31 32 33 34
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="list">
Marcus's avatar
Marcus committed
35 36 37 38 39 40
      <el-table-column :label="$t('日志编号')" align="center" prop="id" />
      <el-table-column :label="$t('任务编号')" align="center" prop="jobId" />
      <el-table-column :label="$t('处理器的名字')" align="center" prop="handlerName" />
      <el-table-column :label="$t('处理器的参数')" align="center" prop="handlerParam" />
      <el-table-column :label="$t('第几次执行')" align="center" prop="executeIndex" />
      <el-table-column :label="$t('执行时间')" align="center" width="180">
sunhongwei's avatar
sunhongwei committed
41 42 43 44
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.beginTime) + ' ~ ' + parseTime(scope.row.endTime) }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
45
      <el-table-column :label="$t('执行时长')" align="center" prop="duration">
sunhongwei's avatar
sunhongwei committed
46 47 48 49
        <template slot-scope="scope">
          <span>{{ scope.row.duration + ' 毫秒' }}</span>
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
50
      <el-table-column :label="$t('任务状态')" align="center" prop="status">
sunhongwei's avatar
sunhongwei committed
51 52 53 54
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="scope.row.status" />
        </template>
      </el-table-column>
Marcus's avatar
Marcus committed
55
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
sunhongwei's avatar
sunhongwei committed
56 57
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)" :loading="exportLoading"
Marcus's avatar
Marcus committed
58
                     v-hasPermi="['infra:job:query']">{{ $t('详细') }}</el-button>
sunhongwei's avatar
sunhongwei committed
59 60 61 62 63 64 65 66
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 调度日志详细 -->
Marcus's avatar
Marcus committed
67
    <el-dialog :title="$t('调度日志详细')" :visible.sync="open" width="700px" append-to-body>
sunhongwei's avatar
sunhongwei committed
68 69 70
      <el-form ref="form" :model="form" label-width="120px" size="mini">
        <el-row>
          <el-col :span="12">
Marcus's avatar
Marcus committed
71 72 73 74 75 76 77 78
            <el-form-item :label="$t('日志编号:')">{{ form.id }}</el-form-item>
            <el-form-item :label="$t('任务编号:')">{{ form.jobId }}</el-form-item>
            <el-form-item :label="$t('处理器的名字:')">{{ form.handlerName }}</el-form-item>
            <el-form-item :label="$t('处理器的参数:')">{{ form.handlerParam }}</el-form-item>
            <el-form-item :label="$t('第几次执行:')">{{ form.executeIndex }}</el-form-item>
            <el-form-item :label="$t('执行时间:')">{{ parseTime(form.beginTime) + ' ~ ' + parseTime(form.endTime) }}</el-form-item>
            <el-form-item :label="$t('执行时长:')">{{ parseTime(form.duration) + ' 毫秒' }}</el-form-item>
            <el-form-item :label="$t('任务状态:')">
sunhongwei's avatar
sunhongwei committed
79 80
              <dict-tag :type="DICT_TYPE.INFRA_JOB_LOG_STATUS" :value="form.status" />
            </el-form-item>
Marcus's avatar
Marcus committed
81
            <el-form-item :label="$t('执行结果:')">{{ form.result }}</el-form-item>
sunhongwei's avatar
sunhongwei committed
82 83 84 85
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
Marcus's avatar
Marcus committed
86
        <el-button @click="open = false">{{ $t('关 闭') }}</el-button>
sunhongwei's avatar
sunhongwei committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getJobLogPage, exportJobLogExcel } from "@/api/infra/jobLog";

export default {
  name: "JobLog",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 调度日志表格数据
      list: [],
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        handlerName: null,
        beginTime: null,
        endTime: null,
        status: null,
      }
    };
  },
  created() {
    this.queryParams.jobId = this.$route.query && this.$route.query.jobId;
    this.getList();
  },
  methods: {
    /** 查询调度日志列表 */
    getList() {
      this.loading = true;
      getJobLogPage({
        ...this.queryParams,
        beginTime: this.queryParams.beginTime ? this.queryParams.beginTime + ' 00:00:00' : undefined,
        endTime: this.queryParams.endTime ? this.queryParams.endTime + ' 23:59:59' : undefined,
      }).then(response => {
          this.list = response.data.list;
          this.total = response.data.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 详细按钮操作 */
    handleView(row) {
      this.open = true;
      this.form = row;
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams,
        beginTime: this.queryParams.beginTime ? this.queryParams.beginTime + ' 00:00:00' : undefined,
        endTime: this.queryParams.endTime ? this.queryParams.endTime + ' 23:59:59' : undefined,
      };
      params.pageNo = undefined;
      params.pageSize = undefined;
      // 执行导出
      this.$modal.confirm('是否确认导出所有定时任务日志数据项?').then(() => {
        this.exportLoading = true;
        return exportJobLogExcel(params);
      }).then(response => {
        this.$download.excel(response, '定时任务日志.xls');
        this.exportLoading = false;
      }).catch(() => {});
    }
  }
};
</script>