刘洋 8 mesi fa
parent
commit
66a2c1e9f0

+ 1 - 1
src/render/ap/baseDataConfig.ts

@@ -10,7 +10,7 @@ export const addOrEditExam = (params: { id?: string | number; name: string }) =>
   });
 
 export const getBaseDataConfig = (params: {
-  examId: number;
+  examId: any;
 }): Promise<ConfigInfo> =>
   request({
     url: "/api/admin/exam/config/info",

+ 1 - 1
src/render/ap/system.ts

@@ -18,7 +18,7 @@ export const scanLogin = (params: { device: string; deviceName: string }) =>
     params,
     loading: true,
   });
-export const getSubjectList = (params: { examId: number | null }) =>
+export const getSubjectList = (params: { examId: any }) =>
   request({
     url: "/api/admin/subject/list",
     params,

+ 8 - 0
src/render/utils/index.ts

@@ -12,3 +12,11 @@ export const getTemporaryImgViewConfig = (routePath: string) => {
   let obj = session.get("temporaryImgViewConfig") || {};
   return obj[routePath];
 };
+
+export const getTextAreaRows = (str: string) => {
+  let num = 0;
+  str.split("\n").forEach(() => {
+    num++;
+  });
+  return num;
+};

+ 11 - 1
src/render/views/AbsentCheck/CheckAction.vue

@@ -152,7 +152,7 @@ import ImportTypeDialog from "./ImportTypeDialog.vue";
 import QuestionPanel from "../DataCheck/QuestionPanel.vue";
 import MoreExamNumberDialog from "../DataCheck/MoreExamNumberDialog.vue";
 import { QuestionInfo } from "../DataCheck/types";
-
+import { getTextAreaRows } from "@/utils";
 defineOptions({
   name: "CheckAction",
 });
@@ -319,4 +319,14 @@ const resetDialogRef = ref();
 function onReset() {
   resetDialogRef.value?.open();
 }
+
+watch(
+  () => searchModel.examNumber,
+  (val, oldVal) => {
+    if (getTextAreaRows(val) > 100) {
+      window.$message.error("最多只能输入100行");
+      searchModel.examNumber = oldVal;
+    }
+  }
+);
 </script>

+ 96 - 28
src/render/views/BaseDataConfig/ScanParams.vue

@@ -9,16 +9,16 @@
         :rules="rules"
       >
         <template #label1></template>
+        <template #subject>
+          <div class="pr-5px">
+            <a-select
+              v-model:value="subjectCode"
+              :options="subjectOptions"
+            ></a-select>
+          </div>
+        </template>
         <template #paperTypeBarcodeContentItem>
           <div class="flex items-center">
-            <!-- <a-input-number
-              style="width: 200px"
-              v-model:value="params.paperTypeBarcodeContentItem"
-              allow-clear
-              :disabled="!canEdit"
-              :min="0"
-              :controls="false"
-            /> -->
             <a-input
               style="width: 200px"
               v-model:value="params.paperTypeBarcodeContentItem"
@@ -35,20 +35,28 @@
               >新增</qm-button
             >
           </div>
-          <div
-            class="p-t-10px p-b-10px"
-            v-if="!!params.paperTypeBarcodeContent.length"
-          >
+        </template>
+        <template #paperTypeBarcodeContent>
+          <div class="p-b-10px" v-if="!!params.paperTypeBarcodeContent.length">
             <div
-              class="tag"
+              class="tags-row flex"
               v-for="(item, index) in params.paperTypeBarcodeContent"
-              :key="item"
-              :style="{ color: token.colorPrimary }"
+              :key="index"
             >
-              {{ item }}
-              <span class="close" v-if="canEdit" @click="delTag(index)"
-                >&times;</span
-              >
+              <span class="s-name">{{ getSubjectName(item.value) }}:</span>
+              <div class="flex-1">
+                <div
+                  class="tag"
+                  v-for="(v, i) in item.paperTypeBarcodeContent"
+                  :key="item"
+                  :style="{ color: token.colorPrimary }"
+                >
+                  {{ v }}
+                  <span class="close" v-if="canEdit" @click="delTag(index, i)"
+                    >&times;</span
+                  >
+                </div>
+              </div>
             </div>
           </div>
         </template>
@@ -106,26 +114,45 @@ import useToken from "@/hooks/useToken";
 import { EditOutlined } from "@ant-design/icons-vue";
 import { getBaseDataConfig, saveBaseDataConfig } from "@/ap/baseDataConfig";
 import { useUserStore } from "@/store";
+import { getSubjectList } from "@/ap/system";
+import { cloneDeep } from "lodash-es";
 
+const subjectOptions = ref<any>([]);
+const subjectCode = ref("");
 const form = ref();
 const canEdit = ref(false);
 const userStore = useUserStore();
 const { token } = useToken();
 const getData = () => {
   getBaseDataConfig({ examId: userStore.curExam?.id }).then((res: any) => {
-    params.paperTypeBarcodeContent = res.paperTypeBarcodeContent || [];
+    if (res.paperTypeBarcodeContent?.length) {
+      params.paperTypeBarcodeContent = res.paperTypeBarcodeContent;
+    }
     params.imageCheckRatio = res.imageCheckRatio * 100;
     params.imageCheckOrder = res.imageCheckOrder;
     params.enableSyncVerify = res.enableSyncVerify;
     params.scannerAssignedMaxCount = res.scannerAssignedMaxCount;
     params.scannerAssignedVerifyPassword = res.scannerAssignedVerifyPassword;
-
-    oldParams = { ...params, paperTypeBarcodeContentItem: "" };
   });
 };
 onMounted(() => {
-  getData();
+  getSubjectList({ examId: userStore.curExam?.id }).then((res: any) => {
+    subjectOptions.value = (res || [])
+      .filter((item: any) => item.code == "1" || item.code == "2")
+      .map((item: any) => ({ label: item.name, value: item.code }));
+    if (subjectOptions.value.length) {
+      subjectCode.value = subjectOptions.value[0].value;
+    }
+    getData();
+  });
 });
+const getSubjectName = (code: string) => {
+  if (!subjectOptions.value.length) {
+    return "";
+  } else {
+    return subjectOptions.value.find((item: any) => item.code == code)?.label;
+  }
+};
 const params = reactive<any>({
   paperTypeBarcodeContentItem: "",
   paperTypeBarcodeContent: [],
@@ -144,12 +171,24 @@ const fields = computed(() => {
       colSpan: 4,
       labelWidth: 130,
     },
+    {
+      cell: "subject",
+      colSpan: 6,
+      labelWidth: 60,
+      label: "科目",
+    },
     {
       prop: "paperTypeBarcodeContentItem",
       cell: "paperTypeBarcodeContentItem",
       label: "",
       labelWidth: 0,
-      colSpan: 20,
+      colSpan: 14,
+    },
+    {
+      cell: "paperTypeBarcodeContent",
+      label: " ",
+      labelWidth: 130,
+      colSpan: 24,
     },
     {
       cell: "label2",
@@ -228,12 +267,26 @@ const addTag = () => {
     window.$message.error(params.paperTypeBarcodeContentItem + " 已存在!");
     return;
   }
-  params.paperTypeBarcodeContent.push(params.paperTypeBarcodeContentItem);
+  // params.paperTypeBarcodeContent.push({
+  //   code: subjectCode.value,
+  //   paperTypeBarcodeContent: params.paperTypeBarcodeContentItem,
+  // });
+  let find = params.paperTypeBarcodeContent.find(
+    (item: any) => item.code == subjectCode.value
+  );
+  if (!find) {
+    params.paperTypeBarcodeContent.push({
+      code: subjectCode.value,
+      paperTypeBarcodeContent: [params.paperTypeBarcodeContentItem],
+    });
+  } else {
+    find.paperTypeBarcodeContent.push(params.paperTypeBarcodeContentItem);
+  }
   params.paperTypeBarcodeContentItem = "";
   form.value.formRef.clearValidate(["paperTypeBarcodeContentItem"]);
 };
-const delTag = (index: number) => {
-  params.paperTypeBarcodeContent.splice(index, 1);
+const delTag = (index: number, i: number) => {
+  params.paperTypeBarcodeContent[index].paperTypeBarcodeContent.splice(i, 1);
 };
 
 const rules = {
@@ -283,7 +336,7 @@ const save = () => {
   });
 };
 const willEdit = () => {
-  oldParams = { ...params, paperTypeBarcodeContentItem: "" };
+  oldParams = { ...cloneDeep(params), paperTypeBarcodeContentItem: "" };
   canEdit.value = !canEdit.value;
 };
 const cancelEdit = () => {
@@ -302,6 +355,21 @@ const inputChange = (e: any) => {
     width: 900px;
     max-height: 100%;
     overflow: auto;
+    :deep(.low-form-item-box) {
+      width: auto !important;
+    }
+    :deep(.other-rows) {
+      .ant-form-item:first-child {
+        .ant-col:first-child {
+          opacity: 0;
+        }
+      }
+    }
+    .tags-row {
+      .s-name {
+        line-height: 31px;
+      }
+    }
     .btns {
       padding-top: 60px;
       text-align: right;

+ 11 - 1
src/render/views/DataCheck/CheckAction.vue

@@ -204,7 +204,7 @@ import { objModifyAssign } from "@/utils/tool";
 import ExportTypeDialog from "../Review/ExportTypeDialog.vue";
 import QuestionPanel from "./QuestionPanel.vue";
 import MoreExamNumberDialog from "./MoreExamNumberDialog.vue";
-
+import { getTextAreaRows } from "@/utils";
 defineOptions({
   name: "CheckAction",
 });
@@ -442,4 +442,14 @@ async function onExportConfirm(type: ReviewExportType) {
   if (!res) return;
   message.success("导出成功!");
 }
+
+watch(
+  () => customSearchModel.examNumber,
+  (val, oldVal) => {
+    if (getTextAreaRows(val) > 100) {
+      window.$message.error("最多只能输入100行");
+      customSearchModel.examNumber = oldVal;
+    }
+  }
+);
 </script>

+ 8 - 1
src/render/views/DataCheck/MoreExamNumberDialog.vue

@@ -24,7 +24,7 @@
 <script setup lang="ts">
 import { onMounted, ref, watch, computed } from "vue";
 import { message } from "ant-design-vue";
-
+import { getTextAreaRows } from "@/utils";
 import useModal from "@/hooks/useModal";
 
 defineOptions({
@@ -66,6 +66,13 @@ watch(
     immediate: true,
   }
 );
+
+watch(examNumber, (val, oldVal) => {
+  if (getTextAreaRows(val) > 100) {
+    window.$message.error("最多只能输入100行");
+    examNumber.value = oldVal;
+  }
+});
 </script>
 
 <style lang="less" scoped>