Browse Source

流程调试

zhangjie 3 years ago
parent
commit
2238814f3c

+ 1 - 1
src/assets/styles/base.scss

@@ -456,7 +456,7 @@ body {
 
 // other
 .tips-info {
-  font-size: 12px;
+  font-size: 14px;
   line-height: 20px;
   color: $--color-text-gray-2;
 }

+ 24 - 4
src/assets/styles/pages.scss

@@ -162,13 +162,33 @@
 }
 // create-exam-and-print-task
 .create-exam-and-print-task {
-  .apply-step {
-    margin-bottom: 60px;
-  }
   .apply-body {
-    width: 900px;
+    width: 1000px;
     margin: 0 auto 30px;
   }
+  .apply-part {
+    padding: 20px 30px;
+    border-radius: 20px;
+    border: 1px solid $--color-text-gray-5;
+    margin-bottom: 20px;
+
+    &-title {
+      font-weight: 600;
+      font-size: 18px;
+      line-height: 1;
+      margin-bottom: 30px;
+    }
+  }
+  .flow-item {
+    &-title {
+      font-size: 16px;
+      line-height: 1;
+      margin-bottom: 5px;
+    }
+    &-desc {
+      color: $--color-text-gray;
+    }
+  }
 }
 // wait-task
 .wait-task {

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

@@ -181,9 +181,8 @@ export const flowDelete = ({ id, enable }) => {
 export const flowRegister = (datas, headers) => {
   return $post("/api/admin/custom/flow/register", datas, { headers });
 };
-export const updateFlow = datas => {
-  // TODO:接口暂时没有
-  return $post("/api/admin/custom/flow/update", datas);
+export const updateFlowName = datas => {
+  return $post("/api/admin/custom/flow/rename", datas);
 };
 export const updateFlowDetail = datas => {
   return $post("/api/admin/custom/flow/save", datas);
@@ -191,6 +190,9 @@ export const updateFlowDetail = datas => {
 export const flowDetail = id => {
   return $postParam("/api/admin/custom/flow/edit", { id });
 };
+export const flowDetailByType = (type = "ELECTRON_FLOW") => {
+  return $postParam("/api/admin/custom/flow/get_flow_info_by_type", { type });
+};
 
 // approve-record
 export const approveRecordListPage = datas => {

+ 2 - 2
src/modules/base/components/ModifyFlow.vue

@@ -51,7 +51,7 @@
 
 <script>
 import { FLOW_TYPE } from "../../../constants/enumerate";
-import { updateFlowDetail } from "../api";
+import { updateFlowName } from "../api";
 
 const initModalForm = {
   id: null,
@@ -135,7 +135,7 @@ export default {
 
       if (this.isSubmit) return;
       this.isSubmit = true;
-      const data = await updateFlowDetail(this.modalForm).catch(() => {
+      const data = await updateFlowName(this.modalForm).catch(() => {
         this.isSubmit = false;
       });
 

+ 22 - 85
src/modules/exam/components/ApplyContent.vue

@@ -304,6 +304,22 @@
         </el-form>
       </div>
     </div>
+
+    <div class="part-box part-box-pad part-box-border">
+      <el-timeline>
+        <el-timeline-item
+          v-for="flow in flowList"
+          :key="flow.taskKey"
+          :type="flow.type"
+        >
+          <div class="flow-item">
+            <h4 class="flow-item-title">{{ flow.taskName }}</h4>
+            <p class="flow-item-desc">{{ flow.approveUserNames }}</p>
+          </div>
+        </el-timeline-item>
+      </el-timeline>
+    </div>
+
     <div class="task-action">
       <el-button
         v-if="IS_APPLY"
@@ -370,11 +386,11 @@ import {
   updateTaskReview,
   taskAuditApply,
   switchCardCreateMethod,
-  taskAllFlowSetups,
-  taskAllApproverPeople,
+  // taskAllFlowSetups,
+  // taskAllApproverPeople,
   taskAllApproverExchangePeople,
-  taskApproverExchange,
-  taskApproverNextPeople
+  taskApproverExchange
+  // taskApproverNextPeople
 } from "../api";
 import { attachmentPreview } from "../../login/api";
 import SimpleImagePreview from "@/components/SimpleImagePreview";
@@ -486,9 +502,7 @@ export default {
         ]
       },
       approveExchangePeople: [],
-      needSetApproveUser: false,
-      approveUserIds: [],
-      approveUserList: [], //审批人
+      flowList: [],
       // image-preview
       curImage: {},
       curImageIndex: 0
@@ -589,87 +603,10 @@ export default {
         !this.curTaskApply.flowId ||
         (this.curTaskApply.setup !== null && this.curTaskApply.setup <= 0)
       ) {
-        this.$emit("step-change", []);
         return;
       }
 
-      const flowStatus = {
-        wait: "待进行",
-        process: "进行中",
-        success: "已完成"
-      };
-      const approveData = await taskAllApproverPeople({
-        taskId: this.curTaskApply.flowTaskId
-      });
-      let approvePeople = {};
-      approveData.approveUserList.forEach(item => {
-        item.users = item.approveUser.map(
-          user => `${user.realName}(${user.orgName})`
-        );
-        item.firstUser = item.users[0];
-        item.moreUser = item.users.length > 1 ? item.users.join(",") : null;
-        approvePeople[item.setup] = item;
-      });
-
-      const flowData = await taskAllFlowSetups(this.curTaskApply.flowId);
-      const curSetup = this.curTaskApply.setup;
-      const curStepIsLast = curSetup === flowData.length;
-      this.flows = flowData.map(item => {
-        item.status =
-          curSetup > item.setup
-            ? "success"
-            : curSetup === item.setup
-            ? "process"
-            : "wait";
-        item.desc = flowStatus[item.status];
-        item.isCurrent = curSetup === item.setup;
-        item = { ...item, ...approvePeople[item.setup] };
-        return item;
-      });
-
-      if (!this.flows.length) {
-        this.$emit("step-change", this.flows);
-        return;
-      }
-
-      const curFlow = this.flows.find(item => item.isCurrent);
-      if (curFlow) {
-        const flows = curStepIsLast
-          ? this.flows.slice(-2, -1)
-          : this.flows.filter(item => item.setup < curFlow.setup);
-        this.setups = flows.map(item => {
-          return {
-            taskKey: item.taskKey,
-            setup: item.setup,
-            taskName: `【${item.taskName}】${item.firstUser}`
-          };
-        });
-      }
-
-      // 下一节点审批人
-      const nextFlow = this.flows.find(
-        item => item.setup > this.curTaskApply.setup
-      );
-      if (
-        (this.IS_APPLY || this.IS_AUDIT) &&
-        nextFlow &&
-        !nextFlow.approveUser.length
-      ) {
-        // 获取审批人
-        this.needSetApproveUser = true;
-        let datas = {};
-        if (this.IS_APPLY) {
-          datas.courseCode = this.curTaskApply.courseCode;
-        }
-        if (this.IS_AUDIT) {
-          datas.taskId = this.curTaskApply.flowTaskId;
-        }
-        const data = await taskApproverNextPeople(datas);
-        this.approveUserList =
-          data && data.approveUserList && data.approveUserList[0].approveUser;
-      }
-
-      this.$emit("step-change", this.flows);
+      // TODO:获取流程节点
     },
     async getExchangeApproverPeople() {
       const data = await taskAllApproverExchangePeople({

+ 26 - 132
src/modules/exam/components/CreateTaskApply.vue

@@ -91,32 +91,6 @@
       </el-form>
     </div>
 
-    <div class="task-apply-steps" v-if="flows.length">
-      <el-steps align-center>
-        <el-step
-          v-for="flow in flows"
-          :key="flow.taskKey"
-          :title="flow.taskName"
-          :status="flow.status"
-        >
-          <div slot="description">
-            <div class="step-info" v-if="flow.firstUser">
-              <span>{{ flow.firstUser }}</span>
-              <el-popover
-                v-if="flow.moreUser"
-                placement="top-start"
-                width="300"
-                trigger="hover"
-                :content="flow.moreUser"
-              >
-                <span class="color-primary ml-1" slot="reference">更多</span>
-              </el-popover>
-            </div>
-          </div>
-        </el-step>
-      </el-steps>
-    </div>
-
     <div class="apply-content task-detail" v-if="modalIsShow">
       <div class="task-body">
         <div class="mb-2 text-right">
@@ -250,31 +224,22 @@
           placeholder="建议不超过100个字"
         ></el-input>
 
-        <!--  -->
-        <div v-if="needSetApproveUser" class="task-audit">
-          <el-form>
-            <el-form-item label="指定审批人:">
-              <el-select
-                v-model="approveUserIds"
-                placeholder="请选择"
-                multiple
-                filterable
-                clearable
-                style="width: 800px"
-              >
-                <el-option
-                  v-for="user in approveUserList"
-                  :key="user.id"
-                  :value="user.id"
-                  :label="`${user.realName}(${user.orgName})`"
-                >
-                  {{ user.realName }}({{ user.orgName }})
-                </el-option>
-              </el-select>
-            </el-form-item>
-          </el-form>
+        <div class="part-box part-box-pad part-box-border">
+          <el-timeline>
+            <el-timeline-item
+              v-for="flow in flowList"
+              :key="flow.taskKey"
+              :type="flow.type"
+            >
+              <div class="flow-item">
+                <h4 class="flow-item-title">{{ flow.taskName }}</h4>
+                <p class="flow-item-desc">{{ flow.approveUserNames }}</p>
+              </div>
+            </el-timeline-item>
+          </el-timeline>
         </div>
       </div>
+
       <div class="task-action">
         <el-button type="primary" :disabled="isSubmit" @click="submit"
           >确认提交</el-button
@@ -285,6 +250,7 @@
         <el-button @click="cancel">取消</el-button>
       </div>
     </div>
+
     <div slot="footer"></div>
 
     <!-- upload-paper-dialog -->
@@ -312,13 +278,11 @@
 </template>
 
 <script>
-import { examRuleDetail } from "../../base/api";
+import { examRuleDetail, flowDetailByType } from "../../base/api";
 import {
   teacherCreateTaskApply,
   teacherCancelTaskApply,
-  switchCardCreateMethod,
-  taskAllApproverPeople,
-  taskApproverNextPeople
+  switchCardCreateMethod
 } from "../api";
 import UploadPaperDialog from "./UploadPaperDialog";
 import CardOptionDialog from "./CardOptionDialog";
@@ -362,36 +326,11 @@ export default {
     return {
       modalIsShow: false,
       isSubmit: false,
+      flowList: [],
       examTask: {},
       needReview: false,
       task: {},
       examRule: {},
-      flows: [
-        {
-          flowId: "160684605807001600",
-          taskName: "提交试卷",
-          taskKey: "usertask1",
-          setup: 1,
-          status: "process",
-          desc: "进行中"
-        },
-        {
-          flowId: "160684605807001600",
-          taskName: "审核试卷",
-          taskKey: "usertask2",
-          setup: 2,
-          status: "wait",
-          desc: "待进行"
-        },
-        {
-          flowId: "160684605807001600",
-          taskName: "审核试卷",
-          taskKey: "usertask3",
-          setup: 3,
-          status: "wait",
-          desc: "待进行"
-        }
-      ],
       rules: {
         semesterId: [
           {
@@ -438,10 +377,6 @@ export default {
       curUploadType: "paper",
       attachmentLimitCount: 26,
       abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
-      // 指定审核人,当查询到下一级没有审批人时需要手动指定
-      needSetApproveUser: false,
-      approveUserIds: [],
-      approveUserList: [],
       // image-preview
       curImage: {},
       curImageIndex: 0
@@ -474,6 +409,7 @@ export default {
   },
   created() {
     this.getExamRule();
+    this.getFlowList();
   },
   methods: {
     async getExamRule() {
@@ -481,6 +417,13 @@ export default {
       this.examRule = examRule || {};
       this.needReview = examRule && examRule.review;
     },
+    async getFlowList() {
+      const data = await flowDetailByType();
+      this.flowList = data || [];
+      if (this.flowList.length) {
+        this.flowList[0].type = "success";
+      }
+    },
     initData() {
       this.examTask = { ...initExamTask };
       this.examTaskDetail = { ...initExamTaskDetail };
@@ -488,9 +431,6 @@ export default {
       this.examTaskDetail.review = this.examRule.review;
       this.examTaskDetail.customCard = this.examRule.customCard;
       this.paperAttachments = [];
-      this.needSetApproveUser = false;
-      this.approveUserIds = [];
-      this.approveUserList = [];
     },
     visibleChange() {
       this.initData();
@@ -668,47 +608,11 @@ export default {
         return;
       }
       this.examTask.courseName = val.name;
-
-      this.needSetApproveUser = false;
-      this.approveUserList = [];
-      this.approveUserIds = [];
       this.clearCard();
-      this.updateApproverPeople();
     },
     clearCard() {
       this.clearMakeMethod();
     },
-    async updateApproverPeople() {
-      const data = await taskAllApproverPeople({
-        courseCode: this.examTask.courseCode
-      });
-      let approvePeople = {};
-      data.approveUserList.forEach(item => {
-        item.users = item.approveUser.map(
-          user => `${user.realName}(${user.orgName})`
-        );
-        item.firstUser = item.users[0];
-        item.moreUser = item.users.length > 1 ? item.users.join(",") : null;
-        approvePeople[item.setup] = item;
-      });
-      this.flows = this.flows.map(flow => {
-        return {
-          ...flow,
-          ...approvePeople[flow.setup]
-        };
-      });
-
-      // 下一节点审批人
-      const nextFlow = this.flows[1];
-      if (nextFlow && !nextFlow.approveUser.length) {
-        this.needSetApproveUser = true;
-        const data = await taskApproverNextPeople({
-          courseCode: this.examTask.courseCode
-        });
-        this.approveUserList =
-          data && data.approveUserList && data.approveUserList[0].approveUser;
-      }
-    },
     getTaskDetailData() {
       let data = { ...this.examTaskDetail };
       data.paperType = this.paperAttachments.map(item => item.name).join(",");
@@ -747,11 +651,6 @@ export default {
         return;
       }
 
-      if (this.needSetApproveUser && !this.approveUserIds.length) {
-        this.$message.error("请指定审批人!");
-        return;
-      }
-
       return true;
     },
     async toSave(silent) {
@@ -765,8 +664,6 @@ export default {
         examTaskDetail: this.examTaskDetail,
         examTask: this.examTask
       };
-      if (this.needSetApproveUser) datas.approveUserIds = this.approveUserIds;
-
       const data = await teacherCreateTaskApply(datas).catch(() => {});
       this.isSubmit = false;
       if (!data) return;
@@ -796,9 +693,6 @@ export default {
             examTaskDetail: this.examTaskDetail,
             examTask: this.examTask
           };
-          if (this.needSetApproveUser)
-            datas.approveUserIds = this.approveUserIds;
-
           const data = await teacherCreateTaskApply(datas).catch(() => {});
 
           if (!data) return;

+ 0 - 30
src/modules/exam/components/ModifyTaskApply.vue

@@ -81,31 +81,6 @@
         </tr>
       </table>
     </div>
-    <div class="task-apply-steps" v-if="flows.length">
-      <el-steps align-center>
-        <el-step
-          v-for="flow in flows"
-          :key="flow.taskKey"
-          :title="flow.taskName"
-          :status="flow.status"
-        >
-          <div slot="description">
-            <div class="step-info" v-if="flow.firstUser">
-              <span>{{ flow.firstUser }}</span>
-              <el-popover
-                v-if="flow.moreUser"
-                placement="top-start"
-                width="300"
-                trigger="hover"
-                :content="flow.moreUser"
-              >
-                <span class="color-primary ml-1" slot="reference">更多</span>
-              </el-popover>
-            </div>
-          </div>
-        </el-step>
-      </el-steps>
-    </div>
 
     <div class="mb-4 tab-btns" v-if="needReview">
       <el-button
@@ -123,7 +98,6 @@
         ref="ApplyContent"
         :exam-task="modalForm"
         :edit-type="editType"
-        @step-change="stepChange"
         @cancel="cancel"
         @modified="modified"
       ></apply-content>
@@ -227,7 +201,6 @@ export default {
         { id: "3", name: "提交记录", component: "apply-submit-history" }
       ],
       curMenu: {},
-      flows: [],
       examRoomInfoList: [],
       printTotalCount: 0
     };
@@ -290,9 +263,6 @@ export default {
     selectMenu(item) {
       this.curMenu = item;
     },
-    stepChange(flows) {
-      this.flows = flows;
-    },
     modified() {
       this.cancel();
       this.$emit("modified");

+ 86 - 45
src/modules/exam/components/createExamAndPrintTask/CreateExamAndPrintTask.vue

@@ -14,33 +14,59 @@
     </div>
 
     <div class="apply-body" v-if="dataReady">
-      <info-exam-task
-        ref="InfoExamTask"
-        :datas="infos"
-        @data-change="dataChange"
-      ></info-exam-task>
-      <info-print-task
-        ref="InfoPrintTask"
-        :datas="infos"
-        @data-change="dataChange"
-      ></info-print-task>
+      <div class="apply-part">
+        <h3 class="apply-part-title">命题信息</h3>
+        <info-exam-task
+          ref="InfoExamTask"
+          :datas="infos"
+          @data-change="dataChange"
+          @course-change="examTaskCourseChange"
+        ></info-exam-task>
+      </div>
+      <div class="apply-part">
+        <h3 class="apply-part-title">考务信息</h3>
+        <info-print-task
+          ref="InfoPrintTask"
+          :datas="infos"
+          @data-change="dataChange"
+        ></info-print-task>
+      </div>
+      <div class="apply-part">
+        <h3 class="apply-part-title">流程</h3>
+        <el-timeline>
+          <el-timeline-item
+            v-for="flow in flowList"
+            :key="flow.taskKey"
+            :type="flow.type"
+          >
+            <div class="flow-item">
+              <h4 class="flow-item-title">{{ flow.taskName }}</h4>
+              <p class="flow-item-desc">{{ flow.approveUserNames }}</p>
+            </div>
+          </el-timeline-item>
+        </el-timeline>
+      </div>
     </div>
 
-    <div slot="footer" class="text-center">
-      <el-button type="success" :disabled="loading" @click="nextStep"
+    <div class="text-center">
+      <el-button type="success" :disabled="loading" @click="submit"
         >确认提交</el-button
       >
       <el-button @click="cancel">取消</el-button>
     </div>
+    <div slot="footer"></div>
   </el-dialog>
 </template>
 
 <script>
-import { examConfigByExamIdOrgId, examRuleDetail } from "../../../base/api";
+import {
+  examConfigByExamIdOrgId,
+  examRuleDetail,
+  flowDetailByType
+} from "../../../base/api";
 import { teacherSubmitTaskApply } from "../../api";
 import InfoExamTask from "./InfoExamTask";
 import InfoPrintTask from "./InfoPrintTask";
-import { deepCopy } from "@/plugins/utils";
 
 const initExamTask = {
   semesterId: "",
@@ -80,7 +106,6 @@ const initPrintPlan = {
   backupMethod: "ROOM",
   backupCount: 1,
   drawRule: "ONE",
-  templateSources: {},
   variableContent: [
     {
       type: "SIGN",
@@ -126,36 +151,29 @@ export default {
       needReview: false,
       examRule: {},
       infos: {},
-      templateSources: {},
+      flowList: [],
       loading: false,
       dataReady: false
     };
   },
+  mounted() {
+    this.getExamRule();
+    this.getFlowList();
+  },
   methods: {
     async getExamRule() {
       const examRule = await examRuleDetail();
       this.examRule = examRule || {};
       this.needReview = examRule && examRule.review;
     },
-    async getPrintPlanInfo(examId) {
-      const data = await examConfigByExamIdOrgId({
-        examId,
-        orgId: this.$ls.get("orgId")
-      });
-      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 getFlowList() {
+      const data = await flowDetailByType();
+      this.flowList = data || [];
+      if (this.flowList.length) {
+        this.flowList[0].type = "success";
+      }
     },
     async initData() {
-      await this.getExamRule();
-      await this.getTemplates();
-
       const examTaskDetail = Object.assign({}, initExamTaskDetail, {
         includePaper: this.examRule.includePaper,
         review: this.examRule.review,
@@ -165,8 +183,7 @@ export default {
       this.infos = {
         examTask: { ...initExamTask },
         examTaskDetail,
-        printTask: { ...initPrintTask },
-        approveUserIds: []
+        printTask: { ...initPrintTask }
       };
 
       this.dataReady = true;
@@ -179,11 +196,14 @@ export default {
     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);
-        }
+        this.infos[key] = Object.assign(this.infos[key], val);
+      });
+    },
+    examTaskCourseChange(data) {
+      this.dataChange(data);
+
+      this.$nextTick(() => {
+        this.$refs.InfoPrintTask.initData();
       });
     },
     async cancel() {
@@ -202,18 +222,39 @@ export default {
       this.modalIsShow = true;
     },
     async submit() {
+      if (this.loading) return;
       const result = await this.$confirm("确定提交该任务?", "提示", {
         type: "warning"
       }).catch(() => {});
-
       if (result !== "confirm") return;
-
-      // TODO:check valid
-
+      this.loading = true;
+      // 数据校验
+      const validAll = [
+        this.$refs.InfoExamTask.checkData(),
+        this.$refs.InfoPrintTask.checkData()
+      ];
+      const validResult = await Promise.all(validAll).catch(() => {});
+      if (!validResult) {
+        this.loading = false;
+        return;
+      }
+      // 更新infos
+      const examDatas = [
+        this.$refs.InfoExamTask.getData(),
+        this.$refs.InfoPrintTask.getData()
+      ];
+      examDatas.forEach(item => {
+        this.dataChange(item);
+      });
+      // 更新printPlan
       const printPlan = await examConfigByExamIdOrgId({
         examId,
         orgId: this.$ls.get("orgId")
-      });
+      }).catch(() => {});
+      if (!printPlan) {
+        this.loading = false;
+        return;
+      }
       let examPrintPlan = Object.assign({}, initPrintPlan, printPlan);
       examPrintPlan.printContent = JSON.parse(data.printContent);
       this.infos.examTask.cardRuleId = examPrintPlan.cardRuleId;

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

@@ -1,266 +0,0 @@
-<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>

+ 6 - 75
src/modules/exam/components/createExamAndPrintTask/InfoExamTask.vue

@@ -214,31 +214,6 @@
           show-word-limit
           placeholder="建议不超过100个字"
         ></el-input>
-
-        <!--  -->
-        <div v-if="approveUserList.length" class="task-audit">
-          <el-form>
-            <el-form-item label="指定审批人:">
-              <el-select
-                v-model="approveUserIds"
-                placeholder="请选择"
-                multiple
-                filterable
-                clearable
-                style="width: 800px"
-              >
-                <el-option
-                  v-for="user in approveUserList"
-                  :key="user.id"
-                  :value="user.id"
-                  :label="`${user.realName}(${user.orgName})`"
-                >
-                  {{ user.realName }}({{ user.orgName }})
-                </el-option>
-              </el-select>
-            </el-form-item>
-          </el-form>
-        </div>
       </div>
     </div>
 
@@ -263,11 +238,7 @@
 import UploadPaperDialog from "../UploadPaperDialog";
 import SimpleImagePreview from "@/components/SimpleImagePreview";
 import { CARD_SOURCE_TYPE } from "@/constants/enumerate";
-import {
-  cardForSelectList,
-  taskAllApproverPeople,
-  taskApproverNextPeople
-} from "../../api";
+import { cardForSelectList } from "../../api";
 import { courseQuery, examSemesterList } from "../../../base/api";
 
 export default {
@@ -328,10 +299,6 @@ export default {
       curUploadType: "paper",
       attachmentLimitCount: 26,
       abc: "abcdefghijklmnopqrstuvwxyz".toUpperCase(),
-      // 指定审核人,当查询到下一级没有审批人时需要手动指定
-      needSetApproveUser: false,
-      approveUserIds: [],
-      approveUserList: [],
       // image-preview
       curImage: {},
       curImageIndex: 0
@@ -353,8 +320,6 @@ export default {
   },
   methods: {
     initData() {
-      // console.log(this.datas.examTask);
-      this.approveUserIds = [...this.datas.approveUserIds];
       this.examTask = { ...this.datas.examTask };
       this.examTaskDetail = { ...this.datas.examTaskDetail };
       this.paperAttachments = this.examTaskDetail.paperAttachmentIds
@@ -372,7 +337,6 @@ export default {
 
       this.getCourses();
       this.getCardList();
-      if (this.examTask.courseCode) this.updateApproverPeople();
 
       this.$nextTick(() => {
         this.$refs.examTaskComp.clearValidate();
@@ -413,10 +377,7 @@ export default {
     },
     async checkData() {
       const valid = await this.$refs.examTaskComp.validate().catch(() => {});
-      if (!valid) {
-        this.$emit("on-ready");
-        return;
-      }
+      if (!valid) return Promise.reject();
 
       const attachmentValid = !this.paperAttachments.some(
         item => !item.attachmentId
@@ -424,8 +385,7 @@ export default {
       // 设置了入库强制包含试卷时,校验试卷是否上传。
       if (this.examTaskDetail.includePaper && !attachmentValid) {
         this.$message.error("请完成试卷文件上传!");
-        this.$emit("on-ready");
-        return;
+        return Promise.reject();
       }
       // if (!this.paperConfirmAttachments.length) {
       //   this.$message.error("请上传附件!");
@@ -434,26 +394,16 @@ export default {
 
       if (!this.examTaskDetail.cardId) {
         this.$message.error("请选择题卡!");
-        this.$emit("on-ready");
-        return;
+        return Promise.reject();
       }
 
-      if (this.needSetApproveUser && !this.approveUserIds.length) {
-        this.$message.error("请指定审批人!");
-        this.$emit("on-ready");
-        return;
-      }
-
-      this.updateData();
-      this.$emit("next-step");
+      return Promise.resolve(true);
     },
     getData() {
       let data = {
         examTask: this.examTask,
         examTaskDetail: this.getTaskDetailData()
       };
-      if (this.needSetApproveUser)
-        data.approveUserIds = [...this.approveUserIds];
       return data;
     },
     updateData() {
@@ -547,27 +497,8 @@ export default {
 
       this.examTaskDetail.cardId = "";
       this.cards = [];
-      this.needSetApproveUser = false;
-      this.approveUserList = [];
-      this.approveUserIds = [];
       this.getCardList();
-      this.updateApproverPeople();
-    },
-    async updateApproverPeople() {
-      const data = await taskAllApproverPeople({
-        courseCode: this.examTask.courseCode
-      });
-
-      // 下一节点审批人
-      const nextFlow = data.approveUserList[1];
-      if (nextFlow && !nextFlow.approveUser.length) {
-        this.needSetApproveUser = true;
-        const data = await taskApproverNextPeople({
-          courseCode: this.examTask.courseCode
-        });
-        this.approveUserList =
-          data && data.approveUserList && data.approveUserList[0].approveUser;
-      }
+      this.$emit("course-change", this.getData());
     },
     getTaskDetailData() {
       let data = { ...this.examTaskDetail };

+ 11 - 20
src/modules/exam/components/createExamAndPrintTask/InfoPrintTask.vue

@@ -90,8 +90,6 @@
       </el-table>
     </div>
 
-    <!-- TODO:审核流程 -->
-
     <!-- ModifyPrintTask -->
     <modify-print-task
       ref="ModifyPrintTask"
@@ -156,8 +154,13 @@ export default {
     }
   },
   mounted() {
-    console.log("mounted");
-    // this.initData();
+    this.getExtendFields();
+    this.getPrintHouses();
+
+    const curDate = getTimeDatestamp(Date.now());
+    const hour = 60 * 60 * 1000;
+    this.curCreateTime = [curDate + 8 * hour, curDate + 10 * hour];
+    this.createTime = [...this.curCreateTime];
   },
   methods: {
     async initData() {
@@ -167,15 +170,8 @@ export default {
         courseCode: this.datas.examTask.courseCode
       });
 
-      await this.getExtendFields();
-      await this.getPrintHouses();
       await this.getClassList();
 
-      const curDate = getTimeDatestamp(Date.now());
-      const hour = 60 * 60 * 1000;
-      this.curCreateTime = [curDate + 8 * hour, curDate + 10 * hour];
-      this.createTime = [...this.curCreateTime];
-
       const data = this.datas.printTask;
       this.tableData =
         data.courseCode === this.datas.examTask.courseCode ? data.list : [];
@@ -199,14 +195,12 @@ export default {
     checkData() {
       if (!this.modalForm.examStartTime || !this.modalForm.examEndTime) {
         this.$message.error("请选择考试时间!");
-        this.$emit("on-ready");
-        return;
+        return Promise.reject();
       }
 
       if (!this.tableData.length) {
         this.$message.error("请添加考试对象!");
-        this.$emit("on-ready");
-        return;
+        return Promise.reject();
       }
 
       let errorMsg = [];
@@ -225,12 +219,9 @@ export default {
       });
       if (errorMsg.length) {
         this.$message.error(errorMsg.join("。"));
-        this.$emit("on-ready");
-        return;
+        return Promise.reject();
       }
-
-      this.updateData();
-      this.$emit("next-step");
+      return Promise.resolve(true);
     },
     getData() {
       this.tableData.forEach(row => {