From 56952e2543a861fb9b8ce4ef11d041a14417650b Mon Sep 17 00:00:00 2001
From: zz <1842059105@qq.com>
Date: 星期二, 18 四月 2023 17:45:04 +0800
Subject: [PATCH] 中标通知书  申请 同意 驳回 Lightning按钮提交

---
 force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js-meta.xml |   11 +
 force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js-meta.xml     |   11 +
 force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.html        |    5 
 force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js            |   53 ++++++++
 force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js              |   65 ++++++++++
 force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js          |   53 ++++++++
 force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js-meta.xml   |   11 +
 force-app/main/default/classes/BidAnnouncementController.cls-meta.xml                                    |    5 
 force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.html          |    5 
 force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.html            |    5 
 force-app/main/default/classes/LightingButtonConstant.cls                                                |    6 +
 force-app/main/default/classes/BidAnnouncementController.cls                                             |  106 +++++++++++++++++
 12 files changed, 336 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/BidAnnouncementController.cls b/force-app/main/default/classes/BidAnnouncementController.cls
new file mode 100644
index 0000000..21e08db
--- /dev/null
+++ b/force-app/main/default/classes/BidAnnouncementController.cls
@@ -0,0 +1,106 @@
+public class BidAnnouncementController {
+    @AuraEnabled
+    public static InitData BidAnnouncementController (String recordId){
+        InitData res = new initData();
+        try{
+            Bid_Announcement__c report = [SELECT 	Id FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
+            res.Id = report.Id;
+            System.debug(LoggingLevel.INFO, '*** res: ' + res);
+        }catch(Exception e){
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }
+    //涓爣閫氱煡涔� 鐢宠
+    @AuraEnabled
+    public static String ApplyFor(String recordId) {
+        String messageText = '';
+        try {
+        Bid_Announcement__c Bid_Announcement = [SELECT 	Id,Status__c,Request_flag__c,Request_user__c,Request_date__c FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
+        Bid_Announcement.Id = Bid_Announcement.Id;
+        Bid_Announcement.Status__c = LightingButtonConstant.STATUS_Bid_Announcement_ApplyFor;
+        Bid_Announcement.Request_flag__c = true;
+        Bid_Announcement.Request_user__c = Userinfo.getUserId();
+        Bid_Announcement.Request_date__c = Datetime.now();
+        update Bid_Announcement;
+        messageText = '1';
+        return messageText;
+        } catch (Exception ex) {
+        System.debug(LoggingLevel.INFO, '*** ApplyForXu: ' + ex);
+        messageText = ex.getMessage();
+        return messageText;
+        }
+    }
+    //涓爣閫氱煡涔� 鍚屾剰
+    @AuraEnabled
+    public static String ConSent(String recordId) {
+        String messageText = '';
+        try {
+        Bid_Announcement__c Bid_Announcement = [SELECT 	Id,Status__c,Complete__c,Agree_user__c,Complete_date__c FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
+        Bid_Announcement.Id = Bid_Announcement.Id;
+        Bid_Announcement.Status__c = LightingButtonConstant.STATUS_Bid_Announcement_Consent;
+        Bid_Announcement.Complete__c = true;
+        Bid_Announcement.Agree_user__c = Userinfo.getUserId();
+        Bid_Announcement.Complete_date__c = Datetime.now();
+        update Bid_Announcement;
+        messageText = '1';
+        return messageText;
+        } catch (Exception ex) {
+        System.debug(LoggingLevel.INFO, '*** ConsentXu: ' + ex);
+        messageText = ex.getMessage();
+        return messageText;
+        }
+    }
+    //涓爣閫氱煡涔� 椹冲洖
+    @AuraEnabled
+    public static String Reject(String recordId) {
+        String messageText = '';
+        try {
+        Bid_Announcement__c Bid_Announcement = [SELECT 	Id,Status__c,Complete__c,Agree_user__c,Complete_date__c,Request_flag__c,Request_user__c,Request_date__c FROM Bid_Announcement__c WHERE Id = :recordId LIMIT 1];
+        Bid_Announcement.Id = Bid_Announcement.Id;
+        Bid_Announcement.Status__c = LightingButtonConstant.STATUS_Bid_Announcement_Reject;
+        Bid_Announcement.Complete__c = false;
+        Bid_Announcement.Agree_user__c = null;
+        Bid_Announcement.Complete_date__c = null;
+        Bid_Announcement.Request_flag__c = false;
+        Bid_Announcement.Request_user__c = null;
+        Bid_Announcement.Request_date__c = null;
+        update Bid_Announcement;
+        messageText = '1';
+        return messageText;
+        } catch (Exception ex) {
+        System.debug(LoggingLevel.INFO, '*** Reject: ' + ex);
+        messageText = ex.getMessage();
+        return messageText;
+        }
+    }
+    //鑾峰彇褰撳墠鐧诲綍浜虹殑 id
+    @AuraEnabled
+    public static UserResult UserInfo_Owner() {
+        UserResult result = new UserResult();
+        ID myUserID = UserInfo.getUserId();
+        try { 
+            User tempUser = [select id,BidCancel__c from user where id = : myUserID ];
+            result.id = tempUser.id;
+            result.BidCancel = tempUser.BidCancel__c;
+        } catch (exception e) {
+            result.result = e.getMessage();
+        }
+        return result;
+    }
+    public class InitData{
+        @AuraEnabled
+        public String Id;
+    }
+    public class UserResult {
+        @AuraEnabled
+        public string result;
+        public UserResult( ) {
+            result = 'Success';
+        }
+        @AuraEnabled
+        public string id;
+        @AuraEnabled
+        public Boolean BidCancel;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/BidAnnouncementController.cls-meta.xml b/force-app/main/default/classes/BidAnnouncementController.cls-meta.xml
new file mode 100644
index 0000000..fbbad0a
--- /dev/null
+++ b/force-app/main/default/classes/BidAnnouncementController.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/classes/LightingButtonConstant.cls b/force-app/main/default/classes/LightingButtonConstant.cls
index dac8ac7..85921bf 100644
--- a/force-app/main/default/classes/LightingButtonConstant.cls
+++ b/force-app/main/default/classes/LightingButtonConstant.cls
@@ -1,4 +1,10 @@
 global without sharing class LightingButtonConstant {
+    //涓爣閫氱煡涔︾殑鐘舵�佲�樺鐞嗗畬姣曗��
+    public static final String STATUS_Bid_Announcement_Consent = '澶勭悊瀹屾瘯';
+    //涓爣閫氱煡涔︾殑鐘舵�佲�樿崏妗堜腑鈥�
+    public static final String STATUS_Bid_Announcement_Reject = '鑽夋涓�';
+    //涓爣閫氱煡涔︾殑鐘舵�佲�樼敵璇蜂腑鈥�
+    public static final String STATUS_Bid_Announcement_ApplyFor = '鐢宠涓�';
     //鎺堟潈鐢宠鐨勭姸鎬佲�樺凡鎻愪氦鈥�
     public static final String STATUS_Application_Submitted = '宸叉彁浜�';
     //鎺堟潈鐢宠鐨勭姸鎬佲�樿崏妗堜腑鈥�
diff --git a/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.html b/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.html
new file mode 100644
index 0000000..e286a5b
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="ApplyFor" 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/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js b/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js
new file mode 100644
index 0000000..3bbe3fc
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js
@@ -0,0 +1,53 @@
+import { LightningElement,wire,track,api} from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import  ApplyFor  from '@salesforce/apex/BidAnnouncementController.ApplyFor';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+export default class lexBidAnnouncementApplyForButton extends LightningElement {
+    @api recordId;//
+    IsLoading = true;
+
+    @wire(CurrentPageReference)
+     getStateParameters(currentPageReference) {
+         if (currentPageReference) {
+           const urlValue = currentPageReference.state.recordId;
+           if (urlValue) {
+             let str = `${urlValue}`;
+             this.recordId = str;
+           }
+         }
+     }
+    
+    connectedCallback(){
+        this.IsLoading = false;
+        this.ApplyFor();
+    }
+    //涓爣閫氱煡涔� 鐢宠
+    ApplyFor(){
+        ApplyFor({recordId:this.recordId}).then(res=>{
+            if(res == '1'){
+                this.showToast('璇锋眰鐢宠鎴愬姛,鐢宠涓�傘�傘��','success');
+                this.updateRecordView();
+            }else{
+                var messageage = "";
+                messageage = res.split(',')[1];
+                this.showToast(messageage,'error');
+            }
+        })
+    }
+    
+    showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+
+    updateRecordView() {
+        updateRecord({fields: { Id: this.recordId }});
+    }
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js-meta.xml b/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js-meta.xml
new file mode 100644
index 0000000..2b7649d
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementApplyForButton/lexBidAnnouncementApplyForButton.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<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/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.html b/force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.html
new file mode 100644
index 0000000..55743be
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="Consent" 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/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js b/force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js
new file mode 100644
index 0000000..b170c4e
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js
@@ -0,0 +1,53 @@
+import { LightningElement,wire,track,api} from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import  ConSent  from '@salesforce/apex/BidAnnouncementController.ConSent';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+export default class lexBidAnnouncementRejectButton extends LightningElement {
+    @api recordId;
+    IsLoading = true;
+
+    @wire(CurrentPageReference)
+     getStateParameters(currentPageReference) {
+         if (currentPageReference) {
+           const urlValue = currentPageReference.state.recordId;
+           if (urlValue) {
+             let str = `${urlValue}`;
+             this.recordId = str;
+           }
+         }
+     }
+    connectedCallback(){
+        this.IsLoading = false;
+        this.Consent();
+    }
+    //涓爣閫氱煡涔� 鍚屾剰
+    Consent(){  
+        ConSent({recordId:this.recordId}).then(res=>{
+            if(res == '1'){
+                this.showToast("鍚屾剰璇锋眰鎴愬姛","success");
+            }
+            if(res != "1"){
+                var messageage = "";
+                messageage = res.split(',')[1];
+                this.showToast(messageage,"error");
+            }
+        })
+    }
+    showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+        if(type == 'success'){
+            this.updateRecordView();
+        }
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+    updateRecordView() {
+        updateRecord({fields: { Id: this.recordId }});
+    }
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js-meta.xml b/force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js-meta.xml
new file mode 100644
index 0000000..2b7649d
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementConsentButton/lexBidAnnouncementConsentButton.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<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/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.html b/force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.html
new file mode 100644
index 0000000..be06a03
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.html
@@ -0,0 +1,5 @@
+<template>
+    <div class="reject" 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/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js b/force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js
new file mode 100644
index 0000000..74a1baf
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js
@@ -0,0 +1,65 @@
+import { LightningElement,wire,track,api} from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import  UserInfo_Owner  from '@salesforce/apex/BidAnnouncementController.UserInfo_Owner';
+import  Reject  from '@salesforce/apex/BidAnnouncementController.Reject';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+export default class lexBidAnnouncementRejectButton extends LightningElement {
+    @api recordId;
+    IsLoading = true;
+    BidCancel = null;
+
+    @wire(CurrentPageReference)
+     getStateParameters(currentPageReference) {
+         if (currentPageReference) {
+           const urlValue = currentPageReference.state.recordId;
+           if (urlValue) {
+             let str = `${urlValue}`;
+             this.recordId = str;
+           }
+         }
+     }
+    
+    connectedCallback(){
+        this.IsLoading = false;
+        this.Reject();
+    }
+    //涓爣閫氱煡涔� 椹冲洖
+    Reject(){
+        UserInfo_Owner().then(res=>{
+            this.BidCancel = res.BidCancel;
+            if(this.BidCancel == false){
+                this.showToast('娌℃湁椹冲洖鐨勬潈闄�',"error");
+            }else{
+                Reject({
+                    recordId: this.recordId
+                }).then(requst=>{
+                    if(requst == '1'){
+                        this.showToast("椹冲洖璇锋眰鎴愬姛","success");
+                    }
+                    if(requst != "1"){
+                        var messageage = "";
+                        messageage = requst.split(',')[1];
+                        this.showToast(messageage,"error");
+                    }
+                })
+            }
+        })
+    }
+    showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+        if(type == 'success'){
+            this.updateRecordView();
+        }
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+    updateRecordView() {
+        updateRecord({fields: { Id: this.recordId }});
+    }
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js-meta.xml b/force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js-meta.xml
new file mode 100644
index 0000000..2b7649d
--- /dev/null
+++ b/force-app/main/default/lwc/lexBidAnnouncementRejectButton/lexBidAnnouncementRejectButton.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<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