index.vue 6.73 KB
Newer Older
dupengyu's avatar
dupengyu committed
1 2
<template>
  <div>
dupengyu's avatar
dupengyu committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    <div class="nav-title">调度日志</div>
    <div class="search">
      <el-form
        class="search-form"
        :model="form"
        ref="form"
        :inline="true"
        size="mini"
      >
        <el-form-item label="执行器:">
          <el-select v-model="form.jobGroup" placeholder="请选择">
            <el-option
              v-for="item in groupList"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
dupengyu's avatar
dupengyu committed
23

dupengyu's avatar
dupengyu committed
24
        <el-form-item label="状态">
dupengyu's avatar
dupengyu committed
25
          <el-select v-model="form.logStatus" placeholder="请选择">
dupengyu's avatar
dupengyu committed
26 27
            <el-option
              v-for="item in options"
dupengyu's avatar
dupengyu committed
28
              :key="item.value"
dupengyu's avatar
dupengyu committed
29
              :label="item.label"
dupengyu's avatar
dupengyu committed
30
              :value="item.value"
dupengyu's avatar
dupengyu committed
31 32 33 34 35
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="时间">
dupengyu's avatar
dupengyu committed
36 37 38 39 40 41 42 43 44
          <el-date-picker
            v-model="dateRange"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>
dupengyu's avatar
dupengyu committed
45 46 47
        </el-form-item>
        <el-form-item>
          <el-button type="success" @click="toSearch">查询</el-button>
dupengyu's avatar
dupengyu committed
48
          <!-- <el-button type="primary" @click="handleEdit()">新增</el-button> -->
dupengyu's avatar
dupengyu committed
49 50 51
        </el-form-item>
      </el-form>
    </div>
dupengyu's avatar
dupengyu committed
52 53 54 55 56 57
    <div>
      <el-table
        :data="tableData"
        style="width: 100%"
        :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
      >
58 59 60
        <el-table-column prop="jobId" label="任务ID" align="center" />
        <el-table-column prop="triggerTime" label="调度时间" align="center" />
        <el-table-column prop="triggerCode" label="调度结果" align="center">
dupengyu's avatar
dupengyu committed
61
          <template slot-scope="scope">
62 63 64
            <el-tag
              :type="scope.row.triggerCode === 200 ? 'success' : 'danger'"
              >{{ scope.row.triggerCode === 200 ? "成功" : "失败" }}</el-tag
dupengyu's avatar
dupengyu committed
65 66 67
            >
          </template>
        </el-table-column>
68 69 70 71 72 73 74 75
        <el-table-column prop="triggerMsg" label="调度备注" align="center">
          <template slot-scope="scope">
            <el-button type="text" @click="handleView(scope.row.triggerMsg)"
              >查看</el-button
            >
          </template>
        </el-table-column>
        <el-table-column prop="handleTime" label="执行时间" align="center" />
dupengyu's avatar
dupengyu committed
76 77 78 79 80 81 82
        <el-table-column prop="handleMsg" label="参数结果" align="center">
          <template slot-scope="scope">
            <el-button type="text" @click="handleOpenView(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
dupengyu's avatar
dupengyu committed
83
      </el-table>
dupengyu's avatar
dupengyu committed
84 85 86 87 88 89 90
      <Pagination
        :limit="params.size"
        :page="params.current"
        :total="total"
        class="pagination"
        @pagination="handlePageChange"
      />
dupengyu's avatar
dupengyu committed
91
    </div>
92 93 94 95 96 97 98 99
    <el-dialog
      title="告警详情"
      :visible.sync="centerDialogVisible"
      width="600px"
      center
    >
      <div v-html="dialogInfo"></div>
    </el-dialog>
dupengyu's avatar
dupengyu committed
100 101 102 103 104 105 106 107 108 109 110 111 112
    <el-dialog
      title="参数结果"
      :visible.sync="DialogVisible"
      width="600px"
      center
    >
    <div class="boxlist">
      <div v-for="(item,index) in dialogOpenInfo" :key="index">
       {{index}}: {{item}}
      </div>
    </div>

    </el-dialog>
dupengyu's avatar
dupengyu committed
113 114 115 116
  </div>
</template>

<script>
dupengyu's avatar
dupengyu committed
117
import { jobgroupList, joblogList, selectByEquipldAndTime } from "@/api/job.js";
dupengyu's avatar
dupengyu committed
118 119 120
export default {
  data() {
    return {
dupengyu's avatar
dupengyu committed
121 122 123 124 125 126
      options: [
        { label: "全部", value: -1 },
        { label: "成功", value: 1 },
        { label: "失败", value: 2 },
        { label: "进行中", value: 3 },
      ],
dupengyu's avatar
dupengyu committed
127
      tableData: [],
128 129
      dialogInfo: "",
      centerDialogVisible: false,
dupengyu's avatar
dupengyu committed
130
      DialogVisible: false,
dupengyu's avatar
dupengyu committed
131
      form: {
dupengyu's avatar
dupengyu committed
132 133 134
        jobGroup: 0,
        jobId: 0,
        logStatus: -1,
dupengyu's avatar
dupengyu committed
135 136
      },
      groupList: [],
dupengyu's avatar
dupengyu committed
137 138 139 140 141 142
      params: {
        current: 1,
        size: 10,
      },
      total: 0,
      dateRange: [],
dupengyu's avatar
dupengyu committed
143
      dialogOpenInfo: "",
dupengyu's avatar
dupengyu committed
144 145 146
    };
  },
  mounted() {
dupengyu's avatar
dupengyu committed
147
    this.handleJobGroupList();
dupengyu's avatar
dupengyu committed
148 149 150
    this.handleJoblogList();
  },
  methods: {
dupengyu's avatar
dupengyu committed
151 152 153 154
    toSearch() {
      this.params.current = 1;
      this.handleJoblogList();
    },
dupengyu's avatar
dupengyu committed
155 156 157 158 159 160 161
    async handleJobGroupList() {
      let data = {
        start: 0,
        length: 999,
      };
      const queryParams = new URLSearchParams(data).toString();
      const res = await jobgroupList(queryParams);
dupengyu's avatar
dupengyu committed
162 163 164 165
      res.data.unshift({
        id: 0,
        title: "全部",
      });
dupengyu's avatar
dupengyu committed
166
      this.groupList = res.data;
dupengyu's avatar
dupengyu committed
167
      // this.form.jobGroup = res.data[0].id;
dupengyu's avatar
dupengyu committed
168
    },
169 170 171 172
    handleView(e) {
      this.dialogInfo = e;
      this.centerDialogVisible = true;
    },
dupengyu's avatar
dupengyu committed
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
    async handleOpenView(e) {
      let equipId;
      e.executorParam.split(";").forEach((part) => {
        if (part.startsWith("equipId:")) {
          equipId = part.split(":")[1];
        }
      });
      let data = {
        jobLogId: equipId,
        time: e.triggerTime.toString(),
      };
      // return;
      const res = await selectByEquipldAndTime(data);

      console.log(res);
      this.dialogOpenInfo = JSON.parse(res.receiveMessage);
      console.log(this.dialogOpenInfo);
      this.DialogVisible = true;
    },
dupengyu's avatar
dupengyu committed
192 193 194 195 196
    handlePageChange(pageData) {
      this.params.size = pageData.size;
      this.params.current = pageData.page;
      this.handleJoblogList();
    },
dupengyu's avatar
dupengyu committed
197
    async handleJoblogList() {
dupengyu's avatar
dupengyu committed
198 199 200
      // filterTime
      //       this.form.startUploadTime = this.dateRange[0];
      // this.form.endUploadTime = this.dateRange[1];
dupengyu's avatar
dupengyu committed
201
      let data = {
dupengyu's avatar
dupengyu committed
202 203 204
        ...this.form,
        start: (this.params.current - 1) * this.params.size,
        length: this.params.size,
dupengyu's avatar
dupengyu committed
205
      };
dupengyu's avatar
dupengyu committed
206 207 208
      if (this.dateRange.length > 0) {
        data.filterTime = this.dateRange[0] + " - " + this.dateRange[1];
      }
dupengyu's avatar
dupengyu committed
209
      const queryParams = new URLSearchParams(data).toString();
dupengyu's avatar
dupengyu committed
210 211
      const res = await joblogList(queryParams);
      console.log(res);
212
      this.tableData = res.data;
dupengyu's avatar
dupengyu committed
213
      this.total = res.recordsTotal;
dupengyu's avatar
dupengyu committed
214 215 216 217 218 219
    },
  },
};
</script>

<style lang="scss" scoped>
dupengyu's avatar
dupengyu committed
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
.nav-title {
  color: #02a7f0;
  font-size: 20px;
  position: relative;
  padding-left: 16px;
  font-weight: bold;
  line-height: 28px;
}
.nav-title::before {
  content: "";
  position: absolute;
  left: 0px;
  top: 1px;
  width: 5px;
  height: 100%;
  background-color: #02a7f0;
  border-radius: 4px;
}
.search {
  margin: 16px 0;
  .search-form {
    padding: 10px;
    background-color: #eaf1fe;
    margin-bottom: 20px;
    border-radius: 8px;
    .el-form-item--mini.el-form-item,
    .el-form-item--small.el-form-item {
      margin-bottom: 0;
    }
  }
}
dupengyu's avatar
dupengyu committed
251 252 253 254 255
.boxlist{
  max-height: 600px;
  overflow: hidden;
  overflow-y: auto;
}
dupengyu's avatar
dupengyu committed
256
</style>