Explorar o código

5.0.4开发中

刘洋 hai 11 meses
pai
achega
2c309b77c3
Modificáronse 2 ficheiros con 218 adicións e 15 borrados
  1. 207 15
      src/modules/examwork/view/ipConfig.vue
  2. 11 0
      src/modules/oe/views/ReexamineRecord.vue

+ 207 - 15
src/modules/examwork/view/ipConfig.vue

@@ -1,5 +1,5 @@
 <template>
-  <section class="content">
+  <div class="ip-config">
     <div class="box box-info">
       <div class="box-body">
         <el-form
@@ -12,9 +12,6 @@
             <el-select
               v-model="formSearch.orgId"
               class="input"
-              :remote-method="getOrgList4Search"
-              :loading="getOrgList4SearchLoading"
-              remote
               filterable
               clearable
               placeholder="请选择"
@@ -57,6 +54,46 @@
           @selection-change="selectChange"
         >
           <el-table-column type="selection" width="50"></el-table-column>
+          <el-table-column prop="ip" width label="IP/IP段"></el-table-column>
+          <el-table-column
+            prop="orgCode"
+            width
+            label="学习中心代码"
+          ></el-table-column>
+          <el-table-column
+            prop="orgName"
+            width
+            label="学习中心"
+          ></el-table-column>
+          <el-table-column prop="remark" width label="备注"></el-table-column>
+          <el-table-column
+            prop="updateTime"
+            width
+            label="操作时间"
+          ></el-table-column>
+          <el-table-column
+            prop="updateName"
+            width
+            label="操作人"
+          ></el-table-column>
+          <el-table-column label="操作" width="300">
+            <div slot-scope="scope">
+              <el-button
+                size="mini"
+                type="primary"
+                plain
+                @click="editItem(scope.row)"
+                >编辑</el-button
+              >
+              <el-button
+                size="mini"
+                type="danger"
+                plain
+                @click="deleteItem(scope.row)"
+                >删除</el-button
+              >
+            </div>
+          </el-table-column>
         </el-table>
         <div class="page pull-right">
           <el-pagination
@@ -85,8 +122,16 @@
         <el-form-item label="选择考试" prop="examId">
           <el-select
             v-model="synchronousForm.examId"
-            placeholder="请选择考试"
-          />
+            filterable
+            placeholder="请选择"
+          >
+            <el-option
+              v-for="item in examList"
+              :key="item.id"
+              :label="item.name"
+              :value="item.id"
+            ></el-option>
+          </el-select>
           <div style="font-size: 12px; color: #e6a23c">
             提示:只能选择开启了IP特殊设置的考试
           </div>
@@ -109,10 +154,30 @@
         label-width="80px"
       >
         <el-form-item label="学习中心" prop="orgId">
-          <el-select v-model="editForm.orgId" placeholder="请选择学习中心" />
+          <el-select
+            v-model="editForm.orgId"
+            filterable
+            clearable
+            placeholder="请选择"
+          >
+            <el-option
+              v-for="item in orgList4Search"
+              :key="item.id"
+              :label="item.name + ' - ' + item.code"
+              :value="item.id"
+            ></el-option>
+          </el-select>
         </el-form-item>
         <el-form-item label="IP/IP段" prop="ip">
-          <el-input v-model="editForm.ip" placeholder="请输入IP或者IP段" />
+          <div style="display: flex; align-items: center">
+            <el-input v-model="editForm.ip" placeholder="请输入IP或者IP段" />
+            <el-button
+              type="primary"
+              style="margin-left: 10px"
+              @click="getIpAddress"
+              >获取本机ip</el-button
+            >
+          </div>
         </el-form-item>
         <el-form-item label="备注" prop="remark">
           <el-input v-model="editForm.remark" type="textarea" />
@@ -123,11 +188,11 @@
         <el-button type="primary" @click="editSubmit">保存</el-button>
       </div>
     </el-dialog>
-  </section>
+  </div>
 </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",
@@ -136,6 +201,7 @@ export default {
   },
   data() {
     return {
+      examList: [],
       curRow: null,
       showSynchronousDialog: false,
       formSearch: {
@@ -153,7 +219,22 @@ export default {
         ip: "",
         remark: "",
       },
-      editRules: {},
+      editRules: {
+        orgId: [
+          {
+            required: true,
+            message: "请选择学习中心",
+            trigger: "blur",
+          },
+        ],
+        ip: [
+          {
+            required: true,
+            message: "请填写IP或IP段",
+            trigger: "blur",
+          },
+        ],
+      },
       synchronousForm: {
         examId: "",
       },
@@ -171,15 +252,91 @@ export default {
   },
   created() {
     this.getOrgList4Search("");
+    this.searchForm();
+    this.getExamList();
   },
   methods: {
-    editSubmit() {},
+    getExamList() {
+      this.$httpWithMsg
+        .get(EXAM_WORK_API + "/exam/queryByNameLike?enable=true&name=" + name)
+        .then((response) => {
+          this.examList = response.data;
+        });
+    },
+    getIpAddress() {
+      let year = new Date().getFullYear();
+      fetch(`https://${year}.ip138.com/`)
+        .then((x) => x.text())
+        .then((h) => {
+          let domParser = new DOMParser();
+          let doc = domParser.parseFromString(h, "text/html");
+          let text = doc?.querySelector("p")?.innerText?.trim();
+          // document.getElementById('content1').innerText = text;
+          // let ipAddress = {ip: "", location: "", type: ""}
+          // try {
+          //     let ip = text.substring(text.indexOf("[")+1,text.indexOf("]")).trim();
+          //     ipAddress.ip = ip;
+          //     let other = text.substring(text.indexOf("来自:")+3).trim();
+          //     let arr = other.split(" ");
+          //     ipAddress.location = arr[0];
+          //     ipAddress.type = arr[1];
+          // }catch (e) {
+          //     console.error(e)
+          // }
+          let ip = text
+            .substring(text.indexOf("[") + 1, text.indexOf("]"))
+            .trim();
+          this.editForm.ip = ip;
+        });
+    },
+    editSubmit() {
+      this.$refs.editRef.validate((valid) => {
+        if (valid) {
+          let url = EXAM_WORK_API + "/org/ip/save";
+          let data = {
+            ...this.editForm,
+            // ip: encodeURIComponent(this.editForm.ip),
+          };
+          if (this.curRow) {
+            data.id = this.curRow.id;
+          }
+          this.$httpWithMsg
+            .post(url, null, {
+              params: data,
+            })
+            .then(() => {
+              this.$notify({
+                type: "success",
+                message: (this.curRow ? "修改" : "新增") + "成功!",
+              });
+              this.resetPageAndSearchForm();
+              this.showEditDialog = false;
+            });
+        }
+      });
+    },
     openSynchronousDialog() {
       this.synchronousForm.examId = "";
       this.showSynchronousDialog = true;
     },
     synchronousSubmit() {
-      this.showSynchronousDialog = false;
+      // this.showSynchronousDialog = false;
+      this.$refs.synchronousRef.validate((valid) => {
+        if (valid) {
+          this.$httpWithMsg
+            .post(EXAM_WORK_API + "/org/ip/exam/add", null, {
+              params: { ...this.synchronousForm },
+            })
+            .then(() => {
+              this.$notify({
+                type: "success",
+                message: "同步成功!",
+              });
+              this.resetPageAndSearchForm();
+              this.showSynchronousDialog = false;
+            });
+        }
+      });
     },
     getOrgList4Search(orgName) {
       this.getOrgList4SearchLoading = true;
@@ -204,7 +361,22 @@ export default {
       this.currentPage = 1;
       this.searchForm();
     },
-    searchForm() {},
+    searchForm() {
+      let url = EXAM_WORK_API + "/org/ip/page";
+      this.$httpWithMsg
+        .post(url, null, {
+          params: {
+            ...this.formSearch,
+          },
+          headers: {
+            "content-type": "application/x-www-form-urlencoded",
+          },
+        })
+        .then((response) => {
+          this.tableData = response.data.list;
+          this.total = response.data.total;
+        });
+    },
     handleCurrentChange(val) {
       this.currentPage = val;
       this.searchForm();
@@ -214,9 +386,19 @@ export default {
       this.searchForm();
     },
     editItem(item) {
+      if (!item) {
+        this.editForm = {
+          orgId: "",
+          ip: "",
+          remark: "",
+        };
+      }
       this.curRow = item;
       this.showEditDialog = true;
     },
+    deleteItem(item) {
+      console.log(item);
+    },
     selectChange(rows) {
       this.selectedIds = rows.map((item) => item.id);
     },
@@ -224,4 +406,14 @@ export default {
 };
 </script>
 
-<style></style>
+<style lang="scss" scoped>
+.ip-config {
+  margin-top: 0 !important;
+  .el-form-item {
+    margin-bottom: 15px !important;
+    :deep(.el-form-item__label) {
+      margin-bottom: 2px !important;
+    }
+  }
+}
+</style>

+ 11 - 0
src/modules/oe/views/ReexamineRecord.vue

@@ -42,6 +42,17 @@
           border
           style="width: 100%; text-align: center; margin-top: 10px"
         >
+          <el-table-column prop="a" width="80" label="姓名"></el-table-column>
+          <el-table-column prop="b" label="学号"></el-table-column>
+          <el-table-column prop="c" label="证件号"></el-table-column>
+          <el-table-column prop="d" label="学习中心"></el-table-column>
+          <el-table-column prop="e" label="课程"></el-table-column>
+          <el-table-column
+            prop="f"
+            width="140"
+            label="操作时间"
+          ></el-table-column>
+          <el-table-column prop="g" width="80" label="操作人"></el-table-column>
         </el-table>
         <div class="page pull-right">
           <el-pagination