| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <?php
- ?>
- <div id="app" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <el-breadcrumb separator="/">
- <el-breadcrumb-item>
- <span style="color: #409EFF;cursor: pointer" @click="$navigate({r:'admin/task/index'})">
- 定时任务
- </span>
- </el-breadcrumb-item>
- <el-breadcrumb-item>任务执行记录</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- <div class="table-body">
- <el-form :inline="true" :model="search_data" size="small" class="demo-form-inline">
- <el-form-item>
- <el-input placeholder="请输入任务名称" v-model="search_data.name"></el-input>
- </el-form-item>
- <el-form-item>
- <el-input placeholder="请输入任务ID精准搜索" v-model="search_data.task_id"></el-input>
- </el-form-item>
- <el-form-item>
- <el-select v-model="search_data.type" placeholder="请选择任务类型">
- <el-option v-for="(value,index) in task_type" :key="index" :label="value" :value="index"> </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select v-model="search_data.status" placeholder="请选择任务状态">
- <el-option v-for="(val,idx) in execute_status" :key="idx" :label="val" :value="idx"> </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-date-picker style="margin-top: 1px;" @change="changeTime" v-model="datetime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"></el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button size="small" type="primary" @click="search">搜索</el-button>
- <el-button size="small" type="danger" @click="clearSearch" v-if="show_clear_search_btn">清除条件</el-button>
- </el-form-item>
- </el-form-item>
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
- <el-table-column label="ID" prop="id" align="center" min-width="80"></el-table-column>
- <!-- <el-table-column label="执行命令" prop="command" align="center" show-overflow-tooltip>
- <template slot-scope="scope">
- <div>{{scope.row.command}}</div>
- </template>
- </el-table-column> -->
- <el-table-column label="任务名称" prop="name" align="center" show-overflow-tooltip>
- <template slot-scope="scope">
- <div>{{scope.row.name}}</div>
- </template>
- </el-table-column>
- <el-table-column label="任务类型" prop="type" align="center">
- <template slot-scope="scope">
- <div>{{task_type[scope.row.type]}}</div>
- </template>
- </el-table-column>
- <el-table-column label="执行耗时" prop="" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.running_time}}ms</div>
- </template>
- </el-table-column>
- <!-- <el-table-column label="预设执行时间" prop="start_time" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.start_time|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column> -->
- <el-table-column label="实际执行时间" prop="execute_time" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.execute_time|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="执行完成时间" prop="complete_time" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.complete_time|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="执行状态" prop="exec_process" align="center">
- <template slot-scope="scope">
- <div>{{execute_status[scope.row.exec_process]}}</div>
- </template>
- </el-table-column>
- <!-- <el-table-column label="任务输出" prop="result" align="center" min-width="180">
- <template slot-scope="scope">
- <div>{{scope.row.result}}</div>
- </template>
- </el-table-column> -->
- <el-table-column label="预警通知" prop="wraning" align="center">
- <template slot-scope="scope">
- <div v-if="scope.row.wraning==1">待发送</div>
- <div v-else-if="scope.row.wraning==2">已发送</div>
- <div v-else>--</div>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" prop="created_at" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="操作" min-width="120" align="center">
- <template slot-scope="scope">
- <el-button type="text" @click="recordDetail(scope.row.id)">查看详情</el-button>
- <el-button type="text" @click="taskRecordDelete(scope.row.id, scope.$index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
- </div>
- </div>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- list: [{
- title: "测试标题"
- }],
- listLoading: false,
- page: 1,
- pageCount: 0,
- search_data: { // 筛选条件
- start: null,
- end: null,
- task_id: null,
- command: null,
- type: null,
- status: null,
- },
- datetime: [],
- task_type: {
- 0: '全部类型',
- 1: 'shell脚本',
- 2: '站内脚本',
- 3: '访问URL'
- },
- execute_status: {
- 1: '准备中',
- 2: '执行中',
- 3: '任务失败',
- 4: '已完成'
- }
- };
- },
- mounted: function() {
- this.getList();
- },
- computed: {
- show_clear_search_btn: function() {
- return !isEmpty(this.search_data.start) || !isEmpty(this.search_data.end) ||
- !isEmpty(this.search_data.task_id) || !isEmpty(this.search_data.name) || !isEmpty(this.search_data.type) || !isEmpty(this.search_data.status);
- }
- },
- methods: {
- changeTime(e) {
- // console.log(e);return null;
- if (e) {
- this.search_data.start = e[0];
- this.search_data.end = e[1];
- } else {
- this.search_data.start = '';
- this.search_data.end = '';
- }
- },
- sortChange(row) {
- if (row.prop) {
- this.search_data.sort_field = row.prop;
- this.search_data.sort_type = row.order == "descending" ? 'desc' : 'asc';
- } else {
- this.search_data.sort_prop = null;
- this.search_data.sort_type = null;
- }
- this.getList(this.search_data);
- },
- search() {
- this.getList(this.search_data);
- },
- clearSearch() {
- this.search_data.start = null;
- this.search_data.end = null;
- this.search_data.task_id = null;
- this.search_data.name = null;
- this.datetime = [];
- this.getList();
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- // 获取任务列表
- getList() {
- let self = this;
- if (self.listLoading == false) {
- self.listLoading = true;
- request({
- params: {
- r: 'admin/task/executed-list',
- page: self.page,
- start_time: this.search_data.start,
- end_time: this.search_data.end,
- task_id: this.search_data.task_id,
- name: this.search_data.name,
- type: this.search_data.type,
- status: this.search_data.status,
- },
- method: 'get',
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- self.list = e.data.data.list;
- self.pageCount = e.data.data.page_count;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.$message.error(e.data.msg);
- self.listLoading = false;
- });
- }
- },
- // 执行记录详情
- recordDetail(id) {
- let params = {
- r: 'admin/task/executed-detail',
- };
- if (id) params = Object.assign(params, {
- id: id
- });
- navigateTo(params);
- },
- // 执行记录删除
- taskRecordDelete(id, index) {
- let self = this;
- self.$confirm('删除记录不可恢复,是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- self.listLoading = true;
- request({
- params: {
- r: 'admin/task/executed-record-del'
- },
- method: 'post',
- data: { id: id }
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- self.list.splice(index, 1);
- self.$message.success(e.data.msg);
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.listLoading = false;
- self.$message.error(e);
- });
- });
- },
- }
- });
- </script>
|