A单据附件面版携带到B单据原创
金蝶云社区-张璋张
张璋张
3人赞赏了该文章 661次浏览 未经作者许可,禁止转载编辑于2023年05月16日 14:59:15

打开B单据时将A单据的id作为参数传递,在B单据的afterCreateNewData方法里获取A单据的id

//附件赋值
List<Map<String, Object>> attachmentData = AttachmentServiceHelper.getAttachments(A单标识", A单id,"attachmentpanel");
attachmentData.forEach(attach -> {
	try {
		//源附件数据的lastModified是timestamp,会出现强转long错误在此置null
		attach.put("lastModified", null);
		//源附件数据的url已经过URL编码,需要在此先解码获取原始下载路径,AttachmentServiceHelper.upload()会进行URL编码
		attach.put("url", getPathfromDownloadUrl(URLDecoder.decode(String.valueOf(attach.get("url")), "UTF-8")));
	} catch (IOException e) {
	   //do something with log.
		e.printStackTrace();
	}
});
//调用AttachmentServiceHelper.upload(formId, pkId, attachKey,  attachments)将附件数据上传到目标附件面板
AttachmentServiceHelper.upload(getView().getEntityId(), getModel().getValue("id"), "attachmentpanel", attachmentData);
赞 3