From ddb0231ef7c5cf2bad9d3f1afc2f733674ad38a5 Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期四, 24 八月 2023 14:50:51 +0800
Subject: [PATCH] 再修理按钮

---
 force-app/main/default/lwc/lexSendRepairsToEtQ/lexSendRepairsToEtQ.js |  147 +++++++++++++++++++++++++++++--------------------
 1 files changed, 87 insertions(+), 60 deletions(-)

diff --git a/force-app/main/default/lwc/lexSendRepairsToEtQ/lexSendRepairsToEtQ.js b/force-app/main/default/lwc/lexSendRepairsToEtQ/lexSendRepairsToEtQ.js
index 927e6d3..bfc137a 100644
--- a/force-app/main/default/lwc/lexSendRepairsToEtQ/lexSendRepairsToEtQ.js
+++ b/force-app/main/default/lwc/lexSendRepairsToEtQ/lexSendRepairsToEtQ.js
@@ -12,9 +12,12 @@
 import init from '@salesforce/apex/otherButtonRepairController.init';
 import selectRecords from '@salesforce/apex/otherButtonRepairController.selectRecords';
 import sendToETQ from '@salesforce/apex/otherButtonRepairController.sendToETQ';
+import initSelectProfile from '@salesforce/apex/otherButtonRepairController.initSelectProfile';
+import initUserName from '@salesforce/apex/otherButtonRepairController.initUserName';
 import {
     ShowToastEvent
 } from 'lightning/platformShowToastEvent';
+import LightningConfirm from 'lightning/confirm';
 
 export default class LexSendRepairsToEtQ extends LightningElement {
     @api recordId;
@@ -29,6 +32,10 @@
     ContainUseRSAC;
     userID;
     profileId;
+    profileName;
+    userName;
+    msg;
+    statu = '';
 
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -48,7 +55,6 @@
         }).then(result => {
             console.log(result);
             if (result != null) {
-                this.IsLoading = false;
                 this.Id = result.Id;
                 this.PAEDetermineC = result.PAEDetermineC;
                 this.ETQUPLOADSTATUSC = result.ETQUPLOADSTATUSC;
@@ -58,16 +64,29 @@
                 this.ContainUseRSAC = result.ContainUseRSAC;
                 this.userID = result.userID;
                 this.profileId = result.profileId;
+                initUserName({
+                    userId: this.userID
+                }).then(result => {
+                    console.log(result);
+                    if (result != null) {
+                        this.userName = result[0].Name;
+                    }
+                })
+                initSelectProfile({
+                    profileId: this.profileId
+                }).then(result => {
+                    if (result != null) {
+                        this.profileName = result[0].Name;
 
-                this.myDate();
-                this.myReload();
-                this.dispatchEvent(new CloseActionScreenEvent());
+                        this.myDate();
+                        this.myReload();
+                    }
+                })
+
             }
         }).catch(error => {
             console.log(error);
-        }).finally(() => {
-
-        });
+        })
     }
 
     // 鏍规嵁鏃ユ湡鏋勫缓MessageGroupNumber
@@ -85,98 +104,91 @@
         selectRecords({
             recordId: this.Id
         }).then(result => {
-            console.log(result);
-            if (result.AsyncData__c == 'true' && result.ETQ_UPLOAD_STATUS__c != '3' || result.Complaint_Number__c != null) {
+            if (result[0].AsyncData__c == true && result[0].ETQ_UPLOAD_STATUS__c != '3' || result[0].Complaint_Number__c != null) {
                 var btns = document.getElementsByName("sendrepairstoetq");
                 for (var i = 0; i < btns.length; i++) {
                     btns[i].disabled = true;
                     btns[i].className = 'btnDisabled';
                 }
                 this.ShowToastEvent('璇ヤ慨鐞嗕箣鍓嶅凡缁忓彂閫佽繃浜�', "error");
-                // alert('璇ヤ慨鐞嗕箣鍓嶅凡缁忓彂閫佽繃浜�')
+                this.dispatchEvent(new CloseActionScreenEvent());
+                return;
             } else {
                 this.SendRepairsToEtQ();
             }
         }).catch(error => {
             console.log(error);
-        }).finally(() => {
-
-        });
+        })
     }
 
     // 鍙戦�丒TQ
     SendRepairsToEtQ() {
-        console.log(this.userID);
-        console.log(this.profileId);
-
-        var uid = this.userID;
-        if (this.profileId != "00e10000000xnoO" && this.profileId != "00e10000000hl7w" && this.profileId != '00e10000000Y3o5') {
+        if (this.profileName != "2F7_OSH鎷呭綋" && this.profileName != "2F7_OSH璐ㄩ噺娉曡" && this.profileName != '绯荤粺绠$悊鍛�') {
             this.ShowToastEvent("鎮ㄦ病鏈夊彂閫佷慨鐞嗗埌EtQ鐨勬潈闄愩��", "error");
-            // alert("鎮ㄦ病鏈夊彂閫佷慨鐞嗗埌EtQ鐨勬潈闄愩��");
+            this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
-        var statu = '';
         if (this.PAEDetermineC == undefined) {
             this.ShowToastEvent("OCSM QARA鐨凱AE鍒ゅ畾鏄┖鐨勬椂鍊欙紝涓嶅彲浠ュ彂閫佸埌EtQ銆�", "error");
-            // alert("OCSM QARA鐨凱AE鍒ゅ畾鏄┖鐨勬椂鍊欙紝涓嶅彲浠ュ彂閫佸埌EtQ銆�");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
+        }
+        if (this.PAEDetermineC == "nonPAE" && this.AEDetermineResultC == "nonAE" && this.PAEDetermineACC == "nonPAE" && this.userName != "闆� 鏂板缓") {
+            this.ShowToastEvent("Close Complait鐨勬椂鍊欙紝涓嶅彲浠ュ彂閫佸埌EtQ", "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
         if (this.ETQUPLOADSTATUSC == "3") {
-            if (!confirm("鏄惁娓呯┖EtQ鍚屾鐘舵�侊紝閲嶆柊鍚屾鏁版嵁锛�")) {
-                return;
-            }
+            this.handleConfirmClick("鏄惁娓呯┖EtQ鍚屾鐘舵�侊紝閲嶆柊鍚屾鏁版嵁锛�");
+        } else {
+            this.ll();
         }
-        if (this.PAEDetermineC == "nonPAE" && this.AEDetermineResultC == "nonAE" && this.PAEDetermineACC == "nonPAE" && uid != "005100000068zJ6") {
-            this.ShowToastEvent("Close Complait鐨勬椂鍊欙紝涓嶅彲浠ュ彂閫佸埌EtQ", "error");
-            // alert("Close Complait鐨勬椂鍊欙紝涓嶅彲浠ュ彂閫佸埌EtQ");
-            return;
-        }
+    }
+
+    ll() {
         if (this.PAEDetermineC != undefined && this.AEDetermineResultC != undefined && this.PAEDetermineACC == undefined) {
-            statu = "R1";
+            this.statu = "R1";
         } else if ((this.AEDetermineResultC != undefined && this.PAEDetermineC != undefined && this.PAEDetermineACC != undefined) &&
             !(this.PAEDetermineC == "nonPAE" && this.AEDetermineResultC == "nonAE" && this.PAEDetermineACC == "nonPAE")) {
-            statu = "R2";
-            if (this.RepairInspectionDateC == "") {
+            this.statu = "R2";
+            if (this.RepairInspectionDateC == undefined) {
                 this.ShowToastEvent("5.淇悊妫�娴嬫棩鏄┖鐨勬椂鍊欙紝涓嶅彲浠ュ彂閫佸埌EtQ銆�", "error");
-                // alert("5.淇悊妫�娴嬫棩鏄┖鐨勬椂鍊欙紝涓嶅彲浠ュ彂閫佸埌EtQ銆�");
+                this.dispatchEvent(new CloseActionScreenEvent());
                 return;
             }
             if (this.ContainUseRSAC == 1) {
                 this.ShowToastEvent("Final universal code涓虹┖锛屾垨鑰呭寘鍚玌seRSA锛岃纭銆�", "error");
-                // alert("Final universal code涓虹┖锛屾垨鑰呭寘鍚玌seRSA锛岃纭銆�");
+                this.dispatchEvent(new CloseActionScreenEvent());
                 return;
             }
         }
 
-        var result;
-        try {
-            var repairids = new Array()
-            repairids[0] = this.Id;
+        var repairids = new Array()
+        repairids[0] = this.Id;
 
-            var statuArr = new Array();
-            statuArr.push(statu);
+        var statuArr = new Array();
+        statuArr.push(this.statu);
 
-            sendToETQ({
-                iflog_Id: "",
-                rowDataSFDC: "",
-                repairIds: repairids,
-                statu: statuArr[0]
-            }).then(result => {
-                this.ShowToastEvent(result, "error");
-                // alert(result);
-            }).catch(error => {
-                console.log(error);
-            })
-
-            var btns = document.getElementsByName("sendrepairstoetq");
-            for (var i = 0; i < btns.length; i++) {
-                btns[i].disabled = true;
-                btns[i].className = 'btnDisabled';
+        sendToETQ({
+            iflog_Id: "",
+            rowDataSFDC: "",
+            repairIds: repairids,
+            statu: statuArr[0]
+        }).then(result => {
+            console.log("result:" + result);
+            if (result == "鍙戦�佹垚鍔�!") {
+                this.ShowToastEvent(result, "success");
+                this.dispatchEvent(new CloseActionScreenEvent());
+            } else {
+                this.ShowToastEvent("鍙戦�佷慨鐞嗗埌EtQ澶辫触," + result, "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
             }
-            location.reload();
-        } catch (error) {
-            this.ShowToastEvent("鍙戦�佷慨鐞嗗埌EtQ澶辫触" + error.faultstring + ' code:' + error.faultcode, "error");
-            // alert("鍙戦�佷慨鐞嗗埌EtQ澶辫触" + error.faultstring + ' code:' + error.faultcode);
+        })
+
+        var btns = document.getElementsByName("sendrepairstoetq");
+        for (var i = 0; i < btns.length; i++) {
+            btns[i].disabled = true;
+            btns[i].className = 'btnDisabled';
         }
     }
 
@@ -189,4 +201,19 @@
         });
         this.dispatchEvent(event);
     }
+
+    async handleConfirmClick(msg) {
+        const result = await LightningConfirm.open({
+            message: msg,
+            variant: 'headerless',
+            label: 'this is the aria-label value'
+        });
+
+        if (result) {
+            this.ll();
+        } else {
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.1