zhangjie il y a 3 ans
Parent
commit
d3f20ab0ea

+ 3 - 0
src/modules/base/api.js

@@ -340,6 +340,9 @@ export const updateExam = datas => {
 export const ableExam = ({ id, enable }) => {
   return $postParam("/api/admin/basic/exam/enable", { id, enable });
 };
+export const examConfigByExamIdOrgId = datas => {
+  return $postParam("/api/admin/basic/exam/get_by_exam_id_and_org_id", datas);
+};
 
 // exam-config
 export const examConfigQuery = datas => {

+ 17 - 8
src/modules/base/components/SelectUserDialog.vue

@@ -27,13 +27,17 @@
           <el-tree
             ref="UserTree"
             :data="userTree"
-            show-checkbox
-            check-on-click-node
             node-key="id"
             :default-checked-keys="selectedUserIds"
             :props="defaultProps"
             @check-change="userChange"
           >
+            <span slot-scope="{ node, data }">
+              <el-checkbox v-if="data.isUser" v-model="node.checked">
+                {{ node.label }}
+              </el-checkbox>
+              <span v-else>{{ node.label }}</span>
+            </span>
           </el-tree>
         </div>
       </el-col>
@@ -99,6 +103,9 @@ export default {
     this.getOrgUser();
   },
   methods: {
+    nodec(q, w) {
+      console.log(q, w);
+    },
     async getOrgUser() {
       const data = await organizationList();
       const parseUser = list => {
@@ -106,20 +113,22 @@ export default {
           let nitem = {
             id: item.id,
             name: item.name,
-            isOrg: true,
+            isUser: false,
             children: []
           };
+
+          if (item["children"] && item["children"].length) {
+            nitem.children = [...nitem.children, ...parseUser(item.children)];
+          }
           if (item["sysUserList"] && item["sysUserList"].length) {
-            nitem.children = item.sysUserList.map(user => {
+            const users = item.sysUserList.map(user => {
               return {
                 id: user.id,
                 name: user.realName,
                 isUser: true
               };
             });
-          }
-          if (item["children"] && item["children"].length) {
-            nitem.children = [...nitem.children, ...parseUser(item.children)];
+            nitem.children = [...nitem.children, ...users];
           }
           return nitem;
         });
@@ -135,7 +144,7 @@ export default {
           if (item["children"] && item["children"].length) {
             fetchUser(item.children);
           } else {
-            userList.push({ id: item.id, name: item.name });
+            if (item.isUser) userList.push({ ...item });
           }
         });
       };

+ 76 - 100
src/modules/exam/components/createExamAndPrintTask/CreateExamAndPrintTask.vue

@@ -13,69 +13,34 @@
       <span class="el-dialog__title">新增命题申请</span>
     </div>
 
-    <el-steps
-      class="apply-step"
-      :active="current"
-      align-center
-      finish-status="success"
-    >
-      <el-step v-for="step in steps" :key="step.name" :title="step.title">
-      </el-step>
-    </el-steps>
-
     <div class="apply-body" v-if="dataReady">
-      <component
-        :is="currentComponent"
-        :ref="currentComponent"
+      <info-exam-task
+        ref="InfoExamTask"
+        :datas="infos"
+        @data-change="dataChange"
+      ></info-exam-task>
+      <info-print-task
+        ref="InfoPrintTask"
         :datas="infos"
-        @next-step="toNext"
-        @on-ready="compReady"
         @data-change="dataChange"
-      ></component>
+      ></info-print-task>
     </div>
 
-    <div class="text-center">
-      <el-button
-        v-if="!isFirstStep"
-        type="primary"
-        :disabled="loading"
-        @click="prevStep"
-        >上一步</el-button
-      >
-      <el-button
-        v-if="isLastStep"
-        type="success"
-        :disabled="loading"
-        @click="nextStep"
+    <div slot="footer" class="text-center">
+      <el-button type="success" :disabled="loading" @click="nextStep"
         >确认提交</el-button
       >
-      <el-button v-else type="primary" @click="nextStep" :disabled="loading"
-        >下一步</el-button
-      >
       <el-button @click="cancel">取消</el-button>
     </div>
-    <div slot="footer"></div>
   </el-dialog>
 </template>
 
 <script>
-import { examRuleDetail } from "../../../base/api";
+import { examConfigByExamIdOrgId, examRuleDetail } from "../../../base/api";
 import { teacherSubmitTaskApply } from "../../api";
-import { printPlanTemplateList } from "../../../print/api";
 import InfoExamTask from "./InfoExamTask";
 import InfoPrintTask from "./InfoPrintTask";
-// import { deepCopy } from "@/plugins/utils";
-
-const STEPS_LIST = [
-  {
-    name: "exam-task",
-    title: "命题信息"
-  },
-  {
-    name: "print-task",
-    title: "考务信息"
-  }
-];
+import { deepCopy } from "@/plugins/utils";
 
 const initExamTask = {
   semesterId: "",
@@ -83,6 +48,7 @@ const initExamTask = {
   courseCode: "",
   courseName: "",
   paperNumber: "",
+  cardRuleId: "",
   teachingRoomId: "",
   teacherName: "",
   paperName: ""
@@ -105,6 +71,43 @@ const initExamTaskDetail = {
   customCard: false
 };
 
+const initPrintPlan = {
+  name: "",
+  examStartTime: "",
+  examEndTime: "",
+  semesterId: "",
+  printContent: [],
+  backupMethod: "ROOM",
+  backupCount: 1,
+  drawRule: "ONE",
+  templateSources: {},
+  variableContent: [
+    {
+      type: "SIGN",
+      templateId: "",
+      oldTemplateId: "",
+      backupMethod: "ROOM",
+      backupCount: 1
+    },
+    {
+      type: "PACKAGE",
+      templateId: "",
+      oldTemplateId: "",
+      backupMethod: "ROOM",
+      backupCount: 1
+    }
+  ],
+  ordinaryContent: [
+    {
+      type: "CHECK_IN",
+      templateId: "",
+      oldTemplateId: "",
+      backupMethod: "ROOM",
+      backupCount: 1
+    }
+  ]
+};
+
 const initPrintTask = {
   examStartTime: "",
   examEndTime: "",
@@ -124,41 +127,30 @@ export default {
       examRule: {},
       infos: {},
       templateSources: {},
-      // step
-      steps: STEPS_LIST,
-      current: 0,
       loading: false,
       dataReady: false
     };
   },
-  computed: {
-    currentComponent() {
-      return `info-${this.steps[this.current].name}`;
-    },
-    isFirstStep() {
-      return this.current === 0;
-    },
-    isLastStep() {
-      return this.current === this.lastStep;
-    },
-    lastStep() {
-      return this.steps.length - 1;
-    }
-  },
   methods: {
     async getExamRule() {
       const examRule = await examRuleDetail();
       this.examRule = examRule || {};
       this.needReview = examRule && examRule.review;
     },
-    async getTemplates() {
-      const data = await printPlanTemplateList();
-      const templateSources = {};
-      const templates = [...data.variable, ...data.ordinary];
-      templates.forEach(item => {
-        templateSources[item.type] = item.template;
+    async getPrintPlanInfo(examId) {
+      const data = await examConfigByExamIdOrgId({
+        examId,
+        orgId: this.$ls.get("orgId")
       });
-      this.templateSources = templateSources;
+      let printPlan = deepCopy(initPrintPlan);
+      printPlan.variableContent = JSON.parse(data.variableContent);
+      printPlan.ordinaryContent = JSON.parse(data.ordinaryContent);
+      printPlan.printContent = JSON.parse(data.printContent);
+
+      return {
+        printPlan,
+        cardRuleId: data.cardRuleId
+      };
     },
     async initData() {
       await this.getExamRule();
@@ -181,26 +173,9 @@ export default {
     },
     visibleChange() {
       this.dataReady = false;
-      this.current = 0;
       this.loading = false;
       this.initData();
     },
-    prevStep() {
-      if (this.isFirstStep) return;
-      this.$refs[this.currentComponent].updateData();
-      this.current -= 1;
-    },
-    nextStep() {
-      this.loading = true;
-      this.$refs[this.currentComponent].checkData();
-    },
-    toNext() {
-      if (this.isLastStep) {
-        this.submit();
-      } else {
-        this.current += 1;
-      }
-    },
     dataChange(data) {
       // console.log(data);
       Object.entries(data).forEach(([key, val]) => {
@@ -208,16 +183,9 @@ export default {
           this.infos[key] = [...val];
         } else {
           this.infos[key] = Object.assign(this.infos[key], val);
-
-          if (key === "examTask") {
-            this.infos.printPlan.semesterId = val.semesterId;
-          }
         }
       });
     },
-    compReady(type = false) {
-      this.loading = type;
-    },
     async cancel() {
       const result = await this.$confirm("确定取消该任务?", "提示", {
         type: "warning"
@@ -238,15 +206,23 @@ export default {
         type: "warning"
       }).catch(() => {});
 
-      if (result !== "confirm") {
-        this.loading = false;
-        return;
-      }
+      if (result !== "confirm") return;
+
+      // TODO:check valid
+
+      const printPlan = await examConfigByExamIdOrgId({
+        examId,
+        orgId: this.$ls.get("orgId")
+      });
+      let examPrintPlan = Object.assign({}, initPrintPlan, printPlan);
+      examPrintPlan.printContent = JSON.parse(data.printContent);
+      this.infos.examTask.cardRuleId = examPrintPlan.cardRuleId;
 
       const examTaskContent = {
         examTask: this.infos.examTask,
         examTaskDetail: this.infos.examTaskDetail,
-        examDetail: this.infos.printTask
+        examDetail: this.infos.printTask,
+        examPrintPlan
       };
       let datas = {
         examTaskContent: JSON.stringify(examTaskContent)

+ 266 - 0
src/modules/exam/components/createExamAndPrintTask/CreateExamAndPrintTaskSteps.vue

@@ -0,0 +1,266 @@
+<template>
+  <el-dialog
+    class="create-exam-and-print-task"
+    :visible.sync="modalIsShow"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    :show-close="false"
+    append-to-body
+    fullscreen
+    @open="visibleChange"
+  >
+    <div slot="title">
+      <span class="el-dialog__title">新增命题申请</span>
+    </div>
+
+    <el-steps
+      class="apply-step"
+      :active="current"
+      align-center
+      finish-status="success"
+    >
+      <el-step v-for="step in steps" :key="step.name" :title="step.title">
+      </el-step>
+    </el-steps>
+
+    <div class="apply-body" v-if="dataReady">
+      <component
+        :is="currentComponent"
+        :ref="currentComponent"
+        :datas="infos"
+        @next-step="toNext"
+        @on-ready="compReady"
+        @data-change="dataChange"
+      ></component>
+    </div>
+
+    <div class="text-center">
+      <el-button
+        v-if="!isFirstStep"
+        type="primary"
+        :disabled="loading"
+        @click="prevStep"
+        >上一步</el-button
+      >
+      <el-button
+        v-if="isLastStep"
+        type="success"
+        :disabled="loading"
+        @click="nextStep"
+        >确认提交</el-button
+      >
+      <el-button v-else type="primary" @click="nextStep" :disabled="loading"
+        >下一步</el-button
+      >
+      <el-button @click="cancel">取消</el-button>
+    </div>
+    <div slot="footer"></div>
+  </el-dialog>
+</template>
+
+<script>
+import { examRuleDetail } from "../../../base/api";
+import { teacherSubmitTaskApply } from "../../api";
+import { printPlanTemplateList } from "../../../print/api";
+import InfoExamTask from "./InfoExamTask";
+import InfoPrintTask from "./InfoPrintTask";
+// import { deepCopy } from "@/plugins/utils";
+
+const STEPS_LIST = [
+  {
+    name: "exam-task",
+    title: "命题信息"
+  },
+  {
+    name: "print-task",
+    title: "考务信息"
+  }
+];
+
+const initExamTask = {
+  semesterId: "",
+  examId: "",
+  courseCode: "",
+  courseName: "",
+  paperNumber: "",
+  teachingRoomId: "",
+  teacherName: "",
+  paperName: ""
+};
+
+const initExamTaskDetail = {
+  operateType: "STAGE",
+  paperType: "A",
+  cardId: "",
+  paperAttachmentIds: "[]",
+  paperConfirmAttachmentIds: "[]",
+  drawCount: 2,
+  remark: "",
+  makeMethod: "SELECT",
+  // 题卡状态
+  status: "",
+  // 考务规则
+  review: false,
+  includePaper: false,
+  customCard: false
+};
+
+const initPrintTask = {
+  examStartTime: "",
+  examEndTime: "",
+  paperNumber: "",
+  courseName: "",
+  courseCode: "",
+  list: []
+};
+
+export default {
+  name: "create-exam-and-print-task",
+  components: { InfoExamTask, InfoPrintTask },
+  data() {
+    return {
+      modalIsShow: false,
+      needReview: false,
+      examRule: {},
+      infos: {},
+      templateSources: {},
+      // step
+      steps: STEPS_LIST,
+      current: 0,
+      loading: false,
+      dataReady: false
+    };
+  },
+  computed: {
+    currentComponent() {
+      return `info-${this.steps[this.current].name}`;
+    },
+    isFirstStep() {
+      return this.current === 0;
+    },
+    isLastStep() {
+      return this.current === this.lastStep;
+    },
+    lastStep() {
+      return this.steps.length - 1;
+    }
+  },
+  methods: {
+    async getExamRule() {
+      const examRule = await examRuleDetail();
+      this.examRule = examRule || {};
+      this.needReview = examRule && examRule.review;
+    },
+    async getTemplates() {
+      const data = await printPlanTemplateList();
+      const templateSources = {};
+      const templates = [...data.variable, ...data.ordinary];
+      templates.forEach(item => {
+        templateSources[item.type] = item.template;
+      });
+      this.templateSources = templateSources;
+    },
+    async initData() {
+      await this.getExamRule();
+      await this.getTemplates();
+
+      const examTaskDetail = Object.assign({}, initExamTaskDetail, {
+        includePaper: this.examRule.includePaper,
+        review: this.examRule.review,
+        customCard: this.examRule.customCard
+      });
+
+      this.infos = {
+        examTask: { ...initExamTask },
+        examTaskDetail,
+        printTask: { ...initPrintTask },
+        approveUserIds: []
+      };
+
+      this.dataReady = true;
+    },
+    visibleChange() {
+      this.dataReady = false;
+      this.current = 0;
+      this.loading = false;
+      this.initData();
+    },
+    prevStep() {
+      if (this.isFirstStep) return;
+      this.$refs[this.currentComponent].updateData();
+      this.current -= 1;
+    },
+    nextStep() {
+      this.loading = true;
+      this.$refs[this.currentComponent].checkData();
+    },
+    toNext() {
+      if (this.isLastStep) {
+        this.submit();
+      } else {
+        this.current += 1;
+      }
+    },
+    dataChange(data) {
+      // console.log(data);
+      Object.entries(data).forEach(([key, val]) => {
+        if (key === "approveUserIds") {
+          this.infos[key] = [...val];
+        } else {
+          this.infos[key] = Object.assign(this.infos[key], val);
+
+          if (key === "examTask") {
+            this.infos.printPlan.semesterId = val.semesterId;
+          }
+        }
+      });
+    },
+    compReady(type = false) {
+      this.loading = type;
+    },
+    async cancel() {
+      const result = await this.$confirm("确定取消该任务?", "提示", {
+        type: "warning"
+      }).catch(() => {});
+
+      if (result !== "confirm") return;
+
+      this.close();
+    },
+    close() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    async submit() {
+      const result = await this.$confirm("确定提交该任务?", "提示", {
+        type: "warning"
+      }).catch(() => {});
+
+      if (result !== "confirm") {
+        this.loading = false;
+        return;
+      }
+
+      const examTaskContent = {
+        examTask: this.infos.examTask,
+        examTaskDetail: this.infos.examTaskDetail,
+        examDetail: this.infos.printTask
+      };
+      let datas = {
+        examTaskContent: JSON.stringify(examTaskContent)
+      };
+      if (this.infos.approveUserIds.length)
+        datas.approveUserIds = this.infos.approveUserIds;
+
+      const data = await teacherSubmitTaskApply(datas).catch(() => {});
+      this.loading = false;
+      if (!data) return;
+      this.$message.success("提交成功!");
+      this.close();
+      this.$emit("modified");
+    }
+  }
+};
+</script>

+ 1 - 1
src/modules/exam/components/createExamAndPrintTask/InfoPrintTask.vue

@@ -157,7 +157,7 @@ export default {
   },
   mounted() {
     console.log("mounted");
-    this.initData();
+    // this.initData();
   },
   methods: {
     async initData() {