Pārlūkot izejas kodu

重复证书添加限制及导入账号名相同解除限制

ellisran 1 gadu atpakaļ
vecāks
revīzija
f306be12e8
2 mainītis faili ar 20 papildinājumiem un 3 dzēšanām
  1. 4 3
      app/public/js/setting.js
  2. 16 0
      app/public/js/tender_cert.js

+ 4 - 3
app/public/js/setting.js

@@ -448,9 +448,10 @@ $(document).ready(() => {
                         if (!reg.test(j.password)) {
                             continue;
                         }
-                        if (_.findIndex(tree, function (o) { return o.account === j.account; }) === -1) {
-                            tree.push(j);
-                        }
+                        tree.push(j);
+                        // if (_.findIndex(tree, function (o) { return o.account === j.account; }) === -1) {
+                        //     tree.push(j);
+                        // }
                     }
                 }
                 console.log(tree);

+ 16 - 0
app/public/js/tender_cert.js

@@ -134,6 +134,22 @@ $(function () {
     });
 
     $('#add_cert_btn').click(function () {
+        // 判断是否有重复项cert_id的,否则不允许提交
+        const certIdList = [];
+        let isRepeat = false;
+        $('#select-certs-table tr[data-remove="0"]').each(function () {
+            const certId = parseInt($(this).attr('data-certid'));
+            if (certIdList.indexOf(certId) === -1) {
+                certIdList.push(certId);
+            } else {
+                isRepeat = true;
+                return;
+            }
+        });
+        if (isRepeat) {
+            toastr.error('用户不能添加重复的证书');
+            return;
+        }
         // 判断增删改
         const insertList = [];
         if ($('#select-certs-table tr[data-insert="1"][data-remove="0"]').length > 0) {