From 84e0a7994d22fa5be5e5f8ae91ca4990ef495afd Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期五, 24 五月 2024 16:49:53 +0800
Subject: [PATCH] 1

---
 force-app/main/default/lwc/lexSubmitSolutionSchemeForApproval/lexSubmitSolutionSchemeForApproval.js |   77 +++++++++++++++++++++++++-------------
 1 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/force-app/main/default/lwc/lexSubmitSolutionSchemeForApproval/lexSubmitSolutionSchemeForApproval.js b/force-app/main/default/lwc/lexSubmitSolutionSchemeForApproval/lexSubmitSolutionSchemeForApproval.js
index 479b649..d1fcae7 100644
--- a/force-app/main/default/lwc/lexSubmitSolutionSchemeForApproval/lexSubmitSolutionSchemeForApproval.js
+++ b/force-app/main/default/lwc/lexSubmitSolutionSchemeForApproval/lexSubmitSolutionSchemeForApproval.js
@@ -1,21 +1,15 @@
-/*
- * @Description: 
- * @version: 
- * @Author: chen jing wu
- * @Date: 2023-06-21 09:17:25
- * @LastEditors: chen jing wu
- * @LastEditTime: 2023-07-07 16:35:41
- */
 import { api, wire,LightningElement } from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
 import { CloseActionScreenEvent } from 'lightning/actions';
 import updateSubmitSolutionSchemeForApprovalButton  from '@salesforce/apex/lexSolutionProgrammeController.updateSubmitSolutionSchemeForApprovalButton';
+import submitApproval  from '@salesforce/apex/lexSolutionProgrammeController.submitApproval';
 import init  from '@salesforce/apex/lexSolutionProgrammeController.initSubmitSolutionSchemeForApprovalButton';
 import queryForAttachments  from '@salesforce/apex/lexSolutionProgrammeController.queryForAttachments';
 import { updateRecord } from 'lightning/uiRecordApi';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 import LightningConfirm from 'lightning/confirm';
-
+import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
+import {loadStyle} from 'lightning/platformResourceLoader';
 export default class LexSubmitSolutionSchemeForApproval extends LightningElement {
     @api recordId;
     schemeType;
@@ -36,26 +30,21 @@
           }
         }
     }
-    showToast(msg,type) {
-        const event = new ShowToastEvent({
-            title: '',
-            message: msg,
-            variant: type
-        });
-        this.dispatchEvent(event);
-    }
-
 
     updateRecordView(recordId) {
         updateRecord({fields: { Id: recordId }});
     }
 
     connectedCallback(){
+        Promise.all([
+            loadStyle(this, lwcCSS)
+           ]);
         init({
             recordId: this.recordId
         }).then(result=>{
-            this.schemeType = result.schemeType == undefined ? result.schemeType : '';
-            this.confirmationResult = result.confirmationResult == undefined ? result.confirmationResult : '';
+            console.log(result);
+            this.schemeType = result.schemeType;
+            this.confirmationResult = result.confirmationResult == undefined ?  '' : result.confirmationResult;
             this.submitSolutionSchemeForApproval();
         });
     }
@@ -76,21 +65,38 @@
         });
         console.log(result);
         if(result){
-            if(this.schemeType == '缁撴' && this.confirmationResult == ''){
+            console.log(this.schemeType);
+            console.log(this.confirmationResult);
+            if(this.schemeType == '缁撴' && (this.confirmationResult == '' || this.confirmationResult == undefined)){
                 this.showToast('缁撴鏂规鎻愪氦鍓嶏紝鏂规閲囩撼缁撴灉蹇呭~','error');
                 this.dispatchEvent(new CloseActionScreenEvent());
                 return;
             }
+            console.log('this.schemeType:'+this.schemeType);
             if((this.records.length > 0 && this.schemeType == '缁撴') || (this.schemeType == '鍒濇')){
+                // submitApproval({recordId:this.recordId}).then(rep => {
+                //     console.log(rep);
+                //     if(rep==='OK'){
+                //         console.log('1');
+                //         this.showToast('鎻愪氦瀹℃壒鎴愬姛','success');
+                //     }else{
+                //         console.log('2');
+                //         this.showToast(rep,'error');
+                //     }
+                // }).catch(err => {
+                //     console.log('3');
+                //     console.log(err);
+                //     this.showToast(err,'error');
+                // })
                 updateSubmitSolutionSchemeForApprovalButton({
                     recordId: this.recordId
-                }).then(result=>{
-                    if(result){
-                        this.showToast(result,'error');
+                }).then(res=>{
+                    if(res){
+                        this.showToast(res,'error');
+                        this.dispatchEvent(new CloseActionScreenEvent());
                     }else{
-                        this.updateRecordView(this.recordId);
+                        window.location.href = '/lightning/r/Solution_Programme__c/'+this.recordId+'/view'; 
                     }
-                    this.dispatchEvent(new CloseActionScreenEvent());
                 });
             }else{
                 this.showToast('缁撴鐨勬柟妗堟彁浜ゅ墠锛屽繀椤讳笂浼犵粨妗堥檮浠�','error');
@@ -103,4 +109,23 @@
             return;
         }
     }
+    showToast(msg, type) {
+        if(type == 'success'){
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type,
+            });
+            this.dispatchEvent(event);
+            window.location.href = '/lightning/r/Solution_Programme__c/'+this.recordId+'/view';
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }else{
+            const event = new ShowToastEvent({
+                message: msg,
+                variant: type,
+                mode: 'sticky'
+            });
+            this.dispatchEvent(event);
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }  
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1