根据下来列表切换来显示单据的视图二开示例
根据下来列表切换来显示单据的视图二开,首先自定义一个下拉字段,设置此字段的值更新属性,当这个下拉列表的值切换的时候,就加载需要的视图。表单插件代码示例如下:
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Web.DynamicForm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.Util;
namespace Kingdee.BOS.Printing.PlugIn.Test
{
public class CoustomShowLayout : AbstractBillPlugIn
{
bool changeLayout = false;//私有变量,用来控制DataChanged发生死循环
public override void OnInitialize(Core.DynamicForm.PlugIn.Args.InitializeEventArgs e)
{
base.OnInitialize(e);
changeLayout = Convert.ToBoolean(this.View.OpenParameter.GetCustomParameter("changeLayout"));
}
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
if (changeLayout)
{
string value = Convert.ToString(this.View.OpenParameter.GetCustomParameter("F_HZQ_PrivateCombo"));
this.Model.SetValue("F_HZQ_PrivateCombo", value);
changeLayout = false;
}
}
public override void DataChanged(Core.DynamicForm.PlugIn.Args.DataChangedEventArgs e)
{
base.DataChanged(e);
if (e.Field.Key == "F_HZQ_PrivateCombo" && !changeLayout)//如果是下拉列表切换,则显示视图
{
Test("614bce7538f11d", "005056a3-0125-856c-11ec-0b8b379fb7e3");
changeLayout = true;
}
}
/// <summary>
///
/// </summary>
/// <param name="defaultBillTypeId">默认的单据类型</param>
/// <param name="layoutId">视图的唯一标识</param>
private void Test(string defaultBillTypeId, string layoutId)
{
BillShowParameter para = new BillShowParameter();
this.CopyCustomeParameter(para);
para.OpenStyle.ShowType = ShowType.InCurrentForm;
para.FormId = this.View.BusinessInfo.GetForm().Id;
para.DefaultBillTypeId = defaultBillTypeId;
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;
// 回调函数处理
Action<FormResult> callbackAction = null;
this.View.ShowForm(para, callbackAction);
}
private void CopyCustomeParameter(BillShowParameter para)
{
Type openParamType = this.View.OpenParameter.GetType();
var properties = openParamType.GetProperties();
List<string> 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[item.Key] = Convert.ToString(item.Value);
}
}
para.CustomParams["F_HZQ_PrivateCombo"] = Convert.ToString(this.Model.GetValue("F_HZQ_PrivateCombo"));
para.CustomParams["changeLayout"] = "true";
}
}
}
根据下来列表切换来显示单据的视图二开示例
本文2024-09-23 04:19:03发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164534.html