表单插件二开案例--多级下拉列表联动

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

表单插件二开案例--多级下拉列表联动

1、下拉列表字段空白时,下拉列表2字段显示所有项可选

image.webp

2、下拉列表字段选择枚举名1时,下拉列表2字段显示两项可选

image.webp

3、下拉列表字段选择枚举名2时,下拉列表2字段显示两项可选

image.webp

4、表单插件代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Metadata.ElementMetadata;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;

namespace Kingdee.BOS.TestPlugIn
{
    [HotUpdate]
    [Description("表单插件")]
    public class BillAFormPlugIn : AbstractBillPlugIn
    {
        /// <summary>
        /// 值改变事件
        /// </summary>
        /// <param name="e"></param>
        public override void DataChanged(DataChangedEventArgs e)
        {
            base.DataChanged(e);
            //下拉列表字段改变事件
            if (e.Key.EqualsIgnoreCase("FCombo1"))
            {
                //下拉列表2字段
                var comboField2 = this.View.BillBusinessInfo.GetField("FCombo2") as ComboField;
                var enumItems = ((EnumObject)comboField2.EnumObject).Items; //下拉列表2字段所有枚举项
                //下拉列表2字段编程对象
                var comboFieldEditor2 = this.View.GetFieldEditor<ComboFieldEditor>("FCombo2", 0);
                //当前需要显示的下拉列表2字段枚举值
                EnumObject currEnumItems = new EnumObject();
                if (e.NewValue.ToString() == "A")
                {
                    foreach (var eItem in enumItems)
                    {
                        if (eItem.Value.Contains("A"))
                        {
                            currEnumItems.Items.Add(eItem);
                        }
                    }
                }
                else if (e.NewValue.ToString() == "B")
                {
                    foreach (var eItem in enumItems)
                    {
                        if (eItem.Value.Contains("B"))
                        {
                            currEnumItems.Items.Add(eItem);
                        }
                    }
                }
                else
                {
                    foreach (var eItem in enumItems)
                    {
                        currEnumItems.Items.Add(eItem);
                    }
                }
                comboFieldEditor2.SetComboItems(currEnumItems.Items.ToList());
                this.View.UpdateView("FCombo2");
            }
        }
    }
}


表单插件二开案例--多级下拉列表联动

1、下拉列表字段空白时,下拉列表2字段显示所有项可选2、下拉列表字段选择枚举名1时,下拉列表2字段显示两项可选3、下拉列表字段选择枚举名...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息