在业务单据的单据体增加“行删除”按钮字段,点击按钮触发相关字段的更新或者校验,只要你有sql增删改查的语法基础,熟悉金蝶云星空数据字典表结构,加之python插件的简单可操作性。以下是基本格式套路。重点关注def EntryBarItemClick(e)和raise Exception,如何取消行操作按钮DeleRow绑定的行删除操作的核心在于点击按钮DeleRow后抛异常Exception
其他按实际业务场景去灵活设计。
Python虽然简单,但是对格式要求很高,建议专门下载python语句编译器。
以采购订单行删除校验为例,在明细信息增加菜单栏按钮“删除行”,命名标识,绑定“删除明细分录”操作
# 引入clr运行库
import clr
# 添加对cloud插件开发的常用组件的引用
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.DataEntity')
clr.AddReference('Kingdee.BOS.ServiceHelper')
# 导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.List import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from System import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.ServiceHelper import *
def EntryBarItemClick(e):
if e.BarItemKey == "DeleRow":
row = this.Model.GetEntryCurrentRowIndex ( "FPOOrderEntry" )
entiry = this.View.Model.BillBusinessInfo.GetEntity ( "FPOOrderEntry" )
pkValue = this.View.Model.GetEntryPKValue ( entiry.Key , row )
IDs = DBServiceHelper.ExecuteDataSet ( this.Context ,"/*dialect*/select 1 from T_BF_INSTANCEENTRY where FSTABLENAME = 't_PUR_POOrderEntry' and FSID = " + str(pkValue))
if IDs.Tables.Count > 0 and IDs.Tables[0].Rows.Count > 0 :
raise Exception ("当前选中行有下游单据,不允许删除,请先删除下游单据!")
return