twysparks
2023-05-17 ba4651fb1416e263325b457c896dbbd83debe663
申请修理
1个文件已删除
6个文件已修改
879 ■■■■■ 已修改文件
force-app/main/default/classes/buttonQISReportCtl.cls 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/otherButtonRepairController.cls 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexRentalApplyDiscountApproval/lexRentalApplyDiscountApproval.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendNFM103/lexSendNFM103.js 692 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendQISToEtQ/lexSendQISToEtQ.js 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendRepairsToEtQ/__tests__/lexSendRepairsToEtQ.test.js 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexSendRepairsToEtQ/lexSendRepairsToEtQ.js 77 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/buttonQISReportCtl.cls
@@ -171,6 +171,18 @@
            return res;
        }
         // 查找简档
     @AuraEnabled
     public static List<Profile> initSelectProfile(String profileId){
         List<Profile> res = new List<Profile>();
         try{
             res = [SELECT Id,name FROM Profile WHERE Id=: profileId ];
         }catch(Exception e){
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
         }
         return res;
     }
     public class InitData{
        @AuraEnabled
        public String isAEProfileC;
force-app/main/default/classes/otherButtonRepairController.cls
@@ -309,7 +309,7 @@
    //通过Is_Validity__c和Id字段查询Account的记录并返回
    @AuraEnabled
    public static List<Account> queryForFindInvalidLicense(Boolean isValidity,String dealerId){
    public static List<Account> queryForFindInvalidLicense(String dealerId){
        try {
            List<Account> accounts = [select Id,Is_Validity__c from Account where Is_Validity__c = false And Id = :dealerId];
            return accounts;
@@ -342,10 +342,9 @@
    //通过Id查询Repair__c中的Dealer__c,再根据Dealer__c查询Account中的记录并返回
    @AuraEnabled
    public static List<Account> queryForrecords3(String recordId){
    public static List<Account> queryForrecords3(String dealer){
        try {
            Repair__c repair = [select Repair__c.Dealer__c from Repair__c where Id =:recordId];
           List<Account> accounts = [select id, FirstParagraph__c from Account where name =:repair.Dealer__c];
           List<Account> accounts = [SELECT id, FirstParagraph__c from Account where name =:dealer];
           return accounts;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
@@ -355,6 +354,7 @@
    //更新Repair__c中的记录,将Maintenance_Contract__c和MaintenanceContractType__c字段更新为空,若捕获到异常则返回错误信息
    @AuraEnabled
    public static String updateForRepair1(String recordId){
        String res='';
        try {
            Repair__c repair = new Repair__c();
            repair.ID = recordId;
@@ -363,11 +363,9 @@
            update repair;
            return null;
        } catch (Exception e) {
            String eMessage = e.getMessage();
            Integer left = eMessage.indexOf(',') + 1;
            Integer right = eMessage.length();
            return eMessage.substring(left,right);
            res = e.getMessage();
        }
        return res;
    }
    //更新Repair__c中的记录,若捕获到异常则返回错误信息
@@ -408,6 +406,30 @@
        }
    }
     // 查找简档
     @AuraEnabled
     public static List<Profile> initSelectProfile(String profileId){
         List<Profile> res = new List<Profile>();
         try{
             res = [SELECT Id,name FROM Profile WHERE Id=: profileId ];
         }catch(Exception e){
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
         }
         return res;
     }
      // 查找UserName
      @AuraEnabled
      public static List<User> initUserName(String userId){
          List<User> res = new List<User>();
          try{
              res = [SELECT Id,name FROM User WHERE Id=: userId ];
          }catch(Exception e){
              System.debug(LoggingLevel.INFO, '*** e: ' + e);
          }
          return res;
      }
    public class InitData{
        @AuraEnabled
        public String detailedAddress;
force-app/main/default/lwc/lexRentalApplyDiscountApproval/lexRentalApplyDiscountApproval.js
@@ -72,10 +72,10 @@
    RentalApplyDiscountApproval() {
        var power = this.profileName;
        // if (power != '2B2_备品中心检测&仓库管理') {
        //     this.ShowToastEvent("对不起,您没有权限提交此申请!", "error");
        //     return;
        // }
        if (power != '2B2_备品中心检测&仓库管理') {
            this.ShowToastEvent("对不起,您没有权限提交此申请!", "error");
            return;
        }
        var status = this.RentalApplyDiscountStatusC;
        if (status == '审批中') {
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";
@@ -75,6 +77,8 @@
  profileId;
  userId;
  AWSDataId;
  userName;
  profileName;
  @wire(CurrentPageReference)
  getStateParameters(currentPageReference) {
@@ -100,19 +104,19 @@
      }
      this.detailedAddress = result.detailedAddress;
      this.dealer = result.dealer;
      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 +127,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;
@@ -133,438 +137,274 @@
      this.SAPcondition = result.SAPcondition;
      this.salesOfficeCodeSelection = result.salesOfficeCodeSelection;
      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();
        }
      })
      this.dispatchEvent(new CloseActionScreenEvent());
    }).catch(error => {
      console.log("error");
      console.log(error);
    });
  }
  foo() {
    queryForrecords3({
      dealer: this.dealer
    }).then(result => {
      // if (result.length > 0 && result[0].FirstParagraph__c == true) {
      //   if (!confirm("该经销商为先款对象,是否继续申请修理?")) {
      //     return;
      //   }
      // }
  showToast(msg, type) {
      // if (
      //   this.numberofEffectiveContract == "无" && this.newProductGuaranteTxt != "2: 多年保修" &&
      //   this.newProductGuaranteTxt != "2: 服务多年保修" && this.newProductGuaranteTxt != "8: 市场多年保修" &&
      //   this.onSiteRepair == "直送SORC修理"
      // ) {
      //   if (!confirm("设备为非维修合同且非多年保修对象品,请确认是否直送SORC修理?")) {
      //     return;
      //   }
      // }
      // if ((this.maintenanceContract != undefined || this.VMMaintenanceContract != undefined) &&
      //   this.onSiteRepair == "RC修理" && this.FSEState == "山东省"
      // ) {
      //   if (!confirm("该设备为维修合同或多年保修对象品,请确认是否送至RC修理?")) {
      //     return;
      //   }
      // }
      // 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转修理") {
      //   alert("申请修理时SAP修理申请日超过问题联络收到日1天,必须填写问超时报告的理由");
      //   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("该型号对应为合同或多年保对象品。如确认为大修理故障,需要选择直送SORC修理,请确认是否继续。")) {
      //       return;
      //     }
      //   } else if (this.RCCD == "1.华北" || this.RCCD == "6.华南" || this.RCCD == "4.西南") {
      //     if (!confirm("该型号对应为合同或多年保对象品。如确认为大修理故障,需要选择直送OGZ修理,请确认是否继续。")) {
      //       return;
      //     }
      //   }
      // }
      // var returnsProductWay = this.returnsProductway;
      // if (returnsProductWay == undefined) {
      //   if (!confirm("返品方式为空,是否继续申请修理!")) {
      //     return;
      //   }
      // }
      var DetailedAddress = this.detailedAddress;
      // if (this.assetOwner != "Olympus") {
      //   if (DetailedAddress != undefined) {
      //     var prompt = '当前直返收货地址为:' + DetailedAddress + ',您确认不修改了吗?';
      //     if (!confirm(prompt)) {
      //       return;
      //     }
      //   } else {
      //     alert('当前修理没有录入直返收货的详细地址,不能申请修理!');
      //     return;
      //   }
      // }
      // queryForEquipments({
      //   deliveredProductId: this.deliveredProductId,
      // }).then(equipments => {
      //   if (equipments != null && equipments.length > 0) {
      //     var equipment = equipments[0];
      //     if (equipment.Status == "廃棄") {
      //       alert("设备废弃,不能提交申请!");
      //       return;
      //     }
      //   }
      // });
      // if (this.FSEApplyForRepairTime != undefined) {
      //   alert("已修理申请,不再修理申请了");
      //   return;
      // }
      var surplusCount = 0;
      // 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;
      //       surplusCount = seriesMaxRepairCount - seriesRepairCount;
      //     }
      //   });
      //   queryForUrfSeriesInfo({
      //     URFLimitSerial: this.URFLimitSerial,
      //   }).then(urfSeriesInfo => {
      //     var urfSeries = "";
      //     if (urfSeriesInfo != null && urfSeriesInfo.length > 0) {
      //       urfSeries = urfSeriesInfo[0].URFLimitSerial__c;
      //     }
      //     queryForRepairCount({
      //       maintenanceContractId: this.maintenanceContractId,
      //       status1: "1.受理完毕",
      //       URFLimitSerial: urfSeries,
      //     }).then(repairCount => {
      //       if (repairCount.length > 0 && surplusCount == 1) {
      //         alert("该设备关联限次合同,目前剩余次数小于送修设备。请等待进行中修理完成后再进行申请");
      //         return;
      //       }
      //     });
      //   });
      // }
      // if (this.status != "草案中" && this.status != "1.受理完毕(SAP待发送)" && this.status != "4.修理品返送阶段") {
      //   alert("不是草案中不能申请");
      // } else {
      //   if (this.dealer != undefined) {
      //     queryForFindInvalidLicense({
      //       dealerId: this.dealerId,
      //     }).then(findInvalidLicense => {
      //       console.log(findInvalidLicense);
      //       if (findInvalidLicense.length > 0) {
      //         alert("经销商三证不在有效期,无法送修");
      //         return;
      //       }
      //     });
      //   }
      // }
      // if (this.ifDeadHurt == "有") {
      //   if (!confirm("是否确认AE要提交?")) {
      //     return;
      //   }
      // }
      // if (this.dayLater30 == "是") {
      //   alert("创建后超过30天,不能申请了");
      //   return;
      // }
      // var prompt11 = "合同内大修次数已用完,当前修理为合同外的修理,是否继续?";
      // if (this.URFReapir == false && surplusCount == 0) {
      //   if (!confirm(prompt11)) {
      //     return;
      //   }
      // }
      updateForRepair1({
        recordId: this.Id,
      }).then(result => {
        if (result.length > 0) {
          var split = result.split(", ");
          alert(split[1]);
          return;
        }
        queryForReocrds({
          inchargeStaffId: this.inchargeStaffId,
        }).then(records => {
          if (records != null && records.length > 0) {
            var staff = records[0];
            updateRepair2({
              recordId: this.Id,
              staff: staff,
              DWSign: this.DWSign,
              statusc: "1.受理完毕",
              DOJStatus: this.DOJStatus,
              SAPcondition: this.SAPcondition,
            }).then(result => {
              if (result.length > 0) {
                var split = result.split(", ");
                alert(split[1]);
              } else {
                if (this.salesOfficeCodeSelection == "成都RC") {
                  alert("现阶段,成都RC仅受理四川(西藏)内镜、西南全域CV/CLV,其余实物请发至广州RC。");
                }
              }
              queryForRds({
                recordId: this.Id,
              }).then(rds => {
                if (rds != null && rds.length > 0) {
                  var repairAft = rds[0];
                  if (
                    repairAft.NewProductGuarante_Formula__c != repairAft.ProductGuarante_Create__c
                  ) {
                    alert("该设备保修信息已发生变化,请了解");
                  }
                }
              });
            });
          } else {
            alert("没有找到 修理委托者");
          }
        });
      });
    });
    // var staticResource;
    // getStaticResource({
    //   sobj: "Repair__c"
    // }).then(result => {
    //   console.log(result);
    //   staticResource = JSON.parse(result);
    //   window.AWSService.query(staticResource.queryUrl,
    //     this.AWSDataId,
    //     function (data) {
    //       console.log(data);
    //       if (data && data.object) {
    //         DetailedAddress = data.object.detailedAddress;
    //       }
    //       this.foo();
    //     },
    //     staticResource.token)
    // })
  }
  ShowToastEvent(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 == "直送SORC修理"
      ) {
        if (
          !confirm("设备为非维修合同且非多年保修对象品,请确认是否直送SORC修理?")
        ) {
          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("申请修理时SAP修理申请日超过问题联络收到日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(
              "该型号对应为合同或多年保对象品。如确认为大修理故障,需要选择直送SORC修理,请确认是否继续。"
            )
          ) {
            this.updateRecordView(this.recordId);
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
          }
        } else if (
          this.RCCD == "1.华北" ||
          this.RCCD == "6.华南" ||
          this.RCCD == "4.西南"
        ) {
          if (
            !confirm(
              "该型号对应为合同或多年保对象品。如确认为大修理故障,需要选择直送OGZ修理,请确认是否继续。"
            )
          ) {
            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);
    }
    var staticResource = null;
    getStaticResource({
      sobj: "Repair__c"
    }).then(result => {
      console.log(result);
      staticResource = JSON.parse(result);
      Promise.all([
        loadScript(this, AWSService + '/AWSService.js'),
        loadScript(this, jqueryurl),
        loadScript(this, jq + "/dist/jquery.js"),
        loadScript(this, con),
        loadScript(this, apex),
        loadScript(this, common)
      ]).then(() => {
        window.AWSService.query(staticResource.queryUrl,
          this.AWSDataId,
          function (data) {
            console.log(data);
            if (data && data.object) {
              var 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);
      });
    }).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;
    }
    if (FirstParagraph__c == "true") {
      if (!confirm("该经销商为先款对象,是否继续申请修理?")) {
        this.updateRecordView(this.recordId);
        this.dispatchEvent(new CloseActionScreenEvent());
        return;
      }
    }
    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);
          this.dispatchEvent(new CloseActionScreenEvent());
        } else {
          if (this.salesOfficeCodeSelection == "成都RC") {
            this.showToast("现阶段,成都RC仅受理四川(西藏)内镜、西南全域CV/CLV,其余实物请发至广州RC。", "error");
            this.updateRecordView(this.recordId);
            this.dispatchEvent(new CloseActionScreenEvent());
          }
        }
        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");
            }
          }
        });
      });
    } else {
      this.showToast("没有找到 修理委托者", "error");
      this.updateRecordView(this.recordId);
      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(",") + "]";
    } else {
      return "";
    }
  }
}
force-app/main/default/lwc/lexSendQISToEtQ/lexSendQISToEtQ.js
@@ -13,7 +13,7 @@
import sendToETQ from '@salesforce/apex/buttonQISReportCtl.sendToETQ';
import updateQISReportC from '@salesforce/apex/buttonQISReportCtl.updateQISReportC';
import selectQISReportC from '@salesforce/apex/buttonQISReportCtl.selectQISReportC';
import initSelectProfile from '@salesforce/apex/otherButtonRepairController.initSelectProfile';
import {
    ShowToastEvent
} from 'lightning/platformShowToastEvent';
@@ -31,6 +31,7 @@
    QISFinalJudgementC;
    ETQUPLOADSTATUSC;
    AEDetermineResultC;
    profileName;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
@@ -60,8 +61,17 @@
                this.ETQUPLOADSTATUSC = result.ETQUPLOADSTATUSC;
                this.AEDetermineResultC = result.AEDetermineResultC;
                this.myDate();
                this.myReload();
                initSelectProfile({
                    profileId: this.profileId
                }).then(result => {
                    if (result != null) {
                        this.IsLoading = false;
                        this.profileName = result[0].Name;
                        this.myDate();
                        this.myReload();
                    }
                })
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
@@ -79,24 +89,22 @@
    // 发送QIS到EtQ    
    SendQISToEtQ() {
        console.log(this.profileName);
        var QId = this.Id;
        var uid = this.userId;
        if (this.profileId != "00e10000000xnoO" && this.profileId != "00e10000000hl7w") {
        if (this.profileName != "2F7_OSH担当" && this.profileName != "2F7_OSH质量法规") {
            alert("您没有发送QIS到EtQ的权限。");
            return;
        }
        if (this.PAEDetermineC == undefined) {
            alert("OCSM QARA的PAE判定是空的时候,不可以发送到EtQ。");
            return;
        }
        if (this.AEDetermineResultC == "nonAE" && this.PAEDetermineC == "nonPAE" && this.PAEDetermineACC == "nonPAE" && this.OCMJudgementC == undefined && this.QISFinalJudgementC == undefined) {
            alert("nonAE并nonPAE的QIS同步到EtQ的时候,检测结论(OCSM)是必填的。不可以发送到EtQ。");
            return;
        }
        if (this.ETQUPLOADSTATUSC == "3") {
            if (!confirm("是否清空EtQ同步状态,重新同步数据?")) {
                return;
@@ -158,7 +166,8 @@
        selectQISReportC({
            QId: this.Id
        }).then(record => {
            if (record.AsyncData__c == 'true' && record.ETQ_UPLOAD_STATUS__c != '3' || record.Complaint_Number__c != null) {
        console.log(record);
            if (record[0].AsyncData__c == 'true' && record[0].ETQ_UPLOAD_STATUS__c != '3' || record[0].Complaint_Number__c != null) {
                var btns = document.getElementsByName("sendqistoetq");
                for (var i = 0; i < btns.length; i++) {
                    btns[i].disabled = true;
@@ -166,7 +175,7 @@
                }
                alert('该QIS之前已经发送过了')
            } else {
                SendQISToEtQ();
                this.SendQISToEtQ();
            }
        })
    }
force-app/main/default/lwc/lexSendRepairsToEtQ/__tests__/lexSendRepairsToEtQ.test.js
File was deleted
force-app/main/default/lwc/lexSendRepairsToEtQ/lexSendRepairsToEtQ.js
@@ -12,6 +12,8 @@
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';
@@ -29,6 +31,8 @@
    ContainUseRSAC;
    userID;
    profileId;
    profileName;
    userName;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
@@ -58,16 +62,32 @@
                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.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.myDate();
                this.myReload();
                        this.myDate();
                        this.myReload();
                    }
                })
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
        }).finally(() => {
        });
        })
    }
    // 根据日期构建MessageGroupNumber
@@ -85,40 +105,30 @@
        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('该修理之前已经发送过了')
                alert('该修理之前已经发送过了');
            } else {
                this.SendRepairsToEtQ();
            }
        }).catch(error => {
            console.log(error);
        }).finally(() => {
        });
        })
    }
    // 发送ETQ
    SendRepairsToEtQ() {
        console.log(this.userID);
        console.log(this.profileId);
        var uid = this.userID;
        if (this.profileId != "00e10000000xnoO" && this.profileId != "00e10000000hl7w" && this.profileId != '00e10000000Y3o5') {
            this.ShowToastEvent("您没有发送修理到EtQ的权限。", "error");
            // alert("您没有发送修理到EtQ的权限。");
        if (this.profileName != "2F7_OSH担当" && this.profileName != "2F7_OSH质量法规" && this.profileName != '系统管理员') {
            alert("您没有发送修理到EtQ的权限。");
            return;
        }
        var statu = '';
        if (this.PAEDetermineC == undefined) {
            this.ShowToastEvent("OCSM QARA的PAE判定是空的时候,不可以发送到EtQ。", "error");
            // alert("OCSM QARA的PAE判定是空的时候,不可以发送到EtQ。");
            alert("OCSM QARA的PAE判定是空的时候,不可以发送到EtQ。");
            return;
        }
        if (this.ETQUPLOADSTATUSC == "3") {
@@ -126,9 +136,8 @@
                return;
            }
        }
        if (this.PAEDetermineC == "nonPAE" && this.AEDetermineResultC == "nonAE" && this.PAEDetermineACC == "nonPAE" && uid != "005100000068zJ6") {
            this.ShowToastEvent("Close Complait的时候,不可以发送到EtQ", "error");
            // alert("Close Complait的时候,不可以发送到EtQ");
        if (this.PAEDetermineC == "nonPAE" && this.AEDetermineResultC == "nonAE" && this.PAEDetermineACC == "nonPAE" && this.userName != "雷 新建") {
            alert("Close Complait的时候,不可以发送到EtQ");
            return;
        }
        if (this.PAEDetermineC != undefined && this.AEDetermineResultC != undefined && this.PAEDetermineACC == undefined) {
@@ -136,19 +145,15 @@
        } 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.ShowToastEvent("5.修理检测日是空的时候,不可以发送到EtQ。", "error");
                // alert("5.修理检测日是空的时候,不可以发送到EtQ。");
            if (this.RepairInspectionDateC == undefined) {
                alert("5.修理检测日是空的时候,不可以发送到EtQ。");
                return;
            }
            if (this.ContainUseRSAC == 1) {
                this.ShowToastEvent("Final universal code为空,或者包含UseRSA,请确认。", "error");
                // alert("Final universal code为空,或者包含UseRSA,请确认。");
                alert("Final universal code为空,或者包含UseRSA,请确认。");
                return;
            }
        }
        var result;
        try {
            var repairids = new Array()
            repairids[0] = this.Id;
@@ -162,10 +167,8 @@
                repairIds: repairids,
                statu: statuArr[0]
            }).then(result => {
                this.ShowToastEvent(result, "error");
                // alert(result);
            }).catch(error => {
                console.log(error);
                alert(result);
                location.reload();
            })
            var btns = document.getElementsByName("sendrepairstoetq");
@@ -173,10 +176,8 @@
                btns[i].disabled = true;
                btns[i].className = 'btnDisabled';
            }
            location.reload();
        } catch (error) {
            this.ShowToastEvent("发送修理到EtQ失败" + error.faultstring + ' code:' + error.faultcode, "error");
            // alert("发送修理到EtQ失败" + error.faultstring + ' code:' + error.faultcode);
            alert("发送修理到EtQ失败" + error.faultstring + ' code:' + error.faultcode);
        }
    }