From ce5755dba4d5ea5e0544e77a7c66685779f36a9e Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@prec-tech.com>
Date: 星期三, 24 五月 2023 16:09:14 +0800
Subject: [PATCH] 新建备品借出申请(QIS)
---
force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls | 68 +++++++++++++++++
force-app/main/default/classes/RentalApplyWebService.cls | 1
force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls-meta.xml | 5 +
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js-meta.xml | 21 +++++
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.html | 5 +
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js | 103 +++++++++++++++++++++++++
force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js-meta.xml | 2
7 files changed, 204 insertions(+), 1 deletions(-)
diff --git a/force-app/main/default/classes/RentalApplyWebService.cls b/force-app/main/default/classes/RentalApplyWebService.cls
index b7c2147..b63ac41 100644
--- a/force-app/main/default/classes/RentalApplyWebService.cls
+++ b/force-app/main/default/classes/RentalApplyWebService.cls
@@ -1762,6 +1762,7 @@
/**
* 娉ㄦ畫鐢宠澶囧搧鐨勭鎺�
*/
+ @AuraEnabled
WebService static String RentalApplyCheckForSAoneEle(String SaID) {
Statu_Achievements__c Sac = [select id,
SalesChannel__c,
diff --git a/force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls b/force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls
new file mode 100644
index 0000000..ac2bb95
--- /dev/null
+++ b/force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls
@@ -0,0 +1,68 @@
+public with sharing class lexEquipmentRentalApply_FromSACtl {
+ public lexEquipmentRentalApply_FromSACtl() {
+
+ }
+
+ //鑾峰彇褰撳墠鐧诲綍浜虹殑 id
+ @AuraEnabled
+ public static UserResult UserInfo_Owner() {
+ UserResult result = new UserResult();
+ ID myUserID = UserInfo.getUserId();
+ try {
+ User tempUser =
+ [select Id,isFormal_Stuff__c,FirstName,LastName from user where id = : myUserID ];
+ result.id = tempUser.Id;
+ result.isFormalStuff = tempUser.isFormal_Stuff__c;
+ result.firstName = tempUser.FirstName;
+ result.lastName = tempUser.LastName;
+ } catch (exception e) {
+
+ result.result = e.getMessage();
+ }
+ return result;
+ }
+
+ @AuraEnabled
+ public static InitData init(String recordId){
+ InitData res = new initData();
+ try {
+ Statu_Achievements__c rep = [select Id,Name,Opp_Hospitalo__c,Opp_DeptClass__c,Opp_ClassName__c,Opportunity__c from Statu_Achievements__c where Id =: recordId];
+ res.achievement = rep.Name;
+ res.hospital = rep.Opp_Hospitalo__c;
+ res.departmentClass = rep.Opp_DeptClass__c;
+ res.oppClassName = rep.Opp_ClassName__c;
+ res.opportunity = rep.Opportunity__c;
+ return res;
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
+ }
+ }
+ public class InitData{
+ @AuraEnabled
+ public String achievement;
+ @AuraEnabled
+ public String hospital;
+ @AuraEnabled
+ public String departmentClass;
+ @AuraEnabled
+ public String oppClassName;
+ @AuraEnabled
+ public String opportunity;
+ }
+
+ public class UserResult {
+ @AuraEnabled
+ public string result;
+ public UserResult( ) {
+ result = 'Success';
+ }
+ @AuraEnabled
+ public string id;
+ @AuraEnabled
+ public Boolean isFormalStuff;
+ @AuraEnabled
+ public string firstName;
+ @AuraEnabled
+ public string lastName;
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls-meta.xml b/force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls-meta.xml
new file mode 100644
index 0000000..9bbf7b4
--- /dev/null
+++ b/force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.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>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js-meta.xml b/force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js-meta.xml
index 4267927..c499f08 100644
--- a/force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js-meta.xml
+++ b/force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js-meta.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>56.0</apiVersion>
- <isExposed>false</isExposed>
+ <isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
diff --git a/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.html b/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.html
new file mode 100644
index 0000000..ae58c6c
--- /dev/null
+++ b/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.html
@@ -0,0 +1,5 @@
+<template>
+ <div class="dispatchOCSMQARAHolder" 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/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js b/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js
new file mode 100644
index 0000000..0794680
--- /dev/null
+++ b/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js
@@ -0,0 +1,103 @@
+import { LightningElement,wire,track,api} from 'lwc';
+import { CurrentPageReference, NavigationMixin} from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import init from '@salesforce/apex/lexEquipmentRentalApply_FromSACtl.init';
+import UserInfo_Owner from '@salesforce/apex/lexEquipmentRentalApply_FromSACtl.UserInfo_Owner';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+import RentalApplyCheckForSAoneEle 聽from '@salesforce/apex/RentalApplyWebService.RentalApplyCheckForSAoneEle';
+
+// 鏂板缓澶囧搧鍊熷嚭鐢宠(娉ㄦ畫)
+export default class LexEquipmentRentalApply_FromSA extends LightningElement {
+ @api recordId;
+ IsLoading = true;
+
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ console.log(111);
+ console.log(currentPageReference);
+
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ console.log("str");
+ console.log(str);
+ this.recordId = str;
+ }
+ }
+ }
+
+ connectedCallback(){
+ console.log(this.recordId);
+ // if(rtn == 'Fin'){
+ // var url = '/a0t/e?CF00N10000006pvpb={!URLENCODE(Statu_Achievements__c.Name)}&CF00N10000006pvpb_lkid={!URLENCODE(Statu_Achievements__c.Id)}&retURL=%2F{!URLENCODE(Statu_Achievements__c.Id)}&CF00N10000003Mp1d={!URLENCODE(Statu_Achievements__c.Opp_Hospitalo__c)}&CF00N10000003Mp1d_lkid={!URLENCODE(Statu_Achievements__c.Opp_Hospital_Id__c)}&Name={!URLENCODE('*')}&00N10000003Msk0={!URLENCODE('浜у搧璇曠敤')}&00N10000003Msk5={!URLENCODE('宸茶喘寰呰揣')}&CF00N10000003O3V6={!URLENCODE(Statu_Achievements__c.Opp_DeptClass__c)}&CF00N10000003O3V6_lkid={!URLENCODE(Statu_Achievements__c.Opp_DeptClass_Id__c)}&CF00N10000003Mp2R={!Statu_Achievements__c.Opp_ClassName__c}&CF00N10000003Mp2R_lkid={!URLENCODE(Statu_Achievements__c.Opp_Class_Id__c)}&CF00N10000005HzRr={!URLENCODE($User.LastName&' '&$User.FirstName)}&CF00N10000005HzRr_lkid={!URLENCODE($User.Id)}&CF00N10000005HzRz={!URLENCODE($User.LastName&' '&$User.FirstName)}&CF00N10000005HzRz_lkid={!URLENCODE($User.Id)}&00N10000003OJzc={!URLENCODE($User.LastName&' '&$User.FirstName)}&CF00N10000003O3VB={!URLENCODE(Statu_Achievements__c.Opportunity__c)}&CF00N10000003O3VB_lkid={!URLENCODE(Statu_Achievements__c.OpportunityId__c)}'
+ // window.top.location.href = url;
+ // }else{
+ // alert(rtn );
+ // }
+ RentalApplyCheckForSAoneEle({SaID:this.recordId})
+ .then(res=>{
+ if(res == 'Fin'){
+ init({
+ recordId: this.recordId
+ }).then(result => {
+ this.IsLoading = false;
+
+ if (result != null) {
+ UserInfo_Owner({}).then(res=>{
+ if(res.isFormalStuff == 'true'){
+ this.showToast('璇曠敤鏈熷唴锛屼笉鑳界敵璇�','warning');
+ return;
+ }else{
+ const defaultValues = encodeDefaultFieldValues({
+ Statu_Achievements: result.achievement,
+ retURL:this.recordId,
+ Hospital: result.hospital,
+ Name:'*',
+ Strategic_dept: result.departmentClass,
+ Account:result.oppClassName,
+ Demo_purpose1:'浜у搧璇曠敤',
+ demo_purpose2:'宸茶喘寰呰揣',
+ Person_In_Charge:res.lastName + res.firstName,
+ applyUser:res.lastName + res.firstName,
+ Loaner_received_staff:res.lastName + res.firstName,
+ Follow_UP_Opp:result.opportunity
+ });
+
+ this[NavigationMixin.Navigate]({
+ type: 'standard__objectPage',
+ attributes: {
+ objectApiName: 'Rental_Apply__c',
+ actionName: 'new'
+ },
+ state:{
+ defaultFieldValues: this.defaultValues
+ }
+ })
+ }
+ })
+ this.dispatchEvent(new CloseActionScreenEvent());
+ // window.location.reload();
+ }
+ }).catch(error => {
+ console.log("error");
+ console.log(error);
+ })
+ }else{
+ this.showToast(res,'warning');
+ return;
+ }
+ })
+ .catch(err=>{console.log(err)})
+ }
+
+ showToast(message, type) {
+ const evt = new ShowToastEvent({
+ title: '',
+ message: message,
+ variant: type
+ });
+ this.dispatchEvent(evt);
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js-meta.xml b/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js-meta.xml
new file mode 100644
index 0000000..c499f08
--- /dev/null
+++ b/force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js-meta.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>56.0</apiVersion>
+ <isExposed>true</isExposed>
+ <targets>
+ <target>lightning__AppPage</target>
+ <target>lightning__RecordPage</target>
+ <target>lightning__HomePage</target>
+ <target>lightning__RecordAction</target>
+ <!-- 灞忓箷娴侀厤缃� -->
+ <target>lightning__FlowScreen</target>
+ </targets>
+ <!-- 瀹氫箟鍙橀噺 -->
+ <targetConfigs>
+ <targetConfig targets="lightning__FlowScreen">
+ <!-- name js涓娇鐢ㄧ殑鍙橀噺锛屼粠灞忓箷娴佷腑鑾峰彇鍙傛暟 label 鍦ㄥ睆骞曟祦鐨勮LWC鐨勮缃腑鏄剧ず -->
+ <property name="recordId" type="String" label="recordId"/>
+ <!-- <property name="rentalApplyIds" type="String[]" label="rentalApplyIds"/> -->
+ </targetConfig>
+ </targetConfigs>
+</LightningComponentBundle>
\ No newline at end of file
--
Gitblit v1.9.1