Browse Source

bug 修改

zhangjie 4 years ago
parent
commit
78295dbf20

+ 8 - 0
card/router/index.js

@@ -25,6 +25,14 @@ const routes = [
     name: "CardPreview",
     component: () =>
       import(/* webpackChunkName: "CardPreview" */ "../views/CardPreview.vue")
+  },
+  {
+    path: "/card/card-rule/preview/:cardRuleId",
+    name: "CardRulePreview",
+    component: () =>
+      import(
+        /* webpackChunkName: "CardRulePreview" */ "../views/CardRulePreview.vue"
+      )
   }
   // {
   //   path: "/about",

+ 2 - 2
card/views/CardPreview.vue

@@ -124,7 +124,7 @@ export default {
       [...cardConfig.requiredFields, ...cardConfig.extendFields]
         .filter(item => item.enable)
         .map(item => {
-          fieldInfos[item.field] = "${" + item.field + "}";
+          fieldInfos[item.code] = "${" + item.code + "}";
         });
       if (cardConfig.examNumberStyle === "PRINT") {
         fieldInfos.examNumber = "data:image/png;base64,${examNumber}";
@@ -187,7 +187,7 @@ export default {
       [...cardConfig.requiredFields, ...cardConfig.extendFields]
         .filter(item => item.enable)
         .map(item => {
-          fieldInfos[item.field] = stdInfo[item.field] || defContent;
+          fieldInfos[item.code] = stdInfo[item.code] || defContent;
         });
       if (cardConfig.examNumberStyle === "PRINT") {
         fieldInfos.examNumber = this.getBase64Barcode(

+ 221 - 0
card/views/CardRulePreview.vue

@@ -0,0 +1,221 @@
+<template>
+  <div :class="classes">
+    <div class="preview-body">
+      <template v-for="(page, pageNo) in pages">
+        <div :class="['page-box', `page-box-${pageNo % 2}`]" :key="pageNo">
+          <div
+            :class="['page-locators', `page-locators-${page.locators.length}`]"
+          >
+            <ul
+              class="page-locator-group"
+              v-for="(locator, iind) in page.locators"
+              :key="iind"
+            >
+              <li
+                v-for="(elem, eindex) in locator"
+                :key="eindex"
+                :id="elem.id"
+              ></li>
+            </ul>
+          </div>
+          <!-- inner edit area -->
+          <div class="page-main-inner">
+            <div
+              :class="['page-main', `page-main-${page.columns.length}`]"
+              :style="{ margin: `0 -${page.columnGap / 2}px` }"
+            >
+              <div
+                class="page-column"
+                v-for="(column, columnNo) in page.columns"
+                :key="columnNo"
+                :style="{ padding: `0 ${page.columnGap / 2}px` }"
+              >
+                <div
+                  class="page-column-main"
+                  :id="[`column-${pageNo}-${columnNo}`]"
+                >
+                  <div class="page-column-body" v-if="column.elements.length">
+                    <topic-element-preview
+                      class="page-column-element"
+                      v-for="element in column.elements"
+                      :key="element.id"
+                      :data="element"
+                    ></topic-element-preview>
+                  </div>
+                  <div class="page-column-body" v-else>
+                    <div
+                      class="page-column-forbid-area"
+                      v-if="cardConfig.showForbidArea"
+                    >
+                      <p>该区域严禁作答</p>
+                    </div>
+                  </div>
+                </div>
+              </div>
+            </div>
+          </div>
+          <!-- outer edit area -->
+          <div class="page-main-outer">
+            <page-number
+              type="rect"
+              :total="pages.length"
+              :current="pageNo + 1"
+            ></page-number>
+            <page-number
+              type="text"
+              :total="pages.length"
+              :current="pageNo + 1"
+            ></page-number>
+          </div>
+        </div>
+      </template>
+    </div>
+  </div>
+</template>
+
+<script>
+import TopicElementPreview from "../components/TopicElementPreview";
+import PageNumber from "../components/PageNumber";
+import { cardConfigInfos } from "../api";
+const JsBarcode = require("jsbarcode");
+import { getCardHeadModel } from "../elementModel";
+
+const pages = [
+  {
+    type: "PAGE",
+    columnGap: 20,
+    locators: [
+      [
+        {
+          type: "LOCATOR",
+          id: "locator-0-00"
+        },
+        {
+          type: "LOCATOR",
+          id: "locator-0-01"
+        }
+      ],
+      [
+        {
+          type: "LOCATOR",
+          id: "locator-0-10"
+        },
+        {
+          type: "LOCATOR",
+          id: "locator-0-11"
+        }
+      ],
+      [
+        {
+          type: "LOCATOR",
+          id: "locator-0-20"
+        },
+        {
+          type: "LOCATOR",
+          id: "locator-0-21"
+        }
+      ]
+    ],
+    columns: [
+      {
+        type: "COLUMN",
+        elements: []
+      },
+      {
+        type: "COLUMN",
+        elements: []
+      }
+    ]
+  }
+];
+
+export default {
+  name: "card-preview",
+  components: { TopicElementPreview, PageNumber },
+  data() {
+    return {
+      cardRuleId: this.$route.params.cardRuleId,
+      cardConfig: {},
+      pages
+    };
+  },
+  computed: {
+    classes() {
+      return ["card-preview"];
+    }
+  },
+  mounted() {
+    if (!this.cardRuleId) {
+      this.$message.error("题卡规则id缺失!");
+      return;
+    }
+    this.init();
+  },
+  methods: {
+    async init() {
+      const data = await cardConfigInfos(this.cardRuleId);
+      if (!data) {
+        this.$message.error("找不到题卡规则!");
+        return;
+      }
+      let config = {
+        ...data,
+        ...{
+          pageSize: "A3",
+          columnNumber: 2,
+          columnGap: 20,
+          showForbidArea: true,
+          cardDesc: ""
+        }
+      };
+      config.requiredFields = JSON.parse(config.requiredFields);
+      config.extendFields = JSON.parse(config.extendFields);
+      config.cardTitle = config.titleRule;
+
+      this.cardConfig = config;
+      let cardHeadElement = getCardHeadModel(this.cardConfig);
+      cardHeadElement.fieldInfos = this.fetchFieldInfos(config, {});
+      this.pages[0].columns[0].elements.push(cardHeadElement);
+    },
+    fetchFieldInfos(cardConfig, stdInfo) {
+      let fieldInfos = {};
+      const defContent = "相关信息";
+      const defNumber = "123456789";
+      [...cardConfig.requiredFields, ...cardConfig.extendFields]
+        .filter(item => item.enable)
+        .map(item => {
+          console.log(item);
+          fieldInfos[item.code] = stdInfo[item.code] || defContent;
+        });
+      if (cardConfig.examNumberStyle === "PRINT") {
+        fieldInfos.examNumber = this.getBase64Barcode(
+          stdInfo["examNumber"] || defNumber
+        );
+        fieldInfos.examNumberStr = stdInfo["examNumber"] || defNumber;
+      }
+      if (cardConfig.aOrB && cardConfig.paperType === "PRINT") {
+        fieldInfos.paperType = this.getBase64Barcode(
+          stdInfo["paperType"] || defNumber
+        );
+        fieldInfos.paperTypeName = stdInfo["paperTypeName"] || "A";
+      }
+
+      return fieldInfos;
+    },
+    getBase64Barcode(str) {
+      const canvas = document.createElement("CANVAS");
+      JsBarcode(canvas, str, {
+        width: 2,
+        height: 30,
+        displayValue: false,
+        marginLeft: 20,
+        marginRight: 20,
+        marginTop: 0,
+        marginBottom: 0
+      });
+
+      return canvas.toDataURL();
+    }
+  }
+};
+</script>

+ 6 - 0
src/assets/styles/base.scss

@@ -322,6 +322,12 @@ body {
     color: $--color-success;
   }
 }
+.ml-1 {
+  margin-left: 5px;
+}
+.ml-2 {
+  margin-left: 10px;
+}
 .mr-1 {
   margin-right: 5px;
 }

+ 4 - 4
src/constants/enumerate.js

@@ -128,10 +128,10 @@ export const DATA_TASK_RESULT = {
 // 印刷计划状态
 export const PRINT_PLAN_STATUS = {
   NEW: "新建",
-  READY: "准备就绪",
-  QUESTION: "命题中",
-  PRINT: "印刷中",
-  END: "已完成"
+  READY: "就绪",
+  PRINTING: "印刷中",
+  PRINT_FINISH: "印刷完成",
+  END: "已结束"
 };
 // 印刷计划相关
 export const DRAW_RULE_TYPE = {

+ 0 - 12
src/modules/admin/views/AdminUserManage.vue

@@ -126,7 +126,6 @@
 import ModifyUser from "../components/ModifyUser";
 import { ABLE_TYPE } from "@/constants/enumerate";
 import { userListPage, ableUser, resetPwd, userRoleListPage } from "../api";
-import { logout } from "@/modules/login/api";
 
 export default {
   name: "user-manage",
@@ -220,17 +219,6 @@ export default {
     async toResetPwd(row) {
       await resetPwd(row.id);
       this.$message.success("密码重置成功!");
-
-      // 修改自己时,会强制重新登录
-      const userId = this.$ls.get("user", { id: "" }).id;
-      if (row.id !== userId) return;
-      this.toLogout();
-    },
-    async toLogout() {
-      await logout();
-      this.$ls.clear();
-      this.$router.push({ name: "Login" });
-      this.$message.info("您的密码已经变更,请重新登录系统!");
     }
   }
 };

+ 23 - 22
src/modules/base/components/ModifyUser.vue

@@ -100,7 +100,7 @@
 
 <script>
 import { updateUser, courseQuery } from "../api";
-import { logout } from "../../login/api";
+// import { logout } from "../../login/api";
 import { phone } from "@/plugins/formRules";
 import SelectOrgs from "./SelectOrgs";
 import { SYS_ADMIN_NAME } from "@/constants/enumerate";
@@ -283,29 +283,30 @@ export default {
 
       this.$message.success("修改成功!");
       this.cancel();
+      this.$emit("modified");
 
-      if (!this.isEdit) {
-        this.$emit("modified");
-        return;
-      }
+      // if (!this.isEdit) {
+      //   this.$emit("modified");
+      //   return;
+      // }
 
-      // 自己把自己的角色改了之后要重新登录,重新获取权限
-      const oldRoleIds = this.instance.roles
-        .map(item => item.id)
-        .sort((a, b) => a - b)
-        .join();
-      const newRoleIds = datas.roleIds.sort((a, b) => a - b).join();
-      if (
-        oldRoleIds !== newRoleIds &&
-        this.$ls.get("user").id === this.instance.id
-      ) {
-        await logout();
-        this.$ls.clear();
-        this.$router.push({ name: "Login" });
-        this.$message.info("您的权限已经变更,请重新登录系统!");
-      } else {
-        this.$emit("modified");
-      }
+      // // 自己把自己的角色改了之后要重新登录,重新获取权限
+      // const oldRoleIds = this.instance.roles
+      //   .map(item => item.id)
+      //   .sort((a, b) => a - b)
+      //   .join();
+      // const newRoleIds = datas.roleIds.sort((a, b) => a - b).join();
+      // if (
+      //   oldRoleIds !== newRoleIds &&
+      //   this.$ls.get("user").id === this.instance.id
+      // ) {
+      //   await logout();
+      //   this.$ls.clear();
+      //   this.$router.push({ name: "Login" });
+      //   this.$message.info("您的权限已经变更,请重新登录系统!");
+      // } else {
+      //   this.$emit("modified");
+      // }
     }
   }
 };

+ 1 - 1
src/modules/base/components/ResetPwd.vue

@@ -131,7 +131,7 @@ export default {
       if (!data) return;
 
       this.isSubmit = false;
-      this.$message.success("修改成功,请重新登录!");
+      this.$message.success("修改成功!");
       this.$emit("modified");
       this.cancel();
     }

+ 11 - 3
src/modules/base/views/CardRuleManage.vue

@@ -237,9 +237,17 @@ export default {
       this.$refs.ModifyCardRule.open();
     },
     toDetail(row) {
-      this.curRule = row;
-      this.editType = "PREVIEW";
-      this.$refs.ModifyCardRule.open();
+      // this.curRule = row;
+      // this.editType = "PREVIEW";
+      // this.$refs.ModifyCardRule.open();
+      window.open(
+        this.getRouterPath({
+          name: "CardRulePreview",
+          params: {
+            cardRuleId: row.id
+          }
+        })
+      );
     },
     toEnable(row) {
       const action = row.enable ? "禁用" : "启用";

+ 10 - 10
src/modules/base/views/UserManage.vue

@@ -156,7 +156,7 @@
 import ModifyUser from "../components/ModifyUser";
 import { ABLE_TYPE } from "@/constants/enumerate";
 import { userListPage, ableUser, resetPwd, userRoleListPage } from "../api";
-import { logout } from "@/modules/login/api";
+// import { logout } from "@/modules/login/api";
 
 export default {
   name: "user-manage",
@@ -244,16 +244,16 @@ export default {
       this.$message.success("密码重置成功!");
 
       // 修改自己时,会强制重新登录
-      const userId = this.$ls.get("user", { id: "" }).id;
-      if (row.id !== userId) return;
-      this.toLogout();
-    },
-    async toLogout() {
-      await logout();
-      this.$ls.clear();
-      this.$router.push({ name: "Login" });
-      this.$message.info("您的密码已经变更,请重新登录系统!");
+      // const userId = this.$ls.get("user", { id: "" }).id;
+      // if (row.id !== userId) return;
+      // this.toLogout();
     }
+    // async toLogout() {
+    //   await logout();
+    //   this.$ls.clear();
+    //   this.$router.push({ name: "Login" });
+    //   this.$message.info("您的密码已经变更,请重新登录系统!");
+    // }
   }
 };
 </script>

+ 8 - 0
src/modules/card/router.js

@@ -15,5 +15,13 @@ export default [
       import(
         /* webpackChunkName: "CardPreview" */ "../../../card/views/CardPreview.vue"
       )
+  },
+  {
+    path: "/card/card-rule/preview/:cardRuleId",
+    name: "CardRulePreview",
+    component: () =>
+      import(
+        /* webpackChunkName: "CardRulePreview" */ "../../../card/views/CardRulePreview.vue"
+      )
   }
 ];

+ 3 - 1
src/modules/customer/api.js

@@ -8,5 +8,7 @@ export const applyCustomerCard = datas => {
   return $post("/api/admin/exam/card/cust_save", datas);
 };
 export const customerPaperExport = datas => {
-  return $post("/api/admin/exam/card/cust_save", datas);
+  return $post("/api/admin/exam/card/download_files", datas, {
+    responseType: "blob"
+  });
 };

+ 9 - 25
src/modules/customer/views/CustomerCard.vue

@@ -155,6 +155,7 @@
 <script>
 import pickerOptions from "@/constants/datePickerOptions";
 import { customerCardTaskList, customerPaperExport } from "../api";
+import { downloadBlob, randomCode } from "@/plugins/utils";
 
 export default {
   name: "customer-card",
@@ -218,7 +219,7 @@ export default {
       this.getList();
     },
     handleSelectionChange(val) {
-      this.multipleSelection = val.map(item => item.id);
+      this.multipleSelection = val.map(item => item.cardId);
     },
     selectMenu(val) {
       if (this.filter.status === val) return;
@@ -238,41 +239,24 @@ export default {
       }
     },
     async toExport() {
-      // TODO:
-      // if (this.loading) return;
-      // this.loading = true;
-      // const res = await download({
-      //   type: "post",
-      //   url: this.GLOBAL.domain + "/api/admin/exam/task_review/export",
-      //   data: {},
-      //   fileName: `${Date.now()}${randomCode()}.zip`,
-      //   header: this.getHeadIds()
-      // }).catch(error => {
-      //   this.$message.error(error + "文件下载失败,请重新尝试!");
-      // });
-      // this.loading = false;
-      // if (!res) return;
-      // this.$message.success("文件下载成功!");
+      if (this.loading) return;
 
       if (!this.multipleSelection.length) {
         this.$message.error("请选择要下载的记录!");
         return;
       }
 
-      if (this.loading) return;
-
       this.loading = true;
-      const res = await customerPaperExport({
-        ids: this.multipleSelection
-      }).catch(() => {});
+      const res = await downloadBlob(() => {
+        return customerPaperExport({ ids: this.multipleSelection });
+      }, `${randomCode()}.zip`).catch(() => {});
+
       this.loading = false;
 
       if (res) {
-        this.$message.success(
-          "下载任务已提交,请在数据管理-任务管理中下载文件!"
-        );
+        this.$message.success("文件下载成功!");
       } else {
-        this.$message.error("下载任务提交失败,请重新尝试!");
+        this.$message.error("文件下载失败,请重新尝试!");
       }
     },
     toEdit(row) {

+ 4 - 4
src/modules/exam/components/ApplyContent.vue

@@ -431,10 +431,10 @@ export default {
         this.$message.error("请完成试卷文件上传!");
         return;
       }
-      if (!this.paperConfirmAttachments.length) {
-        this.$message.error("请上传入库审核表!");
-        return;
-      }
+      // if (!this.paperConfirmAttachments.length) {
+      //   this.$message.error("请上传入库审核表!");
+      //   return;
+      // }
 
       if (!this.curTaskApply.cardId) {
         this.$message.error("请选择题卡创建方式!");

+ 5 - 5
src/modules/exam/components/CardOptionDialog.vue

@@ -70,7 +70,7 @@
                 placeholder="请输入题卡标题"
               ></el-input>
             </el-form-item>
-            <el-form-item prop="attachmentId" label="上传文件:">
+            <el-form-item prop="custAttachmentId" label="上传文件:">
               <upload-file-view
                 input-width="300px"
                 :upload-url="uploadUrl"
@@ -147,7 +147,7 @@ export default {
       // apply-customer
       applyModalForm: {
         title: "",
-        attachmentId: ""
+        custAttachmentId: ""
       },
       applyRules: {
         title: [
@@ -157,7 +157,7 @@ export default {
             trigger: "change"
           }
         ],
-        attachmentId: [
+        custAttachmentId: [
           {
             required: true,
             message: "请上传样卷或试卷结构文件",
@@ -227,8 +227,8 @@ export default {
     },
     uploadSuccess(data) {
       this.$message.success("上传成功!");
-      this.applyModalForm.attachmentId = data.id;
-      this.$refs.ApplyModalForm.validateField("attachmentId");
+      this.applyModalForm.custAttachmentId = data.id;
+      this.$refs.ApplyModalForm.validateField("custAttachmentId");
     },
     async confirm() {
       // 客服制卡

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

@@ -57,6 +57,16 @@
           <el-col :span="10">
             <el-form-item label="审核状态:">
               <span>{{ modalForm.auditStatus | auditStatusFilter }}</span>
+              <el-button
+                v-if="
+                  instance.auditStatus === 'NOT_AUDITED' &&
+                    instance.status === 'SUBMIT'
+                "
+                type="text"
+                class="btn-table-icon ml-2"
+                @click="toCancel"
+                ><span class="color-danger">撤销申请</span></el-button
+              >
             </el-form-item>
           </el-col>
           <el-col :span="14">
@@ -116,6 +126,7 @@
 import ApplyContent from "./ApplyContent";
 import ApplyAuditHistory from "./ApplyAuditHistory";
 import { examRuleDetail } from "../../base/api";
+import { cancelOrRestartTaskApply } from "../api";
 
 const initModalForm = {
   id: null,
@@ -270,6 +281,23 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    toCancel() {
+      this.$confirm("确定要撤销当前申请吗?", "提示", {
+        cancelButtonClass: "el-button--danger is-plain",
+        confirmButtonClass: "el-button--primary",
+        type: "warning"
+      })
+        .then(async () => {
+          const data = await cancelOrRestartTaskApply({
+            id: this.instance.id,
+            status: "CANCEL"
+          }).catch(() => {});
+          if (!data) return;
+          this.$message.success("操作成功!");
+          this.modified();
+        })
+        .catch(() => {});
+    },
     selectMenu(item) {
       this.curMenu = item;
     },

+ 1 - 1
src/modules/exam/views/TaskApplyManage.vue

@@ -123,7 +123,6 @@
             {{ scope.row.reviewStatus | reviewStatusFilter }}
           </template>
         </el-table-column>
-        <el-table-column prop="createName" label="创建人"></el-table-column>
         <el-table-column
           class-name="action-column"
           label="操作"
@@ -273,6 +272,7 @@ export default {
         .catch(() => {});
     },
     toEdit(row) {
+      console.log(row);
       this.curExamTask = row;
       this.editType = "APPLY";
       this.$refs.ModifyTaskApply.open();

+ 4 - 2
src/modules/exam/views/TaskReviewManage.vue

@@ -160,6 +160,7 @@
             {{ scope.row.createTime | timestampFilter }}
           </template>
         </el-table-column>
+        <el-table-column prop="createName" label="创建人"></el-table-column>
         <el-table-column
           class-name="action-column"
           label="操作"
@@ -168,7 +169,7 @@
         >
           <template slot-scope="scope">
             <el-button
-              v-if="auditStatus === 'NOT_AUDITED'"
+              v-if="auditStatus === 'AUDITED'"
               class="btn-table-icon"
               type="text"
               icon="icon icon-circle-right"
@@ -177,7 +178,8 @@
             ></el-button>
             <el-button
               v-if="
-                auditStatus === 'AUDITED' && scope.row.createId === curUserId
+                auditStatus === 'NOT_AUDITED' &&
+                  scope.row.createId === curUserId
               "
               class="btn-table-icon"
               type="text"

+ 1 - 1
src/views/Home.vue

@@ -177,7 +177,7 @@
     </el-dialog>
 
     <!-- 修改密码 -->
-    <reset-pwd @modified="logoutAction" ref="ResetPwd"></reset-pwd>
+    <reset-pwd ref="ResetPwd"></reset-pwd>
   </div>
 </template>