掌上报销单据体附件二开方案

【应用场景】
费用报销PC端相关单据,单据体可通过配置菜单点击事件关联(单据体附件管理)的操作可以实现单据体附件功能,移动端需要二开实现
【注意事项】
该实现方案目前只支持掌上报销5类单据的费用明细,差旅费报销单2019新政行程明细的单据体暂不支持
【案例演示】
PC端费用报销与掌上报销单据头与单据体的映射关系:https://vip.kingdee.com/article/439370655386174720?productLineId=1&isKnowledge=2
【实现步骤】
<1>根据上面的映射关系找到对应的移动表单,以费用报销单为例:
费用报销单分录编辑(单据体)=》ER_MBReimb_ExpItemV3(掌上报销V3_申请/报销单分录)
在BOS设计器中找到ER_MBReimb_ExpItemV3(掌上报销V3_申请/报销单分录)这个表单,然后添加附件布局。
由于是共用表单,附件布局的高度设置为0,由具体的业务插件去设置重新高度。


<2>二开ER_MBReimb_ExpItemV3(掌上报销V3_申请/报销单分录)表单插件
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Attachment;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Interaction;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Mobile.Metadata.ControlDataEntity;
using Kingdee.BOS.Mobile.PlugIn.Args;
using Kingdee.BOS.Orm;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Kingdee.K3.Core.Mobile.Utils;
using Kingdee.K3.FIN.Core.Mobile;
using Kingdee.K3.FIN.ER.Mobile.Business.PlugIn.MobileReimbV3;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace Kingdee.XYZ.Mobile.Business.PlugIn
{
[Description("测试掌上报销V3_申请/报销明细插件")]
public class TestMBReimbExpReimbItemEdit : MBReimbExpReimbItemEdit
{
public override void OnInitialize(InitializeEventArgs e)
{
base.OnInitialize(e);
if (BillView.GetFormId().Equals("ER_ExpReimbursement") || BillView.GetFormId().Equals("ER_ExpReimbursement_Travel"))
{
this.View.GetControl("F_bzsz_FlowLayout").SetCustomPropertyValue("height", 75);
SetAttachment();
}
}
/// <summary>
/// 设置附件控件值
/// </summary>
private void SetAttachment()
{
if (!BillView.Model.GetPKValue().IsNullOrEmptyOrWhiteSpace())
{
Entity ty = BillView.BillBusinessInfo.GetEntity(_entityKey);
var lastAttachFile = MoveAttachmentToTemp(Convert.ToString(BillView.Model.GetPKValue()), BillView.BusinessInfo.GetForm().Id, _entityKey, BillView.Model.GetEntityDataObject(ty, base.MobBillArgs.EntryRow)["Id"].ToString());
AccessoryData _accessoryData = new AccessoryData();
_accessoryData.FormId = BillView.BusinessInfo.GetForm().Id;
_accessoryData.BillId = Convert.ToString(BillView.Model.GetPKValue());
_accessoryData.Data = lastAttachFile.Values.ToList();
this.View.GetControl("FFileUpdateEntry").SetValue(_accessoryData);
this.View.UpdateView("FFileUpdateEntry");
}
}
//获取附件
private Dictionary<string, File> MoveAttachmentToTemp(string interID, string formId, string entryId, string entryInterid)
{
entryId = entryId.IsNullOrEmptyOrWhiteSpace() ? " " : entryId;
entryInterid = entryInterid.IsNullOrEmptyOrWhiteSpace() ? "-1" : entryInterid;
// 加载数据库中附件数据
var filter = Kingdee.BOS.Core.Metadata.OQLFilter.CreateHeadEntityFilter(string.Format("FInterID = '{0}' AND FBILLTYPE = '{1}' AND FENTRYKEY = '{2}' AND FENTRYINTERID = '{3}'", interID, formId, entryId, entryInterid));
var dyns = Kingdee.BOS.ServiceHelper.BusinessDataServiceHelper.Load(this.Context, FormIdConst.BOS_Attachment, null, filter);
Dictionary<string, File> fileList = new Dictionary<string, File>();
if (dyns != null && dyns.Count() > 0)
{
foreach (var dyn in dyns)
{
fileList.Add(Convert.ToString(dyn["Id"]), new File() { FileID = Convert.ToString(dyn["Id"]), Name = Convert.ToString(dyn["AttachmentName"]), Type = Convert.ToString(dyn["ExtName"]) });
}
}
return fileList;
}
public override void AfterMobileUpload(MobileUploadEventArgs e)
{
if (e.Key.ToUpper() == "FFILEUPDATEENTRY")
{
base.AutoDraft(true);
UploadAttachFiles(e);
}
else
{
base.AfterMobileUpload(e);
}
}
public override void MobileDeleteFile(MobileDeleteFileEventArgs e)
{
//获取附件ID
var ids = e.FileNameArray.Select(p => p.FileID.TryPareValue<long>()).ToList();
if (ids == null || ids.Count == 0)
return;
var formMetadata = (FormMetadata)MetaDataServiceHelper.Load(this.Context, FormIdConst.BOS_Attachment);
var option = OperateOption.Create();
option.SetIgnoreWarning(true);
option.SetIgnoreInteractionFlag(true);
option.SetIgnoreScopeValidateFlag(true);
BusinessDataServiceHelper.Delete(this.Context, formMetadata.BusinessInfo, ids.ConvertAll(x => (object)x).ToArray(), option);
}
private void UploadAttachFiles(MobileUploadEventArgs e)
{
Entity ty = BillView.BillBusinessInfo.GetEntity(_entityKey);
//这里是上传整单附件,分录附件上传,请注意EntryKey和EntryInterID的赋值
AttachmentKey attachmentKey = new AttachmentKey();
attachmentKey.BillType = BillView.BusinessInfo.GetForm().Id;
attachmentKey.BillInterID = Convert.ToString(BillView.Model.GetPKValue());
attachmentKey.EntryKey = _entityKey;//单据体标识,单体附件需要把这个值赋上
//attachmentKey.EntryInterID = Convert.ToString(base.MobBillArgs.PKValue);//单据体当前分录内码
if (BillView.Model.GetEntityDataObject(ty, base.MobBillArgs.EntryRow) != null)
{
attachmentKey.EntryInterID = BillView.Model.GetEntityDataObject(ty, base.MobBillArgs.EntryRow)["Id"].ToString();
}
string fileUploadFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, KeyConst.TEMPFILEPATH);
List<string> physicalPaths = new List<string>();
List<FiledUploadEntity> entityList = e.FileNameArray;
//文件名映射(修改后的名称和原名)
Dictionary<string, string> newName_oldName_map = new Dictionary<string, 掌上报销单据体附件二开方案
【应用场景】费用报销PC端相关单据,单据体可通过配置菜单点击事件关联(单据体附件管理)的操作可以实现单据体附件功能,移动端需要二开实...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇



