Browse Source

新增考生复制功能

WANG 5 năm trước cách đây
mục cha
commit
0e52d5a13f
1 tập tin đã thay đổi với 107 bổ sung2 xóa
  1. 107 2
      src/modules/examwork/view/examInfo.vue

+ 107 - 2
src/modules/examwork/view/examInfo.vue

@@ -197,7 +197,14 @@
                         @click="editOrgSettings(scope.row)"
                       >
                         学习中心设置
-                      </el-button></el-dropdown-item
+                      </el-button>
+                      <el-button
+                        size="mini"
+                        type="primary"
+                        icon="el-icon-edit"
+                        @click="showCopyExam(scope.row)"
+                        >复制</el-button
+                      ></el-dropdown-item
                     >
                   </el-dropdown-menu></el-dropdown
                 >
@@ -218,6 +225,51 @@
           >
           </el-pagination>
         </div>
+
+        <!-- 考试复制弹窗 -->
+        <el-dialog
+          :title="examCopyTitle"
+          width="500px"
+          :visible.sync="copyExamDialog"
+        >
+          <el-form
+            :model="examCopyForm"
+            :rules="examCopyFormRules"
+            ref="examCopyForm"
+            class="editForm"
+            :inline="true"
+            label-width="120px"
+          >
+            <el-row>
+              <el-form-item label="考试编码" placeholder="">
+                <el-input
+                  v-model="examCopyForm.destExamName"
+                  class="input"
+                  :disabled="true"
+                  maxlength="20"
+                ></el-input>
+              </el-form-item>
+            </el-row>
+            <el-row>
+              <el-form-item
+                label="考试名称"
+                placeholder="请输入考试名称"
+                prop="destExamName"
+              >
+                <el-input
+                  v-model="examCopyForm.destExamName"
+                  class="input"
+                  maxlength="20"
+                ></el-input>
+              </el-form-item>
+            </el-row>
+
+            <div style="text-align: center;">
+              <el-button type="primary" @click="copyExam">确 定</el-button>
+              <el-button @click="copyExamDialog = false">取 消</el-button>
+            </div>
+          </el-form>
+        </el-dialog>
       </div>
     </div>
   </section>
@@ -226,6 +278,17 @@
 import { CORE_API, EXAM_WORK_API, EXAM_TYPE } from "@/constants/constants.js";
 import { mapState } from "vuex";
 
+let _this = null;
+
+let validateDestExamName = (rule, value, callback) => {
+  let name = _this.examCopyForm.destExamName;
+  if (name == "") {
+    callback(new Error("请输入考试名称"));
+  } else {
+    callback();
+  }
+};
+
 export default {
   data() {
     return {
@@ -253,7 +316,21 @@ export default {
       examInfoDialog: false,
       examId: "",
       selectedExamIds: [],
-      button: {}
+      button: {},
+
+      copyExamDialog: false,
+      examCopyTitle: null,
+      examCopyForm: {
+        srcExamId: null,
+        destExamCode: null,
+        destExamName: null,
+        copyOrgSettings: false
+      },
+      examCopyFormRules: {
+        destExamName: [
+          { required: true, validator: validateDestExamName, trigger: "blur" }
+        ]
+      }
     };
   },
   computed: {
@@ -272,6 +349,32 @@ export default {
   },
 
   methods: {
+    showCopyExam(row) {
+      this.examCopyTitle = "复制考试:" + row.name;
+      this.examCopyForm.srcExamId = row.id;
+      this.examCopyForm.destExamCode = null;
+      this.examCopyForm.destExamName = null;
+      this.copyExamDialog = true;
+    },
+    copyExam() {
+      this.examCopyForm.destExamCode = this.examCopyForm.destExamName;
+      var url = EXAM_WORK_API + "/exam/copyExam";
+      this.$refs.examCopyForm.validate(valid => {
+        if (valid) {
+          this.$httpWithMsg.post(url, this.examCopyForm).then(response => {
+            console.log(response);
+            this.$notify({
+              type: "success",
+              message: "复制成功"
+            });
+            this.copyExamDialog = false;
+            this.searchForm();
+          });
+        } else {
+          return false;
+        }
+      });
+    },
     selectChange(row) {
       this.selectedExamIds = [];
       row.forEach((element, index) => {
@@ -434,6 +537,8 @@ export default {
   },
   //初始化查询
   created() {
+    _this = this;
+
     let sessionData = sessionStorage.getItem("E_EAXM_SEARCH_PARAMS");
     let pageSize = sessionStorage.getItem("E_EAXM_SEARCH_PAGE_SIZE");
     let currentPage = sessionStorage.getItem("E_EAXM_SEARCH_CUR_PAGE");