From b4d6944076f1df6eedaae35c4c2a7072fe988e8a Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期二, 30 四月 2024 15:34:02 +0800
Subject: [PATCH] update: package-lock.json

---
 PAMapp/pages/appointment/_appointmentId/close/index.vue |  213 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 128 insertions(+), 85 deletions(-)

diff --git a/PAMapp/pages/appointment/_appointmentId/close/index.vue b/PAMapp/pages/appointment/_appointmentId/close/index.vue
index 09d6b8b..53c062f 100644
--- a/PAMapp/pages/appointment/_appointmentId/close/index.vue
+++ b/PAMapp/pages/appointment/_appointmentId/close/index.vue
@@ -11,13 +11,13 @@
         </UiField>
       </el-row>
 
-      <template v-if="appointmentCloseInfo.selectCloseOption === 'done'">
+      <template v-if="appointmentCloseInfo.selectCloseOption === contactStatus.DONE">
         <el-row
           type="flex"
           class="pam-paragraph" style="flex-direction: column">
-          <UiField label="靽頨怠�����" :labelSize="20">
+          <UiField label="頨怠�����/撅�����" :labelSize="20" class="required">
             <input
-              class="appointment-client-detail-close__input"
+              class="appointment-client-detail-close__input mt-10"
               :class="{'is-invalid':!identityIdValid}"
               v-model="appointmentCloseInfo.policyholderIdentityId"
               placeholder="隢撓�"
@@ -31,9 +31,9 @@
         <el-row
           type="flex"
           class="pam-paragraph">
-          <UiField label="���誨蝣噗lan Code" :labelSize="20">
+          <UiField label="����迂" :labelSize="20" class="required">
             <input
-              class="appointment-client-detail-close__input"
+              class="appointment-client-detail-close__input mt-10"
               v-model="appointmentCloseInfo.planCode"
               placeholder="隢撓�"
               type="text">
@@ -43,35 +43,29 @@
         <el-row
           type="flex"
           class="pam-paragraph">
-          <UiField label="�脖辣����" :labelSize="20">
-            <DateTimePicker  @changeDateTime="appointmentCloseDate = $event"></DateTimePicker>
+          <UiField label="�脖辣����" :labelSize="20" class="required">
+            <DateTimePicker
+              :defaultValue="appointmentCloseInfo.policyEntryDate"
+              class="mt-10"
+              @changeDateTime="appointmentCloseDate = $event"></DateTimePicker>
           </UiField>
         </el-row>
       </template>
 
-      <template v-if="appointmentCloseInfo.selectCloseOption === 'close'">
+      <template v-if="appointmentCloseInfo.selectCloseOption === contactStatus.CLOSE">
         <el-row
           class="pam-paragraph">
-          <UiField label="���漱����" :labelSize="20">
+          <UiField label="���漱����" :labelSize="20" class="required">
+            <UiSelect :closeReason.sync="appointmentCloseInfo.closedReason"
+              :options="appointmentFailReason" class="mt-10"/>
           </UiField>
-              <select
-                class="appointment-client-detail-close__select"
-                name="closedReason" id="closedReason" v-model="appointmentCloseInfo.closedReason">
-                <option :value="failReason.value" v-for="(failReason, index) in appointmentFailReason" :key="index">
-                  {{ failReason.key }}
-                </option>
-              </select>
-
-              <div style="display: flex" class="mt-10">
-
-                <input
-                  v-if="appointmentCloseInfo.closedReason === 'other'
-                      || appointmentCloseInfo.closedReason === 'no_suitable_commodity'"
-                  class="appointment-client-detail-close__input"
-                  v-model="appointmentCloseInfo.closedOtherReason"
-                  placeholder="隢撓�������50摮��"
-                  type="text">
-              </div>
+          <input
+            v-if="appointmentCloseInfo.closedReason === 'other'
+                || appointmentCloseInfo.closedReason === 'no_suitable_commodity'"
+            class="appointment-client-detail-close__input mt-10"
+            v-model="appointmentCloseInfo.closedOtherReason"
+            placeholder="隢撓�������50摮��"
+            type="text">
         </el-row>
       </template>
 
@@ -80,22 +74,13 @@
         class="pam-paragraph">
         <UiField label="��酉" :labelSize="20">
           <el-input
+          class="mt-10"
             type="textarea"
             :rows="3"
             placeholder="隢撓�"
             v-model="appointmentCloseInfo.remark"
             resize="none">
           </el-input>
-
-          <!-- <textarea
-            v-model="appointmentCloseInfo.archivedDate"
-            class="appointment-close__remark"
-            placeholder="隢撓�"
-            name="remark"
-            id="remark"
-            wrap="off"
-            rows="3">
-          </textarea> -->
         </UiField>
       </el-row>
 
@@ -121,9 +106,10 @@
 import { namespace } from 'nuxt-property-decorator';
 import { Vue, Component } from 'vue-property-decorator';
 import { Appointment, ToCloseAppointment, ToDoneAppointment } from '~/shared/models/appointment.model';
-import { ContactStatus } from '~/shared/models/enum/contact-status';
 
 import appointmentService from '~/shared/services/appointment.service';
+import { appointmentFailReasonList } from '~/shared/const/appointment-fail-reason-list';
+import { ContactStatus } from '~/shared/models/enum/contact-status';
 
 const appointmentStore = namespace('appointment.store');
 
@@ -131,7 +117,10 @@
 export default class AppointmentDetailCloseComponent extends Vue {
 
   @appointmentStore.Action
-  updateAppointmentDetail!: () => Appointment;
+  updateAppointmentDetail!: (appointmentId: number) => Appointment;
+
+  @appointmentStore.State('appointmentDetail')
+  appointmentDetail!: Appointment;
 
   contactStatus = ContactStatus;
 
@@ -142,61 +131,64 @@
     closedOtherReason     : '',
     closedReason          : 'other',
     planCode              : '',
-    policyEntryDate       : this.appointmentCloseDate,
+    policyEntryDate       : '',
     policyholderIdentityId: '',
     remark                : '',
-    selectCloseOption     : 'done',
+    selectCloseOption     : this.contactStatus.DONE,
   };
 
   closeOptions = [
     {
       title:'��漱',
-      label: 'done',
+      label: this.contactStatus.DONE,
     },
     {
       title:'���漱',
-      label: 'close',
+      label: this.contactStatus.CLOSE,
     }
   ];
 
-  appointmentFailReason = [
-    {
-      key: '�瘜蝜怠恥�',
-      value: 'cannot_to_contact_customer'
-    },
-    {
-      key: '�蝝垣閰�',
-      value: 'only_consultation'
-    },
-    {
-      key: '�������',
-      value: 'no_suitable_commodity'
-    },
-    {
-      key: '�靽���- 擃��瓷���璆�',
-      value: 'prohibited_factors'
-    },
-    {
-      key: '蝬����',
-      value: 'economy'
-    },
-    {
-      key: '�隞�',
-      value: 'other'
-    },
-  ];
+  appointmentFailReason = appointmentFailReasonList;
+
+  //////////////////////////////////////////////////////////////////////
+
+  mounted() {
+    const appointmentId = +this.$route.params.appointmentId;
+    const closedInfo = this.appointmentDetail.appointmentClosedInfo;
+    if (this.appointmentDetail.id === appointmentId
+        && (this.appointmentDetail.communicateStatus === this.contactStatus.DONE
+        || this.appointmentDetail.communicateStatus === this.contactStatus.CLOSE
+        || this.appointmentDetail.communicateStatus === this.contactStatus.CANCEL)
+        ) {
+        this.appointmentCloseInfo = {
+        closedOtherReason     : closedInfo?.closedOtherReason,
+        closedReason          : closedInfo?.closedReason,
+        planCode              : closedInfo?.planCode,
+        policyEntryDate       : closedInfo?.policyEntryDate,
+        policyholderIdentityId: closedInfo?.policyholderIdentityId,
+        remark                : closedInfo?.remark,
+        selectCloseOption     : this.appointmentDetail.communicateStatus === this.contactStatus.DONE
+                                ? this.contactStatus.DONE
+                                : this.contactStatus.CLOSE
+      };
+      this.appointmentCloseDate = closedInfo?.policyEntryDate;
+    }
+  }
+
+  //////////////////////////////////////////////////////////////////////
 
   closeAppointment(): void {
     const appointmentId = +this.$route.params.appointmentId;
-    if (this.appointmentCloseInfo.selectCloseOption === 'done') {
+    if (this.appointmentCloseInfo.selectCloseOption === this.contactStatus.DONE) {
       const toDoneAppointment: ToDoneAppointment = {
         appointmentId         : appointmentId,
         contactStatus         : this.contactStatus.DONE,
         planCode              : this.appointmentCloseInfo.planCode,
-        policyEntryDate       : this.appointmentCloseInfo.policyEntryDate,
+        policyEntryDate       : this.appointmentCloseDate,
         policyholderIdentityId: this.appointmentCloseInfo.policyholderIdentityId,
+        remark                : this.appointmentCloseInfo.remark,
       }
-      appointmentService.closeAppointment(toDoneAppointment).then((res) => res);
+      appointmentService.closeAppointment(toDoneAppointment).then((_) => this.updateAppointmentDetail(appointmentId));
       this.isShowSuccessAlert = true;
     } else {
       const toCloseAppointment: ToCloseAppointment = {
@@ -206,8 +198,11 @@
         contactStatus    : this.contactStatus.CLOSE,
         remark           : this.appointmentCloseInfo.remark,
       }
-      appointmentService.closeAppointment(toCloseAppointment).then((res) => res);
-      this.isShowSuccessAlert = true;
+      appointmentService.closeAppointment(toCloseAppointment).then((_) => {
+        this.updateAppointmentDetail(appointmentId);
+        this.isShowSuccessAlert = true;
+      });
+
     }
   }
 
@@ -216,28 +211,63 @@
     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,
       policyholderIdentityId,
       planCode,
-      remark,
       closedReason,
-      closedOtherReason
+      closedOtherReason,
+      remark
     } = this.appointmentCloseInfo;
-    // this.appointmentCloseInfo.policyEntryDate 銝行��齒瘜��澆 this.appointmentCloseDate
-    if (selectCloseOption === 'done') {
-      return !policyholderIdentityId || !this.identityIdValid || !planCode || !this.appointmentCloseDate || !remark
+    if (selectCloseOption === this.contactStatus.DONE) {
+      return !policyholderIdentityId || !this.identityIdValid || !planCode || !this.appointmentCloseDate
     } else if (closedReason === 'other' || closedReason === 'no_suitable_commodity') {
-      return !closedOtherReason || !remark
+      return !closedOtherReason
     }
-    return !remark
+    return false
   }
 
   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;
   }
 
 }
@@ -245,13 +275,13 @@
 
 <style lang="scss" scoped>
 .appointment-close__remark,
-.appointment-client-detail-close__input,
-.appointment-client-detail-close__select {
+.appointment-client-detail-close__input {
   border-radius: 5px;
   border   : 1px solid #707070;
   font-size: 20px;
   padding  : 10px 20px;
   width    : 100%;
+  box-sizing: border-box;
   &::placeholder {
     color: $MID_GREY;
   }
@@ -269,4 +299,17 @@
     @extend .text--primary;
     height: 16px;
   }
+  .required {
+    position: relative;
+
+    &::before {
+      content: '*';
+      font-size: 15px;
+      font-weight: bold;
+      position: absolute;
+      color: #FF0000;
+      transform: translateX(-2px);
+      z-index: 5;
+    }
+  }
 </style>

--
Gitblit v1.8.0