zhangqian
2023-05-17 3528fcf8330187ef7476d13392d778f7b48734b6
遗失报告 提交待审核

1
5个文件已添加
164 ■■■■■ 已修改文件
force-app/main/default/classes/LexLostSubmitApprovalController.cls 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexLostSubmitApprovalController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLostSubmitApproval/lexLostSubmitApproval.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLostSubmitApproval/lexLostSubmitApproval.js 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexLostSubmitApproval/lexLostSubmitApproval.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexLostSubmitApprovalController.cls
New file
@@ -0,0 +1,45 @@
public with sharing class LexLostSubmitApprovalController {
    // 遗失报告 提交待审核
    @AuraEnabled
    public static InitData LexLostSubmitApprovalController(String recordId) {
        InitData res = new initData();
        try{
            List<LostReport_Detail__c> reportDetail = new List<LostReport_Detail__c>();
            LostReport__c report = [SELECT Id,Status__c FROM LostReport__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.statusTf = report.Status__c;
            reportDetail = [SELECT Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c FROM LostReport_Detail__c WHERE id = :recordId AND Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c != null];
            res.reportDetailList = reportDetail;
            System.debug(LoggingLevel.INFO, '*** zq: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** zq: ' + e);
        }
        return res;
    }
    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String statusTf;
        @AuraEnabled
        public List<LostReport_Detail__c> reportDetailList;
    }
    //提交按钮
    @AuraEnabled
    public static String submit(String recordId) {
       try {
        LostReport__c rac = [SELECT Id,Status__c FROM LostReport__c WHERE Id = :recordId LIMIT 1];
        rac.Id = rac.Id;
        rac.Status__c = '填写完毕';
        update rac;
        return '1';
       } catch (Exception ex) {
        System.debug(LoggingLevel.INFO, '*** zq: ' + ex);
        // return errMsg;
        return ex.getMessage();
       }
    }
}
force-app/main/default/classes/LexLostSubmitApprovalController.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/lexLostSubmitApproval/lexLostSubmitApproval.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="exampleHolder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexLostSubmitApproval/lexLostSubmitApproval.js
New file
@@ -0,0 +1,98 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import updateForSubmitButton  from '@salesforce/apex/ReportController.updateForSubmitButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init from '@salesforce/apex/LexLostSubmitApprovalController.LexLostSubmitApprovalController';
import submit from '@salesforce/apex/LexLostSubmitApprovalController.submit';
// 遗失报告 提交待审核
export default class LexLostSubmitApproval 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(){
        this.IsLoading = false;
        // this.submit();
        init({recordId:this.recordId})
        .then(result=>{
            console.log("LexConsumablesLost------>>>",result)
            if (result.statusTf == "填写完毕" ||  result.statusTf == "申请中" || result.statusTf == "已批准") {
              this.showToast('请确认遗失报告状态,已经提交过的申请,不能重复提交','warning')
              return;
            }
            if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) {
                return;
            }
            // -----------------------------------------------------------------------------------------------------
            if (result.reportDetailList.length > 0) {
              var qianpinDate = new Date(result.reportDetailList[0].Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c);
              for (var i = 1; i < result.reportDetailList.length; i++) {
                var d = new Date(result.reportDetailList[i].Rental_Apply_Equipment_Set_Detail__r.Lost_item_check_day__c);
                if(d < qianpinDate){
                  qianpinDate = d;
                }
              }
              qianpinDate.setDate(qianpinDate.getDate() + 90);
              var d = '' + qianpinDate.getFullYear()+'/' + (qianpinDate.getMonth()+1) + '/' + qianpinDate.getDate();
              this.showToast('请您的上级领导于' + d + '前完成遗失报告审批,否则备品自动断念,遗失报告自动取消。','warning');
            }
            // -----------------------------------------------------------------------------------------------------
            this.submitApproval()
        })
        .catch(e=>{console.log(e)})
        .finally(()=>{
            this.dispatchEvent(new CloseActionScreenEvent());
        })
     }
     showToast(msg,type) {
      const event = new ShowToastEvent({
          title: '',
          message: msg,
          variant: type
      });
      this.dispatchEvent(event);
      this.dispatchEvent(new CloseActionScreenEvent());
    }
     updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
    submitApproval(){
      submit({
        recordId: this.recordId
      }).then(result=>{
        if(result != '1'){
          this.showToast(result,"error");
          return
        }
        this.updateRecordView(this.recordId);
        // this.showToast("提交成功","success");
        this.dispatchEvent(new CloseActionScreenEvent());
      })
   }
}
force-app/main/default/lwc/lexLostSubmitApproval/lexLostSubmitApproval.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>