From 9dca2b56fba9e2e3a0346235229e06d9e25fe5fe Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期二, 20 六月 2023 17:58:16 +0800
Subject: [PATCH] 修改页面以及按钮

---
 force-app/main/default/lwc/lexSubmitSolutionForApproval/__tests__/lexSubmitSolutionForApproval.test.js |   25 +++
 force-app/main/default/pages/ImprovedForecastTime.page                                                 |    2 
 force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js-meta.xml                       |   11 +
 force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js-meta.xml       |   11 +
 force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js                |  148 +++++++++++++++++++++
 force-app/main/default/classes/lexSolutionProjectRequirementsController.cls-meta.xml                   |    5 
 force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.html              |    5 
 force-app/main/default/classes/lexSolutionProjectRequirementsController.cls                            |   72 ++++++++++
 force-app/main/default/classes/lexAgencyHospitalController.cls                                         |   17 ++
 force-app/main/default/classes/lexAgencyHospitalController.cls-meta.xml                                |    5 
 force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.html                              |    5 
 force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js                                |   59 ++++++++
 force-app/main/default/lwc/lexNewAgencyHospital/__tests__/lexNewAgencyHospital.test.js                 |   25 +++
 13 files changed, 389 insertions(+), 1 deletions(-)

diff --git a/force-app/main/default/classes/lexAgencyHospitalController.cls b/force-app/main/default/classes/lexAgencyHospitalController.cls
new file mode 100644
index 0000000..c879ca5
--- /dev/null
+++ b/force-app/main/default/classes/lexAgencyHospitalController.cls
@@ -0,0 +1,17 @@
+public with sharing class lexAgencyHospitalController {
+    @AuraEnabled
+    public static InitData queryForAgencyHospitalRecordType(String recordId){
+        InitData res = new InitData();
+        try {
+            RecordType recordType = [
+                select Id from RecordType where DeveloperName = 'AHospital' and SobjectType = 'Agency_Hospital_Link__c'
+            ];
+            
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+    }
+    class InitData{
+
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexAgencyHospitalController.cls-meta.xml b/force-app/main/default/classes/lexAgencyHospitalController.cls-meta.xml
new file mode 100644
index 0000000..45cccbd
--- /dev/null
+++ b/force-app/main/default/classes/lexAgencyHospitalController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>57.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexSolutionProjectRequirementsController.cls b/force-app/main/default/classes/lexSolutionProjectRequirementsController.cls
new file mode 100644
index 0000000..21c4b70
--- /dev/null
+++ b/force-app/main/default/classes/lexSolutionProjectRequirementsController.cls
@@ -0,0 +1,72 @@
+public with sharing class lexSolutionProjectRequirementsController {
+    @AuraEnabled
+    public static InitData initSubmitSolutionForApprovalButton(String recordId){
+        InitData res = new InitData();
+        try {
+            SolutionProjectRequirements__c so = [
+                select
+                Status__c,
+                Submit_Date_YouWant__c,
+                CreatedDate,
+                Department_Class__r.Id,
+                Product_Leader__c
+                from SolutionProjectRequirements__c where Id =: recordId
+            ];
+            res.status = so.Status__c;
+            res.submitDateYouWant = so.Submit_Date_YouWant__c;
+            res.createdDate = so.CreatedDate;
+            res.departmentClassId = so.Department_Class__r.Id;
+            res.productLeader = so.Product_Leader__c;
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return res;
+    }
+
+    @AuraEnabled
+    public static string updateSubmitSolutionForApprovalButton(String recordId){
+        SolutionProjectRequirements__c so = new SolutionProjectRequirements__c();
+        try {
+            so.Id = recordId;
+            so.Submint_TF__c = true;
+            so.Submitter__c = UserInfo.getUserId();
+            update so;
+            return '';
+        } catch (Exception e) {
+            return e.getMessage();
+        }
+    }
+
+    @AuraEnabled
+    public static List<Account> queryForAttachments(String Id){
+        List<Account> accList = null;
+        try {
+            accList = [
+                select id,
+                Department_Class__r.OwnerId,
+                Department_Class__r.Owner.SalesManager__c 
+                from Account where id =: Id
+            ];
+            
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return accList;
+    }
+    class InitData{
+        @AuraEnabled
+        public String status;
+        @AuraEnabled
+        public Date submitDateYouWant;
+        @AuraEnabled
+        public Datetime createdDate;
+        @AuraEnabled
+        public String departmentClassId;
+        @AuraEnabled
+        public String userId;
+        @AuraEnabled
+        public String userName;
+        @AuraEnabled
+        public String productLeader;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexSolutionProjectRequirementsController.cls-meta.xml b/force-app/main/default/classes/lexSolutionProjectRequirementsController.cls-meta.xml
new file mode 100644
index 0000000..45cccbd
--- /dev/null
+++ b/force-app/main/default/classes/lexSolutionProjectRequirementsController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>57.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNewAgencyHospital/__tests__/lexNewAgencyHospital.test.js b/force-app/main/default/lwc/lexNewAgencyHospital/__tests__/lexNewAgencyHospital.test.js
new file mode 100644
index 0000000..422765a
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewAgencyHospital/__tests__/lexNewAgencyHospital.test.js
@@ -0,0 +1,25 @@
+import { createElement } from 'lwc';
+import LexNewAgencyHospital from 'c/lexNewAgencyHospital';
+
+describe('c-lex-new-agency-hospital', () => {
+    afterEach(() => {
+        // The jsdom instance is shared across test cases in a single file so reset the DOM
+        while (document.body.firstChild) {
+            document.body.removeChild(document.body.firstChild);
+        }
+    });
+
+    it('TODO: test case generated by CLI command, please fill in test logic', () => {
+        // Arrange
+        const element = createElement('c-lex-new-agency-hospital', {
+            is: LexNewAgencyHospital
+        });
+
+        // Act
+        document.body.appendChild(element);
+
+        // Assert
+        // const div = element.shadowRoot.querySelector('div');
+        expect(1).toBe(1);
+    });
+});
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.html b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.html
new file mode 100644
index 0000000..d044dbb
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="exampleHolder" 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/lexNewAgencyHospital/lexNewAgencyHospital.js b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js
new file mode 100644
index 0000000..b0deed5
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js
@@ -0,0 +1,59 @@
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { NavigationMixin } from 'lightning/navigation';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+
+export default class LexNewAgencyHospital extends LightningElement {
+    @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;
+          }
+        }
+    }
+    updateRecordView(recordId) {
+        updateRecord({fields: { Id: recordId }});
+    }
+
+    showToast(msg,type) {
+        const event = new ShowToastEvent({
+            title: '',
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+    }
+
+    connectedCallback(){
+        var doubleFlg = false;
+        if(!doubleFlg) {
+        doubleFlg = true;
+        const defaultValues = encodeDefaultFieldValues({
+            Agency__c: this.recordId,
+            Name: '*'
+        });
+        this[NavigationMixin.Navigate]({
+            type: 'standard__objectPage',
+            attributes: {
+                objectApiName: 'Agency_Hospital_Link__c',
+                actionName: 'new'
+            },
+            state: {
+                nooverride: '1',
+                defaultFieldValues: defaultValues
+            }
+        });
+        }
+    }
+}
diff --git a/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js-meta.xml b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.js-meta.xml
new file mode 100644
index 0000000..3392981
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewAgencyHospital/lexNewAgencyHospital.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/lexSubmitSolutionForApproval/__tests__/lexSubmitSolutionForApproval.test.js b/force-app/main/default/lwc/lexSubmitSolutionForApproval/__tests__/lexSubmitSolutionForApproval.test.js
new file mode 100644
index 0000000..38f7779
--- /dev/null
+++ b/force-app/main/default/lwc/lexSubmitSolutionForApproval/__tests__/lexSubmitSolutionForApproval.test.js
@@ -0,0 +1,25 @@
+import { createElement } from 'lwc';
+import LexSubmitSolutionForApproval from 'c/lexSubmitSolutionForApproval';
+
+describe('c-lex-submit-solution-for-approval', () => {
+    afterEach(() => {
+        // The jsdom instance is shared across test cases in a single file so reset the DOM
+        while (document.body.firstChild) {
+            document.body.removeChild(document.body.firstChild);
+        }
+    });
+
+    it('TODO: test case generated by CLI command, please fill in test logic', () => {
+        // Arrange
+        const element = createElement('c-lex-submit-solution-for-approval', {
+            is: LexSubmitSolutionForApproval
+        });
+
+        // Act
+        document.body.appendChild(element);
+
+        // Assert
+        // const div = element.shadowRoot.querySelector('div');
+        expect(1).toBe(1);
+    });
+});
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.html b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.html
new file mode 100644
index 0000000..8fef32d
--- /dev/null
+++ b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="submitSolutionForApprovalHolder" 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/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js
new file mode 100644
index 0000000..08d011f
--- /dev/null
+++ b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js
@@ -0,0 +1,148 @@
+/*
+ * @Description: 
+ * @version: 
+ * @Author: chen jing wu
+ * @Date: 2023-06-20 14:37:24
+ * @LastEditors: chen jing wu
+ * @LastEditTime: 2023-06-20 17:50:52
+ */
+import { api, wire,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import updateSubmitSolutionForApprovalButton  from '@salesforce/apex/lexSolutionProjectRequirementsController.updateSubmitSolutionForApprovalButton';
+import init  from '@salesforce/apex/lexSolutionProjectRequirementsController.initSubmitSolutionForApprovalButton';
+import queryForAttachments  from '@salesforce/apex/lexSolutionProjectRequirementsController.queryForAttachments';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import LightningConfirm from 'lightning/confirm';
+
+export default class LexSubmitSolutionForApproval extends LightningElement {
+    @api recordId;
+    status;
+    submitDateYouWant;
+    createdDate;
+    departmentClassId;
+    userId;
+    userName;
+    productLeader;
+    @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;
+          }
+        }
+    }
+    showToast(msg,type) {
+        const event = new ShowToastEvent({
+            title: '',
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+    }
+
+
+    updateRecordView(recordId) {
+        updateRecord({fields: { Id: recordId }});
+    }
+
+    connectedCallback(){
+        init({
+            recordId: this.recordId
+        }).then(result=>{
+            this.status = result.status;
+            this.submitDateYouWant = result.submitDateYouWant;
+            this.createdDate = result.createdDate;
+            this.departmentClassId = result.departmentClassId;
+            this.userId = result.userId;
+            this.userName = result.userName;
+            this.submitSolutionForApproval();
+        });
+    }
+
+    submitSolutionForApproval(){
+        if(this.status == '07缁撴'){
+            this.showToast('宸茬粨妗�','error');
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
+        }
+        if(this.submitDateYouWant < this.createdDate + 3){
+            this.showToast('甯屾湜鎻愪氦鏃ユ湡涓嶅緱灏忎簬涓夊ぉ锛屽绱ф�ラ渶姹傝閭欢鑱旂粶Solution鎷呭綋','error');
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
+        }
+        queryForAttachments({
+            Id: this.departmentClassId
+        }).then(result=>{
+            var records = result;
+            var header = this.productLeader;
+            var usrname = this.userName;
+            var rtn = '';
+            if(header.contains(usrname.replaceAll(' ', ''))){
+                rtn = 'Y';
+            }else{
+                rtn = 'N';
+            }
+            
+            if(records.length > 0){
+                if(rtn != 'Y' && this.userId != records[0].Department_Class__r.OwnerId && this.userId != records[0].Department_Class__r.Owner.SalesManager__c){
+                    this.showToast('鍙厑鍏舵垬鐣ョ瀹や富鎷呫�佷骇鍝佹媴褰撳強鐪佺粡鐞嗘彁浜olution椤圭洰闇�姹傦紒','error');
+                    this.dispatchEvent(new CloseActionScreenEvent());
+                    return;
+                }
+            }
+
+            //111111111111111111111111111111111111111111
+            this.handleConfirmClick('涓�鏃︽彁浜ゆ璁板綍浠ュ緟鎵瑰噯锛屾牴鎹偍鐨勮缃偍鍙兘涓嶅啀鑳藉缂栬緫姝よ褰曟垨灏嗕粬浠庢壒鍑嗚繃绋嬩腑璋冨洖銆傛槸鍚︾户缁紵');
+            
+        });
+        
+       
+    }
+
+    async handleConfirmClick(msg) {
+        const result = await LightningConfirm.open({
+            message: msg,
+            variant: 'headerless',
+            label: 'this is the aria-label value',
+        });
+        console.log(result);
+        if(result){
+            updateSubmitSolutionForApprovalButton({
+                recordId: this.recordId
+            }).then(results=>{
+                try {
+                   if(results){
+                        this.showToast(results,"error");
+                        this.dispatchEvent(new CloseActionScreenEvent());
+                   } 
+                } catch (error) {
+                    if(err.faultstring !=undefined && err.faultstring.indexOf('INVALID_SESSION_ID') != -1) {
+                        this.showToast('褰撳墠缃戦〉宸茬櫥鍑猴紝璇锋偍閲嶆柊鐧诲綍鍚庡埛鏂拌缃戦〉锛�','error');
+                        this.dispatchEvent(new CloseActionScreenEvent());
+                    } else {
+                        this.showToast(err.faultstring,'error');
+                        this.dispatchEvent(new CloseActionScreenEvent());
+                    }
+                    return;
+                }
+                this.updateRecordView(this.recordId);
+            });
+            // isopd.Id = "{!SolutionProjectRequirements__c.Id}";
+            // isopd.Submint_TF__c = true;
+            // isopd.Submitter__c = "{!$User.Id}";
+        }else{
+            this.dispatchEvent(new CloseActionScreenEvent());
+            return;
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js-meta.xml b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.js-meta.xml
new file mode 100644
index 0000000..3392981
--- /dev/null
+++ b/force-app/main/default/lwc/lexSubmitSolutionForApproval/lexSubmitSolutionForApproval.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/pages/ImprovedForecastTime.page b/force-app/main/default/pages/ImprovedForecastTime.page
index b22d112..2845c61 100644
--- a/force-app/main/default/pages/ImprovedForecastTime.page
+++ b/force-app/main/default/pages/ImprovedForecastTime.page
@@ -1,4 +1,4 @@
-<apex:page showHeader="false" sidebar="false" id="ImprovedForecastTimeApp" title="棰勬祴鏃ユ湡鏀瑰彉">
+<apex:page showHeader="false" sidebar="false" id="ImprovedForecastTimeApp" title="棰勬祴鏃ユ湡鏀瑰彉" lightningStylesheets="true">
     <apex:includeLightning />
     <div style="width:100%;height:100%;" id="ImprovedForecastTimeApp" />
 

--
Gitblit v1.9.1