<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
        <el-form-item label="流程图名称">
          <el-input
            v-model.trim="queryParams.name"
            placeholder="请输入流程图名称"
            clearable
            size="small"
            style="width: 160px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="流程图id">
          <el-input
            v-model.trim="queryParams.procdefId"
            placeholder="请输入流程图id"
            clearable
            size="small"
            style="width: 160px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="时间" label-width="60px">
          <el-date-picker
           style="margin-top:0px;"
            v-model="dateRange"
            size="small"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetimerange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button type="primary" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <!-- height="calc(100vh - 30vh)" -->
    <el-table v-loading="loading" :data="adminList">
      <el-table-column label="id" align="center" prop="id"  show-overflow-tooltip />
      <el-table-column label="流程id" align="center" prop="procdefId"  show-overflow-tooltip />
      <el-table-column label="流程名称" align="center" prop="procdefName" show-overflow-tooltip />
      <el-table-column label="开始时间" align="center" prop="createTime"  show-overflow-tooltip />
      <el-table-column label="结束时间" align="center" prop="endTime"  show-overflow-tooltip />
      <el-table-column label="执行日志" align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            icon="el-icon-view"
            @click="getRecord(scope.row)"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />


    </div>
</template>

<script>
// 引入相关的依赖
import { zkHiExecutionPage } from "@/api/business/Middleware/bpmn";
import router from "../../../../router";
export default {
  name: "",
  created() {},
  mounted() {
  },
  data() {
    return {
      // 日期范围
      dateRange: [],
      // 遮罩层
      loading: false,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 参数表格数据
      adminList: [],

      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        current: 1,
        size: 20,
        name:undefined,
        procdefId:undefined
      },
      // 表单参数
      form: {},
      bpmnViewer: null,
      container: null,
      canvas: null,
      xml:undefined,

    };
  },
  created(){
    this.getList()
  },
  // 方法集合
  methods: {
    /** 查询参数列表 */
    getList() {
      this.loading = false;
      if(this.dateRange.length>0){
        this.queryParams.startTime = this.dateRange[0]
        this.queryParams.endTime = this.dateRange[1]
      }
      //跳转参数注入
      let query = this.$route.query
      if(JSON.stringify(this.$route.query) != '{}'){
        this.queryParams.procdefId = query.procdefId
      }
      zkHiExecutionPage(this.queryParams).then(response => {
        this.adminList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.current = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.name = undefined
      this.queryParams.procdefId = undefined
      this.dateRange = []
      this.queryParams.startTime = undefined
      this.queryParams.endTime = undefined
      if(JSON.stringify(this.$route.query) != '{}'){
        this.$router.push({path:'/Middleware/bpmn/executionRecord'})
      }
      this.handleQuery();
    },
    /** 跳转执行日志 */
    getRecord(row){
      router.push({path:'/Middleware/bpmn/executionLog',query:{'hiExecutionId':row.id}})
    }
  },

};
</script>

<style scoped>

.canvas {
  width: 100%;
  height: 400px;
}
.panel {
  position: absolute;
  right: 0;
  top: 0;
  width: 300px;
}
.buttons {
  position: absolute;
  left: 80px;
  bottom: 20px;
}
.buttons li {
  display: inline-block;
  margin: 5px;
}
.buttons li a {
  color: #999;
  background: #eee;
  cursor: not-allowed;
  padding: 8px;
  border: 1px solid #ccc;
  text-decoration: none;
}
.buttons li a.active {
  color: #333;
  background: #fff;
  cursor: pointer;
}
.demo-drawer-footer {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
  border-top: 1px solid #e8e8e8;
  padding: 10px 16px;
  text-align: right;
  background: #fff;
}
.getBpmn{
  cursor: pointer !important;
  color:#1890ff;
}
</style>
