金蝶雲星空——過濾介面文字框彈出選單介面

shanzm發表於2024-10-29

1.在過濾介面拖一個文字控制元件,設定其“顯示編輯按鈕”:true。若是需要禁止輸入,只能透過編輯按鈕進行修改,則設定“編輯風格”:僅按鈕編輯
2.建立服務外掛,注意過濾介面是繼承:動態表單-->公共過濾 的,所以服務外掛中的需要繼承的是:AbstractDynamicFormPlugIn
3.文字框的編輯按鈕的事件在:BeforeF7Select 中可以獲取到

using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace WeiWaiFaLiaoQingDanFilter4
{
    /// <summary>
    /// 委外發料清單過濾視窗——表單外掛
    /// </summary>
    [Description("委外發料清單過濾視窗——表單外掛—採購訂單彈出可選視窗")]
    //參考:https://vip.kingdee.com/article/393320998612955648?productLineId=1&lang=zh-CN
    public class TextEditButtonPlugIn : AbstractDynamicFormPlugIn
    {
        //參考:https://vip.kingdee.com/article/66518760642775808?productLineId=1&lang=zh-CN
        public override void BeforeF7Select(BeforeF7SelectEventArgs e)
        {
            base.BeforeF7Select(e);
            //FPOBILLNOS是文字框的標識
            if (e.FieldKey.EqualsIgnoreCase("FPOBILLNOS"))
            {
                this.ShowPurchaseOrder();
            }
        }

        //參考:https://vip.kingdee.com/article/158494475516452352?share_fromuid=2147411495&productLineId=1&lang=zh-CN
        //參考:https://vip.kingdee.com/article/67241621690988800?productLineId=1&lang=zh-CN
        private void ShowPurchaseOrder()
        {

            //開啟單據列表
            ListShowParameter listShowPara = new ListShowParameter();
            listShowPara.FormId = "PUR_PurchaseOrder";
            listShowPara.PageId = Guid.NewGuid().ToString();
            listShowPara.ParentPageId = this.View.PageId;
            listShowPara.MultiSelect = true;//允許多選
            listShowPara.ListType = (int)Kingdee.BOS.Core.Enums.BOSEnums.Enu_ListType.BaseList;
            //listShowPara.ListType = (int)Kingdee.BOS.Core.Enums.BOSEnums.Enu_ListType.SelBill;
            listShowPara.IsLookUp = true;
            //過濾條件已稽核
            listShowPara.ListFilterParameter.Filter = listShowPara.ListFilterParameter.Filter.JoinFilterString(" FDocumentStatus ='C' ");
            listShowPara.IsShowUsed = true;
            listShowPara.IsShowApproved = false;

            //基於委託回撥機制,實現往父窗體中傳遞資料
            this.View.ShowForm(listShowPara, delegate (FormResult result)
            {
                if (result.ReturnData != null)
                {
                    ListSelectedRowCollection returnData = result.ReturnData as ListSelectedRowCollection;
                    if (returnData.Count > 0)
                    {
                        List<string> billNumbers = returnData.Select(o => o.BillNo).ToList();
                        //賦值到欄位
                        this.View.Model.SetValue("FPoBillNos", string.Join(",", billNumbers));//將使用者多選的資料進行拼接
                        this.View.UpdateView("FPoBillNos");
                    }
                }
            });
        }
    }
}

相關文章