掌上报销移动端二开新增单据体

【应用场景】
客户在PC端二开新增单据体,需要在移动端也能支持相关二开单据体的展示与录入、删除
【注意事项】
移动端二开方案基于移动列表实现,目前移动列表无法支持自定义字段,所以移动列表展示的字段需要到移动表单里面固定写死,分录录单需要额外新增移动表单录入(2023.06.08补丁,标准产品有预置空白移动表单供二开使用ER_MBReimb_EntityEditV3)
【案例演示】
以费用报销单为例
【实现步骤】
<1>在PC端费用报销单新增单据体

<2>单据体分录增加新增、删除按钮(此知识贴只有新增、删除相关功能,至于复制等其他操作,参考现有操作即可),绑定新增操作,删除操作


<3>拓展ER_MBReimb_ExpReimbV3(掌上报销V3_费用报销单)移动表单,新增移动列表布局,添加移动列表需要展示的字段


勾选新增时不删除默认分录行,不然分录录单触发值更新以后会提示寻找实体上对应的属性描述符失败

表单插件代码如下:
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.FormElement;
using Kingdee.BOS.Mobile;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.Core.Mobile.Const;
using Kingdee.K3.Core.Mobile.Objects;
using Kingdee.K3.Core.Mobile.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace Kingdee.K3.FIN.ER.Mobile.Business.PlugIn.MobileReimbV3.AddEntityTest
{
[Description("掌上报销V3_费用报销单新增单据体测试")]
public class MBReimbAddEntityTest : MBReimbExpReimbEdit
{
public MBReimbAddEntityTest()
{
_commandMethods = new Dictionary<string, Action<MobEventArgs>>(StringComparer.OrdinalIgnoreCase);
_commandMethods["FMobileListViewEntity"] = LinkToEditEntry;
_commandMethods["FButtonAdd"] = LinkToAddEntry;
_commandMethods["FButtonDel"] = LinkToDelete;
}
public override void EntityRowDoubleClick(EntityRowClickEventArgs e)
{
if (_commandMethods.ContainsKey(e.Key))
{
_commandMethods[e.Key](new MobEventArgs(e.Key, e.Row - 1));
}
}
public override void ButtonClick(ButtonClickEventArgs e)
{
if (_commandMethods.ContainsKey(e.Key))
{
_commandMethods[e.Key](new MobEventArgs(e.Key, e.MenuKey.TryPareValue<int>()));
}
}
/// <summary>
/// 通用方法
/// </summary>
protected Dictionary<string, Action<MobEventArgs>> _commandMethods;
/// <summary>
/// 编辑分录
/// </summary>
/// <param name="e"></param>
protected void LinkToEditEntry(MobEventArgs e)
{
var showParameter = GetShowChildParameter("MobAddEntity_Test", Convert.ToString(e.Row), "FEntity1");
showParameter.OpenStyle.ShowType = ShowType.Modal;
showParameter.Status = BOS.Core.Metadata.OperationStatus.EDIT;
this.View.ShowForm(showParameter, x =>
{
if (x.ReturnData != null && Convert.ToBoolean(x.ReturnData))
{
UpdateSingleEntry(e.Row);
}
});
}
/// <summary>
/// 新增分录
/// </summary>
/// <param name="e"></param>
protected void LinkToAddEntry(MobEventArgs e)
{
var op = BillView.BusinessInfo.GetForm().FormOperations.FirstOrDefault(x => x.OperationId == FormOperation.Operation_NewEntry && x.Parmeter != null && !x.Parmeter.OperationObjectKey.IsNullOrEmptyOrWhiteSpace() && x.Parmeter.OperationObjectKey.EqualsIgnoreCase("FEntity1"));
if (op == null)
{
this.View.ShowMessage("找不到新增分录的操作,请检查BOS配置");
return;
}
var opResult = BillView.InvokeFormOperation(op.Operation);
if (!opResult)
return;
var addRow = BillView.Model.GetEntryRowCount("FEntity1") - 1;
if (addRow < 0)
return;
var showParameter = GetShowChildParameter("MobAddEntity_Test", Convert.ToString(addRow), "FEntity1");
showParameter.OpenStyle.ShowType = ShowType.Modal;
this.View.ShowForm(showParameter, x =>
{
if (x.ReturnData != null && Convert.ToBoolean(x.ReturnData))
{
FillEntryData();
}
});
}
protected void LinkToDelete(MobEventArgs e)
{
this.View.ShowMessage(Kingdee.BOS.Resource.ResManager.LoadKDString("是否删除此行明细", "00444575000020654", Kingdee.BOS.Resource.SubSystemType.SCM), MessageBoxOptions.YesNo, x =>
{
if (x != MessageBoxResult.Yes)
return;
BillView.SetEntityFocusRow("FEntity1", e.Row);
var opResult = BillView.InvokeFormOperation("DeleteEntryTest");
if (!opResult)
return;
this.View.Model.DeleteEntryRow("FMobileListViewEntity", e.Row);
UpdateControlState();
});
}
public override void OnSetLayoutInfo(SetLayoutInfoArgs e)
{
base.OnSetLayoutInfo(e);
var entityAppearaces = _myLayoutInfo.GetEntityAppearances();
var entityDict = _myBusinessInfo.Entrys.ToDictionary(x => x.Key, x => x);
if (entityAppearaces != null && entityAppearaces.Count > 0 && entityDict.Count > 0)
{
foreach (var item in entityAppearaces.Where(item => entityDict.ContainsKey(item.Key)))
{
item.Entity = entityDict[item.Key];
}
}
var fieldAppearances = _myLayoutInfo.GetFieldAppearances();
var fieldDict = _myBusinessInfo.GetFieldList().ToDictionary(x => x.Key, x => x);
if (fieldAppearances != null && fieldAppearances.Count > 0 && fieldDict.Count > 0)
{
foreach (var item in fieldAppearances.Where(item => item.Field != null && fieldDict.ContainsKey(item.Key)))
{
item.Field.Entity = fieldDict[item.Key].Entity;
}
}
}
protected override void FillData()
{
base.FillData();
FillEntryData();
}
protected void FillEntryData()
{
//填充移动列表
var localEntryData = this.View.Model.GetEntityDataObject(this.View.BusinessInfo.GetEntryEntity("FMobileListViewEntity"));
localEntryData.Clear();
var billEntryData = BillView.Model.GetEntityDataObject(BillView.BusinessInfo.GetEntryEntity("FEntity1"));
if (billEntryData == null)
return;
//全部展开
if (billEntryData != null && billEntryData.Any())
{
this.View.Model.BatchCreateNewEntryRow("FMobileListViewEntity", billEntryData.Count);
for (var i = 0; i < billEntryData.Count; i++)
{
FillSingleEntry(billEntryData, localEntryData, i);
}
this.View.UpdateView("FMobileListViewEntity");
}
}
/// <summary>
/// 填充单一分录数据
/// </summary>
/// <param name="billEntryData"></param>
/// <param name="localEntryData"></param>
/// <param name="row"></param>
protected void FillSingleEntry(DynamicObjectCollection billEntryData, DynamicObjectCollection localEntryData, int row)
{
if (billEntryData.Count <= row || localEntryData.Count <= row)
return;
this.View.SetEntityFocusRow("FMobileListViewEntity", row);
//var billEntry = billEntryData[row];
var localEntry = localEntryData[row];
var billEntry = billEntryData[row];
localEntry["Text4"] = "费用" + Convert.ToString(row + 1);
localEntry["Text2"] = billEntry.GetPropertyValue<string>("Decimal"); ;//小数
localEntry["Text3"] = billEntry.GetPropertyValue<string>("Date1");//日期
localEntry["Text"] = billEntry.GetPropertyValue<string>("Text");//文本
掌上报销移动端二开新增单据体
【应用场景】客户在PC端二开新增单据体,需要在移动端也能支持相关二开单据体的展示与录入、删除【注意事项】移动端二开方案基于移动列表实...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇



