From 50e96fd88845d033ab55eeb4034a17f74eee7b72 Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期四, 06 七月 2023 11:20:30 +0800
Subject: [PATCH] 主体备品选择

---
 force-app/main/default/lwc/lexSendNFM103/lexSendNFM103.js |  805 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 414 insertions(+), 391 deletions(-)

diff --git a/force-app/main/default/lwc/lexSendNFM103/lexSendNFM103.js b/force-app/main/default/lwc/lexSendNFM103/lexSendNFM103.js
index e6f21ea..66b40ba 100644
--- a/force-app/main/default/lwc/lexSendNFM103/lexSendNFM103.js
+++ b/force-app/main/default/lwc/lexSendNFM103/lexSendNFM103.js
@@ -1,5 +1,7 @@
 import getStaticResource from "@salesforce/apex/ButtonJsUtility.getStaticResource";
 import init from "@salesforce/apex/otherButtonRepairController.init";
+import initSelectProfile from '@salesforce/apex/otherButtonRepairController.initSelectProfile';
+import initUserName from '@salesforce/apex/otherButtonRepairController.initUserName';
 import queryForEquipments from "@salesforce/apex/otherButtonRepairController.queryForEquipments";
 import queryForFindInvalidLicense from "@salesforce/apex/otherButtonRepairController.queryForFindInvalidLicense";
 import queryForRds from "@salesforce/apex/otherButtonRepairController.queryForRds";
@@ -36,10 +38,11 @@
   api,
   wire
 } from "lwc";
+import LightningConfirm from 'lightning/confirm';
+
 
 export default class LexSendNFM103 extends LightningElement {
   @api recordId;
-  detailedAddress;
   dealer;
   numberofEffectiveContract;
   newProductGuaranteTxt;
@@ -75,10 +78,18 @@
   profileId;
   userId;
   AWSDataId;
+  userName;
+  profileName;
+  Id;
+  DetailedAddress;
+  surplusCount = 0;
+  url;
+  HPActiveC;
 
   @wire(CurrentPageReference)
   getStateParameters(currentPageReference) {
     if (currentPageReference) {
+      this.url = currentPageReference.state.backgroundContext;
       const urlValue = currentPageReference.state.recordId;
       if (urlValue) {
         let str = `${urlValue}`;
@@ -98,21 +109,22 @@
         btns[i].disabled = true;
         btns[i].className = 'btnDisabled';
       }
-
-      this.detailedAddress = result.detailedAddress;
-      this.dealer = result.dealer;
+      this.Id = result.Id;
+      this.HPActiveC = result.HPActiveC;
+      this.DetailedAddress = result.detailedAddress;
+      this.dealer = result.DealerC;
       this.numberofEffectiveContract = result.numberofEffectiveContract;
       this.newProductGuaranteTxt = result.newProductGuaranteTxt;
-      this.onSiteRepair = result.onSiteRepair;
+      this.onSiteRepair = result.OnSiteRepairC;
       this.maintenanceContract = result.maintenanceContract;
       this.VMMaintenanceContract = result.VMMaintenanceContract;
       this.FSEState = result.FSEState;
-      this.dateReceiptQuestions = result.dateReceiptQuestions;
-      this.delayReportReason = result.delayReportReason;
+      this.dateReceiptQuestions = result.DateReceiptQuestionsC;
+      this.delayReportReason = result.DelayReportReasonC;
       this.repairSource = result.repairSource;
       this.quickRepairSign = result.quickRepairSign;
       this.RCCD = result.RCCD;
-      this.returnsProductway = result.returnsProductway;
+      this.returnsProductway = result.ReturnsProductWayC;
       this.salesDeptHP = result.salesDeptHP;
       this.isAohuiProduct = result.isAohuiProduct;
       this.stateHospital = result.stateHospital;
@@ -123,7 +135,7 @@
       this.URFLimitSerial = result.URFLimitSerial;
       this.status = result.status;
       this.dealerId = result.dealerId;
-      this.ifDeadHurt = result.ifDeadHurt;
+      this.ifDeadHurt = result.ifDeadHurtC;
       this.dayLater30 = result.dayLater30;
       this.recallCorrespondence = result.recallCorrespondence;
       this.URFReapir = result.URFReapir;
@@ -131,296 +143,59 @@
       this.DWSign = result.DWSign;
       this.DOJStatus = result.DOJStatus;
       this.SAPcondition = result.SAPcondition;
-      this.salesOfficeCodeSelection = result.salesOfficeCodeSelection;
+      this.salesOfficeCodeSelection = result.SalesOfficeCodeSelectionC;
       this.profileId = result.profileId;
-      this.userId = result.userId;
+      this.userId = result.userID;
       this.AWSDataId = result.AWSDataId;
-      
-      this.logicalJudgmentA();
+
+      initUserName({
+        userId: this.userId
+      }).then(result => {
+        if (result != null) {
+          this.IsLoading = false;
+          this.userName = result[0].Name;
+        }
+      })
+
+      initSelectProfile({
+        profileId: this.profileId
+      }).then(result => {
+        if (result != null) {
+          this.IsLoading = false;
+          this.profileName = result[0].Name;
+
+          this.foo();
+        }
+      })
     }).catch(error => {
-      console.log("error");
       console.log(error);
     });
   }
 
-
-  showToast(msg, type) {
-    const event = new ShowToastEvent({
-      title: '',
-      message: msg,
-      variant: type
-    });
-    this.dispatchEvent(event);
-  }
-
-  updateRecordView(recordId) {
-    updateRecord({
-      fields: {
-        Id: recordId
-      }
-    });
-  }
-
-  logicalJudgmentA() {
-    try {
-      if (
-        this.numberofEffectiveContract == "鏃�" &&
-        this.newProductGuaranteTxt != "2: 澶氬勾淇濅慨" &&
-        this.newProductGuaranteTxt != "2: 鏈嶅姟澶氬勾淇濅慨" &&
-        this.newProductGuaranteTxt != "8: 甯傚満澶氬勾淇濅慨" &&
-        this.onSiteRepair == "鐩撮�丼ORC淇悊"
-      ) {
-        if (
-          !confirm("璁惧涓洪潪缁翠慨鍚堝悓涓旈潪澶氬勾淇濅慨瀵硅薄鍝侊紝璇风‘璁ゆ槸鍚︾洿閫丼ORC淇悊锛�")
-        ) {
-          this.updateRecordView(this.recordId);
-          this.dispatchEvent(new CloseActionScreenEvent());
-          return;
-        }
-      }
-      console.log("11");
-      if (
-        (this.maintenanceContract != undefined ||
-          this.VMMaintenanceContract != undefined) &&
-        this.onSiteRepair == "RC淇悊" &&
-        this.FSEState == "灞变笢鐪�"
-      ) {
-        if (
-          !confirm("璇ヨ澶囦负缁翠慨鍚堝悓鎴栧骞翠繚淇璞″搧锛岃纭鏄惁閫佽嚦RC淇悊锛�")
-        ) {
-          this.updateRecordView(this.recordId);
-          this.dispatchEvent(new CloseActionScreenEvent());
-          return;
-        }
-      }
-      var today = Date.now();
-      var dateReceiptQuestions = Date.parse(this.dateReceiptQuestions);
-      var dates = (today - dateReceiptQuestions) / (24 * 60 * 60 * 1000);
-      if (
-        this.profileId != "00e10000000Y3o5" &&
-        this.userId != "0051000000AKgzv" &&
-        this.userId != "0051000000AKh05" &&
-        this.userId != "00510000004q1ed" &&
-        this.delayReportReason == "" &&
-        dates > "1" &&
-        this.repairSource != "QIS杞慨鐞�"
-      ) {
-        this.showToast("鐢宠淇悊鏃禨AP淇悊鐢宠鏃ヨ秴杩囬棶棰樿仈缁滄敹鍒版棩1澶╋紝蹇呴』濉啓闂秴鏃舵姤鍛婄殑鐞嗙敱", "error");
-        this.updateRecordView(this.recordId);
-        this.dispatchEvent(new CloseActionScreenEvent());
-        return;
-      }
-      if (
-        this.quickRepairSign == true &&
-        (this.numberofEffectiveContract == "鏈�" ||
-          this.newProductGuaranteTxt == "2: 澶氬勾淇濅慨" ||
-          this.newProductGuaranteTxt == "2: 鏈嶅姟澶氬勾淇濅慨" ||
-          this.newProductGuaranteTxt == "8: 甯傚満澶氬勾淇濅慨") &&
-        (this.onSiteRepair == "RC淇悊" ||
-          this.onSiteRepair == "鍔炰簨澶勪慨鐞�" ||
-          this.onSiteRepair == "鐜板満淇悊")
-      ) {
-        if (this.RCCD == "2.涓滃寳" || this.RCCD == "3.瑗垮寳") {
-          if (
-            !confirm(
-              "璇ュ瀷鍙峰搴斾负鍚堝悓鎴栧骞翠繚瀵硅薄鍝併�傚纭涓哄ぇ淇悊鏁呴殰锛岄渶瑕侀�夋嫨鐩撮�丼ORC淇悊锛岃纭鏄惁缁х画銆�"
-            )
-          ) {
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-            return;
-          }
-        } else if (
-          this.RCCD == "1.鍗庡寳" ||
-          this.RCCD == "6.鍗庡崡" ||
-          this.RCCD == "4.瑗垮崡"
-        ) {
-          if (
-            !confirm(
-              "璇ュ瀷鍙峰搴斾负鍚堝悓鎴栧骞翠繚瀵硅薄鍝併�傚纭涓哄ぇ淇悊鏁呴殰锛岄渶瑕侀�夋嫨鐩撮�丱GZ淇悊锛岃纭鏄惁缁х画銆�"
-            )
-          ) {
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-            return;
-          }
-        }
-      }
-      var returnsProductWay = this.returnsProductway;
-      var falg = true;
-      if (returnsProductWay == undefined) {
-        if (!confirm("杩斿搧鏂瑰紡涓虹┖锛屾槸鍚︾户缁敵璇蜂慨鐞嗭紒")) {
-          this.updateRecordView(this.recordId);
-          this.dispatchEvent(new CloseActionScreenEvent());
-          return;
-        }
-      }
-      if (this.assetOwner == "Olympus") {} else {
-        console.log(this.detailedAddress);
-        if (this.detailedAddress != undefined) {
-          var prompt =
-            "褰撳墠鐩磋繑鏀惰揣鍦板潃涓猴細" + this.detailedAddress + ",鎮ㄧ‘璁や笉淇敼浜嗗悧锛�";
-          if (!confirm(prompt)) {
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-            return;
-          }
-        } else {
-          this.showToast("褰撳墠淇悊娌℃湁褰曞叆鐩磋繑鏀惰揣鐨勮缁嗗湴鍧�锛屼笉鑳界敵璇蜂慨鐞嗭紒", "error");
-          this.updateRecordView(this.recordId);
-          this.dispatchEvent(new CloseActionScreenEvent());
-          return;
-        }
-      }
-
-      queryForEquipments({
-        deliveredProductId: this.deliveredProductId,
-      }).then((result) => {
-        var equipments = result;
-        if (equipments != null && equipments.length > 0) {
-          var equipment = equipments[0];
-          if (equipment.Status == "寤冩") {
-            this.showToast("璁惧搴熷純锛屼笉鑳芥彁浜ょ敵璇�!", "error");
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-            return;
-          }
-        }
-      });
-      if (this.FSEApplyForRepairTime != undefined) {
-        this.showToast("宸蹭慨鐞嗙敵璇凤紝涓嶅啀淇悊鐢宠浜�", "error");
-        this.updateRecordView(this.recordId);
-        this.dispatchEvent(new CloseActionScreenEvent());
-        return;
-      }
-      var surplusCount = 0;
-      if (this.URFReapir == true) {
-        var urfAsset = null;
-
-        queryForUrfAsset({
-          maintenanceContractId: this.maintenanceContractId,
-          deliveredProductId: this.deliveredProductId,
-        }).then((result) => {
-          urfAsset = result;
-          var seriesMaxRepairCount = 0;
-          var seriesRepairCount = 0;
-          if (urfAsset != null && urfAsset.length > 0) {
-            seriesMaxRepairCount = urfAsset[0].Series_MaxRepairCount_F__c;
-            seriesRepairCount = urfAsset[0].Series_RepairCount_F__c;
-            surplusCount = seriesMaxRepairCount - seriesRepairCount;
-          }
-        });
-        var urfSeriesInfo = null;
-
-        queryForUrfSeriesInfo({
-          URFLimitSerial: this.URFLimitSerial,
-        }).then((result) => {
-          urfSeriesInfo = result;
-          var urfSeries = "";
-          if (urfSeriesInfo != null && urfSeriesInfo.length > 0) {
-            urfSeries = urfSeriesInfo[0].URFLimitSerial__c;
-          }
-          var repairCount = null;
-
-          queryForRepairCount({
-            maintenanceContractId: this.maintenanceContractId,
-            status1: "1.鍙楃悊瀹屾瘯",
-            URFLimitSerial: urfSeries,
-          }).then((result) => {
-            repairCount = result;
-          });
-          if (repairCount.length > 0 && surplusCount == 1) {
-            this.showToast("璇ヨ澶囧叧鑱旈檺娆″悎鍚岋紝鐩墠鍓╀綑娆℃暟灏忎簬閫佷慨璁惧銆傝绛夊緟杩涜涓慨鐞嗗畬鎴愬悗鍐嶈繘琛岀敵璇�", "error");
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-            return;
-          }
-        });
-      }
-      if (
-        this.status != "鑽夋涓�" &&
-        this.status != "1.鍙楃悊瀹屾瘯(SAP寰呭彂閫�)" &&
-        this.status != "4.淇悊鍝佽繑閫侀樁娈�"
-      ) {
-        this.showToast("涓嶆槸鑽夋涓笉鑳界敵璇�", "error");
-        this.updateRecordView(this.recordId);
-        this.dispatchEvent(new CloseActionScreenEvent());
-      } else {
-        if (this.dealer != undefined) {
-          var findInvalidLicense = null;
-
-          queryForFindInvalidLicense({
-            isValidity: false,
-            dealerId: this.dealerId,
-          }).then((result) => {
-            findInvalidLicense = result;
-            if (findInvalidLicense.size > 0) {
-              this.showToast("缁忛攢鍟嗕笁璇佷笉鍦ㄦ湁鏁堟湡锛屾棤娉曢�佷慨", "error");
-              this.updateRecordView(this.recordId);
-              this.dispatchEvent(new CloseActionScreenEvent());
-              return;
-            }
-          });
-        }
-        if (this.ifDeadHurt == "鏈�") {
-          if (!confirm("鏄惁纭AE瑕佹彁浜わ紵")) {
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-            return;
-          }
-        }
-        if (this.dayLater30 == "鏄�") {
-          this.showToast("鍒涘缓鍚庤秴杩�30澶╋紝涓嶈兘鐢宠浜�", "error");
-          this.updateRecordView(this.recordId);
-          this.dispatchEvent(new CloseActionScreenEvent());
-          return;
-        }
-        var prompt11 = "鍚堝悓鍐呭ぇ淇鏁板凡鐢ㄥ畬锛屽綋鍓嶄慨鐞嗕负鍚堝悓澶栫殑淇悊锛屾槸鍚︾户缁紵";
-        if (this.URFReapir == true && surplusCount == 0) {
-          var resultTmp = null;
-          if (!confirm(prompt11)) {
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-            return;
-          }
-
-          updateForRepair1({
-            recordId: this.recordId,
-          }).then((result) => {
-            resultTmp = result;
-            console.log("1111");
-            var messagesTmp = "";
-            if (resultTmp) {
-              messagesTmp = this.getConnectDMLErrorMessages(resultTmp);
-            }
-            if (messagesTmp.length > 0) {
-              this.showToast(messagesTmp.join("\n"), "error");
-              this.updateRecordView(this.recordId);
-              this.dispatchEvent(new CloseActionScreenEvent());
-              return;
-            }
-          });
-        }
-        var records = null;
-
-        queryForReocrds({
-          inchargeStaffId: this.inchargeStaffId,
-        }).then((result) => {
-          records = result;
-          console.log(result);
-          this.logicalJudgmentB(records);
-        });
-      }
-    } catch (error) {
-      console(error);
+  foo() {
+    if (this.HPActiveC == '鐒″姽') {
+      this.ShowToastEvent("鏈尰闄㈠凡鏃犳晥锛屾棤娉曡繘琛岀敵璇枫��", "error");
+      this.dispatchEvent(new CloseActionScreenEvent());
+      return;
     }
-    var staticResource = null;
 
+    queryForrecords3({
+      dealer: this.dealer
+    }).then(result => {
+      if (result.length > 0 && result[0].FirstParagraph__c == true) {
+        this.handleConfirmClick01("璇ョ粡閿�鍟嗕负鍏堟瀵硅薄锛屾槸鍚︾户缁敵璇蜂慨鐞嗭紵");
+      } else {
+        this.ll01();
+      }
+    });
+
+    var staticResource;
     getStaticResource({
       sobj: "Repair__c"
     }).then(result => {
       console.log(result);
       staticResource = JSON.parse(result);
+
       Promise.all([
         loadScript(this, AWSService + '/AWSService.js'),
         loadScript(this, jqueryurl),
@@ -434,137 +209,385 @@
           function (data) {
             console.log(data);
             if (data && data.object) {
-              var DetailedAddress = data.object.detailedAddress;
+              this.DetailedAddress = data.object.detailedAddress;
             }
             this.foo();
           },
-          staticResource.token).then(result => {
-          this.updateRecordView(this.recordId);
-          this.dispatchEvent(new CloseActionScreenEvent());
-        });
-      }).catch(error => {
-        console.log('Failed to load the JQuery : ' + error);
+          staticResource.token);
       });
-    }).catch(error => {
-      console.log('Failed to load the JQuery : ' + error);
-    });
-    console.log('load correctly');
+    })
   }
 
-  foo() {
-    console.log("end");
-    var records3 = null;
-
-    queryForrecords3({
-      recordId: this.recordId,
-    }).then((result) => {
-      records3 = result;
-    });
-    var FirstParagraph__c = "";
-    if (records3.length >= 1) {
-      FirstParagraph__c = records3[0].FirstParagraph__c;
+  ll01() {
+    console.log(1);
+    if (this.numberofEffectiveContract == "鏃�" && this.newProductGuaranteTxt != "2: 澶氬勾淇濅慨" &&
+      this.newProductGuaranteTxt != "2: 鏈嶅姟澶氬勾淇濅慨" && this.newProductGuaranteTxt != "8: 甯傚満澶氬勾淇濅慨" &&
+      this.onSiteRepair == "鐩撮�丼ORC淇悊") {
+      this.handleConfirmClick02("璁惧涓洪潪缁翠慨鍚堝悓涓旈潪澶氬勾淇濅慨瀵硅薄鍝侊紝璇风‘璁ゆ槸鍚︾洿閫丼ORC淇悊锛�");
+    } else {
+      this.ll02();
     }
-    if (FirstParagraph__c == "true") {
-      if (!confirm("璇ョ粡閿�鍟嗕负鍏堟瀵硅薄锛屾槸鍚︾户缁敵璇蜂慨鐞嗭紵")) {
-        this.updateRecordView(this.recordId);
+  }
+
+  ll02() {
+    console.log(2);
+    if ((this.maintenanceContract != undefined || this.VMMaintenanceContract != undefined) &&
+      this.onSiteRepair == "RC淇悊" && this.FSEState == "灞变笢鐪�"
+    ) {
+      this.handleConfirmClick03("璇ヨ澶囦负缁翠慨鍚堝悓鎴栧骞翠繚淇璞″搧锛岃纭鏄惁閫佽嚦RC淇悊锛�");
+    } else {
+      this.ll03();
+    }
+  }
+
+  ll03() {
+    console.log(3);
+    var today = Date.now();
+    var dateReceiptQuestions = Date.parse(this.dateReceiptQuestions);
+    var dates = (today - dateReceiptQuestions) / (24 * 60 * 60 * 1000);
+    if (this.profileName != "绯荤粺绠$悊鍛�" && this.userName != "鑳� 鐜夋垚" && this.userName != "鏉� 鐞竻" &&
+      this.userName != "閮� 娲�" &&
+      this.delayReportReason == undefined && dates > "1" &&
+      this.repairSource != "QIS杞慨鐞�") {
+      this.ShowToastEvent("鐢宠淇悊鏃禨AP淇悊鐢宠鏃ヨ秴杩囬棶棰樿仈缁滄敹鍒版棩1澶╋紝蹇呴』濉啓闂秴鏃舵姤鍛婄殑鐞嗙敱", "error");
+      this.dispatchEvent(new CloseActionScreenEvent());
+      return;
+    }
+    if (this.quickRepairSign == true && (this.numberofEffectiveContract == "鏈�" || this.newProductGuaranteTxt == "2: 澶氬勾淇濅慨" ||
+        this.newProductGuaranteTxt == "2: 鏈嶅姟澶氬勾淇濅慨" || this.newProductGuaranteTxt == "8: 甯傚満澶氬勾淇濅慨") &&
+      (this.onSiteRepair == "RC淇悊" || this.onSiteRepair == "鍔炰簨澶勪慨鐞�" || this.onSiteRepair == "鐜板満淇悊")) {
+      if (this.RCCD == "2.涓滃寳" || this.RCCD == "3.瑗垮寳") {
+        this.handleConfirmClick04("璇ュ瀷鍙峰搴斾负鍚堝悓鎴栧骞翠繚瀵硅薄鍝併�傚纭涓哄ぇ淇悊鏁呴殰锛岄渶瑕侀�夋嫨鐩撮�丼ORC淇悊锛岃纭鏄惁缁х画銆�");
+      } else if (this.RCCD == "1.鍗庡寳" || this.RCCD == "6.鍗庡崡" || this.RCCD == "4.瑗垮崡") {
+        this.handleConfirmClick04("璇ュ瀷鍙峰搴斾负鍚堝悓鎴栧骞翠繚瀵硅薄鍝併�傚纭涓哄ぇ淇悊鏁呴殰锛岄渶瑕侀�夋嫨鐩撮�丱GZ淇悊锛岃纭鏄惁缁х画銆�");
+      } else {
+        if (this.returnsProductway == undefined) {
+          this.handleConfirmClick06("杩斿搧鏂瑰紡涓虹┖锛屾槸鍚︾户缁敵璇蜂慨鐞嗭紒");
+        } else {
+          this.ll06();
+        }
+      }
+    } else {
+      if (this.returnsProductway == undefined) {
+        this.handleConfirmClick06("杩斿搧鏂瑰紡涓虹┖锛屾槸鍚︾户缁敵璇蜂慨鐞嗭紒");
+      } else {
+        this.ll06();
+      }
+    }
+  }
+
+  ll06() {
+    console.log(6);
+    if (this.assetOwner != "Olympus") {
+      if (this.DetailedAddress != undefined) {
+        this.handleConfirmClick07('褰撳墠鐩磋繑鏀惰揣鍦板潃涓猴細' + this.DetailedAddress + ',鎮ㄧ‘璁や笉淇敼浜嗗悧锛�');
+      } else {
+        this.ShowToastEvent('褰撳墠淇悊娌℃湁褰曞叆鐩磋繑鏀惰揣鐨勮缁嗗湴鍧�锛屼笉鑳界敵璇蜂慨鐞嗭紒', "error");
         this.dispatchEvent(new CloseActionScreenEvent());
         return;
       }
+    } else {
+      this.ll07();
     }
-    console.log("endend");
   }
 
-  logicalJudgmentB(records) {
-    if (records != null && records.length > 0) {
-      var staff = records[0];
-      var res = null;
-      updateRepair2({
-        recordId: this.recordId,
-        staff: staff,
-        DWSign: this.DWSign,
-        statusc: "1.鍙楃悊瀹屾瘯",
-        DOJStatus: this.DOJStatus,
-        SAPcondition: this.SAPcondition,
-      }).then((result) => {
-        console.log(result + "result");
-        res = result;
-        console.log("start3");
-        var messages = "";
-        if (res) {
-          messages = this.getConnectDMLErrorMessages(res);
-        }
-        if (messages.length > 0) {
-          this.showToast(messages.join("\n"), "error");
-          this.updateRecordView(this.recordId);
+  ll07() {
+    console.log(7);
+    queryForEquipments({
+      deliveredProductId: this.deliveredProductId,
+    }).then(equipments => {
+      if (equipments != null && equipments.length > 0) {
+        var equipment = equipments[0];
+        if (equipment.Status == "寤冩") {
+          this.ShowToastEvent("璁惧搴熷純锛屼笉鑳芥彁浜ょ敵璇�!", "error");
           this.dispatchEvent(new CloseActionScreenEvent());
-        } else {
-          if (this.salesOfficeCodeSelection == "鎴愰兘RC") {
-
-            this.showToast("鐜伴樁娈碉紝鎴愰兘RC浠呭彈鐞嗗洓宸濓紙瑗胯棌锛夊唴闀溿�佽タ鍗楀叏鍩烠V/CLV锛屽叾浣欏疄鐗╄鍙戣嚦骞垮窞RC銆�", "error");
-            this.updateRecordView(this.recordId);
-            this.dispatchEvent(new CloseActionScreenEvent());
-          }
+          return;
         }
-        var rds = null;
-        
-        queryForRds({
-          recordId: this.recordId,
-        }).then((result) => {
-          rds = result;
-          if (rds != null && rds.length > 0) {
-            var repairAft = rds[0];
-            if (
-              repairAft.NewProductGuarante_Formula__c !=
-              repairAft.ProductGuarante_Create__c
-            ) {
-              this.showToast("璇ヨ澶囦繚淇俊鎭凡鍙戠敓鍙樺寲锛岃浜嗚В", "error");
-            }
+      }
+    });
+    console.log(701);
+    if (this.FSEApplyForRepairTime != undefined) {
+      this.ShowToastEvent("宸蹭慨鐞嗙敵璇凤紝涓嶅啀淇悊鐢宠浜�", "error");
+      this.dispatchEvent(new CloseActionScreenEvent());
+      return;
+    }
+    console.log(702);
+    if (this.URFReapir == false) {
+      queryForUrfAsset({
+        maintenanceContractId: this.maintenanceContractId,
+        deliveredProductId: this.deliveredProductId,
+      }).then(urfAsset => {
+        var seriesMaxRepairCount = 0;
+        var seriesRepairCount = 0;
+        if (urfAsset != null && urfAsset.length > 0) {
+          seriesMaxRepairCount = urfAsset[0].Series_MaxRepairCount_F__c;
+          seriesRepairCount = urfAsset[0].Series_RepairCount_F__c;
+          this.surplusCount = seriesMaxRepairCount - seriesRepairCount;
+        }
+      });
+      console.log(703);
+
+      queryForUrfSeriesInfo({
+        URFLimitSerial: this.URFLimitSerial,
+      }).then(urfSeriesInfo => {
+        var urfSeries = "";
+        if (urfSeriesInfo != null && urfSeriesInfo.length > 0) {
+          urfSeries = urfSeriesInfo[0].URFLimitSerial__c;
+        }
+        console.log(704);
+
+        queryForRepairCount({
+          maintenanceContractId: this.maintenanceContractId,
+          status1: "1.鍙楃悊瀹屾瘯",
+          URFLimitSerial: urfSeries,
+        }).then(repairCount => {
+          if (repairCount.length > 0 && this.surplusCount == 1) {
+            this.ShowToastEvent("璇ヨ澶囧叧鑱旈檺娆″悎鍚岋紝鐩墠鍓╀綑娆℃暟灏忎簬閫佷慨璁惧銆傝绛夊緟杩涜涓慨鐞嗗畬鎴愬悗鍐嶈繘琛岀敵璇�", "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
           }
         });
       });
+    }
+    console.log(705);
 
+    if (this.status != "鑽夋涓�" && this.status != "1.鍙楃悊瀹屾瘯(SAP寰呭彂閫�)" && this.status != "4.淇悊鍝佽繑閫侀樁娈�") {
+      this.ShowToastEvent("涓嶆槸鑽夋涓笉鑳界敵璇�", "error");
+      this.dispatchEvent(new CloseActionScreenEvent());
+      return;
     } else {
-      this.showToast("娌℃湁鎵惧埌 淇悊濮旀墭鑰�", "error");
-      this.updateRecordView(this.recordId);
+      if (this.dealer != undefined) {
+        queryForFindInvalidLicense({
+          dealerId: this.dealerId,
+        }).then(findInvalidLicense => {
+          console.log(findInvalidLicense);
+          if (findInvalidLicense.length > 0) {
+            this.ShowToastEvent("缁忛攢鍟嗕笁璇佷笉鍦ㄦ湁鏁堟湡锛屾棤娉曢�佷慨", "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
+          }
+        });
+      }
+    }
+    if (this.ifDeadHurt == "鏈�") {
+      this.handleConfirmClick08("鏄惁纭AE瑕佹彁浜わ紵");
+    } else {
+      this.ll08();
+    }
+  }
+
+  ll08() {
+    console.log(8);
+    if (this.dayLater30 == "鏄�") {
+      this.ShowToastEvent("鍒涘缓鍚庤秴杩�30澶╋紝涓嶈兘鐢宠浜�", "error");
+      this.dispatchEvent(new CloseActionScreenEvent());
+      return;
+    }
+    if (this.URFReapir == true && this.surplusCount == 0) {
+      this.handleConfirmClick09("鍚堝悓鍐呭ぇ淇鏁板凡鐢ㄥ畬锛屽綋鍓嶄慨鐞嗕负鍚堝悓澶栫殑淇悊锛屾槸鍚︾户缁紵");
+    } else {
+      this.ll09();
+    }
+  }
+
+  ll09() {
+    console.log(9);
+    updateForRepair1({
+      recordId: this.Id
+    }).then(result => {
+      if (result != null && result.length > 0) {
+        var split = result.split(", ");
+        this.ShowToastEvent(split[1], "error");
+        this.dispatchEvent(new CloseActionScreenEvent());
+        return;
+      } else {
+        console.log(901);
+        queryForReocrds({
+          inchargeStaffId: this.inchargeStaffId,
+        }).then(records => {
+          if (records != null && records.length > 0) {
+            var staff = records[0];
+            console.log(staff);
+            console.log(902);
+            updateRepair2({
+              recordId: this.Id,
+              staff: staff,
+              DWSign: this.DWSign,
+              statusc: "1.鍙楃悊瀹屾瘯",
+              DOJStatus: this.DOJStatus,
+              SAPcondition: this.SAPcondition,
+            }).then(result => {
+              console.log(result);
+              console.log(903);
+              if (result != null && result.length > 0) {
+                var split = result.split(", ");
+                this.ShowToastEvent(split[1], "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                return;
+              } else {
+                if (this.salesOfficeCodeSelection == "鎴愰兘RC") {
+                  this.ShowToastEvent("鐜伴樁娈碉紝鎴愰兘RC浠呭彈鐞嗗洓宸濓紙瑗胯棌锛夊唴闀溿�佽タ鍗楀叏鍩烠V/CLV锛屽叾浣欏疄鐗╄鍙戣嚦骞垮窞RC銆�", "error");
+                  this.dispatchEvent(new CloseActionScreenEvent());
+                  return;
+                }
+              }
+              console.log(904);
+              queryForRds({
+                recordId: this.Id,
+              }).then(rds => {
+                console.log(rds);
+                if (rds != null && rds.length > 0) {
+                  var repairAft = rds[0];
+                  if (repairAft.NewProductGuarante_Formula__c != repairAft.ProductGuarante_Create__c) {
+                    this.ShowToastEvent("璇ヨ澶囦繚淇俊鎭凡鍙戠敓鍙樺寲锛岃浜嗚В", "error");
+                    this.dispatchEvent(new CloseActionScreenEvent());
+                    return;
+                  }
+                }
+              });
+              window.open(this.url, "_self");
+            });
+          } else {
+            this.ShowToastEvent("娌℃湁鎵惧埌 淇悊濮旀墭鑰�", "error");
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
+          }
+        });
+      }
+    });
+  }
+
+  ShowToastEvent(msg, type) {
+    const event = new ShowToastEvent({
+      title: '',
+      message: msg,
+      variant: type
+    });
+    this.dispatchEvent(event);
+  }
+
+  async handleConfirmClick01(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      this.ll01();
+    } else {
       this.dispatchEvent(new CloseActionScreenEvent());
     }
   }
 
-  getConnectDMLErrorMessages(results) {
-    console.log(results);
-    var messages = [],
-      i = 0,
-      len = results.length,
-      r;
-    console.log("sos");
-    for (; i < len; i++) {
-      r = results[i];
-      if (!r.getBoolean("success")) {
-        messages = messages.concat(getConnectDMLMessagesOfAResult(r));
-      }
-    }
-    return messages;
-  }
-
-  getConnectDMLMessagesOfAResult(res) {
-    var messages = [],
-      errors = res.getArray("errors"),
-      i = 0,
-      len = errors.length,
-      e;
-    for (; i < len; i++) {
-      e = errors[i];
-      messages.push(e.message + " " + getConnectDMLErrorFields(e));
-    }
-    return messages;
-  }
-
-  getConnectDMLErrorFields(error) {
-    var fields = error.getArray("fields");
-    if (fields.length > 0) {
-      return "[" + fields.join(",") + "]";
+  async handleConfirmClick02(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      this.ll02();
     } else {
-      return "";
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+  }
+
+  async handleConfirmClick03(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      this.ll03();
+    } else {
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+  }
+
+  async handleConfirmClick04(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      if (this.returnsProductway == undefined) {
+        this.handleConfirmClick06("杩斿搧鏂瑰紡涓虹┖锛屾槸鍚︾户缁敵璇蜂慨鐞嗭紒");
+      } else {
+        this.ll06();
+      }
+    } else {
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+  }
+
+  async handleConfirmClick05(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      if (this.returnsProductway == undefined) {
+        this.handleConfirmClick06("杩斿搧鏂瑰紡涓虹┖锛屾槸鍚︾户缁敵璇蜂慨鐞嗭紒");
+      } else {
+        this.ll06();
+      }
+    } else {
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+  }
+
+  async handleConfirmClick06(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      this.ll06();
+    } else {
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+  }
+
+  async handleConfirmClick07(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      this.ll07();
+    } else {
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+  }
+
+  async handleConfirmClick08(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      this.ll08();
+    } else {
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+  }
+
+  async handleConfirmClick09(msg) {
+    const result = await LightningConfirm.open({
+      message: msg,
+      variant: 'headerless',
+      label: 'this is the aria-label value'
+    });
+    if (result) {
+      this.ll09();
+    } else {
+      this.dispatchEvent(new CloseActionScreenEvent());
     }
   }
 }
\ No newline at end of file

--
Gitblit v1.9.1