force-app/main/default/classes/AssetMaintainHeaderWebService.cls
@@ -37,6 +37,7 @@ } return '1'; } @AuraEnabled WebService static String abandon(String amhId) { Savepoint sp = Database.setSavepoint(); try { @@ -68,6 +69,13 @@ } return '1'; } @AuraEnabled public static Boolean applyPermission() { Schema.DescribeSobjectResult schemaMap = Schema.describeSObjects(new String[]{'TransferApply__c'})[0]; return schemaMap.isCreateable(); } @AuraEnabled WebService static String deleteApply(String amhId) { List<AssetMaintainHeader__c> amhList = [select id, Status__c from AssetMaintainHeader__c force-app/main/default/classes/LexVisitReportCancelController.cls
New file @@ -0,0 +1,49 @@ public with sharing class LexVisitReportCancelController { @AuraEnabled public static String init(String recordId){ try { Visit_Report__c vistReport = [SELECT Id, Status__c, OwnerId from Visit_Report__c WHERE Id = :recordId]; UserResult currentUser = userInfoOwner(); if(currentUser.Id == vistReport.OwnerId && vistReport.Status__c=='草案中'){ Visit_Report__c updateData = new Visit_Report__c(); updateData.Id = vistReport.Id; UPDATE updateData; return '取消成功'; }else{ return '只草案中状态及同行报告书的所有人可以取消'; } } catch (Exception e) { return e.getMessage(); } } //获取当前登录人的Id public static UserResult userInfoOwner() { UserResult result = new UserResult(); ID myUserID = UserInfo.getUserId(); try { User tempUser = [select id from user where id = : myUserID ]; result.id = tempUser.id; } catch (exception e) { result.result = e.getMessage(); } return result; } public class UserResult { @AuraEnabled public string result; public UserResult( ) { result = 'Success'; } @AuraEnabled public string id; //20210105 CHAN-BWX3YU you end } } force-app/main/default/classes/LexVisitReportCancelController.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>50.0</apiVersion> <status>Active</status> </ApexClass> force-app/main/default/lwc/lexAssetMaintainHeaderAbandon/lexAssetMaintainHeaderAbandon.css
New file @@ -0,0 +1,22 @@ .outerBorderCss{ border: 1px solid #D4D4D4; border-radius : 5px; border-top : 3px solid #565959; } .borderCss{ border: 1px solid #D4D4D4; border-radius : 5px; margin-bottom : 7px; border-top : 3px solid #565959; } .headerDorderCss{ border-top: 1px solid #565959; border-bottom: 1px solid #D4D4D4; padding:3px; } .centerCss{ text-align: center; } .centerCss .left{ margin-left: 100px; }/* sample css file */ force-app/main/default/lwc/lexAssetMaintainHeaderAbandon/lexAssetMaintainHeaderAbandon.html
New file @@ -0,0 +1,5 @@ <template> <div class="sisToOPDHolder" if:true={IsLoading}> <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner> </div> </template> force-app/main/default/lwc/lexAssetMaintainHeaderAbandon/lexAssetMaintainHeaderAbandon.js
New file @@ -0,0 +1,58 @@ import { LightningElement, track, wire, api } from 'lwc'; import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import abandon from '@salesforce/apex/AssetMaintainHeaderWebService.abandon'; import applyPermission from '@salesforce/apex/AssetMaintainHeaderWebService.applyPermission'; export default class lexAssetMaintainHeaderAbandon extends LightningElement { @api recordId; IsLoading = true; @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.log("str:"+str); this.recordId = str; } } } connectedCallback(){ applyPermission().then(res=>{ if(res=='false'){ this.showToast('没有操作废弃的权限','error'); }else{ abandon({ amhId: this.recordId }).then(result=>{ if(result=='1'){ this.showToast('已启动Batch,完成时会有邮件提醒','success'); }else{ this.showToast(result,'error'); } }) } }) } updateRecordView() { updateRecord({fields: { Id: this.recordId }}); } showToast(msg,type) { const event = new ShowToastEvent({ message: msg, variant: type }); if(type == 'success'){ this.updateRecordView(); } this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } } force-app/main/default/lwc/lexAssetMaintainHeaderAbandon/lexAssetMaintainHeaderAbandon.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" fqn="lexOCMSubmit"> <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> force-app/main/default/lwc/lexAssetMaintainHeaderDeleteApply/lexAssetMaintainHeaderDeleteApply.css
New file @@ -0,0 +1,22 @@ .outerBorderCss{ border: 1px solid #D4D4D4; border-radius : 5px; border-top : 3px solid #565959; } .borderCss{ border: 1px solid #D4D4D4; border-radius : 5px; margin-bottom : 7px; border-top : 3px solid #565959; } .headerDorderCss{ border-top: 1px solid #565959; border-bottom: 1px solid #D4D4D4; padding:3px; } .centerCss{ text-align: center; } .centerCss .left{ margin-left: 100px; }/* sample css file */ force-app/main/default/lwc/lexAssetMaintainHeaderDeleteApply/lexAssetMaintainHeaderDeleteApply.html
New file @@ -0,0 +1,5 @@ <template> <div class="sisToOPDHolder" if:true={IsLoading}> <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner> </div> </template> force-app/main/default/lwc/lexAssetMaintainHeaderDeleteApply/lexAssetMaintainHeaderDeleteApply.js
New file @@ -0,0 +1,57 @@ import { LightningElement, track, wire, api } from 'lwc'; import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import deleteApply from '@salesforce/apex/AssetMaintainHeaderWebService.deleteApply'; import applyPermission from '@salesforce/apex/AssetMaintainHeaderWebService.applyPermission'; export default class lexAssetMaintainHeaderDeleteApply extends LightningElement { @api recordId; IsLoading = true; @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.log("str:"+str); this.recordId = str; } } } connectedCallback(){ applyPermission().then(res=>{ if(res=='false'){ this.showToast('没有删除申请的权限','error'); }else if(confirm("是否确定删除?")){ deleteApply({ amhId:this.recordId }).then(result=>{ if(result=='1'){ this.showToast('已启动Batch,完成时会有邮件提醒','success'); }else{ this.showToast(result,'error'); } }) } }) } updateRecordView() { updateRecord({fields: { Id: this.recordId }}); } showToast(msg,type) { const event = new ShowToastEvent({ message: msg, variant: type }); if(type == 'success'){ this.updateRecordView(); } this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } } force-app/main/default/lwc/lexAssetMaintainHeaderDeleteApply/lexAssetMaintainHeaderDeleteApply.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" fqn="lexOCMSubmit"> <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>