From f1bb6af7ec8ea81ba1b40eef0dabeeef3eee4bbb Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期五, 12 四月 2024 11:48:56 +0800
Subject: [PATCH] 123
---
force-app/main/default/lwc/oppLoseButton/oppLoseButton.js | 219 ++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 154 insertions(+), 65 deletions(-)
diff --git a/force-app/main/default/lwc/oppLoseButton/oppLoseButton.js b/force-app/main/default/lwc/oppLoseButton/oppLoseButton.js
index b7100e8..09e4458 100644
--- a/force-app/main/default/lwc/oppLoseButton/oppLoseButton.js
+++ b/force-app/main/default/lwc/oppLoseButton/oppLoseButton.js
@@ -3,84 +3,173 @@
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import init from '@salesforce/apex/OppLoseController.init';
-
-export default class OppLoseButton extends LightningElement {
- @api
- taskId;
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
+import {loadStyle} from 'lightning/platformResourceLoader';
+export default class OppLoseButton extends NavigationMixin(LightningElement) {
+ @api recordId;
opp;
- stageName;
- SAP_Send_OK;
- Cnt_Lost_cancel_report;
- Name;
- Sales_assistant_name;
- Sales_assistant_ID;
- Manager_name;
- Sales_manager_departmentID;
- Sales_owner_buchang;
- Sales_owner_buchangID;
- OpportunityId;
+ StageName; //闃舵
+ SAP_Send_OK;//SAP涓婁紶(WIN)
+ Cnt_Lost_cancel_report;//绱姹囨�� (COUNT 璇环澶卞崟/鍙栨秷鎶ュ憡)
+ Name;// 涓氬姟鏈轰細鍚�
+ Sales_assistant_name;//璇环鍔╃悊
+ Sales_assistant_ID;//璇环鍔╃悊ID
+ Manager_name;//璇环鎵�鏈変汉鐨凜L6 缁忕悊绾�
+ Sales_manager_departmentID;//璇环鎵�鏈変汉鐨凜L6 缁忕悊绾D
+ Sales_owner_buchang;//璇环鎵�鏈変汉鐨� CL5 鎬荤洃绾�
+ Sales_owner_buchangID;//璇环鎵�鏈変汉鐨凜L5 缁忕悊绾D
+ OpportunityId; //浠诲姟 璇环
task;
-
- connectedCallback(){
- console.log(this.taskId);
- init({
- taskId: this.taskId
- }).then(result => {
- console.log(result);
- if (result != null) {
-
- this.IsLoading = false;
- this.opp = result.opp;
- this.stageName = result.stageName;
- this.SAP_Send_OK = result.SAP_Send_OK;
- this.Cnt_Lost_cancel_report = result.Cnt_Lost_cancel_report;
- this.Name = result.Name;
- this.Sales_assistant_name = result.Sales_assistant_name;
- this.Sales_assistant_ID = result.Sales_assistant_ID;
- this.Manager_name = result.Manager_name;
- this.Sales_manager_departmentID = result.Sales_manager_departmentID;
- this.Sales_owner_buchang = result.Sales_owner_buchang;
- this.Sales_owner_buchangID = result.Sales_owner_buchangID;
- this.OpportunityId = result.OpportunityId;
- this.task = result.task;
-
- this.changeContractType();
- this.dispatchEvent(new CloseActionScreenEvent());
- // window.location.reload();
+ taskStatusOne;
+ reId;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference){
+ if(currentPageReference){
+ const urlValue=currentPageReference.state.recordId;
+ if(urlValue){
+ let str=`${urlValue}`;
+ this.recordId=str;
}
- }).catch(error => {
- console.log("error");
- console.log(error);
- }).finally(() => {
-
- });
+ }
+ }
+ connectedCallback(){
+
+ Promise.all([
+ loadStyle(this, lwcCSS)
+ ]);
+ console.log(this.recordId);
+ init({
+ taskId: this.recordId
+ }).then(result => {
+ console.log("==========================");
+ console.log(result);
+ this.IsLoading = false;
+ this.opp = result.opp;
+ this.StageName = result.StageName;
+ this.SAP_Send_OK = result.SAP_Send_OK;
+ this.Cnt_Lost_cancel_report = result.Cnt_Lost_cancel_report;
+ this.Name = result.Name;
+ this.Sales_assistant_name = result.Sales_assistant_name;
+ this.Sales_assistant_ID = result.Sales_assistant_ID;
+ this.Manager_name = result.Manager_name;
+ this.Sales_manager_departmentID = result.Sales_manager_departmentID;
+ this.Sales_owner_buchang = result.Sales_owner_buchang;
+ this.Sales_owner_buchangID = result.Sales_owner_buchangID;
+ this.OpportunityId = result.OpportunityId;
+ this.taskStatusOne = result.taskStatusOne;
+ this.task = result.task;
+ this.reId=result.reId;
+ this.changeContractType();
+ })
}
changeContractType(){
if(this.StageName != '寮曞悎' && this.StageName != '璇环'){
- alert('鐘舵��1: '+ this.StageName + '銆佷笉鑳藉仛 澶卞崟 浜嗭紒');
+ // alert('鐘舵��1: '+ this.StageName + '銆佷笉鑳藉仛 澶卞崟 浜嗭紒');
+ this.showToast("鐘舵��1:" + this.StageName + "銆佷笉鑳藉仛 澶卞崟 浜嗭紒","error");
+ return;
}
else if(this.SAP_Send_OK == '1'){
- alert('宸茬粡涓婁紶SAP銆佷笉鑳藉仛 澶卞崟 浜嗭紒');
+ // alert('宸茬粡涓婁紶SAP銆佷笉鑳藉仛 澶卞崟 浜嗭紒');
+ this.showToast("宸茬粡涓婁紶SAP銆佷笉鑳藉仛 澶卞崟 浜嗭紒","error");
+ return;
}
- else if(this.Cnt_Lost_cancel_report__c > 0){
- alert('璇环宸茬粡鏈� 鍙栨秷锛忓け鍗曟姤鍛� 浜嗭紒');
+ else if(this.Cnt_Lost_cancel_report > 0){
+ // alert('璇环宸茬粡鏈� 鍙栨秷锛忓け鍗曟姤鍛� 浜嗭紒');
+ this.showToast("璇环宸茬粡鏈� 鍙栨秷锛忓け鍗曟姤鍛� 浜嗭紒","error");
+ return;
// window.location.reload();
}else{
- location.href =
- '/a1U/e?retURL=%2F' + this.OpportunityId +
- '&RecordType=01210000000R4hM' +
- '&CF00N10000004lbGT={!URLENCODE('+this.Name+')}' +
- '&CF00N10000004lbGT_lkid=' + this.OpportunityId +
+ var url = '/lightning/n/PCLLostReportPageLwc#pageStatus=Create&oppId=' + this.OpportunityId + '&lostType=澶卞崟';
+ location.href = url;
+ // const defaultValues = encodeDefaultFieldValues({
+ // Opportunity__c:this.OpportunityId,
+ // Sales_assistant__c:this.Sales_assistant_ID,
+ // Manager_sales__c:this.Sales_manager_departmentID,
+ // Buchang_sales__c:this.Sales_owner_buchangID
+ // });
+ // this[NavigationMixin.Navigate]({
+ // type: 'standard__objectPage',
+ // attributes: {
+ // objectApiName: 'Lost_cancel_report__c',
+ // actionName: 'new'
+ // },
+ // state: {
+ // // nooverride: '1',
+ // defaultFieldValues: defaultValues,
+ // recordTypeId: this.reId
+ // }
+ // });
- '&CF00N10000006QShg={!URLENCODE('+this.Sales_assistant_name+')}' +
- '&CF00N10000006QShg_lkid={!URLENCODE('+this.Sales_assistant_ID+')}' +
- '&CF00N10000006QShq={!URLENCODE('+this.Manager_name+')}' +
- '&CF00N10000006QShq_lkid={!URLENCODE('+this.Sales_manager_departmentID+')}' +
- '&CF00N10000006QShb={!URLENCODE('+this.Sales_owner_buchang+')}' +
- '&CF00N10000006QShb_lkid={!URLENCODE('+this.Sales_owner_buchangID+')}' +
- '';
+ // location.href =
+ // '/a1U/e?retURL=%2F' + this.OpportunityId +
+ // '&RecordType=' + this.reId+
+ // // '&CF00N10000004lbGT='+ this.Name +
+ // '&Opportunity__c=' + this.OpportunityId +
+ // // '&CF00N10000006QShg='+this.Sales_assistant_name+
+ // '&Sales_assistant__c='+this.Sales_assistant_ID +
+ // // '&CF00N10000006QShq='+this.Manager_name +
+ // '&Manager_sales__c='+this.Sales_manager_departmentID +
+ // // '&CF00N10000006QShb='+this.Sales_owner_buchang +
+ // '&Buchang_sales__c='+this.Sales_owner_buchangID +
+ // '';
+ this.dispatchEvent(new CloseActionScreenEvent());
}
}
+ showToast(msg,type) {
+ if(type == 'success'){
+ const event = new ShowToastEvent({
+ message: msg,
+ variant: type
+ });
+ // this.updateRecordView(this.recordId);
+ this.dispatchEvent(event);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }else{
+ const event = new ShowToastEvent({
+ message: msg,
+ variant: type,
+ mode: 'sticky'
+ });
+ // this.updateRecordView(this.recordId);
+ this.dispatchEvent(event);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ }
+}
-}
\ No newline at end of file
+
+
+// var sql = "select Sales_owner_buchangID__c,Manager_name__c,Sales_owner_buchang__c,Sales_manager_departmentID__c,name,Sales_assistant_name__c,Sales_assistant_ID__c,id,StageName,SAP_Send_OK__c,Cnt_Lost_cancel_report__c,Bidding_Project_Name_Bid__c from Opportunity where id = '{!task__c.OpportunityIdId__c}'";
+// var opp_recourd = sforce.connection.query(sql);
+// var opp = opp_recourd.getArray("records")[0];
+// if (opp.StageName != '寮曞悎'
+// && opp.StageName != '璇环'
+// ) {
+// alert("鐘舵��1:" + opp.StageName + "銆佷笉鑳藉仛 澶卞崟 浜嗭紒");
+// }
+// else if (opp.SAP_Send_OK__c == '1') {
+// alert("宸茬粡涓婁紶SAP銆佷笉鑳藉仛 澶卞崟 浜嗭紒");
+// }
+// else if (opp.Cnt_Lost_cancel_report__c > 0) {
+// alert("璇环宸茬粡鏈� 鍙栨秷锛忓け鍗曟姤鍛� 浜嗭紒");
+// }
+
+
+// else {
+// location.href =
+// '/a1U/e?retURL=%2F{!task__c.OpportunityIdId__c}' +
+// '&RecordType=01210000000R4hM' +
+// '&CF00N10000004lbGT={!URLENCODE('+opp.name+')}' +
+// '&CF00N10000004lbGT_lkid={!task__c.OpportunityIdId__c}' +
+
+// '&CF00N10000006QShg={!URLENCODE('+opp.Sales_assistant_name__c+')}' +
+// '&CF00N10000006QShg_lkid={!URLENCODE('+opp.Sales_assistant_ID__c+')}' +
+// '&CF00N10000006QShq={!URLENCODE('+opp.Manager_name__c+')}' +
+// '&CF00N10000006QShq_lkid={!URLENCODE('+opp.Sales_manager_departmentID__c+')}' +
+// '&CF00N10000006QShb={!URLENCODE('+opp.Sales_owner_buchang__c+')}' +
+// '&CF00N10000006QShb_lkid={!URLENCODE('+opp.Sales_owner_buchangID__c+')}' +
+// '';
+// }
\ No newline at end of file
--
Gitblit v1.9.1