From ae4db5435180c44b37f521c463b17f2023ac1d8c Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期五, 18 二月 2022 09:25:50 +0800
Subject: [PATCH] [update] 若顧問停用時,將無法登入 (文案待確認)

---
 PAMapp/pages/appointment/_appointmentId/close/index.vue |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/PAMapp/pages/appointment/_appointmentId/close/index.vue b/PAMapp/pages/appointment/_appointmentId/close/index.vue
index d10476c..3fe2dae 100644
--- a/PAMapp/pages/appointment/_appointmentId/close/index.vue
+++ b/PAMapp/pages/appointment/_appointmentId/close/index.vue
@@ -15,7 +15,7 @@
         <el-row
           type="flex"
           class="pam-paragraph" style="flex-direction: column">
-          <UiField label="靽頨怠�����" :labelSize="20" class="required">
+          <UiField label="頨怠�����/撅�����" :labelSize="20" class="required">
             <input
               class="appointment-client-detail-close__input"
               :class="{'is-invalid':!identityIdValid}"
@@ -209,6 +209,43 @@
     this.$router.push(`/myAppointmentList/contactedList`);
   }
 
+  checkIdentityId(id) {
+    const tab = 'ABCDEFGHJKLMNPQRSTUVXYWZIO';
+    const weight = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1];
+    if (id.length !== 10) return false;
+    let i = tab.indexOf(id.charAt(0)) + 10;
+    if (i === 9) return false;
+    let sum = Math.floor((i % 100) / 10) + (i % 10) * 9;
+    for (i = 1; i < 10; i += 1) {
+      let v = parseInt(id.charAt(i), 10);
+      if (i === 1 && Number.isNaN(v)) {
+        switch (id.charAt(i)) {
+          case 'A':
+            v = 0;
+            break;
+          case 'B':
+            v = 1;
+            break;
+          case 'C':
+            v = 2;
+            break;
+          case 'D':
+            v = 3;
+            break;
+          default:
+            return false;
+        }
+      } else if (i === 1 && ([1, 2, 8, 9].indexOf(v) === -1)) {
+        return false;
+      }
+      if (i > 1 && Number.isNaN(v)) return false;
+      sum += v * weight[i];
+    }
+
+    if (sum % 10 !== 0) return false;
+    return true;
+  }
+
   get isSubmitBtnDisabled() {
     const {
       selectCloseOption,
@@ -227,9 +264,8 @@
   }
 
   get identityIdValid() {
-    const rule = /^[A-Z]\d{9}$/;
     const identityId = this.appointmentCloseInfo.policyholderIdentityId;
-    return identityId ? rule.test(identityId) : true;
+    return identityId ? this.checkIdentityId(identityId) : true;
   }
 
 }

--
Gitblit v1.8.0