// 场景:列表勾选后批量改备注 // 适用:AbstractListPlugIn // 依赖 API:AfterBarItemClick、ListView.SelectedRowsInfo、GetPrimaryKeyValues、 // ListModel.GetData、View.ShowMessage / ShowWarnningMessage、 // BusinessDataServiceHelper.Save // 相关:ListPlugin.md · ListPluginTemplate.cs · enterprise-plugin-shape.md // // 必须只从白名单取 API,禁止: // GetSelectionData / ShowErr / ShowInputBox / ShowProgress / // BusinessServiceHelper(非 Data)/ 无依据的 View.Model.GetSelectionData using System; using System.ComponentModel; using System.Linq; using Kingdee.BOS.Core.List.PlugIn; using Kingdee.BOS.Core.List.PlugIn.Args; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; namespace MyCompany.MyProject.ListPlugIn { [Description("列表批量备注样例"), HotUpdate] public class ListBatchRemarkSample : AbstractListPlugIn { private const string BAR_KEY = "tbBatchRemark"; // 列表行字段用 PropertyName(以元数据为准);下例为假设 private const string PROP_NOTE = "Note"; public override void AfterBarItemClick(AfterBarItemClickEventArgs e) { base.AfterBarItemClick(e); if (!e.BarItemKey.EqualsIgnoreCase(BAR_KEY)) return; var selected = this.ListView.SelectedRowsInfo; var billIds = selected.GetPrimaryKeyValues(); if (billIds == null || billIds.Length == 0) { this.View.ShowWarnningMessage("未选择任何行!"); return; } // 备注内容:设计器可绑交互;此处用固定值演示写包路径 const string newRemark = "批量备注"; var datas = this.ListModel.GetData(selected); foreach (DynamicObject row in datas) { if (row == null) continue; row[PROP_NOTE] = newRemark; } BusinessDataServiceHelper.Save( this.Context, this.View.BillBusinessInfo, datas.Cast().ToArray(), null, "Save"); this.View.ShowMessage("处理完成,共 " + billIds.Length + " 条"); } } }