From b33ac610dffc90157dd4e0fcd94c08bca9c8b517 Mon Sep 17 00:00:00 2001
From: LiJinHuan <lijinhuan@prec-tech.com>
Date: 星期四, 06 七月 2023 16:17:30 +0800
Subject: [PATCH] 备品出借检测分析报告
---
force-app/main/default/classes/lexRentalApplyFaultReportController.cls | 73 ++++++++++++
force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js | 180 ++++++++++++++++++++++++++++++
force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js-meta.xml | 11 +
force-app/main/default/classes/lexRentalApplyFaultReportController.cls-meta.xml | 5
force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.html | 52 ++++++++
5 files changed, 321 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/classes/lexRentalApplyFaultReportController.cls b/force-app/main/default/classes/lexRentalApplyFaultReportController.cls
new file mode 100644
index 0000000..601319b
--- /dev/null
+++ b/force-app/main/default/classes/lexRentalApplyFaultReportController.cls
@@ -0,0 +1,73 @@
+/*
+ * @Description: 澶囧搧妫�娴嬪垎鏋愭姤鍛�
+ * @Author: [lijinhuan]
+ * @Date: 2023-06-25 20:04:41
+ * @LastEditors: [lijinhuan]
+ * @LastEditTime: 2023-07-06 15:50:03
+ */
+public without sharing class lexRentalApplyFaultReportController {
+ @AuraEnabled
+ public static List<RetObject> init(String recordId){
+ try {
+ List<RetObject> retObjectList = new List<RetObject>();
+ //澶囧搧鍊熷嚭鐢宠涓�瑙堟槑缁�
+ List<Rental_Apply_Equipment_Set_Detail__c> eList = [
+ SELECT Id, Name,
+ Rental_Apply__r.OCM_dept_category__c,
+ Rental_Apply__r.Name,
+ Rental_Apply__r.Person_In_Charge__c,
+ Rental_Apply__r.Person_In_Charge__r.Name,
+ Rental_Apply__r.demo_purpose2__c,
+ Rental_Apply__r.WorkPlace__c,
+ Rental_Apply__r.Hospital__r.Name,
+ Loaner_asset_no__c,
+ AssetName__c,
+ Fixture_Model_No__c,
+ SerialNumber_F__c,
+ Inspection_result_after__c,
+ Inspection_result_after_NG__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ WHERE Rental_Apply__c = :recordId
+ AND Inspection_result_after__c = 'NG'
+ AND Is_Body__c = true
+ ORDER BY Id];
+
+ List<Id> eIds = new List<Id>();
+ for(Rental_Apply_Equipment_Set_Detail__c e :eList){
+ eIds.add(e.Id);
+ }
+ //鏌ュ綋鍓嶆槑缁嗕笅鏈夊灏戞晠闅滄姤鍛�
+ // 0 娌℃湁鎶ュ憡
+ // Id 鏈� 鏈�鏂颁竴鏉′负鑽夋涓�
+ // 2 鏈夊緢澶氭潯
+ Map<String,String> sIdMap = New Map<String,String>();
+ for(Rental_Apply_Fault__c raf : [SELECT Id ,status__c ,Rental_Apply_Equipment_Set_Detail__c from Rental_Apply_Fault__c where Rental_Apply_Equipment_Set_Detail__c in :eIds Order By CreatedDate DESC]){
+ if(!sIdMap.containsKey(raf.Rental_Apply_Equipment_Set_Detail__c)){
+ sIdMap.put(raf.Rental_Apply_Equipment_Set_Detail__c,raf.Id);
+ }
+ }
+ for(Rental_Apply_Equipment_Set_Detail__c rae : eList){
+ RetObject temp = new RetObject();
+ temp.rae = rae;
+ if(sIdMap.containsKey(rae.Id)){
+ temp.faultId = sIdMap.get(rae.Id) ;
+ }else{
+ temp.faultId = '';
+ }
+ retObjectList.add(temp);
+ }
+ return retObjectList;
+ }
+ catch (Exception e) {
+ System.debug('*******lexRentalApplyFaultReportController******'+e.getMessage());
+ }
+ return null;
+ }
+
+ public class RetObject {
+ @AuraEnabled
+ public Rental_Apply_Equipment_Set_Detail__c rae;
+ @AuraEnabled
+ public String faultId;
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/lexRentalApplyFaultReportController.cls-meta.xml b/force-app/main/default/classes/lexRentalApplyFaultReportController.cls-meta.xml
new file mode 100644
index 0000000..754ecb1
--- /dev/null
+++ b/force-app/main/default/classes/lexRentalApplyFaultReportController.cls-meta.xml
@@ -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>
diff --git a/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.html b/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.html
new file mode 100644
index 0000000..cd7e839
--- /dev/null
+++ b/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.html
@@ -0,0 +1,52 @@
+<!--
+ * @Description: 澶囧搧妫�娴嬪垎鏋愭姤鍛�
+ * @Author: [lijinhuan]
+ * @Date: 2023-06-25 17:32:18
+ * @LastEditors: [lijinhuan]
+ * @LastEditTime: 2023-07-05 19:31:34
+-->
+<template>
+ <article class="slds-card" if:false={IsLoading} >
+ <!-- 鏍峰紡澶� -->
+ <div class="slds-card__header slds-grid" >
+ <header class="slds-media slds-media_center slds-has-flexi-truncate">
+ <div class="slds-media__body">
+ <h2 class="slds-card__header-title">
+ <!-- <a href="#" class="slds-card__header-link slds-truncate" title="澶囧搧妫�娴嬪垎鏋愭姤鍛�"> -->
+ <span>澶囧搧妫�娴嬪垎鏋愭姤鍛�</span>
+ <!-- </a> -->
+ </h2>
+ </div>
+ </header>
+ </div>
+ <!-- 鏍峰紡澶� -->
+ <div class="slds-card__body slds-card__body_inner" >
+ <div >
+ <!-- 鐢宠No.-->
+ <label class="slds-form-element__label" style="width:23%;text-align:right; margin-left: 20px;"> 鐢宠No.:</label>
+ <div class="slds-form-element__control" style="width:23%; text-align:left;display: inline-block;">{RentalApplyName}</div>
+ <!-- 澶囧搧鍑哄�熸媴褰� -->
+ <label class="slds-form-element__label" style="width:23%;text-align:right;margin-left: 15px;">澶囧搧鍑哄�熸媴褰�:</label>
+ <div class="slds-form-element__control" style="width:23%; text-align:left;display: inline-block;">{PersonInCharge}</div>
+ <!-- 鐢宠鑰呭姙浜嬪 -->
+ <label class="slds-form-element__label" style="width:23%;text-align:right; margin-left: 20px;"> 鐢宠No.:</label>
+ <div class="slds-form-element__control" style="width:23%; text-align:left;display: inline-block;">{WorkPlace}</div>
+ <!-- 浣跨敤鐩殑2 -->
+ <label class="slds-form-element__label" style="width:23%;text-align:right;margin-left: 15px;">浣跨敤鐩殑2:</label>
+ <div class="slds-form-element__control" style="width:23%; text-align:left;display: inline-block;">{DemoPurpose2}</div>
+ </div>
+ </div>
+ </article>
+ <div if:false={IsLoading} class="toast" style="width: 100%">
+ <div>
+ <template if:true={datas}>
+ <lightning-datatable key-field="Id" data={datas} columns={columns} hide-checkbox-column="true"
+ hide-row-number-column="true" onrowaction={callRowAction}>
+ </lightning-datatable>
+ </template>
+ <template if:true={error}>
+ {error}>
+ </template>
+ </div>
+ </div>
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js b/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js
new file mode 100644
index 0000000..9389d67
--- /dev/null
+++ b/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js
@@ -0,0 +1,180 @@
+/*
+ * @Description: 澶囧搧妫�娴嬪垎鏋愭姤鍛�
+ * @Author: [lijinhuan]
+ * @Date: 2023-06-25 17:32:18
+ * @LastEditors: [lijinhuan]
+ * @LastEditTime: 2023-07-06 16:04:00
+ */
+import { LightningElement, track, wire, api } from 'lwc';
+import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { updateRecord } from 'lightning/uiRecordApi';
+import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
+import { CloseActionScreenEvent } from 'lightning/actions';
+
+import init from '@salesforce/apex/lexRentalApplyFaultReportController.init';
+
+const columns = [
+ { label: 'No.', fieldName: 'Name',type: 'text'},
+ { label: '澶囧搧閰嶅鏄庣粏鍨嬪彿', fieldName: 'Fixture_Model_No__c',type: 'text' },
+ { label: '鍥哄畾璧勪骇鍙风爜', fieldName: 'Loaner_asset_no__c',type: 'text' },
+ { label: '鏈鸿韩缂栫爜', fieldName: 'SerialNumber_F__c',type: 'text'},
+ { label: '鎴樼暐绉戝鍒嗙被', fieldName: 'OCMdeptCategory',type: 'text' },
+ { label: '鍖婚櫌', fieldName: 'Hospital',type: 'text' },
+ { label: '妫�娴嬬粨鏋�', fieldName: 'Inspection_result_after__c',type: 'text'},
+ { label: '妫�娴婲G鍖哄垎', fieldName: 'Inspection_result_after_NG__c',type: 'text'},
+ {
+ type: "button", label: '鏁呴殰鎶ュ憡', initialWidth: 130, typeAttributes: {
+ label: '鏁呴殰鎶ュ憡',
+ name: 'View',
+ title: '鏁呴殰鎶ュ憡',
+ disabled: false,
+ value: 'RentalApplyFault',
+ iconPosition: 'left',
+ iconName:'utility:preview',
+ variant:'Brand'
+ }
+ },
+
+];
+export default class LexRentalApplyFaultReport extends NavigationMixin(LightningElement) {
+ @api recordId;
+ IsLoading = true;
+ datas = [];
+ columns = columns;
+ selectedRas = [];
+ RentalApplyName;
+ PersonInCharge;
+ WorkPlace;
+ DemoPurpose2;
+ @track error;
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference){
+ if(currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if(urlValue) {
+ let str = `${urlValue}`;
+ this.recordId = str;
+ }
+ }
+ }
+
+ connectedCallback(){
+ init({
+ recordId: this.recordId
+ }).then(result=>{
+ if(JSON.stringify(result)!= '' && result.length>0){
+ this.IsLoading = false;
+ this.records = result;
+ let resultList = [];
+ let objectTemp;
+
+ result.forEach(item => {
+ this.RentalApplyName = item.rae.Rental_Apply__r.Name;
+ this.PersonInCharge = item.rae.Rental_Apply__r.Person_In_Charge__r.Name;
+ this.WorkPlace = item.rae.Rental_Apply__r.WorkPlace__c;
+ this.DemoPurpose2 = item.rae.Rental_Apply__r.demo_purpose2__c;
+ // console.log(item);
+ objectTemp = item.rae;
+ objectTemp.OCMdeptCategory = item.rae.Rental_Apply__r.OCM_dept_category__c;
+ objectTemp.Hospital = item.rae.Rental_Apply__r.Hospital__r.Name;
+ // objectTemp.RentalApplyFault = '<a href="/'+item.faultId+'" >鐐瑰嚮鏌ョ湅</a>';
+ objectTemp.RentalApplyFault = item.faultId;
+ //console.log(JSON.stringify(objectTemp));
+ resultList.push(objectTemp);
+ });
+ this.datas = resultList;
+ }else{
+ // this.dispatchEvent(new CloseActionScreenEvent());
+ this.showToast('娌℃湁鍥炴敹妫�娴婲G鐨勪竴瑙�','warning');
+ this.updateRecordView(this.recordId);
+ return;
+ }
+ }).catch(err=>{
+ console.log("error:");
+ console.log(err);
+ this.error = err;
+ }).finally(()=>{
+
+ });
+ }
+
+
+ callRowAction(event) {
+ const rec = event.detail.row;
+ const actionName = event.detail.action.name;
+ // console.log(actionName);
+ if (actionName === 'View') {
+ console.log(rec.RentalApplyFault);
+ const recordId = rec.RentalApplyFault;
+ // this.handleAction(rec, 'view');
+ if(recordId != null && recordId !=''){
+ this[NavigationMixin.Navigate]({
+ type: 'standard__recordPage',
+ attributes: {
+ recordId: recordId,
+ objectApiName: 'Rental_Apply_Fault__c',
+ actionName: 'view'
+ }
+ })
+ // window.open("/"+faultId);
+ }else{
+ console.log('zheli00');
+ console.log('C:',rec);
+ // 鏂板缓璺宠浆
+ // window.open("/a5C/e?
+ // Name=*"
+ // + "&CF00N10000009I5UX_lKid=" + radetailId
+ // + "&CF00N10000009I5UX=" + radetailName
+ // + "&CF00N10000009I5UV_lKid=" + personId
+ // + "&CF00N10000009I5UV=" + personName
+ // + "&00N10000009I5Uh=" + purpose2
+ // + "&00N10000009I5UW=" + name
+ // + "&00N10000009I6jv=" + hospitalName
+ // + "&00N10000009I5Ua=" + serialNumber
+ // + "&00N10000009I5UP=" + fixtureNo
+ // + "&00N10000009I5Uf=" + workPlace
+ // + "&00N10000009I5UU=" + deptCategory);
+ let defaultFieldValues = {};
+ // console.log('zheli01');
+ defaultFieldValues['Name'] = '*';
+ defaultFieldValues['Rental_Apply_Equipment_Set_Detail__c'] = rec.Id;
+ defaultFieldValues['Person_In_Charge_User__c']= rec.Rental_Apply__r.Person_In_Charge__c;
+ defaultFieldValues['demo_purpose2__c']= rec.Rental_Apply__r.demo_purpose2__c;
+ defaultFieldValues['RentalApplyNo__c']= rec.Rental_Apply__r.Name;
+ defaultFieldValues['HospitalText__c']= rec.Hospital;
+ defaultFieldValues['Repair_product_body_number__c']= rec.SerialNumber_F__c;
+ defaultFieldValues['Fixture_Model_No__c']= rec.Fixture_Model_No__c;
+ defaultFieldValues['WorkPlace__c']= rec.Rental_Apply__r.WorkPlace__c;
+ defaultFieldValues['OCM_dept_category__c']= rec.OCMdeptCategory;
+ this[NavigationMixin.Navigate]({
+ type: 'standard__objectPage',
+ attributes: {
+ objectApiName: 'Rental_Apply_Fault__c',
+ actionName: 'new'
+ },
+ state: {
+ nooverride: '1',
+ defaultFieldValues: encodeDefaultFieldValues(defaultFieldValues)
+ }
+ });
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+ }
+ }
+ showToast(msg,type) {
+ const event = new ShowToastEvent({
+ message: msg,
+ variant: type
+ });
+ if(type == 'success'){
+ this.updateRecordView(this.recordId);
+ }
+ this.dispatchEvent(event);
+ this.dispatchEvent(new CloseActionScreenEvent());
+ }
+
+ updateRecordView(recordId) {
+ updateRecord({fields: { Id: recordId }});
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js-meta.xml b/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js-meta.xml
new file mode 100644
index 0000000..18324e5
--- /dev/null
+++ b/force-app/main/default/lwc/lexRentalApplyFaultReport/lexRentalApplyFaultReport.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.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