Browse Source

feat: 正反斜杠限制输入

zhangjie 10 months ago
parent
commit
af3725a002

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # paper-library-web
 
-**试卷电子化前端系统**
+**历史试卷电子化前端系统**
 
 ## 项目操作
 

+ 20 - 20
public/index.html

@@ -1,25 +1,25 @@
 <!DOCTYPE html>
 <html>
-  <head>
-    <meta charset="utf-8" />
-    <meta name="viewport" content="width=device-width,initial-scale=1.0,
+
+<head>
+  <meta charset="utf-8" />
+  <meta name="viewport" content="width=device-width,initial-scale=1.0,
     maximum-scale=1.0,minimum-scale=1.0, user-scalable=no"" />
     <meta name=" renderer" content="webkit|ie-comp|ie-stand" />
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
-    <meta name="apple-mobile-web-app-capable" content="yes" />
-    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
-    <title>试卷电子化</title>
-  </head>
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
+  <meta name="apple-mobile-web-app-capable" content="yes" />
+  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
+  <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
+  <title>历史试卷电子化</title>
+</head>
+
+<body>
+  <noscript>
+    <strong>We're sorry but 历史试卷电子化 doesn't work properly without JavaScript
+      enabled. Please enable it to continue.</strong>
+  </noscript>
+  <div id="app"></div>
+  <!-- built files will be auto injected -->
+</body>
 
-  <body>
-    <noscript>
-      <strong
-        >We're sorry but 试卷电子化 doesn't work properly without JavaScript
-        enabled. Please enable it to continue.</strong
-      >
-    </noscript>
-    <div id="app"></div>
-    <!-- built files will be auto injected -->
-  </body>
-</html>
+</html>

+ 1 - 1
src/constants/app.js

@@ -1,7 +1,7 @@
 import { parseHrefParam } from "../plugins/utils";
 const MD5 = require("js-md5");
 
-export const APP_TITLE = "试卷电子化";
+export const APP_TITLE = "历史试卷电子化";
 
 // domain
 export function getOrgCode() {

+ 2 - 0
src/modules/base/components/ModifyExam.vue

@@ -42,6 +42,7 @@
 
 <script>
 import { updateExam } from "../api";
+import { slashesLimitValidator } from "@/plugins/formRules";
 
 const initModalForm = {
   id: null,
@@ -84,6 +85,7 @@ export default {
             max: 100,
             trigger: "change",
           },
+          ...slashesLimitValidator,
         ],
         semesterId: [
           {

+ 3 - 1
src/modules/base/components/ModifySemester.vue

@@ -23,7 +23,7 @@
           placeholder="请输入学期名称"
           clearable
         ></el-input>
-        <p class="tips-info">示例:2021~2022第一学期/上学期</p>
+        <p class="tips-info">示例:2021~2022第一学期上学期</p>
       </el-form-item>
     </el-form>
     <div slot="footer">
@@ -37,6 +37,7 @@
 
 <script>
 import { updateSemester } from "../api";
+import { slashesLimitValidator } from "@/plugins/formRules";
 
 const initModalForm = {
   id: null,
@@ -78,6 +79,7 @@ export default {
             max: 100,
             trigger: "change",
           },
+          ...slashesLimitValidator,
         ],
       },
     };

+ 5 - 0
src/modules/base/components/ModifyStudent.vue

@@ -134,6 +134,7 @@
 
 <script>
 import { updateStudent } from "../api";
+import { slashesLimitValidator } from "@/plugins/formRules";
 
 const initModalForm = {
   id: null,
@@ -227,6 +228,7 @@ export default {
             max: 50,
             trigger: "change",
           },
+          ...slashesLimitValidator,
         ],
         teacher: [
           {
@@ -253,6 +255,7 @@ export default {
             max: 50,
             trigger: "change",
           },
+          ...slashesLimitValidator,
         ],
         courseCode: [
           {
@@ -265,6 +268,7 @@ export default {
             max: 50,
             trigger: "change",
           },
+          ...slashesLimitValidator,
         ],
         examRoom: [
           {
@@ -272,6 +276,7 @@ export default {
             max: 50,
             trigger: "change",
           },
+          ...slashesLimitValidator,
         ],
         remark: [
           {

+ 14 - 0
src/plugins/formRules.js

@@ -81,6 +81,19 @@ const numberValidator = ({ prop, min = 1, max = 100 }) => {
   ];
 };
 
+// 正反斜杠限制输入
+const slashesLimitValidator = [
+  {
+    validator: (rule, value, callback) => {
+      if (value.match(/[\\/]/g)) {
+        callback(new Error("禁止输入正斜杠和反斜杠"));
+      } else {
+        callback();
+      }
+    },
+  },
+];
+
 export {
   username,
   commonCode,
@@ -89,4 +102,5 @@ export {
   phone,
   smscode,
   numberValidator,
+  slashesLimitValidator,
 };