|
|
<template> <el-dialog title="日志列表" :close-on-click-modal="false" :visible.sync="visible" width="75%"> <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()"> <el-form-item> <el-input v-model="dataForm.id" clearable></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="getDataList()">{{ buttons.search || '查询' }}</el-button> </el-form-item> </el-form> <el-table :data="dataList" border v-loading="dataListLoading" height="460" style="width: 100%;"> <el-table-column prop="logId" header-align="center" align="center" width="80" :label="buttons.logId || '日志ID'"> </el-table-column> <el-table-column prop="jobId" header-align="center" align="center" width="80" :label="buttons.jobId ||'任务ID'"> </el-table-column> <el-table-column prop="beanName" header-align="center" align="center" :label="buttons.beanName ||'bean名称'"> </el-table-column> <el-table-column prop="params" header-align="center" align="center" :label="buttons.params ||'参数'"> </el-table-column> <el-table-column prop="status" header-align="center" align="center" :label="buttons.status ||'状态'"> <template slot-scope="scope"> <el-tag v-if="scope.row.status === 0" size="small">{{ buttons.success || '成功' }}</el-tag> <el-tag v-else @click.native="showErrorInfo(scope.row.logId)" size="small" type="danger" style="cursor: pointer;"> {{ buttons.fail || '失败' }} </el-tag> </template> </el-table-column> <el-table-column prop="times" header-align="center" align="center" :label="buttons.times ||'耗时(单位: 毫秒)'"> </el-table-column> <el-table-column prop="createTime" header-align="center" align="center" width="180" :label="buttons.createTime ||'执行时间'"> </el-table-column> <el-table-column prop="errorMsg" header-align="center" align="center" width="180" :label="buttons.errorMsg ||'执行结果'"> </el-table-column> </el-table> <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[20, 50, 100, 200,500]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper"> </el-pagination> </el-dialog></template>
<script>import { searchFunctionButtonList,} from "@/api/sysLanguage.js"export default { data() { return { visible: false, dataForm: { id: '' }, dataList: [], pageIndex: 1, pageSize: 20, totalPage: 0, dataListLoading: false, buttons: { search: '查询', logId: '日志ID', jobId: '任务ID', beanName: 'bean名称', params: '参数', success: '成功', fail: '失败', times: '耗时(单位: 毫秒)', createTime: '执行时间', errorMsg: '执行结果', }, } }, methods: { // 获取button的词典
getFunctionButtonList() { let queryButton = { functionId: this.$route.meta.menuId, tableId: '*', languageCode: this.$i18n.locale, objectType: 'button' } searchFunctionButtonList(queryButton).then(({data}) => { if (data.code == 0 && data.data) { this.buttons = data.data } }) }, init() { this.visible = true this.getDataList() }, // 获取数据列表
getDataList() { this.dataListLoading = true this.$http({ url: this.$http.adornUrl('/sys/scheduleLog/list'), method: 'get', params: this.$http.adornParams({ 'page': this.pageIndex, 'limit': this.pageSize, 'jobId': this.dataForm.id }) }).then(({data}) => { if (data && data.code === 0) { this.dataList = data.page.list this.totalPage = data.page.totalCount } else { this.dataList = [] this.totalPage = 0 } this.dataListLoading = false }) }, // 每页数
sizeChangeHandle(val) { this.pageSize = val this.pageIndex = 1 this.getDataList() }, // 当前页
currentChangeHandle(val) { this.pageIndex = val this.getDataList() }, // 失败信息
showErrorInfo(id) { this.$http({ url: this.$http.adornUrl(`/sys/scheduleLog/info/${id}`), method: 'get', params: this.$http.adornParams() }).then(({data}) => { if (data && data.code === 0) { this.$alert(data.log.error) } else { this.$message.error(data.msg) } }) } }, created() { this.getFunctionButtonList() }}</script>
|