From ab7b9ad962ebd038a8fced2544f569157b5a3e1e Mon Sep 17 00:00:00 2001
From: denny chen <chenbangcai@prec-tech.com>
Date: 星期一, 24 四月 2023 13:36:32 +0800
Subject: [PATCH] 页面描述(修理)-对象(修理)

---
 force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js-meta.xml     |   11 
 force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp          |   78 ++++
 force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraHelper.js     |   20 +
 force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.css             |   12 
 force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp-meta.xml |    5 
 force-app/main/default/classes/lexNewRepairAuraController.cls-meta.xml     |    5 
 force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.html            |   93 +++++
 force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraController.js |  106 ++++++
 force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js              |  171 ++++++++++
 force-app/main/default/classes/lexNewRepairAuraController.cls              |  438 +++++++++++++++++++++++++++
 10 files changed, 939 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp
new file mode 100644
index 0000000..7ecbcbb
--- /dev/null
+++ b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp
@@ -0,0 +1,78 @@
+<!--
+  2023/04/14  鏂板缓锛堜慨鐞嗭級
+-->
+<aura:component implements="flexipage:availableForRecordHome,force:lightningQuickActionWithoutHeader,force:hasRecordId,lightning:actionOverride,lightning:isUrlAddressable" access="global" controller="lexNewRepairAuraController">
+            <aura:attribute name="urlStr" type="String"/>
+            <aura:attribute name="recordId" type="String"/>
+            <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
+            <lightning:notificationsLibrary aura:id="notifLib"/>
+              <!--   <aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
+            <aura:attribute name="fields" type="String[]" default="['Name','AnnualRevenue','Industry']" />
+            <aura:attribute name="recordId" type="String"/>
+            <lightning:notificationsLibrary aura:id="notifLib"/>
+
+            <lightning:recordForm
+                    objectApiName="Account"
+                    fields="{!v.fields}"
+                    onsuccess="{!c.handleSuccess}" />
+</aura:component> -->
+    
+    <!-- <aura:attribute name = "recordId" type = "Id" default = ""/>
+    <aura:attribute name="title" type="string"/>
+    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
+    <aura:attribute name="layout" type="LayoutDescriberHelper.LayoutWrapper"/>
+    <aura:attribute name="record_data" type="Map"/>
+    <aura:attribute name="section_names" type="List"/>
+    <aura:attribute name="showSpinner" type="Boolean" default = "False"/>
+    <aura:attribute name="staticResource" type="Map"/>
+    <aura:attribute name="pi_fields_map" type="Map"/>
+    <aura:attribute name="isClone" type="Boolean" default = "False"/>
+    <ltng:require scripts="{! $Resource.AWSService+'/AWSService.js' }" />
+    <ltng:require scripts="{! $Resource.jquery183minjs }" />
+    <aura:registerEvent name="NewAgencyContactEvent" type="c:NewAgencyContactEvent"/> -->
+    
+    <div class="{! v.container_class}">
+        <!-- header -->
+        <header class="slds-modal__header">
+            <!-- <h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate"> -->
+                <div class="ptBody">
+                  <div class="content" style="font-size: 18px;font-weight: bold;">
+                      <img src="/img/s.gif" alt="淇悊" class="pageTitleIcon" title="淇悊" />
+                      <span class="pageType">淇悊缂栬緫
+                          <span class="titleSeparatingColon">:</span>
+                      </span>
+                      <span class="pageDescription">鏂板缓淇悊</span>
+                      <div class="blank">&nbsp;</div>
+                  </div>
+                  <!-- <div class="links">
+                      <a href="javascript:openPopupFocusEscapePounds(%27https://help.salesforce.com/apex/htdoor?loc=help&amp;target=repairs_edit.htm&amp;section=repairs&amp;language=zh_CN&amp;release=234.18.8&amp;instance=CS117&amp;showSplash=true%27, %27Help%27, 700, 600, %27width=700,height=600,resizable=yes,toolbar=yes,status=no,scrollbars=yes,menubar=yes,directories=no,location=no,dependant=no%27, false, false);"
+                          title="姝ら〉闈㈢殑甯姪 锛堟柊绐楀彛锛�">
+                          <span class="helpLink">姝ら〉闈㈢殑甯姪</span>
+                          <img src="/img/s.gif" alt="" class="helpIcon" />
+                      </a>
+                  </div> -->
+              </div>
+              <div class="ptBreadcrumb"></div>
+            <!-- </h2> -->
+        </header>
+
+        <div class="slds-modal__content slds-p-around_medium">
+          <!-- <aura:iteration items="1,2,3,4,5" var="item">
+            {!item}
+          </aura:iteration> -->
+            <!-- <lightning:recordEditForm recordId="{!v.recordId}"
+                           objectApiName="Repair__c">
+                <lightning:messages />
+                <div class="slds-col slds-size_1-of-2">
+                    Your lightning:inputField components here
+                <lightning:inputField fieldName="Source_QIS__c" />
+                </div>
+                <lightning:button class="slds-m-top_small" type="submit" label="Create new" />
+            </lightning:recordEditForm> -->
+            <c:lexNewRepairLWC recordId="{!v.recordId}" urlStr="{!v.urlStr}" />
+        </div>
+    </div>
+    <!-- <div class="exampleHolder">
+        <c:newRepairLWC recordId="{!v.recordId}"/>
+    </div> -->
+</aura:component>
\ No newline at end of file
diff --git a/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp-meta.xml b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp-meta.xml
new file mode 100644
index 0000000..632b900
--- /dev/null
+++ b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAura.cmp-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>54.0</apiVersion>
+    <description>A Lightning Component Bundle</description>
+</AuraDefinitionBundle>
diff --git a/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraController.js b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraController.js
new file mode 100644
index 0000000..135ffaa
--- /dev/null
+++ b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraController.js
@@ -0,0 +1,106 @@
+({
+    doInit1 : function(component, event, helper) {
+        let rid = component.get('v.recordId');
+        console.log(rid);
+        let pid = window.location.href.replace("https://","").split("/");
+        pid = pid[pid.length-1].replace("new?","");
+        let jsonobj = {};
+        console.log(pid);
+        pid.split("&").forEach(function(v){ 
+
+            console.log(v);
+            let param = v.split("=");
+            jsonobj[param[0]] = param[1];
+        }); 
+        let urlStr = JSON.stringify(jsonobj);
+        console.log(urlStr);
+        // if (rid) {}
+        /*let pid = null;
+        if(!rid){
+            pid = window.location.href.replace("https://","").split("/")[4];
+        }
+        let isClone = component.get('v.isClone');
+        if(!rid || isClone){
+            component.set('v.title',$A.get("$Label.c.New")+'.瀹㈡埛浜哄憳');
+        }else{
+            component.set('v.title',$A.get("$Label.c.Edit")+'.瀹㈡埛浜哄憳');
+        }
+        
+        let record_type_id = null;
+        let pageref = component.get("v.pageReference")
+        if(!record_type_id && pageref){
+           record_type_id = pageref.state.recordTypeId
+        }
+        component.set("v.showSpinner", true);*/
+        helper.CallBackAction(component,'init',{
+            recordId : rid,
+            urlStr : urlStr
+            },function(data){
+            console.log("data");
+            console.log(data);
+        });
+    },
+    doInit : function(component, event, helper) {
+        let rid = component.get('v.recordId');
+        // console.log(rid);
+        let pid = window.location.href.replace("https://","").split("/");
+        pid = pid[pid.length-1].replace("new?","");
+        let jsonobj = {};
+        // console.log(pid);
+        pid.split("&").forEach(function(v){ 
+
+            // console.log(v);
+            let param = v.split("=");
+            jsonobj[param[0]] = param[1];
+        }); 
+        let urlStr = JSON.stringify(jsonobj);
+        // console.log(urlStr);
+        component.set('v.urlStr',urlStr);
+        // create a one-time use instance of the serverEcho action
+        // in the server-side controller
+        /*var action = component.get("c.init");
+        action.setParams({
+            recordId : rid,
+            urlStr : urlStr
+        });
+
+        // Create a callback that is executed after 
+        // the server-side action returns
+        action.setCallback(this, function(response) {
+            console.log("response");
+            console.log(response);
+            // var state = response.getState();
+            if (state === "SUCCESS") {
+                // Alert the user with the value returned 
+                // from the server
+                alert("From server: " + response.getReturnValue());
+
+                // You would typically fire a event here to trigger 
+                // client-side notification that the server-side 
+                // action is complete
+            }
+            else if (state === "INCOMPLETE") {
+                // do something
+            }
+            else if (state === "ERROR") {
+                var errors = response.getError();
+                if (errors) {
+                    if (errors[0] && errors[0].message) {
+                        console.log("Error message: " + 
+                                 errors[0].message);
+                    }
+                } else {
+                    console.log("Unknown error");
+                }
+            }
+        });
+
+        // optionally set storable, abortable, background flag here
+
+        // A client-side action could cause multiple events, 
+        // which could trigger other events and 
+        // other server-side action calls.
+        // $A.enqueueAction adds the server-side action to the queue.
+        $A.enqueueAction(action);*/
+    }
+})
\ No newline at end of file
diff --git a/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraHelper.js b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraHelper.js
new file mode 100644
index 0000000..f1ab449
--- /dev/null
+++ b/force-app/main/default/aura/lexNewRepairAura/lexNewRepairAuraHelper.js
@@ -0,0 +1,20 @@
+({
+    CallBackAction  : function(component,action_name,para,callback) {
+        var action = component.get("c." + action_name.trimStart().replace("c.",""));
+        if(para){
+            action.setParams(para);
+        }
+        if(callback){
+            action.setCallback(this,function(data){
+                callback(data);
+            });
+        }
+        
+        $A.enqueueAction(action);
+    },
+    ShowToast : function(paras){
+        var toastEvent = $A.get("e.force:showToast");
+        toastEvent.setParams(paras);
+        toastEvent.fire();
+    }
+})
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexNewRepairAuraController.cls b/force-app/main/default/classes/lexNewRepairAuraController.cls
new file mode 100644
index 0000000..e8e1279
--- /dev/null
+++ b/force-app/main/default/classes/lexNewRepairAuraController.cls
@@ -0,0 +1,438 @@
+/**
+ * 2023-04-14  
+ * Lightning new Repair
+ */
+public with sharing class lexNewRepairAuraController {
+    public static String sobjectTypeValue = 'Repair__c';
+    //鏌ヨRepair鏁版嵁  淇悊瀵硅薄鐨刵ew鍜寀pdate 
+    @AuraEnabled
+    public static ReturnData init(String recordId,String urlStr) {
+        ReturnData res = new ReturnData();
+        String sobjectId = [SELECT CustomObjectId,CustomObjectName  FROM CustomObjectUserLicenseMetrics   where CustomObjectName ='Repair' limit 1].CustomObjectId;
+        String Input_Required_Field_Msg = Label.Input_Required_Field_Msg;
+        String PIPL_Name_Label = Label.PIPL_Name_Label;
+        String PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg;
+        Map<string,string> mso = (Map<string,string>)JSON.deserialize(urlStr, Map<string,string>.class);
+        system.debug('mso='+mso);
+        if (recordId != null) {
+            res.recordTypeId = [SELECT Id,RecordTypeId FROM Repair__c WHERE Id = :recordId].RecordTypeId;
+            res.status = true;
+        }
+        String RepairSubOrderAWSDataId;
+            // AssignValueFromUrl(mso,controller.getRecord());
+            //閫氳繃id鏌�      闂
+            //PIPL zhj 2022-11-11 start
+            //浠庢姤淇瓙鍗曡繃鏉�00N10000009H1rR
+        if (mso.containsKey('CF00N10000009H1rR_lkid')) {
+            String repairSubOrderId = mso.get('CF00N10000009H1rR_lkid');
+            System.debug('repairSubOrderId = ' + repairSubOrderId);
+            //鏌ヨAWSDataId
+            List<RepairSubOrder__c> rso = [select AWS_Data_Id__c from RepairSubOrder__c where Id=:repairSubOrderId];
+            if(rso.size() > 0){
+                //todo 浠庢姤淇瓙鍗曡繃鏉ワ紝闇�瑕佽В瀵嗘姤淇汉  lwc鏄惁闇�瑕佽繘琛岃В瀵嗗鐞嗭紵
+               RepairSubOrderAWSDataId = rso[0].AWS_Data_Id__c;
+               res.AWS_Data_Id = rso[0].AWS_Data_Id__c;
+               res.status = true;
+            }
+        }
+        //PIPL zhj 2022-11-11 end
+        List<Repair__c> rc = new List<Repair__c>();
+        system.debug('retURL=' + mso.containsKey('retURL'));
+        if (mso.containsKey('retURL')) {
+            String RepairId = mso.get('retURL').substring(1);
+            System.debug('RepairId = ' + RepairId);
+            rc = [select Hospital__c,Department_Class__c,Account__c,Dealer__c,Incharge_Staff_Contact__c,Incharge_Staff__c,  RepairSubOrder__c,On_Call_ID__c,QIS_ID__c,  InsReport__c,Rental_Apply_Equipment_Set_Detail__c from Repair__c where id =:RepairId ];
+            System.debug('rc = ' + rc);
+            if(rc.size() > 0){
+                //宸叉湁鏁版嵁璧嬪��
+                 //鍖婚櫌
+                res.Hospital = rc[0].Hospital__c;
+                //鎴樼暐绉戝鍒嗙被
+                res.Department_Class = rc[0].Department_Class__c;
+                //绉戝
+                res.Account = rc[0].Account__c;
+                //缁忛攢鍟嗗悕
+                res.Dealer = rc[0].Dealer__c;
+                //淇悊濮旀墭鑰咃紙鍛樺伐锛�
+                res.Incharge_Staff_Contact = rc[0].Incharge_Staff_Contact__c;
+                //淇悊濮旀墭鑰�(FSE)
+                res.Incharge_Staff = rc[0].Incharge_Staff__c;
+                //鎶ヤ慨瀛愬崟RepairSubOrder__c
+                res.RepairSubOrder = rc[0].RepairSubOrder__c;
+                //鏌ヨAWSDataId
+                List<RepairSubOrder__c> rso = [select AWS_Data_Id__c from RepairSubOrder__c where Id=:rc[0].RepairSubOrder__c];
+                if(rso.size() > 0){
+                    RepairSubOrderAWSDataId = rso[0].AWS_Data_Id__c;
+                    res.AWS_Data_Id = rso[0].AWS_Data_Id__c;
+                }
+                //On-Call鍙风爜On_Call_ID__c
+                res.On_Call_ID = rc[0].On_Call_ID__c;
+                //QIS鍙风爜QIS_ID__c
+                res.QIS_ID = rc[0].QIS_ID__c;
+                //鐐规鎶ュ憡涔nsReport__c
+                res.InsReport = rc[0].InsReport__c;
+                //鍊熷嚭澶囧搧閰嶅涓�瑙堟槑缁哛ental_Apply_Equipment_Set_Detail__c
+                res.Rental_Apply_Equipment_Set_Detail = rc[0].Rental_Apply_Equipment_Set_Detail__c;
+
+                res.status = true;
+            }
+           
+        }
+        //2023/04/23  lwc鐨勪繚瀛樺苟鏂板缓 淇濆瓨鍚庡埛鏂伴〉闈�
+        // PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo('Repair__c');
+        // PIHelper.PIIntegration piIntegrationAddress = PIHelper.getPIIntegrationInfo('Address__c');
+        // PIHelper.PIIntegration piIntegrationContact = PIHelper.getPIIntegrationInfo('Contact');
+        // PIHelper.PIIntegration piIntegrationRepairSubOrder = PIHelper.getPIIntegrationInfo('RepairSubOrder__c');
+        // String staticResource = JSON.serialize(piIntegration);
+        // //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+        // String staticResourceV2 = JSON.serialize(PIHelper.getPIIntegrationInfo('Repair__cV2'));
+        // //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
+        // String staticResourceAddress = JSON.serialize(piIntegrationAddress);
+        // String staticResourceContact = JSON.serialize(piIntegrationContact);
+        // String staticResourceRepairSubOrder = JSON.serialize(piIntegrationRepairSubOrder);
+        // List<String> encryptedAPIList = piIntegration.PIFields;
+        // String sobjectPrefix = piIntegration.sobjectPrefix;
+
+        //save and new url   page澶勪繚瀛樺苟鏂板缓璺宠浆鍦板潃锛歯ew?recordTypeId=01210000000QmS9&additionalParams=retURL%3D%252Fa0J%252Fo%26&count=1
+        // String newUrl = '/setup/ui/recordtypeselect.jsp?ent=' + sobjectId + '&retURL=/' + sobjectPrefix + '/o&save_new_url=/' + sobjectPrefix + '/e?retURL=%2F' + sobjectPrefix + '%2Fo';
+        // res.newUrl = newUrl;
+
+        return res;
+    }
+
+    public static String getAllFieldNames(String objName){
+        Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
+        List<Schema.sObjectField> fields = schemaMap.get(objName).getDescribe().fields.getMap().values();
+        
+        String fieldString = '';
+        for( Schema.sObjectField field : fields ){
+            fieldString += field + ',';
+        }
+        fieldString = fieldString.removeEnd(',');
+        
+        return fieldString;
+    }
+
+    // @AuraEnabled
+    public static List <LayoutDescriberHelper.LayoutSection > init1(String recordId,String urlStr) {
+        String sobjectId = [SELECT CustomObjectId,CustomObjectName  FROM CustomObjectUserLicenseMetrics   where CustomObjectName ='Repair' limit 1].CustomObjectId;
+        Boolean isNewMode = true;
+        String Input_Required_Field_Msg = Label.Input_Required_Field_Msg;
+        String PIPL_Name_Label = Label.PIPL_Name_Label;
+        String PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg;
+        String rtTypeId;
+        // String sobjecttypeForFrontEnd = sobjectTypeValue;
+        //鑾峰彇鎵�鏈夊瓧娈�
+        // List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Repair__c').getDescribe().fields.getMap().keyset());  
+        // Add fields to controller. This is to avoid the SOQL error in visualforce page
+        // if(!Test.isRunningTest()){
+        //    controller.addFields(fieldList);  
+        // }
+        // SObject obj = controller.getRecord();        
+        if(recordId == ''){
+            //鏇存柊  椤甸潰鍒ゆ柇
+            // isNewMode = false;
+            Repair__c repairData = [select Id,RecordTypeId,AWS_Data_Id__c,Address_AWS_Data_Id__c,Contact_AWS_Data_Id__c,Address_Contacts_Encrypt__c,Address_Contacts_Name_Encrypt__c,Address_Telephone_Encrypt__c,Address_ZipCode_Encrypt__c,Detailed_Address_Encrypt__c from Repair__c where id =: recordId];
+            rtTypeId = repairData.RecordTypeId;
+            String AWSDataId = repairData.AWS_Data_Id__c;
+            String DecryptAWSDataId = String.valueOf(repairData.Address_AWS_Data_Id__c);
+            String ContactAWSDataId = String.valueOf(repairData.Contact_AWS_Data_Id__c);
+        }else{
+            //get url 鍙傛暟
+            // Map<string,string> mso = ApexPages.currentPage().getParameters();
+            Map<string,string> mso = (Map<string,string>)JSON.deserialize(urlStr, Map<string,string>.class);
+            system.debug('mso='+mso);
+            // AssignValueFromUrl(mso,controller.getRecord());
+            //閫氳繃id鏌�      闂
+            //PIPL zhj 2022-11-11 start
+            //浠庢姤淇瓙鍗曡繃鏉�00N10000009H1rR
+            if (mso.containsKey('CF00N10000009H1rR_lkid')) {
+                String repairSubOrderId = mso.get('CF00N10000009H1rR_lkid');
+                System.debug('repairSubOrderId = ' + repairSubOrderId);
+                //鏌ヨAWSDataId
+                List<RepairSubOrder__c> rso = [select AWS_Data_Id__c from RepairSubOrder__c where Id=:repairSubOrderId];
+                if(rso.size() > 0){
+                   String RepairSubOrderAWSDataId = rso[0].AWS_Data_Id__c;
+                }
+            }
+            //PIPL zhj 2022-11-11 end
+            List<Repair__c> rc = new List<Repair__c>();
+            system.debug('retURL=' + mso.containsKey('retURL'));
+            if (mso.containsKey('retURL')) {
+                String RepairId = mso.get('retURL').substring(1);
+                System.debug('RepairId = ' + RepairId);
+                rc = [select Hospital__c,Department_Class__c,Account__c,Dealer__c,Incharge_Staff_Contact__c,Incharge_Staff__c,  RepairSubOrder__c,On_Call_ID__c,QIS_ID__c,  InsReport__c,Rental_Apply_Equipment_Set_Detail__c from Repair__c where id =:RepairId ];
+                System.debug('rc = ' + rc);
+                if(rc.size() > 0){
+                    //宸叉湁鏁版嵁璧嬪��  defaultValue
+                     /*//鍖婚櫌
+                    controller.getRecord().put('Hospital__c',rc[0].Hospital__c);
+                    //鎴樼暐绉戝鍒嗙被
+                    controller.getRecord().put('Department_Class__c',rc[0].Department_Class__c);
+                    //绉戝
+                    controller.getRecord().put('Account__c',rc[0].Account__c);
+                    //缁忛攢鍟嗗悕
+                    controller.getRecord().put('Dealer__c',rc[0].Dealer__c);
+                    //淇悊濮旀墭鑰咃紙鍛樺伐锛�
+                    controller.getRecord().put('Incharge_Staff_Contact__c',rc[0].Incharge_Staff_Contact__c);
+                    //淇悊濮旀墭鑰�(FSE)
+                    controller.getRecord().put('Incharge_Staff__c',rc[0].Incharge_Staff__c);
+                    //鎶ヤ慨瀛愬崟RepairSubOrder__c
+                    controller.getRecord().put('RepairSubOrder__c',rc[0].RepairSubOrder__c);
+                    //鏌ヨAWSDataId
+                    List<RepairSubOrder__c> rso = [select AWS_Data_Id__c from RepairSubOrder__c where Id=:rc[0].RepairSubOrder__c];
+                    if(rso.size() > 0){
+                        RepairSubOrderAWSDataId = rso[0].AWS_Data_Id__c;
+                    }
+                    //On-Call鍙风爜On_Call_ID__c
+                    controller.getRecord().put('On_Call_ID__c',rc[0].On_Call_ID__c);
+                    //QIS鍙风爜QIS_ID__c
+                    controller.getRecord().put('QIS_ID__c',rc[0].QIS_ID__c);
+                    //鐐规鎶ュ憡涔nsReport__c
+                    controller.getRecord().put('InsReport__c',rc[0].InsReport__c);
+                    //鍊熷嚭澶囧搧閰嶅涓�瑙堟槑缁哛ental_Apply_Equipment_Set_Detail__c
+                    controller.getRecord().put('Rental_Apply_Equipment_Set_Detail__c',rc[0].Rental_Apply_Equipment_Set_Detail__c);*/
+                }
+               
+            }
+            
+            // rtTypeId = ApexPages.currentPage().getParameters().get('RecordType');
+            rtTypeId = mso.get('RecordType');
+            if(String.isBlank(rtTypeId)||String.isEmpty(rtTypeId)){
+                List<RecordType> rtList = new List<RecordType>([select Id,DeveloperName from RecordType  where SobjectType ='Repair__c' and DeveloperName ='Repair']);
+                rtTypeId = rtList[0].Id;
+            }
+        }
+        LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Repair__c','classic');
+        List <LayoutDescriberHelper.LayoutSection > layoutSections = LayoutWrapperValue.layoutSections;
+        String layoutSectionsStr = JSON.serialize(layoutSections); //for dynamic add readonly attribute
+        List<String> requiredFieldAPIList = LayoutWrapperValue.requiredFieldAPIList;
+        Map<String,String> fieldAPIToLabelMap = LayoutWrapperValue.fieldAPIToLabelMap;
+        String requiredFieldAPIListStr = JSON.serialize(requiredFieldAPIList);
+        String fieldAPIToLabelMapStr = JSON.serialize(fieldAPIToLabelMap);
+        PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo('Repair__c');
+        PIHelper.PIIntegration piIntegrationAddress = PIHelper.getPIIntegrationInfo('Address__c');
+        PIHelper.PIIntegration piIntegrationContact = PIHelper.getPIIntegrationInfo('Contact');
+        PIHelper.PIIntegration piIntegrationRepairSubOrder = PIHelper.getPIIntegrationInfo('RepairSubOrder__c');
+        String staticResource = JSON.serialize(piIntegration);
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+        String staticResourceV2 = JSON.serialize(PIHelper.getPIIntegrationInfo('Repair__cV2'));
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
+        String staticResourceAddress = JSON.serialize(piIntegrationAddress);
+        String staticResourceContact = JSON.serialize(piIntegrationContact);
+        String staticResourceRepairSubOrder = JSON.serialize(piIntegrationRepairSubOrder);
+        List<String> encryptedAPIList = piIntegration.PIFields;
+        String sobjectPrefix = piIntegration.sobjectPrefix;
+        //鑾峰彇lookup瀛楁
+        List<String> VLookUpFields = new List<String>();
+        for (LayoutDescriberHelper.LayoutSection ls : layoutSections) {
+            for (LayoutDescriberHelper.LayoutField lf : ls.layoutFields) {
+                if (lf.fieldAPI != '' && lf.fieldType == 'reference') {
+                    VLookUpFields.add(lf.fieldAPI);
+                }
+            }
+        }
+        String VLookUpFieldsJson = Json.serialize(VLookUpFields);
+        System.debug(LoggingLevel.INFO, '*** layoutSectionsLWC: ' + layoutSections);
+        return layoutSections;
+    }
+
+    // 浠巙rl鍙傛暟璧嬪�煎埌褰撳墠椤甸潰
+    public static void AssignValueFromUrl(Map<string,string> mso, sobject sobj){
+        
+        String sobject_name = sobj.getSObjectType().getDescribe().getName();
+        Map<string,object> temp = new Map<string,object>();
+        Map<string,FieldDefinition> fdm = new Map<string,FieldDefinition>();
+        List<FieldDefinition> fds = [SELECT Id, DurableId, QualifiedApiName,ValueTypeId , EntityDefinitionId, NamespacePrefix,EntityDefinition.NamespacePrefix, DeveloperName, MasterLabel, Label FROM FieldDefinition where EntityDefinition.QualifiedApiName = :sobject_name];
+        for(FieldDefinition fd : fds){
+            //system.debug(fd.DurableId);
+            fdm.put(fd.DurableId.split('\\.')[1],fd);
+        }
+        
+        for(string key : mso.keySet()){
+            if (key.toLowerCase() == 'id') {
+                System.debug('skip id assign');
+                continue;
+            }
+            string new_key = key;
+            system.debug('new_key='+new_key);
+            if(new_key.contains('_lkid')){
+                new_key = new_key.replace('_lkid', '');
+                new_key = new_key.substring(2);
+            }else{
+                if(temp.containsKey(new_key)){
+                    continue;
+                }
+            }
+            
+            system.debug('now new_key='+new_key);
+            if(fdm.containsKey(new_key)){
+                system.debug('fdm.get(new_key)='+fdm.get(new_key));
+                string val_str = mso.get(key);
+                system.debug('val_str='+val_str);
+                /*鏃犻渶鍋歞ecode锛宻f鍐呴儴宸茬粡鍋氬ソ
+                try{
+                    val_str = EncodingUtil.urlDecode(mso.get(key),'UTF-8');
+                }catch(Exception e){
+                    continue;
+                    system.debug('Exception from get Key:'+e.getMessage());
+                    system.debug(e.getStackTraceString());
+                } */             
+                object val = null;
+                string type_id = fdm.get(new_key).ValueTypeId;
+                // address, boolean, date, datetime, double, id, location, string, time
+                if(string.isBlank(val_str)){
+                    val = null;
+                }else if(type_id == 'boolean'){
+                    if(val_str == '1'){
+                        val = true;
+                    }else{
+                        val = boolean.valueOf(val_str);
+                    }
+                }else if(type_id == 'date'){
+                    //
+                    try{
+                        val = date.parse(val_str);
+                    }catch(Exception e){
+                        system.debug('val_str='+val_str);
+                        system.debug(e.getMessage());
+                        system.debug(e.getStackTraceString());
+                        try{
+                            val = date.valueOf(val_str);
+                        }catch(Exception ee){
+                            system.debug('val_str='+val_str);
+                            system.debug(ee.getMessage());
+                            system.debug(ee.getStackTraceString());
+                            continue;
+                        }
+                    }
+                }else if(type_id == 'datetime'){
+                    //
+                    try{
+                        val = datetime.parse(val_str);
+                    }catch(Exception e){
+                        system.debug('val_str='+val_str);
+                        system.debug(e.getMessage());
+                        system.debug(e.getStackTraceString());
+                        try{
+                            val = datetime.valueOf(val_str);
+                        }catch(Exception ee){
+                            system.debug('val_str='+val_str);
+                            system.debug(ee.getMessage());
+                            system.debug(ee.getStackTraceString());
+                            continue;
+                        }
+                    }
+                }else if(type_id == 'double' || type_id == 'number'){
+                    try{
+                        val = decimal.valueOf(val_str.replace(',', ''));
+                    }catch(Exception ee){
+                        system.debug('val_str='+val_str);
+                        system.debug(ee.getMessage());
+                        system.debug(ee.getStackTraceString());
+                        continue;
+                    }
+                    
+                }else if(type_id == 'id' || type_id == 'string'){
+                    val = val_str;
+                }else{
+                    system.debug('type_id='+type_id+' is not support to convert');
+                    continue;
+                }
+                temp.put(fdm.get(new_key).QualifiedApiName,val);
+            }else{
+                system.debug(key+' is not in fdm');
+            }
+        }
+        
+        for(string key : temp.keySet()){
+            system.debug('assign '+key+'='+temp.get(key));
+            try{
+                sobj.put(key, temp.get(key));
+            }catch(Exception e){
+                system.debug(e.getMessage());
+                system.debug(e.getStackTraceString());
+            }
+        }
+    }
+
+    public class RetrievalData {
+        @AuraEnabled
+        public String Status1;
+        @AuraEnabled
+        public String Status2;
+        @AuraEnabled
+        public String RepairName;
+        @AuraEnabled
+        public String SAPRepairNo;
+        @AuraEnabled
+        public String SerialNumber;
+        @AuraEnabled
+        public String onSiteRepair;
+        @AuraEnabled
+        public String workLocationSelect;
+        @AuraEnabled
+        public String State_Hospital;
+        @AuraEnabled
+        public String HospitalName;
+        @AuraEnabled
+        public Repair__c repair;
+
+        public RetrievalData(){
+            repair = new Repair__c();
+        }
+    }
+
+    public class RepairData {
+        @AuraEnabled
+        public Boolean IFCheck;
+        @AuraEnabled
+        public Repair__c repair;
+        public RepairData(Repair__c RepairInfo){
+            IFCheck = null;
+            repair = RepairInfo;
+        }
+    }
+    //2023/04/18 杩斿洖鏌ヨ缁撴灉鍜岀姸鎬�
+    public class ReturnData {
+        //鍒ゆ柇鏄惁鏈塕epair鐨勯粯璁ゅ��
+        @AuraEnabled
+        public Boolean status;
+        // @AuraEnabled
+        // public Repair__c repair;
+        //todo 鎶ヤ慨浜�
+        @AuraEnabled
+        public String AWS_Data_Id;
+        //鍖婚櫌
+        @AuraEnabled
+        public String Hospital;
+        @AuraEnabled
+        public String Department_Class;
+        @AuraEnabled
+        public String Account;
+        @AuraEnabled
+        public String Dealer;
+        @AuraEnabled
+        public String Incharge_Staff_Contact;
+        @AuraEnabled
+        public String Incharge_Staff;
+        @AuraEnabled
+        public String RepairSubOrder;
+        @AuraEnabled
+        public String On_Call_ID;
+        @AuraEnabled
+        public String QIS_ID;
+        @AuraEnabled
+        public String InsReport;
+        @AuraEnabled
+        public String Rental_Apply_Equipment_Set_Detail;
+        @AuraEnabled
+        public String recordTypeId;
+        // @AuraEnabled
+        // public String newUrl;
+
+        public ReturnData(){
+            this.status = false;
+        }
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexNewRepairAuraController.cls-meta.xml b/force-app/main/default/classes/lexNewRepairAuraController.cls-meta.xml
new file mode 100644
index 0000000..40d6793
--- /dev/null
+++ b/force-app/main/default/classes/lexNewRepairAuraController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>54.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.css b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.css
new file mode 100644
index 0000000..adaad9f
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.css
@@ -0,0 +1,12 @@
+.exampleHolder{
+    position: relative;
+    top: 0;
+    width: 0;
+    left: 0;
+    right: 0;
+    margin: 0 auto;
+}
+.repairTitle{
+	--slds-c-accordion-heading-font-size: 1.05rem;
+	--slds-c-accordion-summary-color-background:#f3f3f3;
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.html b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.html
new file mode 100644
index 0000000..71e2e87
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.html
@@ -0,0 +1,93 @@
+<template>
+  	<div class="exampleHolder" if:true={isLoading}>
+        <lightning-spinner alternative-text="Loading" size="small"></lightning-spinner>
+    </div>
+	<div class="newRepair">
+		<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-2">
+			<!-- onsectiontoggle={handleSectionToggle} -->
+			<lightning-accordion allow-multiple-sections-open="true"
+						                         active-section-name={activeSections}>
+			<!-- Repair__c -->
+			<lightning-record-edit-form onload={handleRecordEditFormLoad} onsubmit={handleSubmit} onsuccess={handleSucess} onerror={handleError} object-api-name='{objectName}' record-type-id={recordTypeId} record-id={recordIdStr}>
+				<lightning-messages></lightning-messages>
+				<template if:true={uiPageLayoutView}>
+					<lightning-layout multiple-rows="true">
+						<lightning-layout-item size="12">
+							<!-- active-section-name={activeSections} -->
+							
+							<template for:each={uiPageLayoutView.sections} for:item="section">
+							        <lightning-accordion-section name={section.id} key={section.id} label={section.heading} class="repairTitle">
+										<lightning-layout multiple-rows="true" style="margin-top: 10px;">
+											<template for:each={section.layoutRows} for:item="layoutRow">
+												<template for:each={layoutRow.layoutItems} for:item="layoutItem">
+													<template for:each={layoutItem.layoutComponents} for:item="layoutComponent">
+														<lightning-layout-item key={layoutComponent.apiName} size="6" padding="horizontal-small">
+															<template if:true={layoutItem.editableForNew}>
+															<lightning-input-field data-fieldname={layoutComponent.apiName}
+															field-name={layoutComponent.apiName} name={layoutComponent.apiName} required={layoutItem.required}>
+															</lightning-input-field>
+															</template>
+															<!-- <template if:false={layoutItem.editableForNew}> -->
+																<!-- 淇悊鍙椾粯鐣彿 -->
+																<!-- <template if:true={layoutComponent.apiName}>
+																<lightning-output-field field-name={layoutComponent.apiName}>
+																</lightning-output-field>
+																</template> -->
+															<!-- </template> -->
+														</lightning-layout-item>
+													</template>
+												</template>
+											</template>
+										</lightning-layout>
+									</lightning-accordion-section>
+							</template>
+						</lightning-layout-item>
+					</lightning-layout>
+				</template>
+				<lightning-messages></lightning-messages>
+				<div class="" style="text-align: center;">
+		            <lightning-button
+		                label="鍙栨秷"
+		                onclick={handleCancel}
+		            ></lightning-button>
+		            <lightning-button
+		                type="submit"
+		                name="save"
+		                label="淇濆瓨"
+		                style="margin-left: 10px;"
+		            ></lightning-button>
+		            <lightning-button if:true={hasRecordId}
+		            	name="saveAndNew"
+		            	type="submit"
+		                label="淇濆瓨骞舵柊寤�"
+		                onclick={handleSubmitAndNew}
+		                style="margin-left: 10px;"
+		            ></lightning-button>
+		        </div>
+			</lightning-record-edit-form>
+			</lightning-accordion>
+		</div>
+		<!-- <div class="footer-background-class">
+			<div class="slds-align_absolute-center slds-p-around_xx-small">
+				<lightning-button class="slds-m-around_xx-small"
+				title="Cancel" label="Cancel"
+				onclick={closeNewObjectModal}>
+				</lightning-button>
+				<lightning-button variant="brand" title="Save"
+				onclick={submitRecordForm} name="Save" label="Save">
+				</lightning-button>
+			</div>
+		</div> -->
+	</div>
+<!-- a0J0l00000Ep9XHEAZ -->
+<!--   <lightning-record-edit-form record-id="" object-api-name='{objectName}'>
+    <lightning-input-field field-name="Delivered_Product__c"> </lightning-input-field>
+    <lightning-button
+        class="slds-m-top_small"
+        variant="brand"
+        type="submit"
+        label="Update"
+    >
+    </lightning-button>
+</lightning-record-edit-form> -->
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js
new file mode 100644
index 0000000..cfe8142
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js
@@ -0,0 +1,171 @@
+import { LightningElement,wire,track,api} from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
+import { CloseActionScreenEvent } from 'lightning/actions';
+import { NavigationMixin } from 'lightning/navigation';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+
+import init from '@salesforce/apex/lexNewRepairAuraController.init';
+
+export default class lexNewRepairLWC extends NavigationMixin(LightningElement) {
+
+    // Flexipage provides recordId 
+    @api recordId;
+    // @api recordId;
+    @api urlStr;
+    @api objectApiName;
+
+    /* @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;
+           }
+         }
+     }*/
+
+    objectName = 'Repair__c';
+    uiPageLayoutView;
+    isNewMode;
+    //灞炴�ч粯璁ゅ��
+    defaultValue = {};
+    isLoading = true;
+    activeSections;
+    isSaveAndNew = false;
+    //鏇存柊鎿嶄綔鏃� 涓嶆樉绀轰繚瀛樻柊寤�
+    hasRecordId = false;
+    recordIdStr;
+    recordTypeId = '';
+
+    connectedCallback(){ 
+        console.log(this.recordId); 
+        console.log(JSON.parse(this.urlStr)); 
+        if (!this.recordId) {
+          this.hasRecordId = true;
+          // urlStr 浼犲弬澶勭悊
+          let urlObj = JSON.parse(this.urlStr);
+          if (urlObj.hasOwnProperty("CF00N10000009H1rR_lkid") || urlObj.hasOwnProperty("retURL") ) {
+              console.log('urlObj.hasOwnProperty:',urlObj);
+              //  init  鍚慍ontroller鍙戦�佽姹傝幏鍙栨暟鎹�
+              init({
+                recordId : this.recordId,urlStr : this.urlStr
+              }).then(result => {
+                  console.log("result");
+                  console.log(result);
+                  this.defaultValue = result;
+                  //杩斿洖缁撴灉璧嬪��
+                  if (result.status) {
+                    this.recordTypeId = result.recordTypeId;
+                  }
+              }).catch(error => {
+                  console.log("error");
+                  console.log(error);
+              }).finally(() => {
+              });  
+          }
+        }
+    }
+    //鑾峰彇Layout瀛楁
+    handleRecordEditFormLoad(event) {
+        if (event.detail.layout == undefined) {
+          return;
+        }
+        console.log('Layout => ', JSON.stringify(event.detail.layout));
+        this.uiPageLayoutView = event.detail.layout;
+        console.log('Layout1 => ',this.uiPageLayoutView);
+    
+       //椤甸潰鍐呭鍒濆鍖� del
+       //to del !  err: Delivered_Product   02i10000004tNXIAA2  Hospital  0011000001g11rDAAQ
+        // this.defaultValue['Delivered_Product'] = '02i10000004tMKgAAM';
+        // // this.defaultValue['Delivered_Product'] = '02i10000004tNXIAA2';
+        // this.defaultValue['Account'] = '0011000001g11rDAAQ';
+        // this.defaultValue['SalesOfficeCode_selection'] = '鍖椾含';
+        // this.defaultValue['On_site_repair'] = 'RC淇悊';
+        // this.defaultValue['Repair_Detail'] = 'testLwcSaveAndNew';
+        // this.defaultValue['Hospital'] = '0011000001g0R8vAAE';
+        // // this.defaultValue['Hospital'] = '0011000001g11rDAAQ';
+        // //  0011000000V9SG5AAN
+        // this.defaultValue['work_location_select'] = '鍖椾含鍔炰簨澶�';
+
+        const inputFields = this.template.querySelectorAll('lightning-input-field');
+        if (inputFields) {
+           inputFields.forEach(field => {
+            let fieldName = field.name.replace("__c","");
+            if (this.defaultValue.hasOwnProperty(fieldName)) {
+                field.value= this.defaultValue[fieldName];
+            }
+           });
+       }
+
+       let checkedSections = new Set();
+        if (this.uiPageLayoutView.sections.length > 0) {
+          for(const tabs of this.uiPageLayoutView.sections){
+            checkedSections.add(tabs.id);
+          }
+          this.activeSections =  Array.from(checkedSections);
+        }
+        this.isLoading = false;   
+        this.recordIdStr = this.recordId;
+              
+    }
+    //淇濆瓨  淇濆瓨鏂板缓鎻愪氦浜嬩欢
+    handleSubmit(event){
+       this.isLoading = true;
+       console.log("handleSubmit");
+       event.preventDefault();       // stop the form from submitting
+       const fields = event.detail.fields;
+       /*console.log("fields");
+       console.log(fields);*/
+       this.template.querySelector('lightning-record-edit-form').submit(fields);
+       // console.log("success");
+    }
+    handleSubmitAndNew(event){
+      this.isSaveAndNew = true;
+    }
+    //鎴愬姛鍚庤烦杞�
+    handleSucess(event){
+      // console.log("handleSucess");
+      const updatedRecord = event.detail.id;
+      console.log('onsuccess: ', updatedRecord);
+      if (this.isSaveAndNew) {
+          // console.log("isSaveAndNew");
+         window.location.reload();
+      }else if (event.detail.id) {
+        // console.log("NavigationMixin");
+         this[NavigationMixin.Navigate]({
+              type:'standard__recordPage',
+              attributes:{
+                  recordId:updatedRecord,
+                  objectApiName:this.objectName,
+                  actionName:'view'
+              }
+          });
+      }
+      this.isLoading = false;
+    }
+    //瀵硅薄楠岃瘉锛屽睘鎬ч獙璇�
+    handleError(event) {
+        console.log("handleError event");
+        console.log(JSON.stringify(event.detail));
+    }
+    handleCancel(event) {
+      window.location.href = "https://ocsm--partial.sandbox.lightning.force.com/lightning/o/Repair__c/list?filterName=Recent&0.source=alohaHeader";
+    }
+
+
+    showToast(theTitle, theMessage, theVariant) {
+          const event = new ShowToastEvent({
+              title: theTitle,
+              message: theMessage,
+              variant: theVariant
+          });
+          this.dispatchEvent(event);
+    }
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js-meta.xml b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js-meta.xml
new file mode 100644
index 0000000..2b7649d
--- /dev/null
+++ b/force-app/main/default/lwc/lexNewRepairLWC/lexNewRepairLWC.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+	<apiVersion>54.0</apiVersion>
+	<isExposed>true</isExposed>
+	<targets>
+		<target>lightning__RecordPage</target>
+		<target>lightning__AppPage</target>
+		<target>lightning__HomePage</target>
+		<target>lightning__RecordAction</target>
+	</targets>
+</LightningComponentBundle>
\ No newline at end of file

--
Gitblit v1.9.1