zhangqian
2023-05-24 ce5755dba4d5ea5e0544e77a7c66685779f36a9e
新建备品借出申请(QIS)

1
2个文件已修改
5个文件已添加
205 ■■■■■ 已修改文件
force-app/main/default/classes/RentalApplyWebService.cls 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js-meta.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js-meta.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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,
force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls
New file
@@ -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;
    }
}
force-app/main/default/classes/lexEquipmentRentalApply_FromSACtl.cls-meta.xml
New file
@@ -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>
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>
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="dispatchOCSMQARAHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js
New file
@@ -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);
    }
}
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js-meta.xml
New file
@@ -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>