From 3b96b51ff6a671445bbeeb0ec155d9b5d85f2998 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期三, 10 四月 2024 16:00:43 +0800
Subject: [PATCH] 1

---
 force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js |  194 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 177 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js b/force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js
index 8f2dd4a..7a9f8f2 100644
--- a/force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js
+++ b/force-app/main/default/lwc/lexAgencyAuthorize/lexAgencyAuthorize.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-04-12 14:51:44
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-05-11 13:46:32
+ * @LastEditTime: 2023-10-10 17:25:57
  */
 import { api, wire,LightningElement } from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
@@ -14,8 +14,15 @@
 import { updateRecord } from 'lightning/uiRecordApi';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 import checkDangerItem from '@salesforce/apex/OpportunityWebService.checkDangerItem';
+import accSendEmail from '@salesforce/apex/OpportunityWebService.accSendEmail';
 import oppCheck from '@salesforce/apex/OpportunityWebService.oppCheck';
 import updReg from '@salesforce/apex/OpportunityWebService.updReg';
+import TradeComplianceStatusFlag from '@salesforce/label/c.TradeComplianceStatusFlag';
+import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';
+import LightningConfirm from 'lightning/confirm';
+import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
+import {loadStyle} from 'lightning/platformResourceLoader';
+import queryQuote from '@salesforce/apex/OpportunityLightingButtonController.queryQuote';
 
 export default class LexAgencyAuthorize extends LightningElement {
     @api recordId;
@@ -42,6 +49,12 @@
     s61ProfileId;
     s62ProfileId;
     m4ProfileId;
+    AccDealerBlacklist;
+    angency1;
+    angency2;
+    accname;
+    ownerids;
+    ddid;
     IsLoading = true;
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -59,6 +72,9 @@
         }
     }
     connectedCallback(){
+        Promise.all([
+            loadStyle(this, lwcCSS)
+           ]);
         init({
             recordId: this.recordId
         }).then(result=>{
@@ -86,8 +102,18 @@
             this.s61ProfileId = result.s61ProfileId;
             this.s62ProfileId = result.s62ProfileId;
             this.m4ProfileId = result.m4ProfileId;
+            this.AccDealerBlacklist = result.AccDealerBlacklist;
+            this.angency1 = result.angency1;
+            this.angency2 = result.angency2;
+            this.accname = result.accname;
+            this.ownerids = result.ownerids;
+            this.ddid = result.ddid;
+            console.log("w");
             this.AgencyAuthorize();
-        })
+        }).catch(error=>{
+            console.log("error");
+            console.log(error);
+        });
     }
     AgencyAuthorize(){
         var btns = document.getElementsByName("agency_authorize");
@@ -99,13 +125,106 @@
         var oppid = this.recordId;
         var angency = this.agency1Id;
         var profileId = this.profileId;
-         //娴嬭瘯宸查攣瀹氭巿鏉冨悎鍚岀敵璇蜂负鈥�1鈥�
-        this.estimationId = 'test';
         this.detailNum = 1;
         if (profileId != this.systemProfileId && profileId != this.j3ProfileId && profileId != this.s61ProfileId && profileId != this.s62ProfileId && profileId != this.m4ProfileId) {
             this.showToast("鎮ㄦ病鏈夋巿鏉冪敵璇风殑鏉冮檺銆傝鑱旂郴绯荤粺绠$悊鍛樸��","error");
             return;
         }
+        queryQuote({
+            estimationId: this.estimationId
+        }).then(result=>{
+            console.log(result);
+            if(result == true){
+                this.showToast("鍖呭惈铏氭嫙浜у搧锛屼笉鑳芥巿鏉冿紝璇锋洿鏂版姤浠峰崟鍚庣敵璇�","error");
+                return;
+            }
+             //璐告槗鍚堣 you
+        var AccDealerBlacklist = this.AccDealerBlacklist;//鍒ゆ柇瀹㈡埛/缁忛攢鍟嗘槸鍚︿负榛戝悕鍗�
+        var angency1 = this.angency1;
+        var angency2 = this.angency2;
+        var accname = this.accname;
+        var ownerids = this.ownerids;
+        var ddid = this.ddid;
+        if(TradeComplianceStatusFlag=='true'){
+            //鎷︽埅+閭欢鎻愰啋
+            var oppflag=false;
+            if (AccDealerBlacklist=='123') {
+                // alert('瀹㈡埛,缁忛攢鍟�1锛岀粡閿�鍟�2閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert);
+                this.showToast('瀹㈡埛,缁忛攢鍟�1锛岀粡閿�鍟�2閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert,'error');
+                oppflag=true;
+
+            }else if(AccDealerBlacklist=='12'){
+                // alert('瀹㈡埛,缁忛攢鍟�1閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert);
+                this.showToast('瀹㈡埛,缁忛攢鍟�1閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert,'error');
+                oppflag=true;
+            }else if(AccDealerBlacklist=='23'){
+                // alert('缁忛攢鍟�1锛岀粡閿�鍟�2閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert);
+                this.showToast('缁忛攢鍟�1锛岀粡閿�鍟�2閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert,'error');
+                oppflag=true;
+            }else if(AccDealerBlacklist=='13'){
+                // alert('瀹㈡埛,缁忛攢鍟�2閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert);
+                this.showToast('瀹㈡埛,缁忛攢鍟�2閮戒负榛戝悕鍗曪紝涓嶈兘鍋氭巿鏉冪敵璇凤紝'+IFTradeComplianceAlert,'error');
+                oppflag=true;
+            }else if(AccDealerBlacklist=='1'){
+                // alert('瀹㈡埛涓洪粦鍚嶅崟锛屼笉鑳藉仛鎺堟潈鐢宠锛�'+IFTradeComplianceAlert);
+                this.showToast('瀹㈡埛涓洪粦鍚嶅崟锛屼笉鑳藉仛鎺堟潈鐢宠锛�'+IFTradeComplianceAlert,'error');
+                oppflag=true;
+            }else if(AccDealerBlacklist=='2'){
+                // alert('缁忛攢鍟�1涓洪粦鍚嶅崟锛屼笉鑳藉仛鎺堟潈鐢宠锛�'+IFTradeComplianceAlert);
+                this.showToast('缁忛攢鍟�1涓洪粦鍚嶅崟锛屼笉鑳藉仛鎺堟潈鐢宠锛�'+IFTradeComplianceAlert,'error');
+                oppflag=true;
+            }else if(AccDealerBlacklist=='3'){
+                // alert('缁忛攢鍟�2涓洪粦鍚嶅崟锛屼笉鑳藉仛鎺堟潈鐢宠锛�'+IFTradeComplianceAlert);
+                this.showToast('缁忛攢鍟�2涓洪粦鍚嶅崟锛屼笉鑳藉仛鎺堟潈鐢宠锛�'+IFTradeComplianceAlert,'error');
+                oppflag=true;
+            }
+            console.log('y');
+            console.log(oppflag);
+            if(oppflag){
+                accSendEmail({
+                    "AccDealerBlacklist":AccDealerBlacklist,
+                    "accname":accname,
+                    "angency1":angency1,
+                    "angency2":angency2,
+                    "ownerids":ownerids,
+                    "ddid":ddid,
+                    "oppid":oppid 
+                }).then(result=>{
+                    console.log('q');
+                    var opprtn = result;
+                    if (opprtn = true) {
+                        return;
+                    }
+                    //璀︾ず鎻愰啋
+                    if (AccDealerBlacklist=='567') {
+                        this.handleConfirmClick('鎮ㄦ墍閫夋嫨鐨勫鎴�,缁忛攢鍟�1锛岀粡閿�鍟�2瀛樺湪璐告槗鍚堣璀︾ず椋庨櫓锛屼笉寤鸿鍋氭巿鏉冪敵璇凤紝璇锋偍纭鏄惁缁х画鐢宠锛�'+IFTradeComplianceAlert);
+                    }else if(AccDealerBlacklist=='56'){
+                        this.handleConfirmClick('鎮ㄦ墍閫夋嫨鐨勫鎴�,缁忛攢鍟�1瀛樺湪璐告槗鍚堣璀︾ず椋庨櫓锛屼笉寤鸿鍋氭巿鏉冪敵璇凤紝璇锋偍纭鏄惁缁х画鐢宠锛�'+IFTradeComplianceAlert);
+                    }else if(AccDealerBlacklist=='67'){
+                        this.handleConfirmClick('鎮ㄦ墍閫夋嫨鐨勭粡閿�鍟�1锛岀粡閿�鍟�2瀛樺湪璐告槗鍚堣璀︾ず椋庨櫓锛屼笉寤鸿鍋氭巿鏉冪敵璇凤紝璇锋偍纭鏄惁缁х画鐢宠锛�'+IFTradeComplianceAlert);
+                    }else if(AccDealerBlacklist=='57'){
+                        this.handleConfirmClick('鎮ㄦ墍閫夋嫨鐨勫鎴�,缁忛攢鍟�2瀛樺湪璐告槗鍚堣璀︾ず椋庨櫓锛屼笉寤鸿鍋氭巿鏉冪敵璇凤紝璇锋偍纭鏄惁缁х画鐢宠锛�'+IFTradeComplianceAlert);
+                    }else if(AccDealerBlacklist=='5'){
+                        this.handleConfirmClick('鎮ㄦ墍閫夋嫨鐨勫鎴峰瓨鍦ㄨ锤鏄撳悎瑙勮绀洪闄╋紝涓嶅缓璁仛鎺堟潈鐢宠锛岃鎮ㄧ‘璁ゆ槸鍚︾户缁敵璇凤紝'+IFTradeComplianceAlert);
+                    }else if(AccDealerBlacklist=='6'){
+                        this.handleConfirmClick('鎮ㄦ墍閫夋嫨鐨勭粡閿�鍟�1瀛樺湪璐告槗鍚堣璀︾ず椋庨櫓锛屼笉寤鸿鍋氭巿鏉冪敵璇凤紝璇锋偍纭鏄惁缁х画鐢宠锛�'+IFTradeComplianceAlert);
+                    }else if(AccDealerBlacklist=='7'){
+                        this.handleConfirmClick('鎮ㄦ墍閫夋嫨鐨勭粡閿�鍟�2瀛樺湪璐告槗鍚堣璀︾ず椋庨櫓锛屼笉寤鸿鍋氭巿鏉冪敵璇凤紝璇锋偍纭鏄惁缁х画鐢宠锛�'+IFTradeComplianceAlert);
+                    }
+                });
+            }else{
+                this.ss();
+            }
+        }else{
+            this.ss();
+        }
+        //璐告槗鍚堣 you
+        });
+        
+
+       
+    }
+    ss(){
         if (this.stageName != '寮曞悎' && this.stageName != '璇环' ) {
             this.showToast("鐘舵��1:" + this.stageName + "銆佷笉鑳藉仛鎺堟潈鐢宠锛�","error");
             return;
@@ -119,10 +238,11 @@
             this.showToast("鑰楁潗涓嶅彲涓庡ゥ杈変骇鍝佸悓鏃跺瓨鍦紒","error");
             return;
         } else if (this.cntLostCancelDraft > 0) {
-            if(!confirm('璇环鏈夎崏妗堜腑鐨勫彇娑�/澶卞崟鎶ュ憡锛屾槸鍚︾户缁紵')){
-                this.dispatchEvent(new CloseActionScreenEvent());
-                return ;
-            }     
+            // if(!confirm('璇环鏈夎崏妗堜腑鐨勫彇娑�/澶卞崟鎶ュ憡锛屾槸鍚︾户缁紵')){
+            //     this.dispatchEvent(new CloseActionScreenEvent());
+            //     return ;
+            // }   
+            this.handleConfirmClick1("璇环鏈夎崏妗堜腑鐨勫彇娑�/澶卞崟鎶ュ憡锛屾槸鍚︾户缁紵");  
         } else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) {
             this.showToast('璇环鏈夊凡鎻愪氦鐨勫彇娑�/澶卞崟鎶ュ憡銆�',"error");
             return;
@@ -138,7 +258,13 @@
         }else if (this.ifSubmit == '1') {
             this.showToast('涓婁紶澶辫触锛岃鑱旂郴绯荤粺绠$悊鍛�!',"error");
             return;
+        }else{
+            this.dd();
         }
+        
+    }
+
+    dd(){
         if (this.ifAuthorizingLock == true) {
             this.showToast('璇环姝e湪鎺堟潈涓紝璇蜂笉瑕侀噸澶嶆彁浜ゃ��',"error");
             return;
@@ -146,7 +272,7 @@
         if (this.trade == '鍐呰部') {
             if(this.isCorrosion == '1'){
                 checkDangerItem({
-                    agency1: angency
+                    agency1: this.agency1Id
                 }).then(result=>{
                     var rtn1 = result;
                     if (rtn1 != 'OK') {
@@ -157,7 +283,7 @@
             });
             }else{
                 oppCheck({
-                    oppid: oppid,
+                    oppid: this.recordId,
                     saveFlg: '1'
                 }).then(result=>{
                     var rtn = result;
@@ -170,20 +296,54 @@
             }
         } else {
             updReg({
-                oppid: oppid
+                oppid: this.recordId
             }).then(()=>{
                 this.update();
             });
         }  
     }
-    showToast(msg,type) {
-        const event = new ShowToastEvent({
-            title: '',
+    async handleConfirmClick(msg) {
+        const result = await LightningConfirm.open({
             message: msg,
-            variant: type
+            variant: 'headerless',
+            label: 'this is the aria-label value'
         });
-        this.dispatchEvent(event);
-        this.dispatchEvent(new CloseActionScreenEvent());
+        if (result) {
+            this.ss();
+        } else {
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }
+    }
+
+    async handleConfirmClick1(msg) {
+        const result = await LightningConfirm.open({
+            message: msg,
+            variant: 'headerless',
+            label: 'this is the aria-label value'
+        });
+        if (result) {
+            this.dd();
+        } else {
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }
+    }
+    showToast(msg,type) {
+        if(type == 'success'){
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type,
+            });
+            this.dispatchEvent(event);
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }else{
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type,
+                mode: 'sticky'
+            });
+            this.dispatchEvent(event);
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }   
     }
     updateRecordView(recordId) {
         updateRecord({fields: { Id: recordId }});

--
Gitblit v1.9.1