Przeglądaj źródła

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-3/examcloud-web-admin

weiwenhai 6 lat temu
rodzic
commit
e5641390db

+ 1 - 1
src/constants/constants.js

@@ -4,5 +4,5 @@ export const MARKING_API = "/api/ecs_marking"; //阅卷API
 export const DATA_PROCESS_API = "/api/ecs_data_process"; //数据中间层API
 export const OE_API = "/api/ecs_oe"; //网考API
 export const QUESTION_API = "/api/ecs_ques"; //题库API
-export const OUTLET_API = "/api/ecs_outlet";
+export const EXCHANGE_API = "/api/ecs_outlet"; //接口机
 export const PRINT_API = "/api/ecs_prt";

+ 5 - 0
src/modules/examwork/routes/routes.js

@@ -11,6 +11,11 @@ export default [
         path: "student", //学生管理
         meta: { pageName: "学生管理" },
         component: student
+      },
+      {
+        path: "exam_student_import", //学生管理
+        meta: { pageName: "考生导入" },
+        component: student
       }
     ]
   }

+ 410 - 0
src/modules/examwork/view/examStudentImport.vue

@@ -0,0 +1,410 @@
+<template>
+  <div>
+    <section class="content" style="margin-top: -10px;">
+      <div class="box box-info">
+        <!-- 头信息 -->
+        <div class="box-header with-border">
+          <h3 class="box-title">考生导入</h3>
+          <div class="box-tools pull-right">
+            <button
+              type="button"
+              class="btn btn-box-tool"
+              data-widget="collapse"
+            >
+              <i class="fa fa-minus"></i>
+            </button>
+          </div>
+        </div>
+
+        <!-- 正文信息 -->
+        <div class="box-body">
+          <el-form
+            :inline="true"
+            :model="formSearch"
+            label-position="right"
+            label-width="100px"
+          >
+            <el-form-item class="pull-right buttonframe">
+              <el-button size="small" type="primary" icon="upload2" @click="imp"
+                >导入
+              </el-button>
+            </el-form-item>
+          </el-form>
+
+          <!-- 导入弹窗 -->
+          <el-dialog
+            title="考生信息导入页"
+            size="tiny"
+            v-model="studentImportDialog"
+          >
+            <el-form :model="studentImportForm" ref="studentImportForm">
+              <el-row>
+                <el-form-item
+                  style="margin-left:30px"
+                  label="考试"
+                  prop="value"
+                >
+                  <el-select
+                    class="input"
+                    :remote-method="queryExams"
+                    remote
+                    :loading="queryExamsLoading"
+                    filterable
+                    clearable
+                    v-model="studentImportForm.examId"
+                    placeholder="请选择"
+                  >
+                    <el-option
+                      v-for="item in examList"
+                      :label="item.name"
+                      :value="item.id"
+                      :key="item.id"
+                      :disabled="!item.enable"
+                    >
+                    </el-option>
+                  </el-select>
+                </el-form-item>
+              </el-row>
+              <el-row>
+                <el-form-item style="margin-left:30px">
+                  <el-upload
+                    class="form_left"
+                    ref="upload"
+                    accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+                    :action="uploadAction"
+                    :headers="uploadHeaders"
+                    :data="uploadData"
+                    :before-upload="beforeUpload"
+                    :on-progress="uploadProgress"
+                    :on-success="uploadSuccess"
+                    :on-error="uploadError"
+                    :file-list="fileList"
+                    :auto-upload="false"
+                    :multiple="false"
+                  >
+                    <el-button size="small" slot="trigger" type="primary"
+                      >选择文件</el-button
+                    >
+                    <el-button
+                      size="small"
+                      style="margin-left:10px;"
+                      type="success"
+                      @click="submitUpload"
+                      >确认上传
+                    </el-button>
+                    <el-button
+                      size="small"
+                      style="margin-left: 10px;"
+                      type="danger"
+                      @click="removeFile"
+                      >清空文件
+                    </el-button>
+                    <el-button size="small" type="info" @click="exportFile"
+                      >下载模板
+                    </el-button>
+                    <div slot="tip" class="el-upload__tip">
+                      只能上传xlsx文件
+                    </div>
+                  </el-upload>
+                </el-form-item>
+              </el-row>
+            </el-form>
+          </el-dialog>
+
+          <!-- 页面列表 -->
+          <el-table
+            :data="tableData"
+            border
+            style="width: 100%;text-align:center;"
+          >
+            <el-table-column inline-template width="100" label="ID">
+              <div>
+                <span>{{ row.id }}</span>
+              </div>
+            </el-table-column>
+            <el-table-column inline-template width="170" label="顶级机构">
+              <div>
+                <span>{{ row.rootOrgName }}</span>
+              </div>
+            </el-table-column>
+            <el-table-column inline-template width="170" label="考试">
+              <div>
+                <span>{{ row.examName }}</span>
+              </div>
+            </el-table-column>
+            <el-table-column inline-template width="170" label="上传文件名">
+              <div>
+                <span>{{ row.fileName }}</span>
+              </div>
+            </el-table-column>
+            <el-table-column inline-template width="170" label="状态">
+              <div>
+                <span>{{ row.statusDesc }}</span>
+              </div>
+            </el-table-column>
+            <el-table-column inline-template label="异常">
+              <div>
+                <span>{{ row.errorDesc }}</span>
+              </div>
+            </el-table-column>
+            <el-table-column inline-template width="170" label="上传时间">
+              <div>
+                <span>{{ row.creationTime }}</span>
+              </div>
+            </el-table-column>
+            <el-table-column inline-template label="操作" width="190">
+              <div>
+                <el-button
+                  size="mini"
+                  type="warning"
+                  @click="getUploadedFile(row.id);"
+                  >下载导入文件
+                </el-button>
+                <el-button
+                  v-if="
+                    row.status == 'DATA_PROCESSING_COMPLETE' ||
+                      row.status == 'ERROR'
+                  "
+                  size="mini"
+                  type="warning"
+                  @click="getReports(row.id);"
+                  >导出报告
+                </el-button>
+              </div>
+            </el-table-column>
+          </el-table>
+          <div class="page pull-right">
+            <el-pagination
+              @current-change="handleCurrentChange"
+              :current-page="currentPage"
+              :page-size="pageSize"
+              layout="total, prev, pager, next, jumper"
+              :total="total"
+            >
+            </el-pagination>
+          </div>
+        </div>
+      </div>
+    </section>
+  </div>
+</template>
+<style scoped></style>
+<script>
+import { mapActions, mapState } from "vuex";
+import { USER_SIGNIN } from "../store/user";
+import { task_api, exam_work_api } from "../store/global";
+
+export default {
+  data() {
+    return {
+      formSearch: {},
+      uploadAction: task_api + "/examStudentImport/import",
+      studentImportDialog: false,
+      examList: [],
+      uploadHeaders: {},
+      uploadData: { examId: "" },
+      fileList: [],
+      fileLoading: false,
+      queryExamsLoading: false,
+      studentImportForm: {
+        examId: null
+      },
+
+      tableData: [],
+      currentPage: 1,
+      pageSize: 10,
+      total: 0
+    };
+  },
+  computed: {
+    ...mapState({ user: state => state.user })
+  },
+  methods: {
+    ...mapActions([USER_SIGNIN]),
+
+    handleCurrentChange(val) {
+      this.currentPage = val;
+      this.queryTableDatas();
+    },
+    imp() {
+      this.studentImportDialog = true;
+      this.initUpload();
+    },
+    initUpload() {
+      if (this.$refs.studentImportForm) {
+        this.$refs.studentImportForm.resetFields();
+      }
+      this.fileList = [];
+      this.studentImportForm.examId = null;
+      this.examList = [];
+    },
+    beforeUpload(file) {
+      console.log(file);
+    },
+    uploadProgress(event, file, fileList) {
+      console.log("uploadProgress");
+      console.log(event);
+      console.log(file);
+      console.log(fileList);
+    },
+    uploadSuccess(response, file, fileList) {
+      console.log("uploadSuccess");
+      console.log(response);
+      console.log(file);
+      console.log(fileList);
+      this.$notify({
+        message: "上传成功",
+        type: "success"
+      });
+      this.fileLoading = false;
+      this.studentImportDialog = false;
+      this.queryTableDatas();
+    },
+    uploadError(response, file, fileList) {
+      console.log("uploadError");
+      console.log(response);
+      console.log(file);
+      console.log(fileList);
+      var jsonStr = response.message.substring(4);
+      var resp = eval("(" + jsonStr + ")");
+      if (response.status == 500) {
+        this.$notify({
+          message: resp.desc,
+          type: "error"
+        });
+      }
+      this.fileLoading = false;
+    },
+    //确定上传
+    submitUpload() {
+      if (!this.checkUpload()) {
+        return false;
+      }
+      this.$refs.upload.submit();
+      this.fileLoading = true;
+    },
+    checkUpload() {
+      if (!this.studentImportForm.examId) {
+        this.$notify({
+          message: "请选择考试批次",
+          type: "error"
+        });
+        return false;
+      } else {
+        this.uploadData.examId = this.studentImportForm.examId;
+      }
+      var fileList = this.$refs.upload.uploadFiles;
+      if (fileList.length == 0) {
+        this.$notify({
+          message: "上传文件不能为空",
+          type: "error"
+        });
+        return false;
+      }
+      if (fileList.length > 1) {
+        this.$notify({
+          message: "每次只能上传一个文件",
+          type: "error"
+        });
+        return false;
+      }
+      for (let file of fileList) {
+        if (!file.name.endsWith(".xlsx")) {
+          this.$notify({
+            message: "上传文件必须为xlsx格式",
+            type: "error"
+          });
+          this.initUpload();
+          return false;
+        }
+      }
+      return true;
+    },
+    //清空文件
+    removeFile() {
+      this.$refs.upload.clearFiles();
+    },
+    //下载模板
+    exportFile() {
+      window.location.href =
+        "/api/ecs_exam_work/exam_student/downloadTemplate?$key=" +
+        this.user.key +
+        "&$token=" +
+        this.user.token;
+    },
+    //下载报告
+    getReports(id) {
+      window.location.href =
+        task_api +
+        "/examStudentImport/getReports/" +
+        id +
+        "?$key=" +
+        this.user.key +
+        "&$token=" +
+        this.user.token;
+    },
+    //下载导入文件
+    getUploadedFile(id) {
+      window.location.href =
+        task_api +
+        "/examStudentImport/getUploadedFile/" +
+        id +
+        "?$key=" +
+        this.user.key +
+        "&$token=" +
+        this.user.token;
+    },
+    queryExams(name) {
+      console.log("queryExams; name: " + name);
+      this.queryExamsLoading = true;
+      this.$http
+        .get(exam_work_api + "/exam/queryByNameLike?name=" + name)
+        .then(response => {
+          this.queryExamsLoading = false;
+          this.examList = response.body;
+        })
+        .catch(response => {
+          if (response.status == 500) {
+            this.$notify({
+              showClose: true,
+              message: response.body.desc,
+              type: "error"
+            });
+          }
+          this.queryExamsLoading = false;
+        });
+    },
+    queryTableDatas: function() {
+      var url =
+        task_api +
+        "/examStudentImport/all/" +
+        (this.currentPage - 1) +
+        "/" +
+        this.pageSize;
+      this.$http
+        .get(url)
+        .then(response => {
+          console.log(response);
+          this.tableData = response.body.list;
+          this.total = response.body.total;
+        })
+        .catch(response => {
+          if (response.status == 500) {
+            this.$notify({
+              showClose: true,
+              message: response.body.desc,
+              type: "error"
+            });
+          }
+        });
+    }
+  },
+  created() {
+    this.queryTableDatas();
+    this.uploadHeaders = {
+      key: this.user.key,
+      token: this.user.token
+    };
+  }
+};
+</script>

+ 6 - 2
src/modules/examwork/view/student.vue

@@ -417,7 +417,11 @@
 </template>
 
 <script>
-import { CORE_API, EXAM_WORK_API, OUTLET_API } from "@/constants/constants.js";
+import {
+  CORE_API,
+  EXAM_WORK_API,
+  EXCHANGE_API
+} from "@/constants/constants.js";
 import { mapState } from "vuex";
 
 export default {
@@ -462,7 +466,7 @@ export default {
       photo: { url: "" },
 
       errMessages: [],
-      uploadAction: OUTLET_API + "/facepp/add",
+      uploadAction: EXCHANGE_API + "/facepp/add",
       uploadData: {},
       fileLoading: false,
       fileList: [],