New file |
| | |
| | | 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 '; |
| | | // 现在,fieldMap中包含了对象的所有字段信息 |
| | | for (String fieldName : fieldMap.keySet()) { |
| | | if(!fieldName.equals('id') |
| | | &&!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=fieldMap.get(fieldName).getDescribe().getName(); |
| | | if(opportunitys.get(0).get(fieldName)!=null&&!opportunitys.get(0).get(fieldName).equals('null')){ |
| | | if(formaF.equals('Id') |
| | | ||formaF.equals('OwnerId') |
| | | ||formaF.equals('CreatedDate') |
| | | ||formaF.equals('CreatedById') |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | Object val=opportunitys.get(0).get(fieldName); |
| | | if(val instanceof Date ){ |
| | | String str=String.valueOf(val); |
| | | str=str.replace(' ','T'); |
| | | str+='.000Z'; |
| | | s+=formaF+'='+str+','; |
| | | }else if (val instanceof DateTime){ |
| | | String str=String.valueOf(val); |
| | | str=str.replace(' ','T'); |
| | | str+='.000Z'; |
| | | s+=formaF+'='+str+','; |
| | | }else{ |
| | | 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 getData(){ |
| | | |
| | | // } |
| | | 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); |
| | | 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(charArr); |
| | | res+=str.substring(str.length()-1,str.length()); |
| | | |
| | | return res; |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>51.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
New file |
| | |
| | | <template> |
| | | <div class="Holder" style=" |
| | | position: relative; |
| | | width:100%; |
| | | height:200px; |
| | | --sds-c-progress-ring__stroke-color: #0070d2;"> |
| | | <lightning-spinner alternative-text="Loading" size="medium" variant="brand"></lightning-spinner> |
| | | </div> |
| | | </template> |
New file |
| | |
| | | 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'; |
| | | import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; |
| | | import {loadStyle} from 'lightning/platformResourceLoader'; |
| | | 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(){ |
| | | Promise.all([ |
| | | loadStyle(this, lwcCSS) |
| | | ]); |
| | | init({ |
| | | recordId: this.recordId |
| | | }).then(result=>{ |
| | | this.dateF = result; |
| | | this.createOPDFromRentalApply().then(res=>{ |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | }); |
| | | }); |
| | | } |
| | | async createOPDFromRentalApply(){ |
| | | let tt='dd'; |
| | | const data = encodeDefaultFieldValues({ |
| | | 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:'', |
| | | 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:'', |
| | | Old_Opportunity_ID__c:'', |
| | | LeadSource:'', |
| | | Authorized_Finish_Sales__c:'', |
| | | IsAuthorized__c:'', |
| | | }); |
| | | console.log(this.dateF+","+data); |
| | | this[NavigationMixin.Navigate]({ |
| | | type: 'standard__objectPage', |
| | | attributes: { |
| | | objectApiName: 'Opportunity', // 要新建的对象API |
| | | actionName: 'new', |
| | | }, |
| | | state:{ |
| | | nooverride: '1', |
| | | defaultFieldValues:this.dateF+","+data |
| | | } |
| | | }); |
| | | } |
| | | } |
New file |
| | |
| | | <?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> |