二开案例.单据插件.切换视图

【应用场景】
通过插件的方式,切换单据视图,刷新单据界面。
【案例演示】
采购订单,通过下拉列表显示所有扩展上的视图,并且可任意切换视图。

【实现步骤】
<1>编写单据插件,代码如下。
using Kingdee.BOS;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// <summary>
/// 【单据插件】切换视图
/// </summary>
[Description("【单据插件】切换视图"), HotUpdate]
public class ChangeLayoutFormPlugIn : AbstractBillPlugIn
{
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
BindComboField();
var layoutId = Convert.ToString(this.View.OpenParameter.GetCustomParameter("Jac_LayoutId", true));
if (!string.IsNullOrWhiteSpace(layoutId))
{
// 切换视图后,下拉列表绑定当前视图
this.Model.DataObject["F_Jac_Combo"] = layoutId;
this.View.UpdateView("F_Jac_Combo");
}
}
public override void DataChanged(DataChangedEventArgs e)
{
base.DataChanged(e);
if (e.Field.Key.EqualsIgnoreCase("F_Jac_Combo"))
{
var layoutId = e.NewValue as string;
var para = new BillShowParameter();
CopyCustomeParameter(para);
para.OpenStyle.ShowType = ShowType.InCurrentForm;
para.FormId = this.View.OpenParameter.FormId;
para.DefaultBillTypeId = ((DynamicObject)this.Model.GetValue(this.View.BillBusinessInfo.GetBillTypeField())).ToString();
para.LayoutId = layoutId;
para.Status = this.View.OpenParameter.Status;
para.PKey = null;
para.ParentPageId = this.View.OpenParameter.ParentPageId;
// PageId必须确保一致
para.PageId = this.View.PageId;
// 本view标记为已经失效,需要重新构建
this.View.OpenParameter.IsOutOfTime = true;
para.CustomParams["Jac_LayoutId"] = layoutId;
this.View.ShowForm(para);
}
}
/// <summary>
/// 复制用户定制的属性
/// </summary>
/// <param name="para"></param>
private void CopyCustomeParameter(BillShowParameter para)
{
var openParamType = this.View.OpenParameter.GetType();
var properties = openParamType.GetProperties();
var IsnotCustomerPropertyKeys = new List<string>() { "pk", "billType" };
// 复制定制参数
var customerParams = this.View.OpenParameter.GetCustomParameters();
if (customerParams != null && customerParams.Count > 0)
{
foreach (var item in customerParams)
{
if (IsnotCustomerPropertyKeys.Contains(item.Key)) continue;
if (item.Value == null) continue;
if (!(item.Value is string)) continue; // 只复制字符串参数
var prop = properties.FirstOrDefault(p => p.Name.EqualsIgnoreCase(item.Key));
if (prop != null) continue;
para.CustomParams[i二开案例.单据插件.切换视图
【应用场景】通过插件的方式,切换单据视图,刷新单据界面。【案例演示】采购订单,通过下拉列表显示所有扩展上的视图,并且可任意切换视图...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇



