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/lexOCSMToReportRepair/lexOCSMToReportRepair.js |   55 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/force-app/main/default/lwc/lexOCSMToReportRepair/lexOCSMToReportRepair.js b/force-app/main/default/lwc/lexOCSMToReportRepair/lexOCSMToReportRepair.js
index 40ebdc3..5c44fe5 100644
--- a/force-app/main/default/lwc/lexOCSMToReportRepair/lexOCSMToReportRepair.js
+++ b/force-app/main/default/lwc/lexOCSMToReportRepair/lexOCSMToReportRepair.js
@@ -14,7 +14,7 @@
 import {
     ShowToastEvent
 } from 'lightning/platformShowToastEvent';
-
+import LightningConfirm from 'lightning/confirm';
 
 export default class LexOCSMToReportRepair extends LightningElement {
     @api recordId;
@@ -42,13 +42,11 @@
         }).then(result => {
             console.log(result);
             if (result != null) {
-                this.IsLoading = false;
                 this.Id = result.Id;
                 this.AwareDateC = result.AwareDateC;
                 this.OCSMAdministrativeReportStatusC = result.OCSMAdministrativeReportStatusC;
                 
                 this.OCSMToReport();
-                this.dispatchEvent(new CloseActionScreenEvent());
             }
         }).catch(error => {
             console.log(error);
@@ -59,25 +57,7 @@
 
     // OCSM瑕佹姤鍛�
     OCSMToReport() {
-        if (!confirm("鎶ュ憡鍚庢棤娉曟挙鍥烇紝鏄惁缁х画锛�")) {
-            return;
-        }
-        if (this.OCSMAdministrativeReportStatusC == undefined && this.AwareDateC != undefined) {
-            updateRepair({
-                recordId: this.Id
-            }).catch(error => {
-                if (error.body.pageErrors.length > 0) {
-                    // alert(messages.join("\n"));
-                    var errmsg = error.body.pageErrors[0].message.toString();
-                    this.ShowToastEvent(errmsg.join("\n"), "error")
-                    return;
-                }
-            })
-            window.location.reload();
-        } else {
-            this.ShowToastEvent("娌℃湁AwareDate鎴栧凡缁廜CSM琛屾斂鎶ュ憡锛岃纭銆�", "error")
-            return;
-        }
+        this.handleConfirmClick("鎶ュ憡鍚庢棤娉曟挙鍥烇紝鏄惁缁х画锛�");
     }
 
     // 寮圭獥
@@ -89,4 +69,35 @@
         });
         this.dispatchEvent(event);
     }
+
+    async handleConfirmClick(msg) {
+        const result = await LightningConfirm.open({
+            message: msg,
+            variant: 'headerless',
+            label: 'this is the aria-label value'
+        });
+        if(result){
+            if (this.OCSMAdministrativeReportStatusC == undefined && this.AwareDateC != undefined) {
+                updateRepair({
+                    recordId: this.Id
+                }).then(result => {
+                    console.log(result);
+                    if (result.length > 0) {
+                        var split = result.split(", ");
+                        this.ShowToastEvent(split[1], "error");
+                        this.dispatchEvent(new CloseActionScreenEvent());
+                        return;
+                    }
+                    location.reload();
+                })
+            } else {
+                this.ShowToastEvent("娌℃湁AwareDate鎴栧凡缁廜CSM琛屾斂鎶ュ憡锛岃纭銆�", "error");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                return;
+            }
+        }
+        else{
+            this.dispatchEvent(new CloseActionScreenEvent());
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1