瀏覽代碼

feat: 题卡管理

zhangjie 3 月之前
父節點
當前提交
85583f4a5b

+ 8 - 0
src/components/base/ExamSelect.vue

@@ -60,6 +60,13 @@ export default {
         this.$emit("change", {});
       }
     },
+    examModel(val, oldval) {
+      if (val !== oldval) {
+        this.search();
+        this.$emit("input", "");
+        this.$emit("change", {});
+      }
+    },
   },
   created() {
     this.search();
@@ -72,6 +79,7 @@ export default {
       let data = {
         semesterId: this.semesterId,
         category: this.category || undefined,
+        examModel: this.examModel || undefined,
       };
       if (this.enable !== null) data.enable = this.enable;
       const res = await conditionListExam(data);

+ 2 - 1
src/modules/base/api.js

@@ -20,7 +20,7 @@ export const conditionListSemester = (datas, config) => {
 };
 // exam
 export const conditionListExam = (
-  { semesterId, category, enable },
+  { semesterId, category, enable, examModel },
   config = {}
 ) => {
   return $postParam(
@@ -29,6 +29,7 @@ export const conditionListExam = (
       semesterId,
       category,
       enable,
+      examModel,
     },
     config
   );

+ 208 - 0
src/modules/base/components/ModifyModeCardInfo.vue

@@ -0,0 +1,208 @@
+<template>
+  <el-dialog
+    class="modify-card-info"
+    :visible.sync="modalIsShow"
+    :title="title"
+    width="600px"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    @open="visibleChange"
+  >
+    <el-form
+      ref="modalFormComp"
+      label-width="120px"
+      :rules="rules"
+      :model="modalForm"
+    >
+      <el-form-item label="学期:">
+        <semester-select
+          v-model.trim="modalForm.semesterId"
+          placeholder="学期"
+          :disabled="isEdit"
+        ></semester-select>
+      </el-form-item>
+      <el-form-item label="考试:">
+        <exam-select
+          v-model="modalForm.examId"
+          :semester-id="modalForm.semesterId"
+          exam-model="MODEL4"
+          :disabled="isEdit"
+          @change="examChange"
+        ></exam-select>
+      </el-form-item>
+      <el-form-item label="课程(代码):">
+        <course-select
+          v-model.trim="modalForm.courseId"
+          :semester-id="modalForm.semesterId"
+          :exam-id="modalForm.examId"
+          placeholder="课程(代码)"
+          :disabled="isEdit"
+          @change="courseChange"
+        ></course-select>
+      </el-form-item>
+      <el-form-item prop="title" label="题卡名称:">
+        <el-input
+          v-model.trim="modalForm.title"
+          placeholder="建议不超过30个字,题卡名称不允许重复"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="remark" label="备注:">
+        <el-input
+          v-model="modalForm.remark"
+          type="textarea"
+          resize="none"
+          :rows="2"
+          :maxlength="50"
+          clearable
+          show-word-limit
+          placeholder="建议不超过50个字"
+        ></el-input>
+      </el-form-item>
+    </el-form>
+
+    <div slot="footer">
+      <el-button type="primary" :disabled="isSubmit" @click="submit"
+        >确认</el-button
+      >
+      <el-button @click="cancel">取消</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { updateCard } from "../api";
+import { examConfigByExamIdOrgId } from "@/modules/exam/api";
+
+const initModalForm = {
+  id: null,
+  semesterId: "",
+  examId: "",
+  courseId: "",
+  title: "",
+  remark: "",
+  courseName: "",
+  courseCode: "",
+  makeMethod: "SELF",
+  type: "CUSTOM",
+  createMethod: "STANDARD",
+};
+
+export default {
+  name: "modify-mode-card-info",
+  props: {
+    instance: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+  },
+  computed: {
+    isEdit() {
+      return !!this.modalForm.id;
+    },
+    title() {
+      return (this.isEdit ? "编辑" : "新增") + "题卡";
+    },
+  },
+  data() {
+    return {
+      modalIsShow: false,
+      isSubmit: false,
+      modalForm: {},
+      curExam: {},
+      rules: {
+        semesterId: [
+          {
+            required: true,
+            message: "请选择学期",
+            trigger: "change",
+          },
+        ],
+        examId: [
+          {
+            required: true,
+            message: "请选择考试",
+            trigger: "change",
+          },
+        ],
+        courseId: [
+          {
+            required: true,
+            message: "请选择课程",
+            trigger: "change",
+          },
+        ],
+        title: [
+          {
+            required: true,
+            message: "题卡名称不能超过30个字",
+            max: 30,
+            trigger: "change",
+          },
+        ],
+      },
+    };
+  },
+  methods: {
+    initData(val) {
+      this.modalForm = this.$objAssign(initModalForm, val);
+    },
+    visibleChange() {
+      this.initData(this.instance);
+
+      this.$nextTick(() => {
+        this.$refs.modalFormComp.clearValidate();
+      });
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    courseChange(val) {
+      this.modalForm.courseName = val?.courseName || "";
+      this.modalForm.courseCode = val?.courseCode || "";
+    },
+    examChange(val) {
+      this.curExam = val || {};
+    },
+    async submit() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      if (!this.isEdit) {
+        const examPrintPlan = await examConfigByExamIdOrgId({
+          examId: this.modalForm.examId,
+          orgId: this.curExam.orgId,
+        });
+
+        const datas = {
+          ...this.modalForm,
+          cardRuleId: examPrintPlan.cardRuleId,
+          schoolName: this.$ls.get("schoolName"),
+        };
+        this.$emit("new-card", datas);
+        this.cancel();
+        return;
+      }
+
+      if (this.isSubmit) return;
+      this.isSubmit = true;
+      let datas = {
+        ...this.modalForm,
+      };
+      const data = await updateCard(datas).catch(() => {});
+      this.isSubmit = false;
+      if (!data) return;
+
+      this.$message.success("保存成功!");
+      this.$emit("modified");
+      this.cancel();
+    },
+  },
+};
+</script>

+ 20 - 0
src/modules/base/views/CardManage.vue

@@ -73,6 +73,13 @@
           @click="toAdd"
           >新增</el-button
         >
+        <el-button
+          v-if="checkPrivilege('button', 'add')"
+          type="primary"
+          icon="el-icon-circle-plus-outline"
+          @click="toAddModeCard"
+          >新增题卡</el-button
+        >
       </div>
     </div>
     <div class="part-box part-box-pad">
@@ -224,6 +231,13 @@
       @new-card="toNewCard"
       @modified="getList"
     ></modify-card-info>
+    <!-- ModifyModeCardInfo -->
+    <modify-mode-card-info
+      ref="ModifyModeCardInfo"
+      :instance="curCard"
+      @new-card="toNewCard"
+      @modified="getList"
+    ></modify-mode-card-info>
     <!-- ModifyCard -->
     <modify-card ref="ModifyCard" @modified="getList"></modify-card>
     <!-- image-preview -->
@@ -260,12 +274,14 @@ import ModifyCard from "../../card/components/ModifyCard";
 import SimpleImagePreview from "@/components/SimpleImagePreview";
 import CardPreviewDialog from "../../card/components/CardPreviewDialog.vue";
 import { downloadByApi } from "@/plugins/download";
+import ModifyModeCardInfo from "../components/ModifyModeCardInfo";
 
 export default {
   name: "card-manage",
   components: {
     ModifyCardInfo,
     ModifyCard,
+    ModifyModeCardInfo,
     SimpleImagePreview,
     CardPreviewDialog,
   },
@@ -326,6 +342,10 @@ export default {
       this.curCard = {};
       this.$refs.ModifyCardInfo.open();
     },
+    toAddModeCard() {
+      this.curCard = {};
+      this.$refs.ModifyModeCardInfo.open();
+    },
     toPreview(row) {
       this.curCard = row;
       this.$refs.CardPreviewDialog.open();

+ 0 - 2
src/modules/card/views/CardEdit.vue

@@ -83,8 +83,6 @@ export default {
     this.cardId = this.cardId || this.prepareTcPCard.id;
     this.cardType = this.prepareTcPCard.type || "CUSTOM";
     this.sysCardSize = this.$ls.get("schoolInfo", { cardSize: "A3" }).cardSize;
-    // TODO: test
-    this.sysCardSize = "8K";
     this.initCard();
     this.openAutoSave();
   },