LiJinHuan
2023-06-06 ae8abf10439475e838d49a3fd5e400c61b7f5174
Merge branch 'LEX_dev' of http://47.92.229.245:8089/r/lightningupdate into LEX_dev
2个文件已修改
5个文件已添加
244 ■■■■■ 已修改文件
force-app/main/default/classes/lexConsumApply_FromAccountCtl.cls 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/lexConsumApply_FromAccountCtl.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexConsumApply_FromAccount/lexConsumApply_FromAccount.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexConsumApply_FromAccount/lexConsumApply_FromAccount.js 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexConsumApply_FromAccount/lexConsumApply_FromAccount.js-meta.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/lexConsumApply_FromAccountCtl.cls
New file
@@ -0,0 +1,71 @@
public with sharing class lexConsumApply_FromAccountCtl {
    public lexConsumApply_FromAccountCtl() {
    }
    @AuraEnabled
    public static List<FieldDefinition> fieldDefineApp(){
        try {
            List<FieldDefinition> rep = [Select QualifiedApiName, EntityDefinition.KeyPrefix, DurableId From FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Consum_Apply__c'];
            return rep;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
    //获取当前登录人的 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 {
            Account rep = [select Id,Name,Hospital__c,Department_Class__c from Account where Id =: recordId];
            res.name = rep.Name;
            res.hospitalName = rep.Hospital__c;
            res.departClass = rep.Department_Class__c;
            return res;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
    public class InitData{
        @AuraEnabled
        public String hospitalName;
        @AuraEnabled
        public String departClass;
        @AuraEnabled
        public String name;
    }
    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/lexConsumApply_FromAccountCtl.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>57.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/lwc/lexConsumApply_FromAccount/lexConsumApply_FromAccount.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/lexConsumApply_FromAccount/lexConsumApply_FromAccount.js
New file
@@ -0,0 +1,97 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference, NavigationMixin} from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import  init  from '@salesforce/apex/lexConsumApply_FromAccountCtl.init';
import  fieldDefineApp  from '@salesforce/apex/lexConsumApply_FromAccountCtl.fieldDefineApp';
import UserInfo_Owner from '@salesforce/apex/lexConsumApply_FromAccountCtl.UserInfo_Owner';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
export default class LexConsumApply_FromAccount 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);
        init({
            recordId: this.recordId
        }).then(result=>{
            UserInfo_Owner({}).then(res=>{
                if(res.isFormalStuff == 'true'){
                    this.showToast('试用期内,不能申请','warning');
                    return;
                }else{
                    fieldDefineApp({}).then(resp=>{
                        var fieldmap = new Map();
                        for (var i=0; i< resp.length; i++) {
                            var record = resp[i];
                            fieldmap.set(record.QualifiedApiName,record.DurableId.toString().split('.')[1]);
                        }
                    })
                    .catch(e=>{console.log(e)})
                    const defaultValues = encodeDefaultFieldValues({
                        Hospital__c:result.hospitalName,
                        Strategic_dept__c:result.departClass,
                        Account__c:result.name,
                        Name:'*',
                        demo_purpose2__c:'OPD试用',
                        Person_In_Charge__c:res.lastName + res.firstName,
                        applyUser__c:res.lastName + res.firstName
                    });
                    this[NavigationMixin.Navigate]({
                        type: 'standard__objectPage',
                        attributes: {
                            objectApiName: 'Consum_Apply__c',
                            actionName: 'new'
                        },
                        state:{
                            defaultFieldValues: this.defaultValues
                        }
                    })
                }
            })
            .catch(error => {
                console.log("error");
                console.log(error);
            })
        })
        .catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
            this.dispatchEvent(new CloseActionScreenEvent());
        });
    }
    showToast(message, type) {
        const evt = new ShowToastEvent({
            title: '',
            message: message,
            variant: type
        });
        this.dispatchEvent(evt);
    }
}
force-app/main/default/lwc/lexConsumApply_FromAccount/lexConsumApply_FromAccount.js-meta.xml
New file
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexEquipmentRentalApply_FromSA">
    <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"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
force-app/main/default/lwc/lexEquipmentRentalApply_FromQIS2/lexEquipmentRentalApply_FromQIS2.js
@@ -1,9 +1,9 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference, NavigationMixin} from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import  init  from '@salesforce/apex/lexEquipmentRentalApply_FromQISCtl.rentalApp';
import  rentalApp  from '@salesforce/apex/lexEquipmentRentalApply_FromQISCtl.init';
import UserInfo_Owner from '@salesforce/apex/lexEquipmentRentalApply_FromQISCtl.UserInfo_Owner';
import  init  from '@salesforce/apex/LexEquipmentRentalApply_FromQISCtl.rentalApp';
import  rentalApp  from '@salesforce/apex/LexEquipmentRentalApply_FromQISCtl.init';
import UserInfo_Owner from '@salesforce/apex/LexEquipmentRentalApply_FromQISCtl.UserInfo_Owner';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
@@ -78,17 +78,17 @@
                        }else{
                            const defaultValues = encodeDefaultFieldValues({
                                QIS_Report__c: this.recordId,
                                Hospital: result.hospital,
                                Strategic_dept: result.departmentClass,
                                Account:result.hospitalDepartment,
                                Demo_purpose1:'维修代用',
                                demo_purpose2:'索赔QIS',
                                Hospital__c: result.hospital,
                                Strategic_dept__c: result.departmentClass,
                                Account__c:result.hospitalDepartment,
                                Demo_purpose1__c:'维修代用',
                                demo_purpose2__c:'索赔QIS',
                                Name:'*',
                                Person_In_Charge:res.lastName + res.firstName,
                                applyUser:res.lastName + res.firstName,
                                Loaner_received_staff:res.lastName + res.firstName,
                                QIS_number:result.name,
                                QISRepair:result.repair
                                Person_In_Charge__c:res.lastName + res.firstName,
                                applyUser__c:res.lastName + res.firstName,
                                Loaner_received_staff__c:res.lastName + res.firstName,
                                QIS_number__c:result.name,
                                QISRepair__c:result.repair
                            });
                            this[NavigationMixin.Navigate]({
force-app/main/default/lwc/lexEquipmentRentalApply_FromSA/lexEquipmentRentalApply_FromSA.js
@@ -51,18 +51,18 @@
                                return;
                            }else{
                                const defaultValues = encodeDefaultFieldValues({
                                    Statu_Achievements: result.achievement,
                                    Statu_Achievements__c: result.achievement,
                                    retURL:this.recordId,
                                    Hospital: result.hospital,
                                    Hospital__c: 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
                                    Strategic_dept__c: result.departmentClass,
                                    Account__c:result.oppClassName,
                                    Demo_purpose1__c:'产品试用',
                                    demo_purpose2__c:'已购待货',
                                    Person_In_Charge__c:res.lastName + res.firstName,
                                    applyUser__c:res.lastName + res.firstName,
                                    Loaner_received_staff__c:res.lastName + res.firstName,
                                    Follow_UP_Opp__c:result.opportunity
                                });
    
                                this[NavigationMixin.Navigate]({