فهرست منبع

5.0.4接口对接

刘洋 11 ماه پیش
والد
کامیت
caefc808d9
2فایلهای تغییر یافته به همراه308 افزوده شده و 7 حذف شده
  1. 188 2
      src/modules/examwork/view/ipConfig.vue
  2. 120 5
      src/modules/oe/views/ReexamineRecord.vue

+ 188 - 2
src/modules/examwork/view/ipConfig.vue

@@ -37,14 +37,25 @@
             <el-button size="small" type="primary" @click="editItem(null)"
               >新增</el-button
             >
-            <el-button size="small" type="primary">批量导入</el-button>
-            <el-button size="small" type="danger">批量删除</el-button>
+            <el-button size="small" type="primary" @click="impCourse"
+              >批量导入</el-button
+            >
+            <el-button
+              size="small"
+              type="danger"
+              :disabled="!selectedIds.length"
+              @click="deleteMult(selectedIds)"
+              >批量删除</el-button
+            >
             <el-button
               size="small"
               type="success"
               @click="openSynchronousDialog"
               >同步到考试</el-button
             >
+            <el-button size="small" type="primary" @click="exportHandler"
+              >导出</el-button
+            >
           </el-form-item>
         </el-form>
         <el-table
@@ -190,6 +201,66 @@
         <el-button type="primary" @click="editSubmit">保存</el-button>
       </div>
     </el-dialog>
+
+    <!-- 导入弹窗 -->
+    <el-dialog title="导入窗口" width="520px" :visible.sync="impDialog">
+      <el-form>
+        <el-row>
+          <el-form-item style="margin-left: 20px">
+            <el-upload
+              ref="upload"
+              class="form_left"
+              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
+                slot="trigger"
+                size="small"
+                type="primary"
+                icon="el-icon-search"
+              >
+                选择文件
+              </el-button>
+              &nbsp;
+              <el-button
+                size="small"
+                type="primary"
+                icon="el-icon-check"
+                @click="submitUpload"
+              >
+                确认上传
+              </el-button>
+              <el-button
+                size="small"
+                type="primary"
+                icon="el-icon-refresh"
+                @click="removeFile"
+              >
+                清空文件
+              </el-button>
+              <el-button
+                size="small"
+                type="primary"
+                icon="el-icon-download"
+                @click="exportFile"
+              >
+                下载模板
+              </el-button>
+              <div slot="tip" class="el-upload__tip">只能上传xlsx文件</div>
+            </el-upload>
+          </el-form-item>
+        </el-row>
+      </el-form>
+    </el-dialog>
   </div>
 </template>
 
@@ -251,12 +322,25 @@ export default {
         ],
       },
       showEditDialog: false,
+      impDialog: false,
+      uploadAction: EXAM_WORK_API + "/org/ip/import",
+      uploadHeaders: {},
+      uploadData: {},
+      errMessages: [],
+      errDialog: false,
+      fileLoading: false,
+      loading: false,
+      fileList: [],
     };
   },
   created() {
     this.getOrgList4Search("");
     this.searchForm();
     this.getExamList();
+    this.uploadHeaders = {
+      key: this.user.key,
+      token: this.user.token,
+    };
   },
   methods: {
     getExamList() {
@@ -428,6 +512,108 @@ export default {
     },
     selectChange(rows) {
       this.selectedIds = rows.map((item) => item.id);
+    }, //导入
+    impCourse() {
+      this.impDialog = true;
+      this.initUpload();
+    },
+    initUpload() {
+      this.fileList = [];
+    },
+    beforeUpload(file) {
+      console.log(file);
+    },
+    uploadProgress() {
+      console.log("uploadProgress");
+    },
+    uploadSuccess(response) {
+      if (!response.hasError) {
+        this.$notify({
+          message: "上传成功",
+          type: "success",
+        });
+        this.fileLoading = false;
+        this.impDialog = false;
+        this.searchForm();
+      } else {
+        this.fileLoading = false;
+        this.impDialog = false;
+        this.errMessages = response.failRecords;
+        this.errDialog = true;
+      }
+    },
+    uploadError(response) {
+      var json = JSON.parse(response.message);
+      if (response.status == 500) {
+        this.$notify({
+          message: json.desc,
+          type: "error",
+        });
+      }
+      this.fileLoading = false;
+    },
+    //确定上传
+    submitUpload() {
+      if (!this.checkUpload()) {
+        return false;
+      }
+      this.$refs.upload.submit();
+      this.fileLoading = true;
+    },
+    checkUpload() {
+      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.fileList = [];
+      this.$refs.upload.clearFiles();
+    },
+    //下载模板
+    exportFile() {
+      window.location.href =
+        EXAM_WORK_API +
+        "/org/ip/template?$key=" +
+        this.user.key +
+        "&$token=" +
+        this.user.token;
+    },
+    exportHandler() {
+      var param = new URLSearchParams(this.formSearch);
+      window.open(
+        EXAM_WORK_API +
+          "/org/ip/export" +
+          "?$key=" +
+          this.user.key +
+          "&$token=" +
+          this.user.token +
+          "&" +
+          param
+      );
     },
   },
 };

+ 120 - 5
src/modules/oe/views/ReexamineRecord.vue

@@ -8,6 +8,21 @@
           :inline="true"
           label-width="70px"
         >
+          <el-form-item label="考试">
+            <el-select
+              v-model="formSearch.examId"
+              class="input"
+              filterable
+              placeholder="请选择"
+            >
+              <el-option
+                v-for="item in examList4Search"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              ></el-option>
+            </el-select>
+          </el-form-item>
           <el-form-item label="学习中心">
             <el-select
               v-model="formSearch.orgId"
@@ -27,6 +42,31 @@
               ></el-option>
             </el-select>
           </el-form-item>
+          <el-form-item label="课程">
+            <el-select
+              v-model="formSearch.courseId"
+              class="input"
+              filterable
+              clearable
+              placeholder="请选择"
+            >
+              <el-option
+                v-for="item in courseList4Search"
+                :key="item.id"
+                :label="item.name + ' - ' + item.code"
+                :value="item.id"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item label="学生姓名">
+            <el-input v-model="formSearch.studentName" class="input" />
+          </el-form-item>
+          <el-form-item label="学号">
+            <el-input v-model="formSearch.studentCode" class="input" />
+          </el-form-item>
+          <el-form-item label="证件号">
+            <el-input v-model="formSearch.identityNumber" class="input" />
+          </el-form-item>
           <el-form-item>
             <el-button
               size="small"
@@ -34,7 +74,9 @@
               @click="resetPageAndSearchForm"
               >查询</el-button
             >
-            <el-button size="small" type="primary">导出</el-button>
+            <el-button size="small" type="primary" @click="exportHandler"
+              >导出</el-button
+            >
           </el-form-item>
         </el-form>
         <el-table
@@ -71,7 +113,7 @@
 </template>
 
 <script>
-import { CORE_API } from "@/constants/constants.js";
+import { CORE_API, EXAM_WORK_API } from "@/constants/constants.js";
 import { mapState } from "vuex";
 export default {
   name: "IpConfig",
@@ -80,19 +122,38 @@ export default {
   },
   data() {
     return {
-      formSearch: {},
+      formSearch: {
+        examId: "",
+        orgId: "",
+        courseId: "",
+        studentName: "",
+        studentCode: "",
+        identityNumber: "",
+      },
       getOrgList4SearchLoading: false,
       orgList4Search: [],
       tableData: [],
       currentPage: 1,
       pageSize: 10,
       total: 10,
+      examList4Search: [],
+      courseList4Search: [],
     };
   },
   created() {
     this.getOrgList4Search("");
+    this.queryExams4Search("");
+    this.getCourses4Search("");
   },
   methods: {
+    getCourses4Search(query) {
+      this.courseLoading4Search = true;
+      this.$httpWithMsg
+        .get(CORE_API + "/course/query?name=" + query)
+        .then((response) => {
+          this.courseList4Search = response.data;
+        });
+    },
     getOrgList4Search(orgName) {
       this.getOrgList4SearchLoading = true;
       let url =
@@ -112,11 +173,40 @@ export default {
           this.getOrgList4SearchLoading = false;
         });
     },
+    queryExams4Search() {
+      this.$httpWithMsg
+        .get(EXAM_WORK_API + "/exam/queryByNameLike?enable=true&name=" + name)
+        .then((response) => {
+          this.examList4Search = response.data;
+        });
+    },
     resetPageAndSearchForm() {
       this.currentPage = 1;
       this.searchForm();
     },
-    searchForm() {},
+    searchForm() {
+      if (!this.formSearch.examId) {
+        this.$notify({
+          type: "warning",
+          message: "请选择考试",
+        });
+        return;
+      }
+      let url = "/api/ecs_oe_admin/reexamine/log/list";
+      this.$httpWithMsg
+        .post(url, null, {
+          params: {
+            ...this.formSearch,
+          },
+          headers: {
+            "content-type": "application/x-www-form-urlencoded",
+          },
+        })
+        .then((response) => {
+          this.tableData = response.data.content || [];
+          this.total = response.data.totalElements;
+        });
+    },
     handleCurrentChange(val) {
       this.currentPage = val;
       this.searchForm();
@@ -129,8 +219,33 @@ export default {
       this.curRow = item;
       this.showEditDialog = true;
     },
+    exportHandler() {
+      if (!this.formSearch.examId) {
+        this.$notify({
+          type: "warning",
+          message: "请选择考试",
+        });
+        return;
+      }
+      var param = new URLSearchParams(this.formSearch);
+      window.open(
+        "/api/ecs_oe_admin/reexamine/log/list/export" +
+          "?$key=" +
+          this.user.key +
+          "&$token=" +
+          this.user.token +
+          "&" +
+          param
+      );
+    },
   },
 };
 </script>
 
-<style></style>
+<style lang="scss" scoped>
+.box-body {
+  .input {
+    width: 200px !important;
+  }
+}
+</style>