From 756f8a63347119f511fc964bf1e2ff2417339c56 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期四, 11 一月 2024 17:16:42 +0800
Subject: [PATCH] update: 改寫 lodash 方法為純 js

---
 PAMapp/shared/services/message-box.service.ts   |    3 +--
 PAMapp/components/phoneContactTimePicker.vue    |   23 +++++++++++------------
 PAMapp/pages/agentInfo/edit/_agentNo.vue        |   13 ++++++-------
 PAMapp/shared/services/my-consultant.service.ts |    9 ++++-----
 4 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/PAMapp/components/phoneContactTimePicker.vue b/PAMapp/components/phoneContactTimePicker.vue
index 1055196..e297e0b 100644
--- a/PAMapp/components/phoneContactTimePicker.vue
+++ b/PAMapp/components/phoneContactTimePicker.vue
@@ -74,18 +74,17 @@
   import { dayTimeFrames } from "~/shared/const/day-time-frames";
   import { OptionBtnDto, OptionDto } from "~/shared/models/optionBtnDto.model";
   import { weekDays } from "~/shared/const/week-days";
-  import * as _ from "lodash";
   @Component({
     filters:{
       titleFormatByIndex(index:number):string{
         const chineseNumber = ['銝�','鈭�','銝�','���','鈭�','�','銝�','�','銋�','���'];
         return '��挾'+chineseNumber[index];
       },
-      optionsFormat(selectedOptions:string[]|[], compareOptions:OptionDto): string{
-        return _.isEqual(selectedOptions.length,compareOptions.options.length)
-                ? compareOptions.selectAll
-                : _.join(selectedOptions,',');
-      },
+      optionsFormat(selectedOptions = [], compareOptions) {
+        return selectedOptions.length === compareOptions.options.length
+          ? compareOptions.selectAll
+          : selectedOptions.join(',');
+      }
     }
   })
   export default class PhoneContactTimePicker extends Vue {
@@ -110,7 +109,7 @@
     //////////////////////////////////////////////////////////////////////
 
     get isOpenByDayPopUp(): boolean{
-      return _.isEqual(this.popUpMode , TimePickerMode.SELECT_DAY)
+      return this.popUpMode === TimePickerMode.SELECT_DAY;
     }
 
     set isOpenByDayPopUp(value:boolean){
@@ -118,7 +117,7 @@
     }
 
     get isOpenByTimePopUp(): boolean{
-      return _.isEqual(this.popUpMode , TimePickerMode.SELECT_TIME);
+      return this.popUpMode === TimePickerMode.SELECT_TIME;
     }
 
     set isOpenByTimePopUp(value:boolean){
@@ -128,7 +127,7 @@
     //////////////////////////////////////////////////////////////////////
 
     openPopUp(schedule:scheduleDto,index:number):void{
-      this.initPickerControl = _.cloneDeep(schedule);
+      this.initPickerControl = JSON.parse(JSON.stringify(schedule));
       this.popUpMode = TimePickerMode.SELECT_DAY;
       this.scheduleIndex = index;
     }
@@ -144,8 +143,8 @@
     }
 
     private initPickerFormatSort(initPickerControl:scheduleDto):scheduleDto{
-      _.keys(initPickerControl).forEach(keyName=>{
-        const options = _.isEqual(keyName,'selectWeekOptions') ? weekDays : dayTimeFrames;
+      Object.keys(initPickerControl).forEach(keyName=>{
+        const options = keyName === 'selectWeekOptions' ? weekDays : dayTimeFrames;
         initPickerControl[keyName] = this.getOptionsBySort(initPickerControl[keyName],options);
       })
       return initPickerControl;
@@ -153,7 +152,7 @@
 
     // 鞈�������儔銝���������
     private getOptionsBySort( selectedOptions:string[] , options:OptionBtnDto[]): string[] {
-      return options.map( o => _.includes(selectedOptions , o.label) ? o.label as string : '').filter(String);
+      return options.map( o => selectedOptions.includes(o.label as string) ? o.label as string : '').filter(String);
     }
 
     addNewSchedule(): void {
diff --git a/PAMapp/pages/agentInfo/edit/_agentNo.vue b/PAMapp/pages/agentInfo/edit/_agentNo.vue
index e4cb6f6..cb4f9b3 100644
--- a/PAMapp/pages/agentInfo/edit/_agentNo.vue
+++ b/PAMapp/pages/agentInfo/edit/_agentNo.vue
@@ -264,7 +264,6 @@
 import { Context } from '@nuxt/types';
 import { namespace } from 'nuxt-property-decorator';
 import { Vue, Component, Prop } from 'vue-property-decorator';
-import * as _ from "lodash";
 
 import myConsultantService from '~/shared/services/my-consultant.service';
 import accountSettingService from '~/shared/services/account-setting.service';
@@ -410,7 +409,7 @@
 
     this.editInfoValue = {
       ...this.defaultAgentInfoSetting,
-      expertise: _.cloneDeep(this.defaultAgentInfoSetting.expertise),
+      expertise: JSON.parse(JSON.stringify(this.defaultAgentInfoSetting.expertise)),
       communicationStyle: this.defaultAgentInfoSetting.communicationStyle?.split('��') || [],
     };
   }
@@ -467,11 +466,11 @@
   }
 
   get phoneValid(): boolean {
-            const rule = /^09[0-9]{8}$/;
-            return this.editInfoValue.phoneNumber
-            ? rule.test(this.editInfoValue.phoneNumber) && _.isEqual(this.editInfoValue.phoneNumber.length,10)
-            : true;
-        }
+    const rule = /^09[0-9]{8}$/;
+    return this.editInfoValue.phoneNumber
+      ? rule.test(this.editInfoValue.phoneNumber) && this.editInfoValue.phoneNumber.length === 10
+      : true;
+  }
 
   get emailValid() {
       const rule = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
diff --git a/PAMapp/shared/services/message-box.service.ts b/PAMapp/shared/services/message-box.service.ts
index c785c43..b47d4a0 100644
--- a/PAMapp/shared/services/message-box.service.ts
+++ b/PAMapp/shared/services/message-box.service.ts
@@ -1,6 +1,5 @@
 import { MessageBox } from 'element-ui';
 import { MessageBoxData } from "element-ui/types/message-box";
-import _ from "lodash";
 
 class MessageBoxService {
 
@@ -22,7 +21,7 @@
 
   // ������銵�
   private breakTextByComma(errorMsg:string):string{
-    return _.split(errorMsg,"嚗�").join('<br>');
+    return errorMsg.split("嚗�").join('<br>');
   }
 
 }
diff --git a/PAMapp/shared/services/my-consultant.service.ts b/PAMapp/shared/services/my-consultant.service.ts
index 8219eb0..5356979 100644
--- a/PAMapp/shared/services/my-consultant.service.ts
+++ b/PAMapp/shared/services/my-consultant.service.ts
@@ -1,9 +1,8 @@
-import _ from "lodash";
 
-import { http } from "./httpClient";
 import { AgentInfo } from '~/shared/models/agent-info.model';
-import { Consultant } from "../models/consultant.model";
 import { Appointment } from "../models/appointment.model";
+import { Consultant } from "../models/consultant.model";
+import { http } from "./httpClient";
 class MyConsultantService {
 
   async getFavoriteConsultantList(): Promise<Consultant[]> {
@@ -56,8 +55,8 @@
     return http.get(`/consultant/avatar/${agentNo}`,{ responseType : 'arraybuffer' })
       .then( response => {
         const toBase64 = window.btoa(
-                          _.reduce( new Uint8Array(response.data),(data,byte) =>
-                            data + String.fromCharCode(byte),'')
+                          Array.from(new Uint8Array(response.data)).reduce((data, byte) =>
+                            data + String.fromCharCode(byte), '')
                         );
         const imgSrc = `data:image/png;base64,${toBase64}`;
         return imgSrc;

--
Gitblit v1.8.0