Prechádzať zdrojové kódy

feat: 配置例题ID时,支持uuid

vian 2 rokov pred
rodič
commit
17e3a52000

+ 5 - 1
modules/users/models/compilation_model.js

@@ -167,7 +167,11 @@ class CompilationModel extends BaseModel {
         let data = [];
         if (example) {
             for (let projId of example) {
-                data.push(parseInt(projId));
+                if (/^[0-9]+$/.test(projId)) {
+                    data.push(parseInt(projId));
+                } else if (projId) {
+                    data.push(projId);
+                }
             }
         }
         return await this.updateById(compilationId, {example: data});

+ 1 - 8
web/users/js/compilation.js

@@ -491,14 +491,7 @@ $(document).ready(function() {
     //例题建设项目ID, 用英文字符;分隔建设项目ID
     $('#example').keyup(function () {
         let exampleVal = $(this).val();
-        let tempExample = exampleVal.split(/[;,;]/g),
-            example = [];
-        for (let te of tempExample) {
-            let intTe = parseInt(te);
-            if (!isNaN(intTe)) {
-                example.push(intTe);
-            }
-        }
+        let example = exampleVal.split(/[;,;]/g);
         example = Array.from(new Set(example));
         delayKeyup(function () {
             $.ajax({