From 5f8c97f8716088019ad9a0302c5dea461bc668b1 Mon Sep 17 00:00:00 2001
From: zhangzhengmei <zhangzhengmei@prec-tech.com>
Date: 星期一, 07 八月 2023 15:35:56 +0800
Subject: [PATCH] CIC相关按钮
---
force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.js | 99 ++++++++++++++++++++++++
force-app/main/default/classes/LexCICInputSolutionController.cls | 42 ++++++++++
force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.html | 5 +
force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.js-meta.xml | 12 +++
force-app/main/default/lwc/lexCustomClone/lexCustomClone.js | 45 ++++++++--
5 files changed, 193 insertions(+), 10 deletions(-)
diff --git a/force-app/main/default/classes/LexCICInputSolutionController.cls b/force-app/main/default/classes/LexCICInputSolutionController.cls
new file mode 100644
index 0000000..ed4b58d
--- /dev/null
+++ b/force-app/main/default/classes/LexCICInputSolutionController.cls
@@ -0,0 +1,42 @@
+public with sharing class LexCICInputSolutionController {
+ @AuraEnabled
+ public static List<Case> initCICInputSolution(String recordId) {
+ return [Select Id,inquiry_detail__c,answer_detail_content__c from Case Where Id = :recordId];
+ }
+
+ @AuraEnabled
+ public static InitCustomCloneData initCustomClone(String recordId) {
+ InitCustomCloneData customCloneData = new InitCustomCloneData();
+ String caseRecordType = [select Id,DeveloperName from RecordType where SobjectType = 'Case' and DeveloperName = 'CICRecordType'].Id;
+ customCloneData.caseRecordType = caseRecordType;
+ customCloneData.caseList = [Select Id,inquiry_detail__c,answer_detail_content__c from Case Where Id = :recordId];
+ return customCloneData;
+ }
+
+ @AuraEnabled
+ public static InitNewCICContactData initNewCICContact(String recordId) {
+ InitNewCICContactData initNewCICContactData = new InitNewCICContactData();
+ String contactRecordType = [select Id,DeveloperName from RecordType where SobjectType = 'Contact' and DeveloperName = 'Agency'].Id;
+ String caseRecordType = [select Id,DeveloperName from RecordType where SobjectType = 'Case' and DeveloperName = 'CICRecordType'].Id;
+ initNewCICContactData.contactRecordType = contactRecordType;
+ initNewCICContactData.caseRecordType = caseRecordType;
+ List<Contact> contactList = [select id, Account.Id,Account.Parent_Parent__c ,RecordTypeId from Contact where Id= :recordId];
+ initNewCICContactData.contactList = contactList;
+ return initNewCICContactData;
+ }
+ public class InitNewCICContactData{
+ @AuraEnabled
+ public String contactRecordType;
+ @AuraEnabled
+ public String caseRecordType;
+ @AuraEnabled
+ public List<Contact> contactList;
+ }
+ public class InitCustomCloneData{
+
+ @AuraEnabled
+ public String caseRecordType;
+ @AuraEnabled
+ public List<Case> caseList;
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexCustomClone/lexCustomClone.js b/force-app/main/default/lwc/lexCustomClone/lexCustomClone.js
index 8e437bd..9280a1d 100644
--- a/force-app/main/default/lwc/lexCustomClone/lexCustomClone.js
+++ b/force-app/main/default/lwc/lexCustomClone/lexCustomClone.js
@@ -3,15 +3,17 @@
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
-import init from '@salesforce/apex/CaseController.initForlexCustomCloneButton';
-import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
-import { updateRecord } from 'lightning/uiRecordApi';
+// import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
+import init from '@salesforce/apex/LexCICInputSolutionController.initCustomClone';
+
+// import { updateRecord } from 'lightning/uiRecordApi';
export default class lexCustomClone extends LightningElement {
@api recordId;
IsLoading = true;
inquirydetail;
answerdetailcontent;
+ RecordType;
@wire(CurrentPageReference)
getStateParameters(currentPageReference) {
@@ -34,16 +36,39 @@
recordId: this.recordId
}).then(result => {
this.IsLoading = false;
- this.inquirydetail = result.inquirydetail;
- this.answerdetailcontent = result.answerdetailcontent;
- var url = "/500/e?retURL="+this.recordId+"&RecordType=01210000000QsYp&ent=Case"+
- "&00N10000003M4vA="+this.inquirydetail+
- "&00N10000003M4v8="+this.answerdetailcontent;
- window.open(url);
+ if (result != null) {
+ console.log(result);
+ this.initData = result;
+ if(result !=null) {
+ if(result.caseList.length>0) {
+ this.inquirydetail = result.caseList[0].inquiry_detail__c;
+ this.answerdetailcontent = result.caseList[0].answer_detail_content__c;
+ }
+ this.RecordType = result.caseRecordType;
+ }
+ }
+ this.cancelSubmit().then(res=>{
+ this.IsLoading=false;
+ this.dispatchEvent(new CloseActionScreenEvent());
+ });
+ // var url = "/500/e?retURL="+this.recordId+"&RecordType=01210000000QsYp&ent=Case"+
+ // "&00N10000003M4vA="+this.inquirydetail+
+ // "&00N10000003M4v8="+this.answerdetailcontent;
+ // window.open(url);
}).catch(error => {
console.log('error='+error);
}).finally(() => {
});
+
}
-}
\ No newline at end of file
+ async cancelSubmit(){
+ // window.open('/apex/NewAndEditCase?retURL='+this.recordId+'&RecordType='+this.RecordType+'&inquiry_detail__c='+this.inquirydetail+'&answer_detail_content__c='+this.answerdetailcontent);
+ window.open('/apex/NewAndEditCase?retURL='+this.recordId+'&RecordType='+this.RecordType+'&inquiry_detail__c='+this.inquirydetail+'&answer_detail_content__c='+this.answerdetailcontent);
+ }
+}
+
+//oldjs
+// /500/e?retURL={!Case.Id}&RecordType=01210000000QsYp&ent=Case
+// &00N10000003M4vA={!HTMLENCODE(Case.inquiry_detail__c)}
+// &00N10000003M4v8={!HTMLENCODE(Case.answer_detail_content__c)}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.html b/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.html
new file mode 100644
index 0000000..2ef2898
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.html
@@ -0,0 +1,5 @@
+<template>
+ <div class="Holder" 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/lexNewCICContact/lexNewCICContact.js b/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.js
new file mode 100644
index 0000000..6ba3a80
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.js
@@ -0,0 +1,99 @@
+import { LightningElement, track, wire, api } from 'lwc';
+import { CurrentPageReference } from 'lightning/navigation';
+import { NavigationMixin } from 'lightning/navigation';
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+
+import init from '@salesforce/apex/LexCICInputSolutionController.initNewCICContact';
+
+
+
+
+
+export default class lexNewCICContact extends LightningElement {
+ IsLoading = true;
+ @api recordId;
+ initData = {};
+ def_account_id = '';
+ RecordType = '';
+
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+
+ this.recordId = str;
+ }
+ }
+ }
+ connectedCallback(){
+ // this.recordId ='0030l00000wy2IgAAI';
+ init({
+ recordId: this.recordId
+ }).then(result => {
+ if (result != null) {
+ console.log(result);
+ this.initData = result;
+ if(result !=null) {
+ if(result.contactList.length>0) {
+ if(result.contactList[0].RecordTypeId == result.contactRecordType) {
+ this.def_account_id = result.contactList[0].Account.Id;
+ } else {
+ this.def_account_id = result.contactList[0].Account.Parent_Parent__c;
+ }
+
+ }
+ this.RecordType = result.caseRecordType;
+ }
+ this.cancelSubmit().then(res=>{
+ this.IsLoading=false;
+ this.dispatchEvent(new CloseActionScreenEvent());
+ });
+ }
+ }).catch(error => {
+ console.log(error);
+ })
+ }
+
+ async cancelSubmit(){
+ // this.navigateToNewObjectPage();
+ window.open('/apex/NewAndEditCase?retURL='+this.recordId+'&def_contact_id='+this.recordId+'&def_account_id='+this.def_account_id+'&RecordType='+this.RecordType);
+ }
+
+
+ navigateToNewObjectPage() {
+ alert();
+ const defaultFieldValues =encodeDefaultFieldValues({
+ retURL: this.recordId,
+ def_contact_id: this.recordId,
+ def_account_id: this.def_account_id,
+ RecordType: this.RecordType
+ });
+
+ this[NavigationMixin.Navigate]({
+ type: 'standard__objectPage',
+ attributes: {
+ objectApiName: 'Case',
+ actionName: 'new'
+ },
+ state: {
+ nooverride: '1',
+ defaultFieldValues: defaultFieldValues
+ }
+ });
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+
+
+
+}
+
+//old js
+// /500/e?retURL=%2F{!Contact.Id}&def_contact_id={!Contact.Id}&
+// def_account_id={!IF(Contact.RecordTypeId='01210000000QfWi',Account.Id,Account.Parent_Parent__c)}
+// &RecordType=01210000000QsYp&ent=Case
+
+//01210000000QfWi: select Id,DeveloperName from RecordType where SobjectType = 'Contact' and DeveloperName = 'Agency'
+//01210000000QsYp: select Id,DeveloperName from RecordType where SobjectType = 'Case' and DeveloperName = 'CICRecordType'
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.js-meta.xml b/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.js-meta.xml
new file mode 100644
index 0000000..7c418fa
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewCICContact/lexNewCICContact.js-meta.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexCreateOnCALLFromAsset">
+ <apiVersion>51.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__AppPage</target>
+ <target>lightning__RecordPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ <target>lightningCommunity__Page_Layout</target>
+ </targets>
+</LightningComponentBundle>
\ No newline at end of file
--
Gitblit v1.9.1