Przeglądaj źródła

feat: 批次号调整

zhangjie 10 miesięcy temu
rodzic
commit
416eb5e384

+ 4 - 0
src/modules/client/api.js

@@ -44,6 +44,10 @@ export const taskInfos = (datas) => {
 //   });
 //   return res.records[0];
 // };
+export const getBatchNo = (datas) => {
+  // examId,userId
+  return $postParam(`/api/admin/client/batch_no/get`, datas);
+};
 export const getStudentInfo = (datas) => {
   // examId,courseCode,studentCode
   return $postParam(`/api/admin/client/student/get`, datas);

+ 22 - 28
src/modules/client/components/SelectBatchNoDialog.vue

@@ -16,26 +16,19 @@
       :key="modalForm.id"
       label-width="70px"
     >
-      <el-form-item prop="serialNo" label="批次号:">
-        <el-select
-          v-model.trim="modalForm.code"
-          filterable
+      <el-form-item prop="sequence" label="批次号:">
+        <el-input
+          v-model.trim="modalForm.alphabet"
           placeholder="编码"
-          :disabled="!!originCode"
+          disabled
           style="width: 80px"
         >
-          <el-option
-            v-for="item in codes"
-            :key="item"
-            :label="item"
-            :value="item"
-          ></el-option>
-        </el-select>
+        </el-input>
         <el-input-number
-          v-model="modalForm.serialNo"
-          placeholder="请输入编号"
+          v-model="modalForm.sequence"
+          placeholder="请输入"
           :min="1"
-          :max="9999"
+          :max="999999"
           :step="1"
           step-strictly
           :controls="false"
@@ -51,16 +44,16 @@
 </template>
 
 <script>
+const initModalForm = { alphabet: "A", sequence: 1 };
+
 export default {
   name: "select-batch-no-dialog",
   data() {
     return {
       modalIsShow: false,
-      modalForm: { code: "", serialNo: 1 },
-      originCode: "",
-      codes: "abcdefghijklmnopqrstuvwxyz".toUpperCase().split(""),
+      modalForm: { ...initModalForm },
       rules: {
-        serialNo: [
+        sequence: [
           {
             required: true,
             message: "请输入批次号",
@@ -78,15 +71,13 @@ export default {
       this.modalIsShow = true;
     },
     dialogOpened() {
-      const batchNo = this.$ls.get("batchNo", "");
-      if (batchNo) {
-        this.modalForm.code = batchNo[0];
-        this.modalForm.serialNo = Number(batchNo.substring(1) || "0") + 1;
+      const batchInfo = this.$ls.get("batchInfo");
+      if (batchInfo) {
+        this.modalForm.alphabet = batchInfo.alphabet;
+        this.modalForm.sequence = batchInfo.sequence + 1;
       } else {
-        this.modalForm.code = "";
-        this.modalForm.serialNo = 1;
+        this.modalForm = { ...initModalForm };
       }
-      this.originCode = this.modalForm.code;
 
       this.$nextTick(() => {
         this.$refs.modalFormComp.clearValidate();
@@ -96,9 +87,12 @@ export default {
       const valid = await this.$refs.modalFormComp.validate().catch(() => {});
       if (!valid) return;
 
-      const batchNo = `${this.modalForm.code}${this.modalForm.serialNo}`;
+      const batchNo = `${this.modalForm.alphabet}${this.modalForm.sequence}`;
 
-      this.$ls.set("batchNo", batchNo);
+      this.$ls.set("batchInfo", {
+        ...this.modalForm,
+        batchNo,
+      });
       this.$emit("confirm", batchNo);
       this.cancel();
     },

+ 20 - 1
src/modules/client/views/Scan.vue

@@ -105,7 +105,7 @@
 
 <script>
 import db from "../../../plugins/db";
-import { taskInfos } from "../api";
+import { taskInfos, getBatchNo } from "../api";
 import SecSelect from "@/components/SecSelect.vue";
 import OcrAreaSetDialog from "../components/OcrAreaSetDialog.vue";
 import { setScanner } from "../../../plugins/scanner";
@@ -160,6 +160,25 @@ export default {
       const res = await taskInfos(this.filter);
       this.task = { ...res, semesterId: this.filter.semesterId };
       this.searchFilter = { ...this.filter };
+      await this.updateBatchNo();
+    },
+    async updateBatchNo() {
+      const res = await getBatchNo({
+        examId: this.filter.examId,
+        userId: this.$ls.get("user", { id: "" }).id,
+      });
+      const batchInfo = res
+        ? {
+            alphabet: res.alphabet,
+            sequence: Number(res.sequence),
+            batchNo: res.batchNo,
+          }
+        : {
+            alphabet: "A",
+            sequence: 1,
+            batchNo: "A1",
+          };
+      this.$ls.set("batchInfo", batchInfo);
     },
     async getOcrArea() {
       const ocrArea = await db.getDict("ocrArea", "").catch(() => {});

+ 2 - 1
src/plugins/imageUpload.js

@@ -9,7 +9,7 @@ import { MD5 } from "./md5";
  */
 export async function toUploadImg(options) {
   const formData = new FormData();
-  // frontFile,frontMd5,versoFile,vers5,taskId
+  // frontFile,frontMd5,versoFile,vers5,taskId,scanUserId
 
   const { file: frontFile, md5: frontMd5 } = await getFileAndMd5(
     options.frontOriginImgPath
@@ -24,6 +24,7 @@ export async function toUploadImg(options) {
 
   formData.append("paperScanTaskId", options.taskId);
   formData.append("batchNo", options.batchNo);
+  formData.append("scanUserId", options.clientUserId);
 
   if (options.isFormal) {
     formData.append("studentCode", options.studentCode);