From 8ab46e96abe0abd100bef3f4fb27614b00490167 Mon Sep 17 00:00:00 2001
From: liwentao <1376563863@qq.com>
Date: 星期五, 28 七月 2023 16:52:17 +0800
Subject: [PATCH] 营业: 询价按钮: 复制(不带产品)

---
 force-app/main/default/classes/lexCopyToBaseController.cls-meta.xml |    5 
 force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.html         |    6 +
 force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js           |  209 ++++++++++++++++++++++++++++++++++
 force-app/main/default/classes/lexCopyToBaseController.cls          |   77 ++++++++++++
 force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js-meta.xml  |   11 +
 5 files changed, 308 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/lexCopyToBaseController.cls b/force-app/main/default/classes/lexCopyToBaseController.cls
new file mode 100644
index 0000000..49d7ecb
--- /dev/null
+++ b/force-app/main/default/classes/lexCopyToBaseController.cls
@@ -0,0 +1,77 @@
+public with sharing class lexCopyToBaseController {
+    public lexCopyToBaseController() {
+        
+    }
+
+    @AuraEnabled
+    public static String init(String recordId){
+        String s='';
+        try {
+            String objectName = 'Opportunity'; // 瑕佽幏鍙栧瓧娈电殑瀵硅薄鍚�
+
+            Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();
+            Schema.SObjectType objType = globalDescribe.get(objectName);
+            if (objType != null) {
+                Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
+                Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
+                s+='SELECT ';
+                // 鐜板湪锛宖ieldMap涓寘鍚簡瀵硅薄鐨勬墍鏈夊瓧娈典俊鎭�
+                for (String fieldName : fieldMap.keySet()) {
+                    if(!fieldName.equals('id'))
+                        s+=fieldName+',';
+                }
+                s=s.removeEnd(',');
+                s+=' FROM Opportunity where id=\''+recordId+'\'';
+                system.debug('SQL:'+s);
+                List<Opportunity> opportunitys = Database.query(s);
+                s='';
+                if(opportunitys.size()>0){
+                    system.debug('in!');
+                    for (String fieldName : fieldMap.keySet()) {
+                        String formaF=forma(fieldName);
+                        if(opportunitys.get(0).get(fieldName)!=null&&!opportunitys.get(0).get(fieldName).equals('null'))
+                            s+=formaF+'='+opportunitys.get(0).get(fieldName)+',';
+                    }
+                    s=s.removeEnd(',');
+                    return s;
+                }
+            }
+			return s;
+        } catch (Exception e) {
+            System.debug('lexCopyToBaseController init error:'+e.getMessage());
+        }
+        return s;
+    }
+
+    public static String forma(String str){
+        String res='';
+        String stra='a';
+        Integer a=stra.charAt(0);
+        String strz='z';
+        Integer z=strz.charAt(0);
+        String strAa='A';
+        Integer bA=strAa.charAt(0);
+        String strZz='Z';
+        Integer bZ=strZz.charAt(0);
+        String strx='_';
+        Integer x=strx.charAt(0);
+        List<Integer> charArr = new List<Integer>();
+        Integer change=bA-a;
+        Integer st=(str.charAt(0)+change);
+        //res+=String.valueOf(st);
+        charArr.add(st);
+        for(Integer i=0;i<str.length()-2;i++){
+            Integer c=str.charAt(i);
+            Integer nextC=str.charAt(i+1);
+            if(c==x&&nextC>=a&&nextC<z&&i!=str.length()-2){
+                nextC+=change;
+            }
+            charArr.add(nextC);
+            //res+=String.fromCharArray(List<Integer> charArr)(nextC);
+        }
+        res=String.fromCharArray(charArr);
+        res+=str.substring(str.length()-1,str.length());
+
+        return res;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexCopyToBaseController.cls-meta.xml b/force-app/main/default/classes/lexCopyToBaseController.cls-meta.xml
new file mode 100644
index 0000000..d75b058
--- /dev/null
+++ b/force-app/main/default/classes/lexCopyToBaseController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>51.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.html b/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.html
new file mode 100644
index 0000000..9608e80
--- /dev/null
+++ b/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.html
@@ -0,0 +1,6 @@
+<template>
+    <div class="baseHolder" if:true={IsLoading}>
+        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
+        <lightning-button label="Show Toast" onclick={ShowToastEvent}></lightning-button>
+    </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js b/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js
new file mode 100644
index 0000000..9ceda9c
--- /dev/null
+++ b/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js
@@ -0,0 +1,209 @@
+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';
+import { getRecord } from 'lightning/uiRecordApi';
+import init from '@salesforce/apex/lexCopyToBaseController.init';
+export default class lexCopyToBase extends NavigationMixin(LightningElement) {
+    @api recordId;
+    dateF;
+    @wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            this.recordId = str;
+          }
+        }
+    }
+    connectedCallback(){
+        init({
+            recordId: this.recordId
+        }).then(result=>{
+            this.dateF = result;
+            this.createOPDFromRentalApply();
+        });
+    }
+    createOPDFromRentalApply(){
+		// '&00N10000002CpEp:'',
+		// '&00N10000002CpEV:'',
+  //       let url='/lightning/r/Opportunity/'+this.recordId+'/clone?count=1'+
+  //       '&retURL=%2F'+this.recor+
+  //       '&common.udd.actions.ActionsUtilORIG_URI=%2F'+this.recordId+'%2F'+
+  //       '&Lead_CreateBy__c='+
+  //       '&Lead_CreateDate__c='+
+  //       '&Estimation_No__c='+
+  //       '&Estimation_Name__c='+
+  //       '&Estimation_List_Price__c='+
+  //       '&Agency1__c='+
+  //       '&Sales_Contract_No__c='+
+  //       '&Agency2__c='+
+  //       '&Bid_Publish_Date__c='+
+  //       '&Bidding_Company__c='+
+  //       '&Bidding_No__c='+
+  //       '&Bidding_Project_Name__c='+
+  //       '&Bidding_Content__c='+
+  //       '&Bid_Planned_Date__c='+
+  //       '&Closing_Bid_Company__c='+
+  //       '&Closing_Bid_Price__c='+
+  //       '&Opp_Confirmation_Day__c='+
+  //       '&Last_Follow_Up_Date__c='+
+  //       '&Estimation_Proposal_Date__c='+
+  //       '&Authorized_Date__c='+
+  //       '&Autholization_Activated_Date__c='+
+  //       '&Bid_Date__c='+
+  //       '&Closing_Bid_Date__c='+
+  //       '&Assistant_Applied_Date__c='+
+  //       '&Contract_DB_SalesDept_complite_day__c='+
+  //       '&Contract_DB_complite_day__c='+
+  //       '&Agency_Contract_Date1__c='+
+  //       '&SAP_Send_OK_Date__c='+
+  //       '&Sales_Shop_Hospital_Contract__c='+
+  //       '&Forecast_Collect_Money__c='+
+  //       '&Contract_Invalid_Date__c='+
+  //       '&Next_action__c='+
+  //       '&Follow_up_comment__c='+
+  //       '&Xin_Gross_Follow_Num__c='+
+  //       '&OPD1__c='+
+  //       '&Num_Of_OPD__c='+
+  //       '&OPD_SIS_collect_evaluation_sight__c='+
+  //       '&Detail_Suggestion__c='+
+  //       '&Num_Of_NTC__c='+
+  //       '&Deleted_Reason__c='+
+  //       '&Lost_Opportunity_Date__c='+
+  //       '&opp14='+
+  //       '&Request_quotation_update__c='+
+  //       '&old_Oppo_No__c='+
+  //       '&Old_Opportunity_ID__c='+
+  //       '&Oppor_Number_Report__c='+
+  //       '&Manager_name_text__c='+
+  //       '&Sales_assistant_name_text__c='+
+  //       '&Sales_window_text__c='+
+  //       '&If_Authorizing__c='+
+  //       '&Opportunity_No__c:this.recor='+
+  //       '&Collect_Customer_sign__c='+
+  //       '&Estimation_Decision__c='+
+  //       '&SAP_Send_OK__c='+
+  //       '&Authorized_DB_No__c='+
+  //       '&NotesApprovedNo__c='+
+  //       '&is_CheckTarget_TF__c='+
+  //       '&Whether_FALSE_order__c='+
+  //       '&Stock_apply_status__c='+
+  //       '&Stock_apply_time__c='+
+  //       '&Stock_apply_passtime__c='+
+  //       '&Stock_cancel_reason__c='+
+  //       '&Stock_cancel_reason_text__c='+
+  //       '&Stock_Confrim_Date__c='+
+  //       '&Last_opportunity_file__c='+
+  //       '&Application_Amount_Submit__c='+
+  //       '&Agency_Opportunity__c='+
+  //       '&Budget_Amount_Approval__c='+
+  //       '&Hospital_Budget__c='+
+  //       '&Key_tipics_last_update_day__c='+
+  //       '&Lead_Num__c=1'+
+  //       '&opp6='+
+  //       '&opp17='+
+  //       '&Other_Society__c='+
+  //       '&Contract_DB_Finalcomplite_day__c='+
+  //       '&Contract_Authorize_Lock__c=';
+		// console.log("ddd"+url);
+      let tt='dd';
+  		const data = encodeDefaultFieldValues({
+  			// count:1,
+  			// retURL:'%2F'+this.recordId,
+  			// common.udd.actions.ActionsUtilORIG_URI:'%2:'',this.recordId+'%2:'',
+  			Lead_CreateBy__c:'',
+  			Lead_CreateDate__c:'',
+  			Estimation_No__c:'',
+  			Estimation_Name__c:'',
+  			Estimation_List_Price__c:'',
+  			Agency1__c:'',
+  			Sales_Contract_No__c:'',
+  			Agency2__c:'',
+  			Bid_Publish_Date__c:'',
+  			Bidding_Company__c:'',
+  			Bidding_No__c:'',
+  			Bidding_Project_Name__c:'',
+  			Bidding_Content__c:'',
+  			Bid_Planned_Date__c:'',
+  			Closing_Bid_Company__c:'',
+  			Closing_Bid_Price__c:'',
+  			Opp_Confirmation_Day__c:'',
+  			Last_Follow_Up_Date__c:'',
+  			Estimation_Proposal_Date__c:'',
+  			Authorized_Date__c:'',
+  			Autholization_Activated_Date__c:'',
+  			Bid_Date__c:'',
+  			Closing_Bid_Date__c:'',
+  			Assistant_Applied_Date__c:'',
+  			Contract_DB_SalesDept_complite_day__c:'',
+  			Contract_DB_complite_day__c:'',
+  			Agency_Contract_Date1__c:'',
+  			SAP_Send_OK_Date__c:'',
+  			Sales_Shop_Hospital_Contract__c:'',
+  			Forecast_Collect_Money__c:'',
+  			Contract_Invalid_Date__c:'',
+  			Next_action__c:'',
+  			Follow_up_comment__c:'',
+  			Xin_Gross_Follow_Num__c:'',
+  			OPD1__c:'',
+  			Num_Of_OPD__c:'',
+  			OPD_SIS_collect_evaluation_sight__c:'',
+  			Detail_Suggestion__c:'',
+  			Num_Of_NTC__c:'',
+  			Deleted_Reason__c:'',
+  			Lost_Opportunity_Date__c:'',
+  			opp14:'',
+  			Request_quotation_update__c:'',
+  			old_Oppo_No__c:'',
+  			Old_Opportunity_ID__c:this.recordId,
+  			Oppor_Number_Report__c:'',
+  			Manager_name_text__c:'',
+  			Sales_assistant_name_text__c:'',
+  			Sales_window_text__c:'',
+  			If_Authorizing__c:'',
+        Opportunity_No__c:'',
+        Collect_Customer_sign__c:'',
+        Estimation_Decision__c:'',
+        SAP_Send_OK__c:'',
+        Authorized_DB_No__c:'',
+        NotesApprovedNo__c:'',
+        is_CheckTarget_TF__c:'',
+        Whether_FALSE_order__c:'',
+        Stock_apply_status__c:'',
+        Stock_apply_time__c:'',
+        Stock_apply_passtime__c:'',
+        Stock_cancel_reason__c:'',
+        Stock_cancel_reason_text__c:'',
+        Stock_Confrim_Date__c:'',
+        Last_opportunity_file__c:'',
+        Application_Amount_Submit__c:'',
+        Agency_Opportunity__c:'',
+        Budget_Amount_Approval__c:'',
+        Hospital_Budget__c:'',
+        Key_tipics_last_update_day__c:'',
+        Lead_Num__c:'',
+        opp6:'',
+        opp17:'',
+        Other_Society__c:'',
+        Contract_DB_Finalcomplite_day__c:'',
+        Contract_Authorize_Lock__c:'',
+      });
+      this[NavigationMixin.Navigate]({
+          type: 'standard__objectPage',
+          attributes: {
+              objectApiName: 'Opportunity', // 瑕佹柊寤虹殑瀵硅薄API
+              actionName: 'new',
+          },
+          state:{
+              nooverride: '1',
+              defaultFieldValues:this.dateF+","+data
+          }
+      });
+      this.dispatchEvent(new CloseActionScreenEvent());
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js-meta.xml b/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js-meta.xml
new file mode 100644
index 0000000..0bbf731
--- /dev/null
+++ b/force-app/main/default/lwc/lexCopyToBase/lexCopyToBase.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexCopyToBase">
+    <apiVersion>51.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+        <target>lightning__AppPage</target>
+        <target>lightning__RecordPage</target>
+        <target>lightning__HomePage</target>
+        <target>lightning__RecordAction</target>
+    </targets>
+</LightningComponentBundle>
\ No newline at end of file

--
Gitblit v1.9.1