zhangjie 3 年 前
コミット
c2d4178c0c
2 ファイル変更61 行追加3 行削除
  1. 17 0
      src/mixins/timeMixin.js
  2. 44 3
      src/modules/analysis/views/AnalysisBatchManage.vue

+ 17 - 0
src/mixins/timeMixin.js

@@ -0,0 +1,17 @@
+export default {
+  data() {
+    return {
+      setTs: []
+    };
+  },
+  methods: {
+    addSetTime(action, time = 1 * 1000) {
+      this.setTs.push(setTimeout(action, time));
+    },
+    clearSetTs() {
+      if (!this.setTs.length) return;
+      this.setTs.forEach(t => clearTimeout(t));
+      this.setTs = [];
+    }
+  }
+};

+ 44 - 3
src/modules/analysis/views/AnalysisBatchManage.vue

@@ -51,9 +51,25 @@
         <el-table-column prop="batchName" label="分析批次"></el-table-column>
         <el-table-column prop="semesterName" label="学期"></el-table-column>
         <el-table-column prop="status" label="状态">
-          <span slot-scope="scope">
-            {{ scope.row.status | analysisBatchStatusFilter }}
-          </span>
+          <template slot-scope="scope">
+            <span>
+              {{ scope.row.status | analysisBatchStatusFilter }}
+            </span>
+            <span v-if="scope.row.status === 'CALCULATING'" class="ml-2">
+              {{ scope.row.progress }}%</span
+            >
+            <span
+              v-if="scope.row.status === 'FINISH_CALCULATE'"
+              :class="[
+                'ml-2',
+                scope.row.result === 'SUCCESS'
+                  ? 'color-success'
+                  : 'color-danger'
+              ]"
+            >
+              {{ scope.row.result === "SUCCESS" ? "成功" : "失败" }}
+            </span>
+          </template>
         </el-table-column>
         <el-table-column
           class-name="action-column"
@@ -111,6 +127,16 @@
               @click="toDelete(scope.row)"
               >删除</el-button
             >
+            <el-button
+              v-if="
+                scope.row.reportFilePath &&
+                  scope.row.status === 'FINISH_CALCULATE'
+              "
+              class="btn-primary"
+              type="text"
+              @click="toViewLog(row)"
+              >下载日志</el-button
+            >
           </template>
         </el-table-column>
       </el-table>
@@ -169,10 +195,12 @@ import ModifyAnalysisBatch from "../components/ModifyAnalysisBatch.vue";
 import ModifyAnalysisBatchPaper from "../components/ModifyAnalysisBatchPaper.vue";
 import ImportFile from "@/components/ImportFile";
 import { downloadByApi } from "@/plugins/download";
+import timeMixins from "../../../mixins/timeMixin";
 
 export default {
   name: "analysis-batch-manage",
   components: { ModifyAnalysisBatch, ModifyAnalysisBatchPaper, ImportFile },
+  mixins: [timeMixins],
   data() {
     return {
       filter: {
@@ -195,9 +223,13 @@ export default {
   mounted() {
     this.toPage(1);
   },
+  beforeDestroy() {
+    this.clearSetTs();
+  },
   methods: {
     async getList() {
       if (!this.checkPrivilege("list", "list")) return;
+      this.clearSetTs();
 
       const datas = {
         ...this.filter,
@@ -210,6 +242,12 @@ export default {
         return item;
       });
       this.total = data.total;
+
+      if (this.dataList.some(item => item.status === "CALCULATING")) {
+        this.addSetTime(() => {
+          this.getList();
+        }, 10 * 1000);
+      }
     },
     toPage(page) {
       this.multipleSelection = [];
@@ -303,6 +341,9 @@ export default {
       await deleteAnalysisBatch([row.id]);
       this.$message.success("删除成功!");
       this.deletePageLastItem();
+    },
+    toViewLog(row) {
+      window.open(row.reportFilePath);
     }
   }
 };