From 87861ae5f1ed5456685f97f8a8e7625e47b9576d Mon Sep 17 00:00:00 2001
From: KKbes <1620284052@qq.com>
Date: 星期四, 13 四月 2023 11:12:26 +0800
Subject: [PATCH] Merge branch 'LEX_dev' of http://47.92.229.245:8089/r/lightningupdate into LEX_dev
---
force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 155 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js b/force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js
new file mode 100644
index 0000000..5bd9188
--- /dev/null
+++ b/force-app/main/default/lwc/lexUploadToSap/lexUploadToSap.js
@@ -0,0 +1,155 @@
+import {
+ LightningElement,
+ wire,
+ api
+} from 'lwc';
+import {
+ CurrentPageReference
+} from "lightning/navigation";
+import {
+ CloseActionScreenEvent
+} from 'lightning/actions';
+import init from '@salesforce/apex/otherButtonMaintenanceContractCtl.init';
+import updateColunm from '@salesforce/apex/MaintenanceContractSetColunmWebService.updateColunm';
+import updateFirstContract from '@salesforce/apex/updateFirstServiceContractWebService.updateFirstContract';
+import Check_plan from '@salesforce/apex/MaintenanceContractWebService.Check_plan';
+import up2sap from '@salesforce/apex/MaintenanceContractWebService.up2sap';
+import {
+ ShowToastEvent
+} from 'lightning/platformShowToastEvent';
+
+export default class LexUploadToSap extends LightningElement {
+ @api recordId;
+ str;
+ IsLoading = true;
+ MCApprovalStatusC;
+ MaintenanceContractNoC;
+ uploadToSapTimeC;
+ oldIsRecognitionModelC;
+ uploadToRMTimeC;
+ IsRecognitionModelTrueC;
+ Id;
+ URFContractFC;
+ urfFlag;
+ rtn1;
+ rtn;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ this.recordId = str;
+ }
+ }
+ }
+
+ connectedCallback() {
+ console.log(this.recordId);
+ init({
+ recordId: this.recordId
+ }).then(result => {
+ console.log(result);
+ if (result != null) {
+ this.IsLoading = false;
+ this.MCApprovalStatusC = result.MCApprovalStatusC;
+ this.MaintenanceContractNoC = result.MaintenanceContractNoC;
+ this.uploadToSapTimeC = result.uploadToSapTimeC;
+ this.oldIsRecognitionModelC = result.oldIsRecognitionModelC;
+ this.uploadToRMTimeC = result.uploadToRMTimeC;
+ this.IsRecognitionModelTrueC = result.IsRecognitionModelTrueC;
+ this.Id = result.Id;
+ this.URFContractFC = result.URFContractFC;
+
+ this.uploadToSap();
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ }).catch(error => {
+ console.log(error);
+ }).finally(() => {
+
+ });
+ }
+
+ // 涓婁紶SAP
+ uploadToSap() {
+ if (this.MCApprovalStatusC != 'Pass') {
+ this.ShowToastEvent("鍚堝悓澶嶆牳鎵瑰噯鍚庢墠鍙互涓婁紶SAP銆�", "error")
+ // alert("鍚堝悓澶嶆牳鎵瑰噯鍚庢墠鍙互涓婁紶SAP銆�");
+ } else if (this.MaintenanceContractNoC == undefined) {
+ this.ShowToastEvent('缁翠慨鍚堝悓绠$悊缂栫爜涓虹┖锛屼笉鑳戒笂浼燬AP銆�', "error")
+ // alert('缁翠慨鍚堝悓绠$悊缂栫爜涓虹┖锛屼笉鑳戒笂浼燬AP銆�');
+ } else if (this.uploadToSapTimeC != undefined) {
+ this.ShowToastEvent('宸茬粡涓婁紶SAP锛屼笉鑳介噸澶嶄笂浼犮��', "error")
+ // alert('宸茬粡涓婁紶SAP锛屼笉鑳介噸澶嶄笂浼犮��');
+ } else {
+ if (this.oldIsRecognitionModelC) {
+ if (this.uploadToRMTimeC == undefined) {
+ this.ShowToastEvent('褰撳墠缁翠慨鍚堝悓鐨勭粡閿�鍟嗘槸鍏堟瀵硅薄锛岄渶瑕佸厛銆愪笂浼犺娆惧悎鍚屻�戯紝鐒跺悗瀹屾垚璁ゆ浠ュ悗鎵嶈兘涓婁紶SAP銆�', "error")
+ // alert('褰撳墠缁翠慨鍚堝悓鐨勭粡閿�鍟嗘槸鍏堟瀵硅薄锛岄渶瑕佸厛銆愪笂浼犺娆惧悎鍚屻�戯紝鐒跺悗瀹屾垚璁ゆ浠ュ悗鎵嶈兘涓婁紶SAP銆�');
+ return;
+ } else {
+ if (!this.IsRecognitionModelTrueC) {
+ this.ShowToastEvent('褰撳墠缁翠慨鍚堝悓娌℃湁瀹屾垚璁ゆ锛屼笉鑳戒笂浼燬AP銆�', "error")
+ // alert('褰撳墠缁翠慨鍚堝悓娌℃湁瀹屾垚璁ゆ锛屼笉鑳戒笂浼燬AP銆�');
+ return;
+ }
+ }
+ }
+ updateColunm({
+ mcid: this.Id
+ }).then(result => {
+ if (result != '1') {
+ this.ShowToastEvent('涓婁紶SAP澶辫触,鍥犱负 鏉ュ勾鍚堝悓鐩稿叧淇℃伅淇敼澶辫触', "error")
+ // alert('涓婁紶SAP澶辫触,鍥犱负 鏉ュ勾鍚堝悓鐩稿叧淇℃伅淇敼澶辫触');
+ }
+ });
+ updateFirstContract({
+ mcid: this.Id
+ }).then(result => {
+ if (result != '1') {
+ this.ShowToastEvent(result, "error")
+ // alert(result);
+ }
+ });
+ this.urfFlag = this.URFContractFC;
+ this.rtn1 = '1';
+ this.rtn = '1';
+ if (this.urfFlag == 'false') {
+ Check_plan({
+ mcidList: this.Id
+ }).then(result => {
+ this.rtn1 = result;
+ });
+ }
+ if (this.rtn1 == '1') {
+ up2sap({
+ mcid: this.Id
+ }).then(result => {
+ this.rtn = result;
+ });
+ if (this.rtn == '1') {
+ this.ShowToastEvent("涓婁紶SAP鎴愬姛", "success")
+ // alert("涓婁紶SAP鎴愬姛");
+ window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Maintenance_Contract__c/" + this.recordId + "/view");
+ } else {
+ this.ShowToastEvent(this.rtn, "error")
+ // alert(this.rtn);
+ }
+ } else {
+ this.ShowToastEvent(this.rtn1, "error")
+ // alert(this.rtn1);
+ }
+ }
+ }
+
+ // 寮圭獥
+ ShowToastEvent(msg, type) {
+ const event = new ShowToastEvent({
+ title: '',
+ message: msg,
+ variant: type
+ });
+ this.dispatchEvent(event);
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1