<!--定时任务-->
<template>
  <div class="app-container timingTask">
    <div class="page-container timingTaskPage">
      <div class="page-form-title-box">
        <el-form :model="queryParams" class="form-box" ref="queryForm"
                 :inline="true" style="width:100%;">
          <el-form-item label="任务名称" prop="jobName" label-width="90px">
            <el-input
              maxLength="30"
              v-model="queryParams.jobName"
              placeholder="请输入任务名称"
              clearable
              style="width: 200px"
            />
          </el-form-item>
          <el-form-item label="任务组名" prop="jobGroup">
            <el-select v-model="queryParams.jobGroup" clearable placeholder="请选择任务组名" style="width: 200px">
              <el-option
                v-for="dict in jobGroupOptions"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="执行状态" prop="status">
            <el-select v-model="queryParams.status" clearable placeholder="请选择分类" style="width: 200px">
              <el-option
                v-for="dict in statusOptions"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
          <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
          <p class="page-submit-common-style-button"
             style="float: right;"
             @click="dialogOpen"
          >新增</p>
        </el-form>
      </div>
      <div class="page-content-box">
        <el-table class="table-box" v-loading="loading" border :data="dataList">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="日志编号" width="80" align="left" prop="jobLogId" />
          <el-table-column label="任务名称" align="left" prop="jobName" :show-overflow-tooltip="true" />
          <el-table-column label="任务组名" align="left" prop="jobGroup" :formatter="jobGroupFormat" :show-overflow-tooltip="true" />
          <el-table-column label="调用目标字符串" align="left" prop="invokeTarget" :show-overflow-tooltip="true" />
          <el-table-column label="日志信息" align="left" prop="jobMessage" :show-overflow-tooltip="true" />
          <el-table-column label="执行状态" align="left" prop="status" :formatter="statusFormat" />
          <el-table-column label="执行时间" align="left" prop="createTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime,"{y}-{m}-{d} {h}:{i}") }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="left" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-view"
                @click="handleView(scope.row)"
                v-hasPermiRouter="['monitor:job:detail']"
              >详细</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination :page-sizes="[20, 30, 40, 50]"
                    v-show="total>0"
                    :total="total"
                    :page.sync="queryParams.page"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getList"
        />
      </div>
    </div>
    <!--新增弹窗-->
    <el-dialog class="trainingCourseAddDialog" :title='dialogTitle' width="540px" append-to-body
               :visible.sync="dialogType" v-if="dialogType" @close="dialogOff()"
               :close-on-click-modal="false" :close-on-press-escape="false">

      <div slot="footer" class="dialog-footer dialog-footer-box">
        <p class="dialog-footer-button-null"></p>
        <p class="dialog-footer-button-info" @click="dialogOff">取消</p>
        <p class="dialog-footer-button-primary" @click="dialogSubmit">提交</p>
        <p class="dialog-footer-button-null"></p>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { getDicts } from "@/api/commonality/noPermission";
  import { listJobLog, delJobLog, cleanJobLog } from "@/api/serviceCenter/index";
  export default {
    name: 'index',
    data(){
      return{
        loading:false,
        statusOptions:[],
        jobGroupOptions:[],
        queryParams:{
          page:1,
          pageSize:20,
          jobName:"",
          jobGroup:null,
          status:null,
        },
        dateRange:[],
        dataList:[{}],
        total:110,
        //dialog弹层数据
        dialogTitle:"",
        dialogType:false,
      }
    },
    created(){
      // this.getList();
    },
    mounted(){
      //学生类别查询
      getDicts('sys_common_status').then(response => {
        this.$set(this,'statusOptions',response.data);
      });
      //学生类别查询
      getDicts('sys_job_group').then(response => {
        this.$set(this,'jobGroupOptions',response.data);
      });
    },
    methods:{
      //弹层关闭
      dialogOff(){
        this.$set(this,'dialogType',false);
      },
      //弹层开启
      dialogOpen(){
        this.$set(this,'dialogTitle','新增');
        this.$set(this,'dialogType',true);
      },
      //弹层确定
      dialogSubmit(){
        this.$set(this,'dialogType',false);
      },
      handleQuery(){
        this.$set(this.queryParams,'page',1);
        this.getList();
      },
      resetQuery(){
        this.$set(this,'dateRange',[])
        this.$set(this,'queryParams',{
          page:1,
          pageSize:20,
          jobName:"",
          jobGroup:null,
          status:null,
        });
        this.getList();
      },
      //获取数据列表
      getList(){
        this.$set(this,'loading',true);
        listJobLog(this.queryParams).then(response => {
          this.$set(this,'loading',false);
          this.$set(this,'dataList',response.data.records);
          this.$set(this,'total',response.data.total);
        });
      },
    },
  }
</script>

<style scoped lang="scss">
  .timingTask{
    .timingTaskPage{

    }
  }
</style>
