Jelajahi Sumber

feat: 生成试卷参数保存

zhangjie 1 bulan lalu
induk
melakukan
e2d26dda1e

+ 10 - 0
src/modules/paper-export/api.js

@@ -72,3 +72,13 @@ export const answerPdfDownloadApi = (datas) => {
 export const paperAndAnswerPdfDownloadApi = (datas) => {
   return $httpWithMsg.post(QUESTION_API + "/paper/data/file/create", datas);
 };
+export const paperParamInfoApi = (paperId) => {
+  return $httpWithMsg.post(
+    QUESTION_API + "/paper/param/get",
+    {},
+    { params: { paperId } }
+  );
+};
+export const paperParamSaveApi = (datas) => {
+  return $httpWithMsg.post(QUESTION_API + "/paper/param/save", datas);
+};

+ 9 - 1
src/modules/paper-export/components/PaperBuildConfig.vue

@@ -66,6 +66,8 @@
 </template>
 
 <script>
+import { objAssign } from "@/plugins/utils";
+
 const initModalForm = {
   showDetailNo: true,
   showDetailScoreInfo: true,
@@ -82,6 +84,12 @@ export default {
         return [];
       },
     },
+    buildConfig: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
     showConfirmBtn: {
       type: Boolean,
       default: true,
@@ -121,7 +129,7 @@ export default {
           trigger: "change",
         };
       });
-      this.modalForm = modalForm;
+      this.modalForm = objAssign(modalForm, this.buildConfig || {});
       this.rules = rules;
     },
     checkData() {

+ 24 - 2
src/modules/paper-export/views/PaperTemplateBuild.vue

@@ -136,7 +136,12 @@ import AnswerTemplateView from "../components/AnswerTemplateView.vue";
 
 import { deepCopy } from "../../card/plugins/utils";
 import { paperDetailInfoApi } from "../../paper/api";
-import { paperTemplateListApi, paperAndAnswerPdfDownloadApi } from "../api";
+import {
+  paperTemplateListApi,
+  paperAndAnswerPdfDownloadApi,
+  paperParamInfoApi,
+  paperParamSaveApi,
+} from "../api";
 import paperTemplateBuildMixins from "./paperTemplateBuildMixins";
 import { buildPdf } from "@/plugins/htmlToPdf";
 
@@ -155,6 +160,7 @@ export default {
       viewType: this.$route.params.viewType,
       seqMode: "MODE3",
       showScaleEdit: false,
+      buildConfig: {},
       keys: [],
       pdfScale: 6,
       paperJson: {},
@@ -189,7 +195,6 @@ export default {
       this.initFrame();
       return;
     }
-
     this.initData();
     this.registScaleEvent();
   },
@@ -293,6 +298,8 @@ export default {
         });
     },
     async initData() {
+      await this.getParamInfo();
+
       this.watermarkBg = await this.initWatermark();
       await this.getPaperJson();
       await this.getPaperTempList();
@@ -303,6 +310,20 @@ export default {
       }
       this.paperTempChange(this.paperTempList[0]);
     },
+    async getParamInfo() {
+      const res = await paperParamInfoApi(this.paperId);
+      this.seqMode = res.data.seqMode;
+      this.curPaperTemp = res.data.curPaperTemp;
+      this.buildConfig = res.data;
+    },
+    async saveParamInfo() {
+      await paperParamSaveApi({
+        paperId: this.paperId,
+        seqMode: this.seqMode,
+        curPaperTemp: this.curPaperTemp,
+        ...this.$refs.PaperBuildConfig.getData(),
+      });
+    },
     async getPaperJson() {
       const res = await paperDetailInfoApi({
         paperId: this.paperId,
@@ -513,6 +534,7 @@ export default {
       );
       if (!valid) return;
 
+      this.saveParamInfo();
       this.actionType = actionType;
       const configData = this.$refs.PaperBuildConfig.getData();
       if (JSON.stringify(configData) === JSON.stringify(this.configModalForm)) {