From 81d625efb473471a649c0c0822cca3c818f34b8a Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期三, 29 三月 2023 11:34:41 +0800
Subject: [PATCH] 陈京武修改按钮(更新至2023.3.22)

---
 force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.css         |   10 +
 force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js-meta.xml         |   11 +
 force-app/main/default/classes/MonthlyReportController.cls-meta.xml            |    5 
 force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.html                |    5 
 force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js          |   89 ++++++++++++++
 force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.html        |    5 
 force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js-meta.xml |   11 +
 force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js                  |   70 +++++++++++
 force-app/main/default/classes/MonthlyReportController.cls                     |   94 +++++++++++++++
 force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.css                 |   10 +
 10 files changed, 310 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/MonthlyReportController.cls b/force-app/main/default/classes/MonthlyReportController.cls
new file mode 100644
index 0000000..a68b5da
--- /dev/null
+++ b/force-app/main/default/classes/MonthlyReportController.cls
@@ -0,0 +1,94 @@
+public with sharing class MonthlyReportController {
+    @AuraEnabled
+    public static InitData initForCancelSubmitButton (String recordId){
+        InitData res = new initData();
+        try{
+            Monthly_Report__c report = [SELECT 	OwnerId,Id,Next_week_plan__c FROM Monthly_Report__c WHERE Id = :recordId LIMIT 1];
+            res.OwnerId = report.OwnerId;
+            res.Id = report.Id;
+            res.nextWeekPlan = report.Next_week_plan__c;
+            System.debug(LoggingLevel.INFO, '*** res: ' + res);
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }
+
+
+    @AuraEnabled
+    public static InitData initForCreateNoteEmailButton (String recordId) {
+        InitData res = new initData();
+        try{
+            Monthly_Report__c report = [SELECT
+            Owner_email__c,
+            Owner_alias__c,
+            Key_issue__c,
+            Feedback__c,
+            Task_follow__c,
+            Other_issue__c,
+            Next_week_plan__c,
+            Dr_Sum_URL__c
+            FROM Monthly_Report__c WHERE Id = :recordId LIMIT 1];
+            String userName = UserInfo.getUserName();
+            User activeUser = [Select Email From User where Username = : userName limit 1];
+            String userEmail = activeUser.Email;
+            res.ownerEmail = report.Owner_email__c;
+            res.ownerAlias = report.Owner_alias__c;
+            res.keyIssue = report.Key_issue__c;
+            res.feedBack = report.Feedback__c;
+            res.taskFollow = report.Task_follow__c;
+            res.otherIssue = report.Other_issue__c;
+            res.nextWeekPlan = report.Next_week_plan__c;
+            res.drSumUrl = report.Dr_Sum_URL__c;
+            res.userEmail = activeUser.Email;
+            
+            System.debug(LoggingLevel.INFO, '*** res: ' + res);
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }
+
+    @AuraEnabled
+    public static void cancel(String recordId) {
+       try {
+        Monthly_Report__c report = [SELECT 	Id,Status__c,Submit_check_flag__c,RecordTypeId,Submit_time__c FROM Monthly_Report__c WHERE Id = :recordId LIMIT 1];
+        report.Status__c = '鑽夋涓�';
+        report.RecordTypeId = '01210000000Qggf';
+        report.Submit_check_flag__c = false;
+        report.Submit_time__c = null;
+        update report;
+       } catch (Exception e) {
+        System.debug(LoggingLevel.INFO, '*** e: ' + e);
+       } finally {
+
+       }
+
+    }
+
+
+    public class InitData{
+        @AuraEnabled
+        public String Id;
+        @AuraEnabled
+        public String OwnerId;
+        @AuraEnabled
+        public String ownerEmail;
+        @AuraEnabled
+        public String ownerAlias;
+        @AuraEnabled
+        public String keyIssue;
+        @AuraEnabled
+        public String feedBack;
+        @AuraEnabled
+        public String taskFollow;
+        @AuraEnabled
+        public String otherIssue;
+        @AuraEnabled
+        public String nextWeekPlan;
+        @AuraEnabled
+        public String drSumUrl;
+        @AuraEnabled
+        public String userEmail;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/MonthlyReportController.cls-meta.xml b/force-app/main/default/classes/MonthlyReportController.cls-meta.xml
new file mode 100644
index 0000000..fbbad0a
--- /dev/null
+++ b/force-app/main/default/classes/MonthlyReportController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>56.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.css b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.css
new file mode 100644
index 0000000..2cca6a5
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.css
@@ -0,0 +1,10 @@
+.cancelSubmitHolder{
+    position: relative;
+    display: inline-block;
+    width: 80px;
+    height: 80px;
+    text-align: center;
+}
+.container .uiContainerManager{
+	display: none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.html b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.html
new file mode 100644
index 0000000..02203b4
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="cancelSubmitHolder" if:true={IsLoading}>
+        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+    </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js
new file mode 100644
index 0000000..4826892
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js
@@ -0,0 +1,70 @@
+import { LightningElement,wire,track,api} from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { NavigationMixin } from 'lightning/navigation';
+import init  from '@salesforce/apex/MonthlyReportController.initForCancelSubmitButton';
+import cancel  from '@salesforce/apex/MonthlyReportController.cancel';
+import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
+import { updateRecord } from 'lightning/uiRecordApi';
+
+export default class LexCancelSubmit extends LightningElement {
+    @api recordId;//OwnerId
+    ownerId;
+    monthlyReportId;
+    IsLoading = true;
+
+    @wire(CurrentPageReference)
+     getStateParameters(currentPageReference) {
+             console.log(111);
+             console.log(currentPageReference);
+
+         if (currentPageReference) {
+           const urlValue = currentPageReference.state.recordId;
+           if (urlValue) {
+             let str = `${urlValue}`;
+             console.log("str");
+             console.log(str);
+             this.recordId = str;
+           }
+         }
+     }
+    
+    connectedCallback () {
+        console.log(this.recordId);
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            console.log(result);
+            if (result != null) {
+                this.IsLoading = false;
+                this.ownerId = result.ownerId;
+                this.monthlyReportId = result.Id;
+                this.cancelSubmit();
+                console.log("end");
+                this.dispatchEvent(new CloseActionScreenEvent());
+                this.updateRecordView(this.recordId);
+
+                //window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Monthly_Report__c/" + this.monthlyReportId + "/view");
+            }
+        }).catch(error => {
+            console.log("error");
+            console.log(error);
+        }).finally(() => {
+            
+        });   
+    }
+    updateRecordView(recordId) {
+        updateRecord({fields: { Id: recordId }});
+    }
+    cancelSubmit () {
+        //闇�瑕佸畬鍠�
+        if(this.ownerId == UserInfo_Owner.Id) {
+            cancel({
+                recordId: this.recordId
+            });
+            console.log("321");
+            } else {
+            alert("鍙懆鎶ョ殑鎵�鏈変汉鍙互鍙栨秷");
+            }
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js-meta.xml b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js-meta.xml
new file mode 100644
index 0000000..709c8f7
--- /dev/null
+++ b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+     <apiVersion>54.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+		<target>lightning__RecordPage</target>
+		<target>lightning__AppPage</target>
+		<target>lightning__HomePage</target>
+		<target>lightning__RecordAction</target>
+	</targets>
+</LightningComponentBundle>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.css b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.css
new file mode 100644
index 0000000..8d634cd
--- /dev/null
+++ b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.css
@@ -0,0 +1,10 @@
+.createEmailHolder{
+    position: relative;
+    display: inline-block;
+    width: 80px;
+    height: 80px;
+    text-align: center;
+}
+.container .uiContainerManager{
+	display: none !important;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.html b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.html
new file mode 100644
index 0000000..61d9b05
--- /dev/null
+++ b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="createEmailHolder" if:true={IsLoading}>
+        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+    </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js
new file mode 100644
index 0000000..0ede44e
--- /dev/null
+++ b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js
@@ -0,0 +1,89 @@
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { NavigationMixin } from 'lightning/navigation';
+import init  from '@salesforce/apex/MonthlyReportController.initForCreateNoteEmailButton';
+import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
+
+export default class LexCreateNotesEmail extends LightningElement {
+    @api recordId;
+    ownerEmail;
+    ownerAlias;
+    keyIssue;
+    feedBack;
+    taskFollow;
+    otherIssue;
+    nextWeekPlan;
+    drSumUrl;
+    IsLoading = true;
+    url;
+
+    @wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+            console.log(111);
+            console.log(currentPageReference);
+
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            console.log("str");
+            console.log(str);
+            this.recordId = str;
+          }
+        }
+    }
+
+
+    connectedCallback(){
+        console.log(this.recordId);
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            console.log(result);
+            if (result != null) {
+                this.IsLoading = false;
+                this.ownerEmail = result.ownerEmail;
+                this.ownerAlias = result.ownerAlias;
+                this.keyIssue = result.keyIssue;
+                this.feedBack = result.feedBack;
+                this.taskFollow = result.taskFollow;
+                this.otherIssue = result.otherIssue;
+                this.nextWeekPlan = result.nextWeekPlan;
+                this.drSumUrl = result.drSumUrl;
+                this.userEmail = result.userEmail;
+                this.createEmail();
+                this.dispatchEvent(new CloseActionScreenEvent());
+            }
+        }).catch(error => {
+            console.log("error");
+            console.log(error);
+        }).finally(() => {
+            
+        });
+    }
+    createEmail() {
+        console.log("start");
+    
+       window.location.href = ("mailto:" 
+        + this.ownerEmail
+        +"?bcc=" 
+        +   this.userEmail
+        +"&subject=銆愬懆鎶�:" 
+        + this.ownerAlias 
+        + "銆�" + "&body=鍏堢敓/濂冲+" + "%0D%0A" + "%0D%0A" + "涓昏鎶ュ憡浜嬮」锛�"
+        + this.keyIssue 
+        +"%0D%0A" + "涓嬪睘浜嬮」/鐘舵�佹姤鍛婏細"
+        + this.feedBack 
+        +"%0D%0A" + "璇鹃鍙婂搴旂粨鏋�/鎻愭锛�" 
+        +  this.taskFollow 
+        +"%0D%0A" + "鍏朵粬浜嬮」锛�" 
+        + this.otherIssue 
+        +"%0D%0A" + "涓嬪懆璁″垝锛�" 
+        + this.nextWeekPlan 
+        +"%0D%0A" + "杩炴帴锛�" 
+        + this.drSumUrl
+        +"%0D%0A").substring(0,320).split("<br>").join("%0D%0A");
+
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js-meta.xml b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js-meta.xml
new file mode 100644
index 0000000..329e839
--- /dev/null
+++ b/force-app/main/default/lwc/lexCreateNotesEmail/lexCreateNotesEmail.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>54.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+		<target>lightning__RecordPage</target>
+		<target>lightning__AppPage</target>
+		<target>lightning__HomePage</target>
+		<target>lightning__RecordAction</target>
+	</targets>
+</LightningComponentBundle>
\ No newline at end of file

--
Gitblit v1.9.1