| | |
| | | public without sharing class BatchSelectRepairPDFDelete { |
| | | public void deletePDF(List<Repair__c> repList){ |
| | | List<String> attachmentNameList = new List<String>(); |
| | | List<Attachment> isGeneratedPDFList = new List<Attachment>(); |
| | | for(Repair__c re : repList){ |
| | | attachmentNameList.add(re.name + '_' + 'MaintenanceCommission.pdf'); |
| | | //修改删除附件,改为删除文件(lightning改造) |
| | | List<String> attachmentNameList = new List<String>(); |
| | | List<Id> parentIdList = new List<Id>(); |
| | | List<ContentDocumentLink> isGeneratedPDFLinkList = new List<ContentDocumentLink>(); |
| | | List<ContentDocument> isGeneratedPDFList = new List<ContentDocument>(); |
| | | for(Repair__c re : repList){ |
| | | attachmentNameList.add(re.name + '_' + 'MaintenanceCommission.pdf'); |
| | | parentIdList.add(re.Id); |
| | | } |
| | | isGeneratedPDFList = [select id from Attachment where name IN:attachmentNameList]; |
| | | System.debug(LoggingLevel.INFO, '*** isGeneratedPDFList: ' + isGeneratedPDFList); |
| | | isGeneratedPDFLinkList = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId in: parentIdList]; |
| | | List<Id> attachmentIdList = new List<Id>(); |
| | | for (ContentDocumentLink PDFLink : isGeneratedPDFLinkList) { |
| | | attachmentIdList.add(PDFLink.ContentDocumentId); |
| | | } |
| | | isGeneratedPDFList = [select Id from ContentDocument where Id in: attachmentIdList and Title in: attachmentNameList]; |
| | | if(isGeneratedPDFList.size() > 0){ |
| | | delete isGeneratedPDFList; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // List<String> attachmentNameList = new List<String>(); |
| | | // List<Attachment> isGeneratedPDFList = new List<Attachment>(); |
| | | // for(Repair__c re : repList){ |
| | | // attachmentNameList.add(re.name + '_' + 'MaintenanceCommission.pdf'); |
| | | // } |
| | | // isGeneratedPDFList = [select id from Attachment where name IN:attachmentNameList]; |
| | | // System.debug(LoggingLevel.INFO, '*** isGeneratedPDFList: ' + isGeneratedPDFList); |
| | | // if(isGeneratedPDFList.size() > 0){ |
| | | // delete isGeneratedPDFList; |
| | | // } |
| | | } |
| | | |
| | | public void createPDF(List<Repair__c> repList){ |
| | | PageReference pdfPage; |
| | | List<Attachment> attachments = new List<Attachment>(); |
| | | for(Repair__c re : repList){ |
| | | pdfPage = new PageReference('/apex/MaintenanceCommissionPDF?id=' + re.Id); |
| | | // PageReference pdfPage; |
| | | // List<Attachment> attachments = new List<Attachment>(); |
| | | // for(Repair__c re : repList){ |
| | | // pdfPage = new PageReference('/apex/MaintenanceCommissionPDF?id=' + re.Id); |
| | | // Blob pdfBody; |
| | | // if(System.Test.isRunningTest()) { |
| | | // pdfBody = blob.valueOf('Unit.Test'); |
| | | // } else { |
| | | // pdfBody = pdfPage.getContentAsPDF(); |
| | | // } |
| | | // Attachment attach = new Attachment(); |
| | | // attach.Body = pdfBody; |
| | | // attach.Name = re.name + '_' + 'MaintenanceCommission.pdf'; |
| | | // attach.ParentId = re.id; |
| | | // attachments.add(attach); |
| | | // } |
| | | // System.debug(LoggingLevel.INFO, '*** attachments: ' + attachments); |
| | | // insert attachments; |
| | | |
| | | PageReference pdfPage; |
| | | List<ContentVersion> versions = new List<ContentVersion>(); |
| | | for(Repair__c re : repList){ |
| | | pdfPage = new PageReference('/apex/MaintenanceCommissionPDF?id=' + re.Id); |
| | | Blob pdfBody; |
| | | if(System.Test.isRunningTest()) { |
| | | pdfBody = blob.valueOf('Unit.Test'); |
| | | } else { |
| | | pdfBody = pdfPage.getContentAsPDF(); |
| | | } |
| | | Attachment attach = new Attachment(); |
| | | attach.Body = pdfBody; |
| | | attach.Name = re.name + '_' + 'MaintenanceCommission.pdf'; |
| | | attach.ParentId = re.id; |
| | | attachments.add(attach); |
| | | ContentVersion version = new ContentVersion(); |
| | | version.VersionData = pdfBody; |
| | | version.Title = re.name + '_' + 'MaintenanceCommission.pdf'; |
| | | version.ContentLocation = 's'; |
| | | version.PathOnClient = re.name + '_' + 'MaintenanceCommission.pdf'; |
| | | versions.add(version); |
| | | } |
| | | System.debug(LoggingLevel.INFO, '*** attachments: ' + attachments); |
| | | insert attachments; |
| | | } |
| | | if (versions.size() > 0) { |
| | | insert versions; |
| | | } |
| | | List<Id> idList = new List<Id>(); |
| | | for (ContentVersion newVersion : versions) { |
| | | idList.add(newVersion.Id); |
| | | } |
| | | versions = [select ContentDocumentId from ContentVersion where Id in: idList]; |
| | | List<ContentDocumentLink> links = new List<ContentDocumentLink>(); |
| | | Integer i = 0; |
| | | for (ContentVersion newVersion : versions) { |
| | | ContentDocumentLink link = new ContentDocumentLink(); |
| | | link.ContentDocumentId = newVersion.ContentDocumentId; |
| | | link.LinkedEntityId = repList[i].Id; |
| | | link.ShareType = 'I'; |
| | | link.Visibility = 'AllUsers'; |
| | | links.add(link); |
| | | i++; |
| | | } |
| | | if (links.size() > 0) { |
| | | insert links; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>46.0</apiVersion> |
| | | <apiVersion>43.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
| | |
| | | |
| | | public void init() { |
| | | Bid_Announcement__c bid = [select Id, Web_URL__c, Web_URL_ModifiedDate__c from Bid_Announcement__c where Id = :recordId]; |
| | | List<Attachment> attList = [select Id, LastModifiedDate from Attachment where ParentId = :recordId order by LastModifiedDate desc limit 1]; |
| | | Attachment att = null; |
| | | if (attList.size() > 0) { |
| | | att = attList[0]; |
| | | // List<Attachment> attList = [select Id, LastModifiedDate from Attachment where ParentId = :recordId order by LastModifiedDate desc limit 1]; |
| | | List<ContentDocumentLink> links = [select ContentDocumentId from ContentDocumentLink where LinkedEntityId =: recordId]; |
| | | List<Id> idList = new List<Id>(); |
| | | for (ContentDocumentLink link : links) { |
| | | idList.add(link.ContentDocumentId); |
| | | } |
| | | List<ContentDocument> docList = [select Id,ContentModifiedDate from ContentDocument where Id in: idList order by ContentModifiedDate desc limit 1]; |
| | | // Attachment att = null; |
| | | ContentDocument doc = null; |
| | | if (docList.size() > 0) { |
| | | doc = docList[0]; |
| | | } |
| | | |
| | | if (bid.Web_URL__c != null) { |
| | | // 中标通知书URL更新时间 と 最新Attachmentの時間と比較、新しいものを適用 |
| | | if (att != null) { |
| | | if (bid.Web_URL_ModifiedDate__c < att.LastModifiedDate) { |
| | | iframe = '/servlet/servlet.FileDownload?file=' + att.Id; |
| | | if (doc != null) { |
| | | if (bid.Web_URL_ModifiedDate__c < doc.ContentModifiedDate) { |
| | | iframe = '/lightning/r/ContentDocument/' + doc.Id + '/view'; |
| | | } else { |
| | | iframe = bid.Web_URL__c; |
| | | } |
| | |
| | | } |
| | | } else { |
| | | // Attachmentを適用 |
| | | if (att != null) { |
| | | iframe = '/servlet/servlet.FileDownload?file=' + att.Id; |
| | | if (doc != null) { |
| | | iframe = '/lightning/r/ContentDocument/' + doc.Id + '/view'; |
| | | } |
| | | } |
| | | } |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>29.0</apiVersion> |
| | | <apiVersion>46.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
| | |
| | | } |
| | | |
| | | public static string GetImageBase64(string id){ |
| | | List<Attachment> atts = [SELECT Id, IsDeleted, ParentId, Name, IsPrivate, ContentType, BodyLength, Body, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, Description FROM Attachment where id=:id]; |
| | | if (atts.size()==0) { |
| | | List<ContentVersion> version = [select VersionData from ContentVersion where ContentDocumentId =: id]; |
| | | // List<Attachment> atts = [SELECT Id, IsDeleted, ParentId, Name, IsPrivate, ContentType, BodyLength, Body, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, Description FROM Attachment where id=:id]; |
| | | if (version.size()==0) { |
| | | return null; |
| | | } |
| | | return 'data:image/png;base64,' + EncodingUtil.base64Encode(atts[0].body); |
| | | return 'data:image/png;base64,' + EncodingUtil.base64Encode(version[0].VersionData); |
| | | } |
| | | } |
| | |
| | | public String Id { get; set; } |
| | | public Boolean isShow { get; set; } |
| | | public List<Attachment> attachments { get; set; } |
| | | |
| | | public List<ContentDocument> contents { get; set; } |
| | | //分页功能 |
| | | public Integer pageLimit{get;set;} |
| | | public String soql {get;set;} |
| | |
| | | isShow = false; |
| | | Statu_AchievementsId = ApexPages.currentPage().getParameters().get('Statu_AchievementsId'); |
| | | Id = ApexPages.currentPage().getParameters().get('Id'); |
| | | |
| | | System.debug('id:'+Id+' and sId:'+Statu_AchievementsId); |
| | | statusEdit = ApexPages.currentPage().getParameters().get('KeyWords'); |
| | | guaranteePeriodAlterationDetailRecords = new List<GuaranteePeriodAlterationDetailInfo>(); |
| | | guaranteePeriodAlterationDetaiRecordsview = new List<GuaranteePeriodAlterationDetailInfo>(); |
| | |
| | | pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize); |
| | | |
| | | attachments = new List<Attachment>(); |
| | | List<ContentDocumentLink> cdlList = [SELECT ContentDocumentId |
| | | FROM ContentDocumentLink |
| | | WHERE LinkedEntityId = :Id]; |
| | | List<ID> fileIDs = new List<ID>(); |
| | | for (ContentDocumentLink docLink : cdlList) { |
| | | fileIDs.add(docLink.ContentDocumentId); |
| | | } |
| | | contents=[SELECT Title,OwnerId,ContentModifiedDate from ContentDocument WHERE id IN :fileIDs]; |
| | | } |
| | | |
| | | // 画面初始化 |
| | |
| | | } else { |
| | | statu_AchievementId = ambc.GpaaStatu_Achievements__c; |
| | | } |
| | | statu_AchievementId=''; |
| | | String soql = 'select Id,name,SerialNumber,Asset_situation__c,Order_No__c,Account.Name,Status,Installation_Site__c,CurrentContract__c,guarantee_period__c,RepairQuantity__c from Asset where Backorder__c = \'' + statu_AchievementId +'\''; |
| | | soql += ' AND AssetMark__c != \'耗材\''; |
| | | if(!String.isBlank(text1)){ |
| | |
| | | ref.setRedirect(true); |
| | | return ref; |
| | | } |
| | | |
| | | //跳转到上传附件页面Lightning |
| | | public PageReference uploadingAttachmentLightning(){ |
| | | //PageReference ref = new Pagereference('/p/attach/NoteAttach?pid=' + Id +'&retURL=%2Fapex/AssetGuaranteePeriodAlteration?Id='+Id); |
| | | PageReference ref = new Pagereference('/lightning/n/lightning?objectApiName&context=RECORD_DETAIL&backgroundContext=%2Flightning%2Fr%2FAssetGuaranteePeriodAlteration__c%2F'+Id+'%2Fedit%3F0.source%3DalohaHeader&0.recordId='+Id+''); |
| | | ref.setRedirect(true); |
| | | return ref; |
| | | } |
| | | //查找"保有设备"是否含有"QIS"和"修理"和"保有设备的保修期限变更过" |
| | | public Boolean find_QIS_Repair(List<String> assetIdList) { |
| | | |
| | |
| | | // PageReference ref = new Pagereference('/p/attach/NoteAttach?pid='+id+'&retURL=%2F' + '/apex/MaintenanceProductData?id=' +id); |
| | | // ref.setRedirect(true); |
| | | // return ref; |
| | | PageReference ref = new Pagereference('/lightning/n/lightning?backgroundContext=%2Flightning%2Fr%2FAssetModifyBelongsChange__c%2F'+id+'%2Fedit%3Fcount%3D1&0.recordId='+id+''); |
| | | PageReference ref = new Pagereference('/lightning/n/lightning?backgroundContext=%2Flightning%2Fr%2FMaintenance_Product_Data__c%2F'+id+'%2Fedit%3Fcount%3D1&0.recordId='+id+''); |
| | | ref.setRedirect(true); |
| | | return ref; |
| | | } |
| | |
| | | |
| | | public void saveSign() { |
| | | // Sign画像は一つでいいじゃない?Delete⇒Insertにする |
| | | List<Attachment> atts = [select Id from Attachment where ParentId = :rp.Id and Name = :(rp.Name + '_Sign')]; |
| | | if (atts.size() > 0) delete atts; |
| | | // List<Attachment> atts = [select Id from Attachment where ParentId = :rp.Id and Name = :(rp.Name + '_Sign')]; |
| | | // if (atts.size() > 0) delete atts; |
| | | |
| | | Attachment ac = new Attachment(); |
| | | ac.Body = EncodingUtil.base64Decode(this.signStr.removeStart('data:image/png;base64,')); |
| | | ac.Name = rp.Name + '_Sign'; |
| | | ac.ParentId = rp.Id; |
| | | ac.ContentType = 'jpg'; |
| | | // Attachment ac = new Attachment(); |
| | | // ac.Body = EncodingUtil.base64Decode(this.signStr.removeStart('data:image/png;base64,')); |
| | | // ac.Name = rp.Name + '_Sign'; |
| | | // ac.ParentId = rp.Id; |
| | | // ac.ContentType = 'jpg'; |
| | | // try { |
| | | // insert ac; |
| | | // rp.Sign__c = '<img src="/servlet/servlet.FileDownload?file=' + ac.Id + '"/>'; |
| | | // rp.SignUrl__c = '/servlet/servlet.FileDownload?file=' + ac.Id; |
| | | // rp.SignDate__c = Date.today(); |
| | | // update rp; |
| | | // } catch (Exception ex) { |
| | | // ApexPages.addMessages(ex); |
| | | // //return; |
| | | // } |
| | | |
| | | |
| | | |
| | | List<ContentDocumentLink> cdlList = [SELECT ContentDocumentId |
| | | FROM ContentDocumentLink |
| | | WHERE LinkedEntityId = :rp.Id]; |
| | | List<ID> fileIDs = new List<ID>(); |
| | | for (ContentDocumentLink docLink : cdlList) { |
| | | fileIDs.add(docLink.ContentDocumentId); |
| | | } |
| | | List<ContentDocument> attachmentinfo=[SELECT Title,OwnerId from ContentDocument WHERE id IN :fileIDs and Title =: (rp.Name + '_Sign')]; |
| | | if (attachmentinfo.size() > 0) delete attachmentinfo; |
| | | ContentVersion contVerFile = new ContentVersion(); |
| | | contVerFile.VersionData = EncodingUtil.base64Decode(this.signStr.removeStart('data:image/png;base64,')); |
| | | contVerFile.Title = rp.Name + '_Sign'; |
| | | contVerFile.ContentLocation= 's'; |
| | | contVerFile.PathOnClient=rp.Name + '_Sign.jpg'; |
| | | insert contVerFile; |
| | | Id conDoc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:contVerFile.Id].ContentDocumentId; |
| | | ContentDocumentLink cDe = new ContentDocumentLink(); |
| | | cDe.ContentDocumentId = conDoc; |
| | | cDe.LinkedEntityId = rp.Id; |
| | | cDe.ShareType = 'I'; |
| | | cDe.Visibility = 'AllUsers'; |
| | | insert cDe; |
| | | try { |
| | | insert ac; |
| | | rp.Sign__c = '<img src="/servlet/servlet.FileDownload?file=' + ac.Id + '"/>'; |
| | | rp.SignUrl__c = '/servlet/servlet.FileDownload?file=' + ac.Id; |
| | | |
| | | rp.Sign__c = '<img src="/lightning/r/ContentDocument/' + contVerFile.ContentDocumentId + '/view"/>'; |
| | | rp.SignUrl__c = '/lightning/r/ContentDocument/' + contVerFile.ContentDocumentId + '/view'; |
| | | rp.SignDate__c = Date.today(); |
| | | update rp; |
| | | } catch (Exception ex) { |
| | | ApexPages.addMessages(ex); |
| | | //return; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public void savePDF() { |
| | | // String pdfPageURL = '/apex/OFSRepairConsignPDF?id=' + rp.Id; |
| | | // PageReference pageRef = new PageReference(pdfPageURL); |
| | | |
| | | // Attachment att = new Attachment(); |
| | | // // TODO TestMethodはgetContentをサポートしない |
| | | // if (!Test.isRunningTest()) { |
| | | // att.body = pageRef.getContent(); |
| | | // } else { |
| | | // att.body = EncodingUtil.base64Decode('test'); |
| | | // } |
| | | // att.Name = rp.Name + '_维修委托书_' + String.valueOf(Datetime.now()) + '.pdf'; |
| | | // att.ParentId = rp.Id; |
| | | // try { |
| | | // insert att; |
| | | // } catch (Exception ex) { |
| | | // ApexPages.addMessages(ex); |
| | | // //return; |
| | | // } |
| | | |
| | | |
| | | String pdfPageURL = '/apex/OFSRepairConsignPDF?id=' + rp.Id; |
| | | PageReference pageRef = new PageReference(pdfPageURL); |
| | | |
| | | Attachment att = new Attachment(); |
| | | ContentVersion contVerFile = new ContentVersion(); |
| | | // TODO TestMethodはgetContentをサポートしない |
| | | if (!Test.isRunningTest()) { |
| | | att.body = pageRef.getContent(); |
| | | contVerFile.VersionData = pageRef.getContent(); |
| | | } else { |
| | | att.body = EncodingUtil.base64Decode('test'); |
| | | contVerFile.VersionData = EncodingUtil.base64Decode('test'); |
| | | } |
| | | att.Name = rp.Name + '_维修委托书_' + String.valueOf(Datetime.now()) + '.pdf'; |
| | | att.ParentId = rp.Id; |
| | | contVerFile.Title = rp.Name + '_维修委托书_' + String.valueOf(Datetime.now()) + '.pdf'; |
| | | contVerFile.ContentLocation= 's'; |
| | | contVerFile.PathOnClient=rp.Name + '_维修委托书_' + String.valueOf(Datetime.now()) + '.pdf'; |
| | | // att.ParentId = rp.Id; |
| | | try { |
| | | insert att; |
| | | insert contVerFile; |
| | | Id conDoc = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:contVerFile.Id].ContentDocumentId; |
| | | ContentDocumentLink cDe = new ContentDocumentLink(); |
| | | cDe.ContentDocumentId = conDoc; |
| | | cDe.LinkedEntityId = rp.Id; |
| | | cDe.ShareType = 'I'; |
| | | cDe.Visibility = 'AllUsers'; |
| | | insert cDe; |
| | | } catch (Exception ex) { |
| | | ApexPages.addMessages(ex); |
| | | //return; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private Repair__c getReportData(String id) { |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>29.0</apiVersion> |
| | | <apiVersion>43.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
| | |
| | | insert insertCloneList; |
| | | } |
| | | } |
| | | List<Attachment> getAttachmentList = [SELECT Id, Body, Name, ParentId |
| | | FROM Attachment |
| | | WHERE ParentId In:reapplyopdMap.keySet()]; |
| | | List<Attachment> insertAttachmentCloneList = new List<Attachment>(); |
| | | if (getAttachmentList.size() > 0 ) { |
| | | for(Attachment att :getAttachmentList){ |
| | | Attachment attClone = new Attachment(); |
| | | attClone = att.clone(); |
| | | attClone.Id = null; |
| | | attClone.Body = att.Body; |
| | | attClone.Name = att.Name; |
| | | attClone.ParentId = reapplyopdMap.get(att.ParentId); |
| | | insertAttachmentCloneList.add(attClone); |
| | | } |
| | | |
| | | if (insertAttachmentCloneList.size() > 0) { |
| | | insert insertAttachmentCloneList; |
| | | } |
| | | |
| | | List<ContentDocumentLink> cdlList = [SELECT ContentDocumentId,LinkedEntityId |
| | | FROM ContentDocumentLink |
| | | WHERE LinkedEntityId In:reapplyopdMap.keySet()]; |
| | | List<ID> fileIDs = new List<ID>(); |
| | | for (ContentDocumentLink docLink : cdlList) { |
| | | fileIDs.add(docLink.ContentDocumentId); |
| | | } |
| | | List<ContentDocument> attachmentinfo=[SELECT Id,Title,OwnerId from ContentDocument WHERE id IN :fileIDs]; |
| | | List<Id> idList = new List<Id>(); |
| | | for (ContentDocument attachment : attachmentinfo) { |
| | | idList.add(attachment.Id); |
| | | } |
| | | List<ContentVersion> versionList = [select Id,VersionData,Title,ContentLocation,PathOnClient from ContentVersion where ContentDocumentId in: idList]; |
| | | List<ContentVersion> newVersionList = new List<ContentVersion>(); |
| | | for (ContentVersion version : versionList) { |
| | | ContentVersion newVersion = new ContentVersion(); |
| | | newVersion = version.clone(); |
| | | newVersion.Id = null; |
| | | newVersion.VersionData = version.VersionData; |
| | | newVersion.Title = version.Title; |
| | | newVersion.ContentLocation = version.ContentLocation; |
| | | newVersion.PathOnClient = version.PathOnClient; |
| | | newVersionList.add(newVersion); |
| | | } |
| | | |
| | | if (newVersionList.size() > 0) { |
| | | insert newVersionList; |
| | | } |
| | | idList = new List<Id>(); |
| | | for (ContentVersion newVersion : newVersionList) { |
| | | idList.add(newVersion.Id); |
| | | } |
| | | newVersionList = [SELECT ContentDocumentId FROM ContentVersion WHERE Id IN:idList]; |
| | | List<ContentDocumentLink> linkList = new List<ContentDocumentLink>(); |
| | | Integer i = 0; |
| | | for (ContentVersion newVersion : newVersionList) { |
| | | ContentDocumentLink link = new ContentDocumentLink(); |
| | | link.ContentDocumentId = newVersion.ContentDocumentId; |
| | | link.LinkedEntityId = reapplyopdMap.get(cdlList[i].LinkedEntityId); |
| | | link.ShareType = 'I'; |
| | | link.Visibility = 'AllUsers'; |
| | | linkList.add(link); |
| | | i++; |
| | | } |
| | | if (linkList.size() > 0) { |
| | | insert linkList; |
| | | } |
| | | |
| | | // List<Attachment> getAttachmentList = [SELECT Id, Body, Name, ParentId |
| | | // FROM Attachment |
| | | // WHERE ParentId In:reapplyopdMap.keySet()]; |
| | | // List<Attachment> insertAttachmentCloneList = new List<Attachment>(); |
| | | // if (getAttachmentList.size() > 0 ) { |
| | | // for(Attachment att :getAttachmentList){ |
| | | // Attachment attClone = new Attachment(); |
| | | // attClone = att.clone(); |
| | | // attClone.Id = null; |
| | | // attClone.Body = att.Body; |
| | | // attClone.Name = att.Name; |
| | | // attClone.ParentId = reapplyopdMap.get(att.ParentId); |
| | | // insertAttachmentCloneList.add(attClone); |
| | | // } |
| | | |
| | | // if (insertAttachmentCloneList.size() > 0) { |
| | | // insert insertAttachmentCloneList; |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | private void updateOppPlan() { |
| | |
| | | public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) { |
| | | base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8'); |
| | | |
| | | Attachment oAttachment = new Attachment(); |
| | | oAttachment.parentId = parentId; |
| | | // Attachment oAttachment = new Attachment(); |
| | | // oAttachment.parentId = parentId; |
| | | |
| | | oAttachment.Body = EncodingUtil.base64Decode(base64Data); |
| | | oAttachment.Name = fileName; |
| | | oAttachment.ContentType = contentType; |
| | | // oAttachment.Body = EncodingUtil.base64Decode(base64Data); |
| | | // oAttachment.Name = fileName; |
| | | // oAttachment.ContentType = contentType; |
| | | |
| | | insert oAttachment; |
| | | |
| | | return oAttachment.Id; |
| | | // insert oAttachment; |
| | | ContentVersion version = new ContentVersion(); |
| | | version.Title = fileName; |
| | | version.VersionData = EncodingUtil.base64Decode(base64Data); |
| | | version.ContentLocation = 's'; |
| | | version.PathOnClient = fileName + '.' +contentType; |
| | | insert version; |
| | | version = [select ContentDocumentId from ContentVersion where Id =: version.Id limit 1]; |
| | | ContentDocumentLink link = new ContentDocumentLink(); |
| | | link.ContentDocumentId = version.ContentDocumentId; |
| | | link.LinkedEntityId = parentId; |
| | | link.ShareType = 'I'; |
| | | link.Visibility = 'AllUsers'; |
| | | insert link; |
| | | |
| | | return link.ContentDocumentId; |
| | | } |
| | | |
| | | private static void appendToFile(Id fileId, String base64Data) { |
| | | base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8'); |
| | | |
| | | Attachment a = [ |
| | | SELECT Id, Body |
| | | FROM Attachment |
| | | WHERE Id =: fileId |
| | | ]; |
| | | // Attachment a = [ |
| | | // SELECT Id, Body |
| | | // FROM Attachment |
| | | // WHERE Id =: fileId |
| | | // ]; |
| | | ContentVersion version = [select Id,VersionData from ContentVersion where ContentDocumentId =: fileId]; |
| | | |
| | | String existingBody = EncodingUtil.base64Encode(a.Body); |
| | | // String existingBody = EncodingUtil.base64Encode(a.Body); |
| | | String existingBody = EncodingUtil.base64Encode(version.VersionData); |
| | | |
| | | a.Body = EncodingUtil.base64Decode(existingBody + base64Data); |
| | | // a.Body = EncodingUtil.base64Decode(existingBody + base64Data); |
| | | version.VersionData = EncodingUtil.base64Decode(existingBody + base64Data); |
| | | |
| | | update a; |
| | | update version; |
| | | } |
| | | |
| | | //文件删除功能 精琢技术 thh 2021-09-26 start |
| | | @AuraEnabled |
| | | public static void deleteChunk(Id AttachmentId) { |
| | | Attachment attachment = new Attachment(); |
| | | attachment.id = AttachmentId; |
| | | |
| | | delete attachment; |
| | | // Attachment attachment = new Attachment(); |
| | | // attachment.id = AttachmentId; |
| | | ContentDocument con = new ContentDocument(); |
| | | con.Id = AttachmentId; |
| | | delete con; |
| | | // delete attachment; |
| | | } |
| | | //文件删除功能 精琢技术 thh 2021-09-26 end |
| | | } |
| | |
| | | public static Id saveTheFile(Id parentId, String fileName, String base64Data, String contentType) { |
| | | base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8'); |
| | | |
| | | Attachment oAttachment = new Attachment(); |
| | | oAttachment.parentId = parentId; |
| | | ContentVersion version = new ContentVersion(); |
| | | version.Title = fileName; |
| | | version.VersionData = EncodingUtil.base64Decode(base64Data); |
| | | version.ContentLocation = 's'; |
| | | version.PathOnClient = fileName + '.' + contentType; |
| | | insert version; |
| | | version = [select ContentDocumentId from ContentVersion where Id =: version.Id]; |
| | | ContentDocumentLink link = new ContentDocumentLink(); |
| | | link.ContentDocumentId = version.ContentDocumentId; |
| | | link.LinkedEntityId = parentId; |
| | | link.ShareType = 'I'; |
| | | link.Visibility = 'AllUsers'; |
| | | insert link; |
| | | // Attachment oAttachment = new Attachment(); |
| | | // oAttachment.parentId = parentId; |
| | | |
| | | oAttachment.Body = EncodingUtil.base64Decode(base64Data); |
| | | oAttachment.Name = fileName; |
| | | oAttachment.ContentType = contentType; |
| | | // oAttachment.Body = EncodingUtil.base64Decode(base64Data); |
| | | // oAttachment.Name = fileName; |
| | | // oAttachment.ContentType = contentType; |
| | | |
| | | insert oAttachment; |
| | | // insert oAttachment; |
| | | |
| | | return oAttachment.Id; |
| | | return link.ContentDocumentId; |
| | | } |
| | | |
| | | private static void appendToFile(Id fileId, String base64Data) { |
| | | base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8'); |
| | | |
| | | Attachment a = [ |
| | | SELECT Id, Body |
| | | FROM Attachment |
| | | WHERE Id =: fileId |
| | | ]; |
| | | // Attachment a = [ |
| | | // SELECT Id, Body |
| | | // FROM Attachment |
| | | // WHERE Id =: fileId |
| | | // ]; |
| | | ContentVersion version = [select Id,VersionData from ContentVersion where ContentDocumentId =: fileId]; |
| | | |
| | | String existingBody = EncodingUtil.base64Encode(a.Body); |
| | | // String existingBody = EncodingUtil.base64Encode(a.Body); |
| | | String existingBody = EncodingUtil.base64Encode(version.VersionData); |
| | | |
| | | a.Body = EncodingUtil.base64Decode(existingBody + base64Data); |
| | | // a.Body = EncodingUtil.base64Decode(existingBody + base64Data); |
| | | version.VersionData = EncodingUtil.base64Decode(existingBody + base64Data); |
| | | |
| | | update a; |
| | | update version; |
| | | } |
| | | |
| | | //文件删除功能 精琢技术 thh 2021-09-26 start |
| | | @AuraEnabled |
| | | public static void deleteChunk(Id AttachmentId) { |
| | | Attachment attachment = new Attachment(); |
| | | attachment.id = AttachmentId; |
| | | // Attachment attachment = new Attachment(); |
| | | // attachment.id = AttachmentId; |
| | | |
| | | delete attachment; |
| | | // delete attachment; |
| | | ContentDocument con = new ContentDocument(); |
| | | con.Id = AttachmentId; |
| | | delete con; |
| | | } |
| | | //文件删除功能 精琢技术 thh 2021-09-26 end |
| | | } |
| | |
| | | <apex:page standardController="GuaranteePeriodAlterationApplication__c" extensions="GuaranteePeriodAlterationController" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="保修期变更申请"> |
| | | <apex:page standardController="GuaranteePeriodAlterationApplication__c" extensions="GuaranteePeriodAlterationController" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="保修期变更申请" lightningStylesheets="true"> |
| | | <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> |
| | | <apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/> |
| | | |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/> |
| | |
| | | </apex:actionFunction> |
| | | <apex:actionFunction name="DelConsumable" action="{!DelConsumable}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CheckStatusAfter()"> |
| | | </apex:actionFunction> |
| | | <apex:actionFunction name="uploadingAttachmentJs" action="{!uploadingAttachment}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CheckStatusAfter()"> |
| | | <apex:actionFunction name="uploadingAttachmentJs" action="{!uploadingAttachmentLightning}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CheckStatusAfter()"> |
| | | </apex:actionFunction> |
| | | <!-- <apex:actionFunction name="returnChangePage" action="{!returnChangePage}" rerender="ConsumableorderdetailsSection, message" onComplete="unblockUI();CheckStatusAfter()"> |
| | | </apex:actionFunction> --> |
| | |
| | | <apex:outputPanel id="allPanel"> |
| | | <apex:pageBlock id="allBlock" > |
| | | <apex:pageBlock id="EDCline_1" > |
| | | <apex:commandButton style="display:none"/> |
| | | <apex:commandButton onclick="EditConsumable();" value="编辑" style="margin-left:30px;width:180px" rerender="dummy" rendered="{!!(editAble)}" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准'||ambc.Change_status__c='驳回',true,false)}"/> |
| | | |
| | | <apex:commandButton onclick="SorderJs();" value="提交申请" style="margin-left:30px;width:180px" rerender="dummy" rendered="{!!(editAble )}" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准',true,false)}"/> |
| | |
| | | id="val1" style="width:100px"/> |
| | | </td> |
| | | <td align="right"></td> |
| | | <td><apex:commandButton value="保有设备搜索" style="width: 100px;" onclick="searchProductJs('0');return false;" /></td> |
| | | <td><apex:commandButton value="保有设备搜索" style="width: 120px;" onclick="searchProductJs('0');return false;" /></td> |
| | | <td><input type="button" value="清空" style="width: 100px;" onclick="ClearJs();return false;" class="btn"/></td> |
| | | <td/> |
| | | </tr> |
| | |
| | | |
| | | <td colspan="3"/> |
| | | |
| | | <td colspan="4"> 变更原因:<!-- <apex:selectList value="{!ambc.ChangeReason__c}" id="changeReason01" size="1" style="width:204px" onchange="ChangeReasonjs('{!ambc.ChangeReason__c}');"><apex:selectOptions value="{!changeReasonOpts}" /> --> |
| | | <td colspan="4" style="height:50px"> 变更原因:<!-- <apex:selectList value="{!ambc.ChangeReason__c}" id="changeReason01" size="1" style="width:204px" onchange="ChangeReasonjs('{!ambc.ChangeReason__c}');"><apex:selectOptions value="{!changeReasonOpts}" /> --> |
| | | <!-- </apex:selectList> --> |
| | | <apex:inputField value="{!ambc.ChangeReason__c}" style="width:200px"></apex:inputField> |
| | | </td> |
| | |
| | | <td colspan="3"/> |
| | | <!-- <td colspan="1"/> --> |
| | | <!-- <td colspan="5"> 变更原因其他:<apex:inputText value="{!ambc.ChangeReason_text__c}" style="width:200px"/></td> --> |
| | | <td colspan="4"> 安装日期:<apex:outputField value="{!ambc.WarrantyStartDate__c}" style="width:200px"/></td> |
| | | <td colspan="4"> 安装日期:<apex:outputField value="{!ambc.WarrantyStartDate__c}" style="width:200px"/></td> |
| | | <!-- <td colspan="4"> 保修天数:<apex:inputText value="{!ambc.WarrantyDays__c}" style="width:200px"/></td> --> |
| | | <!-- <td colspan="4"/> --> |
| | | </tr> |
| | |
| | | </apex:outputPanel> |
| | | <apex:pageBlock title="保有设备所属变更明细" id="ConsumableorderdetailsSection"> |
| | | <input type="hidden" id="allPage:allForm:allBlock:ConsumableorderdetailsSection:ConsumableorderdetailsCount" value="{!ConsumableorderdetailsviewCount}" /> |
| | | <input type="hidden" id="allPage:allForm:allBlock:ConsumableorderdetailsSection:Id" value="{!Id}" /> |
| | | <table class="list" border="0" cellpadding="0" cellspacing="0"> |
| | | <tr class="headerRow"> |
| | | <apex:variable var="v" value="" rendered="{!editAble}"> |
| | |
| | | |
| | | </apex:pageBlock> |
| | | <!-- CHAN-BC6BV2 XHL AddStart 20190522 --> |
| | | <apex:pageBlock title="附件" id="accessory" rendered="{!isShow}"> |
| | | <apex:pageBlock title="文件" id="accessory" rendered="{!isShow}"> |
| | | |
| | | <apex:pageBlockButtons location="top"> |
| | | <apex:commandButton value="附件上传" onclick="uploadingAttachmentJs();" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准',true,false)}"/> |
| | | <apex:commandButton value="文件上传" onclick="uploadingAttachmentJs();" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准',true,false)}"/> |
| | | </apex:pageBlockButtons> |
| | | <apex:pageBlockTable value="{!attachments}" var="attachment" > |
| | | <apex:pageBlockTable value="{!contents}" var="attachment" > |
| | | |
| | | |
| | | <apex:column headerValue="标题" style="width: 33%"> |
| | | <apex:outputField value="{!attachment.Name}"/> |
| | | <apex:outputField value="{!attachment.Title}"/> |
| | | </apex:column> |
| | | <apex:column headerValue="上次修改时间" style="width: 33%"> |
| | | <apex:outputField value="{!attachment.CreatedDate}"/> |
| | | <apex:outputField value="{!attachment.ContentModifiedDate}"/> |
| | | </apex:column> |
| | | <apex:column headerValue="创建人" style="width: 33%"> |
| | | <apex:outputField value="{!attachment.OwnerId}"/> |
| | |
| | | <apex:pageBlock id="searchBlock" rendered="{!editAble}"> |
| | | <table> |
| | | <colgroup> |
| | | <col width="10px"/> |
| | | <col width="10px"/> |
| | | <col width="0px"/> |
| | | <col width="0px"/> |
| | | <col width="60px"/> |
| | | <col width="85px"/> |
| | | <col width="60px"/> |
| | |
| | | <td align="right"></td> |
| | | <td></td> |
| | | <td/> |
| | | <td align="right">选择条件:</td> |
| | | <td align="right"> 选择条件:</td> |
| | | <td> |
| | | <apex:selectList value="{!text1}" id="text1" size="1" style="width:90px"><apex:selectOptions value="{!textOpts}"/> |
| | | </apex:selectList> |
| | | </td> |
| | | <td> |
| | | <apex:inputText value="{!val1}" |
| | | id="val1" style="width:100px"/> |
| | | id="val1" style="width:200px"/> |
| | | </td> |
| | | <td align="left"><div id="seachdiv">合同编码精确查询<apex:inputCheckbox value="{!checkexact}" id="RowCheckbox"/></div></td> |
| | | <td><apex:commandButton value="保有设备搜索" style="width: 120px;" onclick="searchProductJs('0');return false;" /></td> |
| | |
| | | </tr> |
| | | <tr> |
| | | <td colspan="3"/> |
| | | <td colspan="4"> 原客户:<apex:outputField value="{!ambc.rawAccount__c}"/></td> |
| | | <td colspan="4">目标客户:<apex:inputField id="OEC" value="{!ambc.AccountField__c}" style="width:200px"/></td> |
| | | <td colspan="4" style="height:50px;"> 原客户:<apex:outputField value="{!ambc.rawAccount__c}"/></td> |
| | | <td colspan="4">目标客户:<apex:inputField id="OEC" value="{!ambc.AccountField__c}" style="height:25px;width:200px"/></td> |
| | | </tr> |
| | | |
| | | <tr > |
| | | <apex:outputPanel rendered="{!checkUser}"> |
| | | <td colspan="3"/> |
| | | <td colspan="4">SPO表单号:<apex:inputText value="{!ambc.SPOLink__c}" style="width:200px"/></td> |
| | | <td colspan="4"> SPO表单号:<apex:inputText value="{!ambc.SPOLink__c}" style="width:200px"/></td> |
| | | </apex:outputPanel> |
| | | <!-- CHAN-B9B68N Start --> |
| | | <td colspan="4">变更原因:<!-- <apex:selectList value="{!ambc.ChangeReason__c}" id="changeReason01" size="1" style="width:204px"><apex:selectOptions value="{!changeReasonOpts}"/> --><apex:inputField value="{!ambc.ChangeReason__c}"></apex:inputField> |
| | |
| | | </tr> |
| | | <tr> |
| | | <td colspan="3"/> |
| | | <td colspan="4"> |
| | | 备注:<apex:inputText value="{!ambc.remark__c}" style="width:200px"/></td> |
| | | |
| | | <td colspan="4" style="height:50px;"> |
| | | 备注:<apex:inputText value="{!ambc.remark__c}" style="width:200px"/></td> |
| | | <!-- LZHU-BPJ8DF 20200513 Start --> |
| | | <td colspan="4">变更设备总数:<apex:outputField value="{!ambc.DetailCnt__c}"/></td> |
| | | <td colspan="4" style="height:50px;">变更设备总数:<apex:outputField value="{!ambc.DetailCnt__c}"/></td> |
| | | <!-- LZHU-BPJ8DF 20200513 End --> |
| | | </tr> |
| | | </tr> |
| | | <!-- WLIG-BS7B4T ---20200806---update By rentongxiao---Start --> |
| | | <tr> |
| | | <!-- 共享字段的回显 --> |
| | | <td colspan="3"/> |
| | | <td colspan="4"> |
| | | 共享:<apex:inputCheckbox value="{!ambc.share__c}" style="width:50px"/> |
| | | 共享:<apex:inputCheckbox value="{!ambc.share__c}" style="height:20px;width:20px"/> |
| | | </td> |
| | | <td colspan="4"></td> |
| | | </tr> |
| | |
| | | <apex:pageBlock title="文件" id="accessory" rendered="{!isShow}"> |
| | | |
| | | <apex:pageBlockButtons location="top"> |
| | | <apex:commandButton value="文件上传" onclick="uploadingAttachmentJs();" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准',true,false)}"/> |
| | | <apex:commandButton value="附件上传" onclick="uploadingAttachmentJs();" disabled="{!IF(ambc.Change_status__c='已提交'||ambc.Change_status__c='批准',true,false)}"/> |
| | | </apex:pageBlockButtons> |
| | | |
| | | <apex:pageBlockTable value="{!contents}" var="attachment" > |
| | |
| | | |
| | | sforce.connection.sessionId = '{!GETSESSIONID()}'; |
| | | |
| | | var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Asset.Id}\' and name = \'QRCode\'"); |
| | | |
| | | // var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Asset.Id}\' and name = \'QRCode\'"); |
| | | var record = sforce.connection.query("SELECT ContentDocumentId from ContentDocumentLink where LinkedEntityId =\'{!Asset.Id}\'"); |
| | | var records; |
| | | if(record.size > 0){ |
| | | records = record.getArray("records"); |
| | | var idList = records.map(obj => "'" + obj.ContentDocumentId + "'").join(","); |
| | | record = sforce.connection.query("SELECT Id,Title, OwnerId, ContentModifiedDate FROM ContentDocument WHERE Id IN (" + idList + ") AND Title = 'QRCode'"); |
| | | } |
| | | // 既にあれば無視 |
| | | if (record.size == 0) { |
| | | var atta = new sforce.SObject("Attachment"); |
| | | atta.Name = "QRCode"; |
| | | atta.ParentId = "{!Asset.Id}"; |
| | | atta.Body = src; |
| | | var result = sforce.connection.create([atta]); |
| | | // var atta = new sforce.SObject("Attachment"); |
| | | // atta.Name = "QRCode"; |
| | | // atta.ParentId = "{!Asset.Id}"; |
| | | // atta.Body = src; |
| | | // var result = sforce.connection.create([atta]); |
| | | var version = new sforce.SObject("ContentVersion"); |
| | | version.VersionData = src; |
| | | version.Title = "QRCode"; |
| | | version.ContentLocation= 's'; |
| | | version.PathOnClient="QRCode.jpg"; |
| | | var versionResult = sforce.connection.create([version]); |
| | | record = sforce.connection.query("SELECT ContentDocumentId FROM ContentVersion WHERE Id =\'" + versionResult[0].id + "\'"); |
| | | records = record.getArray("records"); |
| | | var link = new sforce.SObject("ContentDocumentLink"); |
| | | link.ContentDocumentId = records[0].ContentDocumentId; |
| | | link.LinkedEntityId = "{!Asset.Id}"; |
| | | link.ShareType = 'I'; |
| | | link.Visibility = 'AllUsers'; |
| | | var result = sforce.connection.create([link]); |
| | | |
| | | |
| | | var es = new sforce.SObject("Asset"); |
| | | es.Id = "{!Asset.Id}"; |
| | | es.QRId__c = result[0].id; |
| | | es.QRId__c = result[0].ContentDocumentId; |
| | | es.Fixture_QRCode_Text__c = "{!Asset.Fixture_QRCode__c}"; |
| | | result = sforce.connection.update([es]); |
| | | } else if ("{!Asset.QRId__c}" == null || "{!Asset.QRId__c}" == '' || "{!Asset.Fixture_QRCode__c}" != "{!Asset.Fixture_QRCode_Text__c}"){ |
| | | var records = record.getArray("records"); |
| | | var atta = new sforce.SObject("Attachment"); |
| | | atta.Name = "QRCode"; |
| | | atta.Body = src; |
| | | atta.Id = records[0].Id; |
| | | var result = sforce.connection.update([atta]); |
| | | // var records = record.getArray("records"); |
| | | // var version = |
| | | // var atta = new sforce.SObject("Attachment"); |
| | | // atta.Name = "QRCode"; |
| | | // atta.Body = src; |
| | | // atta.Id = records[0].Id; |
| | | // var result = sforce.connection.update([atta]); |
| | | |
| | | |
| | | var result = sforce.connection.query("SELECT Id from ContentDocumentLink where ContentDocumentId =" + record[0].Id); |
| | | var version = sforce.connection.query("SELECT Id from ContentVersion where ContentDocumentId =" + record[0].Id); |
| | | var versions = version.getArray("versions"); |
| | | var atta = new sforce.SObject("ContentVersion"); |
| | | atta.VersionData = src; |
| | | atta.Id = versions[0].Id; |
| | | version = sforce.connection.update([atta]); |
| | | records = result.getArray("records"); |
| | | var es = new sforce.SObject("Asset"); |
| | | es.Id = "{!Asset.Id}"; |
| | | es.QRId__c = result[0].id; |
| | | es.QRId__c = records[0].Id; |
| | | es.Fixture_QRCode_Text__c = "{!Asset.Fixture_QRCode__c}"; |
| | | result = sforce.connection.update([es]); |
| | | // TODO Name変わる可能性あり、upsertにします |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexPage xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>35.0</apiVersion> |
| | | <apiVersion>43.0</apiVersion> |
| | | <availableInTouch>false</availableInTouch> |
| | | <confirmationTokenRequired>false</confirmationTokenRequired> |
| | | <label>AssetQR</label> |
| | |
| | | src = srcNew.substring(22, srcNew.length); |
| | | sforce.connection.sessionId = '{!GETSESSIONID()}'; |
| | | |
| | | var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Consum_Apply__c.Id}\' and name = \'BRCode-{!Consum_Apply__c.Name_No__c}\'"); |
| | | // var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Consum_Apply__c.Id}\' and name = \'BRCode-{!Consum_Apply__c.Name_No__c}\'"); |
| | | |
| | | var record = sforce.connection.query("select Id,ContentDocumentId from ContentDocumentLink where LinkedEntityId = \'{!Consum_Apply__c.Id}\'"); |
| | | if(record.size > 0){ |
| | | var records = record.getArray("records"); |
| | | var idList = records.map(obj => "'" + obj.ContentDocumentId + "'").join(","); |
| | | record = sforce.connection.query("select Id from ContentDocument where Id in (" + idList + ") and Title = \'BRCode-{!Consum_Apply__c.Name_No__c}\'"); |
| | | } |
| | | // 既にあれば無視 |
| | | if (record.size == 0) { |
| | | var atta = new sforce.SObject("Attachment"); |
| | | atta.Name = "BRCode-{!Consum_Apply__c.Name_No__c}"; |
| | | atta.ParentId = "{!Consum_Apply__c.Id}"; |
| | | atta.Body = src; |
| | | var result = sforce.connection.create([atta]); |
| | | // var atta = new sforce.SObject("Attachment"); |
| | | // atta.Name = "BRCode-{!Consum_Apply__c.Name_No__c}"; |
| | | // atta.ParentId = "{!Consum_Apply__c.Id}"; |
| | | // atta.Body = src; |
| | | // var result = sforce.connection.create([atta]); |
| | | var version = new sforce.SObject("ContentVersion"); |
| | | version.VersionData = src; |
| | | version.Title = "BRCode-{!Consum_Apply__c.Name_No__c}"; |
| | | version.ContentLocation = 's'; |
| | | version.PathOnClient= "BRCode-{!Consum_Apply__c.Name_No__c}.jpg"; |
| | | var versionResult = sforce.connection.create([version]); |
| | | record = sforce.connection.query("SELECT ContentDocumentId FROM ContentVersion WHERE Id =\'" + versionResult[0].id + "\'"); |
| | | var records = record.getArray("records"); |
| | | var link = new sforce.SObject("ContentDocumentLink"); |
| | | link.ContentDocumentId = records[0].ContentDocumentId; |
| | | link.LinkedEntityId = "{!Consum_Apply__c.Id}"; |
| | | link.ShareType = 'I'; |
| | | link.Visibility = 'AllUsers'; |
| | | var result = sforce.connection.create([link]); |
| | | |
| | | var es = new sforce.SObject("Consum_Apply__c"); |
| | | es.Id = "{!Consum_Apply__c.Id}"; |
| | | es.BRId__c = result[0].id; |
| | | es.BRId__c = records[0].ContentDocumentId; |
| | | result = sforce.connection.update([es]); |
| | | //申请书更新失败的话再次更新 |
| | | } else if ("{!Consum_Apply__c.BRId__c}" == '' || "{!Consum_Apply__c.BRId__c}" == null) { |
| | |
| | | result = sforce.connection.update([es]); |
| | | // TODO Name変わる可能性あり、upsertにします |
| | | } else { |
| | | alert(record[0].id); |
| | | var records = record.getArray("records"); |
| | | // alert(records[0].Id); |
| | | } |
| | | } |
| | | // BRcode生成後、Attachmentを作成 |
| | |
| | | |
| | | sforce.connection.sessionId = '{!GETSESSIONID()}'; |
| | | |
| | | var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Consum_Apply__c.Id}\' and name = \'QRCode-{!Consum_Apply__c.Name}\'"); |
| | | // var record = sforce.connection.query("select id from Attachment where ParentId = \'{!Consum_Apply__c.Id}\' and name = \'QRCode-{!Consum_Apply__c.Name}\'"); |
| | | var record = sforce.connection.query("select ContentDocumentId from ContentDocumentLink where LinkedEntityId = \'{!Consum_Apply__c.Id}\'"); |
| | | // 不存在qr文件时,新生成一个,并连到申请单上 |
| | | console.log(record.size); |
| | | if(record.size > 0){ |
| | | var records = record.getArray("records"); |
| | | var idList = records.map(obj => "'" + obj.ContentDocumentId + "'").join(","); |
| | | record = sforce.connection.query("select Id from ContentDocument where Id in (" + idList + ") and Title = \'QRCode-{!Consum_Apply__c.Name}\'"); |
| | | console.log("select Id from ContentDocument where Id in (" + idList + ") and Title = \'QRCode-{!Consum_Apply__c.Name}\'"); |
| | | } |
| | | console.log(record.size); |
| | | if (record.size == 0) { |
| | | var atta = new sforce.SObject("Attachment"); |
| | | atta.Name = "QRCode-{!Consum_Apply__c.Name}"; |
| | | atta.ParentId = "{!Consum_Apply__c.Id}"; |
| | | atta.Body = src; |
| | | var result = sforce.connection.create([atta]); |
| | | // var atta = new sforce.SObject("Attachment"); |
| | | // atta.Name = "QRCode-{!Consum_Apply__c.Name}"; |
| | | // atta.ParentId = "{!Consum_Apply__c.Id}"; |
| | | // atta.Body = src; |
| | | // var result = sforce.connection.create([atta]); |
| | | |
| | | var version = new sforce.SObject("ContentVersion"); |
| | | version.Title = "QRCode-{!Consum_Apply__c.Name}"; |
| | | version.VersionData = src; |
| | | version.ContentLocation = "s"; |
| | | version.PathOnClient = "QRCode-{!Consum_Apply__c.Name}.jpg"; |
| | | var result = sforce.connection.create([version]); |
| | | console.log(result[0].id); |
| | | version = sforce.connection.query("select ContentDocumentId from ContentVersion where Id = \'" + result[0].id + "\'"); |
| | | console.log(version); |
| | | version = version.getArray("records"); |
| | | console.log(version); |
| | | var link = new sforce.SObject("ContentDocumentLink"); |
| | | link.LinkedEntityId = "{!Consum_Apply__c.Id}"; |
| | | link.ContentDocumentId = version[0].ContentDocumentId; |
| | | link.ShareType = 'I'; |
| | | link.Visibility = 'AllUsers'; |
| | | result = sforce.connection.create([link]); |
| | | |
| | | var es = new sforce.SObject("Consum_Apply__c"); |
| | | es.Id = "{!Consum_Apply__c.Id}"; |
| | | es.QRId__c = result[0].id; |
| | | es.QRId__c = version[0].ContentDocumentId; |
| | | result = sforce.connection.update([es]); |
| | | } |
| | | else { |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexPage xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>46.0</apiVersion> |
| | | <apiVersion>48.0</apiVersion> |
| | | <availableInTouch>false</availableInTouch> |
| | | <confirmationTokenRequired>false</confirmationTokenRequired> |
| | | <label>ConsumApplyQR</label> |
| | |
| | | <apex:page controller="OFSRepairConsignPDFController" showHeader="false" sidebar="false" action="{!init}" applyHtmlTag="false"> |
| | | <apex:page controller="OFSRepairConsignPDFController" showHeader="false" sidebar="false" action="{!init}" applyHtmlTag="false" renderAs="pdf"> |
| | | <html> |
| | | <head> |
| | | <style> |
| | |
| | | rt.style.width = "300px"; |
| | | rt.style.height = "150px"; |
| | | }); |
| | | |
| | | </script> |
| | | </div> |
| | | </apex:form> |
| | |
| | | <apex:includeScript value="{!URLFOR($Resource.apex20)}"/> |
| | | |
| | | <title> |
| | | 查看附件 |
| | | 查看文件 |
| | | </title> |
| | | <script> |
| | | var widthJs = "500px"; |
| | |
| | | <!-- 标题 --> |
| | | <div style="height: 40px;background-color:#0f218b;width: 100%;text-align: center;"> |
| | | <h1 style="color: white;font-size: 24px;"> |
| | | 查看附件 |
| | | 查看文件 |
| | | </h1> |
| | | </div> |
| | | <div style="height: 30px; margin-top: 10px;"> |
| | |
| | | 4、#control 旋转图标 |
| | | 5、#OriginalDiv 切换原图和画布 --> |
| | | <div id="popLayer"> |
| | | <!--左侧表格 展示所有的附件--> |
| | | <!--左侧表格 展示所有的文件--> |
| | | <div class="solution-list"> |
| | | <apex:pageBlock id="oppBlock" tabStyle="Report"> |
| | | <apex:outputPanel > |
| | |
| | | <apex:variable value="identif" var="identif" rendered="{!IF(identifier == '经销商', true, false)}" > |
| | | <table class="list" style="border-bottom-width: 0px; width:100%; font-size:11px; border-spacing:0;" border="" id="tableHeader_L"> |
| | | <tr class="headerRow" height="30px" align="center"> |
| | | <td><a href="#" onclick="return false;" >附件名称</a></td> |
| | | <td width="55px"><a href="#" onclick="return false;">附件类型</a></td> |
| | | <td><a href="#" onclick="return false;" >文件名称</a></td> |
| | | <td width="55px"><a href="#" onclick="return false;">文件类型</a></td> |
| | | </tr> |
| | | <apex:repeat value="{!acccData}" var="or" id="oppTable"> |
| | | <apex:variable value="{!1}" var="cnt"/> |
| | |
| | | <table class="list" style="border-bottom-width: 0px; width:100%; font-size:11px; border-spacing:0;" border="" id="tableHeader_M"> |
| | | <apex:variable value="identif" var="identif" rendered="{!IF(identifier2 == '医院' && identifier != '经销商' , true, false)}"> |
| | | <tr class="headerRow" height="30px" align="center"> |
| | | <td><a href="#" onclick="return false;" >附件名称</a></td> |
| | | <td width="55px"><a href="#" onclick="return false;">附件类型</a></td> |
| | | <td><a href="#" onclick="return false;" >文件名称</a></td> |
| | | <td width="55px"><a href="#" onclick="return false;">文件类型</a></td> |
| | | </tr> |
| | | </apex:variable> |
| | | <apex:variable value="identif" var="identif" rendered="{!IF(identifier2 == '医院' && identifier == '经销商' , true, false)}"> |
| | |
| | | </h1> |
| | | </div> |
| | | <div class="solution-item" id="imgeDiv"> |
| | | <div id="onCloseId" style="position: absolute;top:55px;padding-left:73%;cursor:pointer;display:none;"><a href="javascript:void(0)" onclick="closePop()" style="padding-rigth:13px;color:#fff;font-weight:bolder;font-size:15px;text-decoration: none;">关闭</a></div> |
| | | <div id="onCloseId" style="position: absolute;top:75px;padding-left:67%;cursor:pointer;display:none;"><a href="javascript:void(0)" onclick="closePop()" style="padding-rigth:13px;color:#fff;font-weight:bolder;font-size:15px;text-decoration: none;">关闭</a></div> |
| | | <!-- 增加pdf关闭按钮 精琢技术 thh 2021-09-27 start --> |
| | | <div class="PdfCss" id="fontpdf" style="display: none;"> |
| | | <h1 style="position:absolute;top:50%;margin:-4% 0 0 -10%;"> |
| | | <h1 style="position:absolute;top:50%;"> |
| | | <font face="verdana" style="font-size: 40px;">此页暂时只支持图片文件的预览</font> |
| | | </h1> |
| | | </div> |
| | |
| | | document.getElementById("imgeDiv").style.display='block'; |
| | | |
| | | fadeIn("imgeDiv",1000); |
| | | //获取点击的附件名称 |
| | | //获取点击的文件名称 |
| | | var accName = obj.cells[0].innerText; |
| | | //asdf-kjklljk 电子签收-担当环节优化开发 精琢技术 wql 2021/08/09 start |
| | | //获取点击的附件类型 |
| | | //获取点击的文件类型 |
| | | var accContentType = obj.cells[1].innerText; |
| | | //asdf-kjklljk 电子签收-担当环节优化开发 精琢技术 wql 2021/08/09 end |
| | | //截取后缀名 |
| | |
| | | mouseDownLocation = windowToCanvas(canvas, event.clientX, event.clientY); |
| | | if (isPointInImageArea(mouseDownLocation)) { |
| | | isMouseDown = true; |
| | | document.title = '查看附件'; |
| | | document.title = '查看文件'; |
| | | } |
| | | } |
| | | /**鼠标弹起*/ |
| | | document.body.onmouseup = function() { |
| | | isMouseDown = false; |
| | | canvas.style.cursor = "default"; |
| | | document.title = '查看附件'; |
| | | document.title = '查看文件'; |
| | | } |
| | | /**鼠标移动*/ |
| | | pandiv.onmousemove = function(event) { |