force-app/main/default/classes/QISToETQWebService.cls
@@ -20,7 +20,8 @@ apiNames.add('Photo_OSH_3__c'); apiNames.add('Photo_OSH_4__c'); List<QIS_Report__c> updateQis = new List<QIS_Report__c>(); List<Attachment> attachments = new List<Attachment>(); // List<Attachment> attachments = new List<Attachment>(); List<ContentDocumentLink> attachments = new List<ContentDocumentLink>(); PageReference pdfPage ; for(QIS_Report__c qis : temp){ for (String apiName : apiNames) { @@ -39,16 +40,27 @@ } else { pdfBody = pdfPage.getContentAsPDF(); } Attachment attach = new Attachment(); attach.Body = pdfBody; // Attachment attach = new Attachment(); // attach.Body = pdfBody; ContentVersion cv = new ContentVersion(); cv.VersionData = pdfBody; if ('problem_detail_photo__c'.equals(apiName)) { attach.Name = substringApiName(qis.name) + '_Problem_Discription.pdf'; // attach.Name = substringApiName(qis.name) + '_Problem_Discription.pdf'; cv.Title = substringApiName(qis.name) + '_Problem_Discription.pdf'; }else { attach.Name = substringApiName(qis.name) + '_' + 'Problem_' + apiName.substring(0,apiName.length()-3) + '.pdf'; // attach.Name = substringApiName(qis.name) + '_' + 'Problem_' + apiName.substring(0,apiName.length()-3) + '.pdf'; cv.Title = substringApiName(qis.name) + '_' + 'Problem_' + apiName.substring(0,apiName.length()-3) + '.pdf'; } attach.ParentId = qis.id; attachments.add(attach); // attach.ParentId = qis.id; insert cv; Id docId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id].ContentDocumentId; ContentDocumentLink cdl = new ContentDocumentLink(); cdl.ContentDocumentId = docId; cdl.LinkedEntityId = qis.id; cdl.ShareType = 'I'; cdl.visibility = 'AllUser'; // attachments.add(attach); attachments.add(cdl); if (generatedFields == null) { qis.GeneratedPDFField__c = apiName; }else { @@ -90,7 +102,8 @@ PageReference pdfPage ; List<Repair__c> updateRpr = new List<Repair__c>(); List<Attachment> attachments = new List<Attachment>(); // List<Attachment> attachments = new List<Attachment>(); List<ContentDocumentLink> attachments = new List<ContentDocumentLink>(); for(Repair__c re : tempRe){ String generatedFields = re.GeneratedPDFField__c; if (checkFieldisGeneratedPDF('ProblemDescription__c',re)) { @@ -108,11 +121,23 @@ } else { pdfBody = pdfPage.getContentAsPDF(); } Attachment attach = new Attachment(); attach.Body = pdfBody; attach.Name = re.name + '_' + 'Problem_Discription.pdf'; attach.ParentId = re.id; attachments.add(attach); // Attachment attach = new Attachment(); // attach.Body = pdfBody; // attach.Name = re.name + '_' + 'Problem_Discription.pdf'; // attach.ParentId = re.id; ContentVersion cv = new ContentVersion(); cv.VersionData = pdfBody; cv.Title = re.name + '_' + 'Problem_Discription.pdf'; insert cv; Id docId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id].ContentDocumentId; ContentDocumentLink cdl = new ContentDocumentLink(); cdl.ContentDocumentId = docId; cdl.LinkedEntityId = re.id; cdl.ShareType = 'I'; cdl.visibility = 'AllUser'; // attachments.add(attach); attachments.add(cdl); re.GeneratedPDFField__c = 'ProblemDescription__c'; updateRpr.add(re); } force-app/main/default/classes/RentalApplyTriggerHandler.cls
@@ -181,45 +181,52 @@ } if(!childRaList.isEmpty()) { update childRaList; // 主单里附件 List<Attachment> attList = [SELECT Id, Body, Name, ParentId FROM Attachment WHERE ParentId IN: raIdSet ]; List<ContentDocumentLink> attList = [SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, ContentDocument.Title FROM ContentDocumentLink WHERE LinkedEntityId IN: raIdSet]; // 从单里附件,放到一起查会报limit错 attList.addAll([SELECT Id, Name, ParentId FROM Attachment WHERE ParentId IN:childRaList]); List<Id> racIdList = new List<Id>(); for (Rental_Apply__c rac : childRaList) { racIdList.add(rac.Id); } List<ContentDocumentLink> attList1 =[SELECT Id, LinkedEntityId, ContentDocumentId, IsDeleted, ContentDocument.Title FROM ContentDocumentLink WHERE LinkedEntityId IN: racIdList]; attList.addAll(attList1); if(attList.isEmpty()) { return; } Map<Id, List<Attachment>> parentFiles = new Map<Id, List<Attachment>>(); Map<Id, List<ContentDocumentLink>> parentFiles = new Map<Id, List<ContentDocumentLink>>(); // 待删除附件 List<Attachment> deleteFiles = new List<Attachment>(); for(Attachment att: attList) { if(att.Name.startsWith('QRCode-')) { List<ContentDocumentLink> deleteFiles = new List<ContentDocumentLink>(); for(ContentDocumentLink att: attList) { if(att.ContentDocument.Title.startsWith('QRCode-') || att.ContentDocument.Title.startsWith('BRCode-')) { continue; } if(raIdSet.contains(att.ParentId)) { List<Attachment> tempList = null; if(parentFiles.containsKey(att.ParentId)) { tempList = parentFiles.get(att.ParentId); if(raIdSet.contains(att.LinkedEntityId)) { List<ContentDocumentLink> tempList = null; if(parentFiles.containsKey(att.LinkedEntityId)) { tempList = parentFiles.get(att.LinkedEntityId); } else { tempList = new List<Attachment>(); tempList = new List<ContentDocumentLink>(); } tempList.add(att); parentFiles.put(att.ParentId, tempList); parentFiles.put(att.LinkedEntityId, tempList); } else { deleteFiles.add(att); } } // 待插入的附件 List<Attachment> newFiles = new List<Attachment>(); List<ContentDocumentLink> newFiles = new List<ContentDocumentLink>(); for(Rental_Apply__c childRa: childRaList) { if(parentFiles.containsKey(childRa.Old_Rental_Apply__c)) { for(Attachment att : parentFiles.get(childRa.Old_Rental_Apply__c)){ newFiles.add(new Attachment(Body = att.Body,Name = att.Name, ParentId = childRa.Id)); for(ContentDocumentLink att : parentFiles.get(childRa.Old_Rental_Apply__c)){ newFiles.add(new ContentDocumentLink(ContentDocumentId = att.ContentDocumentId,LinkedEntityId = childRa.Id,ShareType = 'I',Visibility = 'AllUsers')); } } } @@ -229,6 +236,54 @@ if(!newFiles.isEmpty()) { insert newFiles; } // // 主单里附件 // List<Attachment> attList = [SELECT Id, Body, Name, ParentId // FROM Attachment // WHERE ParentId IN: raIdSet // ]; // // 从单里附件,放到一起查会报limit错 // attList.addAll([SELECT Id, Name, ParentId FROM Attachment WHERE ParentId IN:childRaList]); // if(attList.isEmpty()) { // return; // } // Map<Id, List<Attachment>> parentFiles = new Map<Id, List<Attachment>>(); // // 待删除附件 // List<Attachment> deleteFiles = new List<Attachment>(); // for(Attachment att: attList) { // if(att.Name.startsWith('QRCode-')) { // continue; // } // if(raIdSet.contains(att.ParentId)) { // List<Attachment> tempList = null; // if(parentFiles.containsKey(att.ParentId)) { // tempList = parentFiles.get(att.ParentId); // } // else { // tempList = new List<Attachment>(); // } // tempList.add(att); // parentFiles.put(att.ParentId, tempList); // } // else { // deleteFiles.add(att); // } // } // // 待插入的附件 // List<Attachment> newFiles = new List<Attachment>(); // for(Rental_Apply__c childRa: childRaList) { // if(parentFiles.containsKey(childRa.Old_Rental_Apply__c)) { // for(Attachment att : parentFiles.get(childRa.Old_Rental_Apply__c)){ // newFiles.add(new Attachment(Body = att.Body,Name = att.Name, ParentId = childRa.Id)); // } // } // } // if(!deleteFiles.isEmpty()) { // delete deleteFiles; // } // if(!newFiles.isEmpty()) { // insert newFiles; // } } } } @@ -241,6 +296,7 @@ List<Rental_Apply__Share> rasList = new List<Rental_Apply__Share>(); List<Id> deleteOfficeAssistantShare_nObjId_List = new List<Id>(); // 共享删除用 List<Id> deleteApplyUserShare_nObjId_List = new List<Id>();// 20210727 ljh SFDC-C54C33 共享删除用 Set<Id> shareSet = new Set<Id>(); // 20230301 ljh DB202302444522 add for (Rental_Apply__c nObj : newList) { Rental_Apply__c oObj = (null == this.oldMap) ? null : this.oldMap.get(nObj.Id); // 服务部审批人 @@ -296,6 +352,7 @@ ) { deleteApplyUserShare_nObjId_List.add(nObj.Id); if(nObj.SalesManager__c != null){ shareSet.add(nObj.SalesManager__c);// 20230301 ljh DB202302444522 add Rental_Apply__Share rasSalesManager = new Rental_Apply__Share( RowCause = 'ApplyUserShare__c', ParentId = nObj.Id, @@ -305,6 +362,7 @@ rasList.add(rasSalesManager); } if(nObj.BuchangApprovalManagerSales__c != null){ shareSet.add(nObj.BuchangApprovalManagerSales__c);// 20230301 ljh DB202302444522 add Rental_Apply__Share rasBz = new Rental_Apply__Share( RowCause = 'ApplyUserShare__c', ParentId = nObj.Id, @@ -314,6 +372,7 @@ rasList.add(rasBz); } if(nObj.ZongjianApprovalManager__c != null){ shareSet.add(nObj.ZongjianApprovalManager__c);// 20230301 ljh DB202302444522 add Rental_Apply__Share rasZj = new Rental_Apply__Share( RowCause = 'ApplyUserShare__c', ParentId = nObj.Id, @@ -336,10 +395,18 @@ if(deleteOfficeAssistantShare_nObjId_List.size() > 0){ soql += ' AND (RowCause = \'Office_Assistant__c\' AND ParentId =: deleteOfficeAssistantShare_nObjId_List) '; if(deleteApplyUserShare_nObjId_List.size() > 0){ soql += ' OR (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)'; // 20230301 ljh DB202302444522 update start // soql += ' OR (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)'; soql += ' OR (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List'; soql += ' and UserOrGroupId IN :shareSet)'; // 20230301 ljh DB202302444522 update end } }else if(deleteApplyUserShare_nObjId_List.size() > 0){ soql += ' AND (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)'; // 20230301 ljh DB202302444522 update start // soql += ' AND (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List)'; soql += ' AND (RowCause = \'ApplyUserShare__c\'AND ParentId =: deleteApplyUserShare_nObjId_List'; soql += ' and UserOrGroupId IN :shareSet)'; // 20230301 ljh DB202302444522 update end } List<Rental_Apply__Share> deleteShareList = new List<Rental_Apply__Share>(); if(deleteOfficeAssistantShare_nObjId_List.size() > 0 || deleteApplyUserShare_nObjId_List.size() > 0){ @@ -1899,7 +1966,6 @@ @testVisible private void testI() { Integer i = 0; } } force-app/main/default/lwc/lexAssetMaintainHeaderAbandon/lexAssetMaintainHeaderAbandon.js
@@ -2,6 +2,7 @@ import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import abandon from '@salesforce/apex/AssetMaintainHeaderWebService.abandon'; import applyPermission from '@salesforce/apex/AssetMaintainHeaderWebService.applyPermission'; @@ -23,12 +24,15 @@ connectedCallback(){ applyPermission().then(res=>{ this.IsLoading = false; console.log("res11111:"+res); if(res=='false'){ this.showToast('没有操作废弃的权限','error'); this.showToast('没有提交申请的权限','error'); }else{ abandon({ amhId: this.recordId }).then(result=>{ console.log("result11111:"+result); if(result=='1'){ this.showToast('已启动Batch,完成时会有邮件提醒','success'); }else{ force-app/main/default/lwc/lexAssetMaintainHeaderDeleteApply/lexAssetMaintainHeaderDeleteApply.js
@@ -2,6 +2,7 @@ import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import deleteApply from '@salesforce/apex/AssetMaintainHeaderWebService.deleteApply'; import applyPermission from '@salesforce/apex/AssetMaintainHeaderWebService.applyPermission'; @@ -24,11 +25,13 @@ connectedCallback(){ applyPermission().then(res=>{ if(res=='false'){ this.IsLoading = false; this.showToast('没有删除申请的权限','error'); }else if(confirm("是否确定删除?")){ deleteApply({ amhId:this.recordId }).then(result=>{ console.log("result2222:"+result); if(result=='1'){ this.showToast('已启动Batch,完成时会有邮件提醒','success'); }else{ force-app/main/default/lwc/lexConsumApplyEquipmentSetReassign/lexConsumApplyEquipmentSetReassign.css
@@ -1,22 +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{ .holder{ position: relative; display: inline-block; width: 80px; height: 80px; text-align: center; } .centerCss .left{ margin-left: 100px; }/* sample css file */ .container .uiContainerManager{ display : none !important; } .toast{ border: 1px solid #c9c9c9; border-radius: 10px; width: 50%; margin: 0 auto; font-size: 18px; font-weight: bold; padding: 10px 20px; background: #feb75d; display: flex; } force-app/main/default/lwc/lexConsumApplyEquipmentSetReassign/lexConsumApplyEquipmentSetReassign.html
@@ -1,5 +1,13 @@ <template> <div class="sisToOPDHolder" if:true={IsLoading}> <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner> </div> <div class="holder" if:true={IsLoading}> <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner> </div> <div if:true={IsDisplay} class="toast"> <span style="padding: 10px;">{msg}</span> <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" onclick={closeAction} title="Close" style="background-color: #e5e4e2;margin-top: 15px;"> <lightning-icon class="greyIcon" icon-name="utility:close" alternative-text="Connected" variant="inverse" size="small" title="Close" style="color: black;"></lightning-icon> <span class="slds-assistive-text">Close</span> </button> </div> </template> force-app/main/default/lwc/lexConsumApplyEquipmentSetReassign/lexConsumApplyEquipmentSetReassign.js
@@ -3,54 +3,53 @@ import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import LightningConfirm from 'lightning/confirm'; import reassign from '@salesforce/apex/ConsumApplyEquipmentSetReaController.reassign'; import reassign from '@salesforce/apex/LexConsumApplyEquipmentSetReaController.reassign'; export default class LexConsumApplyEquipmentSetReassign extends LightningElement { @api recordId; @api consumEquipmentId; 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; } } } IsDisplay=false; //提示信息 msg; connectedCallback(){ this.IsLoading = false; reassign({recordId:this.recordId}).then(result=>{ console.log('result--->'+result); if (result.status != '已出库指示' ) { this.showToast('耗材请单没有出库指示不能重新分配','error') return; console.log('result--->'+ JSON.stringify(result)); console.log('this.recordId--->'+this.recordId); if(this.consumEquipmentId){ if (result.status != '已出库指示' ) { this.IsDisplay = true; this.msg = '耗材请单没有出库指示不能重新分配'; return; } LightningConfirm.open({ message: "你确定要重新分配吗?", variant: 'headerless', label: '提示信息', // setting theme would have no effect }).then(submit=>{ this.dispatchEvent(new CloseActionScreenEvent()); window.open("/apex/ConsumReassign?caid="+this.recordId); this.closeAction(); return; }) }else{ this.IsDisplay = true; this.msg = '未选择耗材备品配套一览'; } if(confirm('你确定要重新分配吗')){ window.open("/apex/ConsumReassign?caid="+this.recordId); } // window.location.href = "/apex/ConsumReassign?caid={!Consum_Apply__c.Id}"; }) } 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 }}); } updateRecordView(recordId) { updateRecord({fields: { Id: recordId }}); closeAction() { window.open("/"+this.recordId,'_self'); } } force-app/main/default/lwc/lexConsumApplySubmitApprovalProcess/lexConsumApplySubmitApprovalProcess.js
@@ -152,6 +152,7 @@ // } //没有this.status == '引当完了'状态 console.log("状态---------",this.status); if(this.status == '填写完毕' || this.status == '申请中' || this.status == '已批准' || this.status == '已出库指示' || this.status == '删除' || this.status == '取消'){ this.showToast('请备品申请状态确认,已经提交过的申请,不能重复提交','error');