Browse Source

导入导出任务

Michael Wang 4 years ago
parent
commit
1c0777f673

+ 3 - 12
src/api/examwork-task.js

@@ -2,18 +2,9 @@ import { httpApp } from "@/plugins/axiosIndex";
 import { pickBy } from "lodash-es";
 import { object2QueryString } from "@/utils/utils";
 
-export function searchTasks({
-  type = "",
-  entityId = "",
-  pageNumber = 1,
-  pageSize = 10,
-}) {
-  const data = pickBy(
-    { type, entityId, pageNumber, pageSize },
-    (v) => v !== ""
-  );
-  if (data.type)
-    return httpApp.post("/api/admin/task/query?" + object2QueryString(data));
+export function searchTasks({ type = "", pageNumber = 1, pageSize = 10 }) {
+  const data = pickBy({ type, pageNumber, pageSize }, (v) => v !== "");
+  return httpApp.post("/api/admin/task/query?" + object2QueryString(data));
 }
 
 export function importExamStudent({ examId, fileName, file, md5 }) {

+ 62 - 0
src/components/TaskSelect.vue

@@ -0,0 +1,62 @@
+<template>
+  <el-select
+    v-model="selected"
+    class="size-select"
+    placeholder="请选择"
+    @change="select"
+    :style="styles"
+    clearable
+  >
+    <el-option
+      v-for="item in optionList"
+      :key="item.code"
+      :label="item.name"
+      :value="item.code"
+    >
+      <span>{{ item.name }}</span>
+    </el-option>
+  </el-select>
+</template>
+
+<script>
+export default {
+  name: "TaskSelect",
+  props: {
+    value: {
+      type: String,
+      default: "",
+    },
+    options: { type: Array, default: () => null },
+    styles: { type: String, default: "width: 100px;" },
+  },
+  data() {
+    return {
+      optionList: this.options || [
+        { code: "CALCULATE_EXAM_SCORE", name: "考试重新算分" },
+        { code: "IMPORT_EXAM_STUDENT", name: "导入考生" },
+        { code: "IMPORT_EXAM_PAPER", name: "导入试卷" },
+        { code: "IMPORT_INVIGILATE_USER", name: "导入监考员" },
+        { code: "EXPORT_INVIGILATE_USER", name: "导出监考员" },
+      ],
+      selected: "",
+    };
+  },
+  async created() {},
+  watch: {
+    value: {
+      immediate: true,
+      handler(val) {
+        this.selected = val;
+      },
+    },
+  },
+  methods: {
+    select() {
+      this.$emit("input", this.selected);
+      this.$emit("change", this.selected);
+    },
+  },
+};
+</script>
+
+<style></style>

+ 129 - 0
src/features/examwork/ImportExportTask/ImportExportTask.vue

@@ -0,0 +1,129 @@
+<template>
+  <div>
+    <!-- 下载链接 -->
+    <el-form ref="form" :model="form" :rules="rules" inline>
+      <el-form-item label="任务名称" prop="type">
+        <TaskSelect v-model="form.type" />
+      </el-form-item>
+      <el-button @click="searchForm">查询</el-button>
+    </el-form>
+
+    <el-table :data="tableData" stripe style="width: 100%;">
+      <el-table-column type="selection" width="42" />
+      <el-table-column width="100" label="ID">
+        <span slot-scope="scope">{{ scope.row.id }}</span>
+      </el-table-column>
+      <el-table-column width="150" label="任务名称">
+        <span slot-scope="scope">{{ scope.row.entityName }}</span>
+      </el-table-column>
+      <el-table-column width="150" label="上传文件名">
+        <span slot-scope="scope">{{ scope.row.importFileName }}</span>
+      </el-table-column>
+      <el-table-column width="120" label="状态">
+        <span slot-scope="scope">{{ scope.row.status }}</span>
+      </el-table-column>
+      <el-table-column label="异常">
+        <span slot-scope="scope">{{ scope.row.summary }}</span>
+      </el-table-column>
+      <el-table-column width="100" label="上传时间">
+        <span slot-scope="scope">{{
+          scope.row.createTime | datetimeFilter
+        }}</span>
+      </el-table-column>
+      <el-table-column :context="_self" label="操作" width="210">
+        <div slot-scope="scope">
+          <el-button
+            size="mini"
+            type="primary"
+            plain
+            v-if="scope.row.status === 'FINISH'"
+            @click="
+              download({
+                id: scope.row.id,
+                type: scope.row.hasResultFile === '1' ? 'RESULT' : 'IMPORTFILE',
+              })
+            "
+          >
+            下载文件
+          </el-button>
+          <el-button
+            size="mini"
+            type="primary"
+            plain
+            v-if="scope.row.hasReportFile === '1'"
+            @click="download({ id: scope.row.id, type: 'REPORT' })"
+          >
+            导出报告
+          </el-button>
+        </div>
+      </el-table-column>
+    </el-table>
+    <div class="page float-right">
+      <el-pagination
+        @current-change="handleCurrentChange"
+        :current-page="currentPage"
+        :page-size="pageSize"
+        :page-sizes="[10, 20, 50, 100, 200, 300]"
+        @size-change="handleSizeChange"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="total"
+      />
+    </div>
+  </div>
+</template>
+
+<script>
+import { searchTasks } from "@/api/examwork-task";
+import { downloadFileURL } from "@/utils/utils";
+import { downloadFile } from "@/api/system-info";
+
+export default {
+  name: "ImportExportTask",
+  data() {
+    return {
+      form: {
+        type: "",
+      },
+      rules: {},
+      tableData: [],
+      currentPage: 1,
+      pageSize: 10,
+      total: 10,
+    };
+  },
+  methods: {
+    async searchForm() {
+      // try {
+      //   const valid = await this.$refs.form.validate();
+      //   if (!valid) return;
+      // } catch (error) {
+      //   console.log(error);
+      //   return;
+      // }
+      const res = await searchTasks({
+        type: this.form.type,
+        pageNumber: this.currentPage,
+        pageSize: this.pageSize,
+      });
+      this.tableData = res.data.data.records.records;
+      this.total = res.data.data.records.total;
+    },
+    handleCurrentChange(val) {
+      this.currentPage = val;
+      this.searchForm();
+    },
+    handleSizeChange(val) {
+      this.pageSize = val;
+      this.currentPage = 1;
+      this.searchForm();
+    },
+    async download({ id, type }) {
+      const res = await downloadFile({ id, type });
+      const url = res.data.data.url;
+      downloadFileURL(url);
+    },
+  },
+};
+</script>
+
+<style></style>

+ 8 - 0
src/router/index.js

@@ -138,6 +138,14 @@ const routes = [
             /* webpackChunkName: "exam" */ "../features/examwork/InvigilateManagement/InvigilateManagement.vue"
           ),
       },
+      {
+        path: "task",
+        name: "ImportExportTask",
+        component: () =>
+          import(
+            /* webpackChunkName: "exam" */ "../features/examwork/ImportExportTask/ImportExportTask.vue"
+          ),
+      },
     ],
   },
   {

+ 4 - 0
src/views/Layout/components/menu.js

@@ -68,6 +68,10 @@ const businessMenuConfig = [
         title: "考场监考设置",
         name: "InvigilateManagement",
       },
+      {
+        title: "导入导出任务",
+        name: "ImportExportTask",
+      },
     ],
   },
 ];