星空中python脚本初实现
#Title:SetNewSerial
#引入clr运行库
import clr
#添加对cloud插件开发的常用组件的引用
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
from System import DateTime
from Kingdee.BOS.Core import *
#这里说明py也是可以调用函数的,当然也是可以继承其他类的
def EntryCellFocued(e):
ResetSNEntityRows();
def ResetSNEntityRows():
entity=this.View.BillBusinessInfo.GetEntity("FEntity"); #获取明细信息表体
nCurParRow=this.View.Model.GetEntryCurrentRowIndex("FEntity");#获取明细信息表体的当前所在行
rowentity =this.Model.GetEntityDataObject(entity, nCurParRow);#得到明细表体中当前行的所有数据的对象,通过这个对象可以访问该行所有数据列内容
nRows=int(rowentity["RealQty"]);#获取当前行实发数量的值,int是对该值整数化,注意的是【】中的值对应的是实发数量的实体字段名
nOldRows=this.Model.GetEntryRowCount("F_ora_SubEntity");#获取新序列号单据体的行数
nRow=0;
if(nRows>0):
#this.View.ShowMessage("name:"+str(rowentity["FMaterialID"])); showmessage函数经常会用到,尤其是调试的时候
#下面语句是让序列号单据体行数随明细单据体实发数量数值发生增减
if(nRows<nOldRows):
nDelRow=nOldRows-1;
#由于子单据体删行是删掉一行后,下面一行会自动补上上一个行号,所以删除只能从下往上删除
for nRow in range(nDelRow,nRows-1,-1): #利用while总是不能正确执行,所以只能用for
this.Model.DeleteEntryRow("F_ora_SubEntity",nRow); #在model中删除指定行,然后使用view的updateview更新前端的显示。
this.View.UpdateView("F_ora_SubEntity");
else:
while nRow<(nRows-nOldRows):
this.Model.CreateNewEntryRow("F_ora_SubEntity");#在model中用createnew新增行,不用使用updateview即可更新前端
nRow+=1;
#在数值更新事件中执行,开始的时候实发数量改变增加序列号单据体也在这里了,但是这个事件不能响应下推的单据事件,因为下推的数量就不需要修改了
#所以目前只是执行了序列号填写了后序列号数量随之发生变化
def DataChanged(e):
if(e.Field.Key.ToUpperInvariant()=="F_ORA_TEXT"): #注意这里用了upperinvariant函数,名称变为全部大写来比较
strCurSN=e.NewValue.ToString();#获取事件参数的值
#this.View.ShowMessage("sn:"+str(strCurSN)+";erow:"+str(e.Row));
if strCurSN=="":
this.Model.SetValue("F_ora_Integer","0",e.Row); #使用model.setvalue来设置子单据体某行某列的数值,更新完成后记得用updateview来更新前端显示
else:
this.Model.SetValue("F_ora_Integer","1",e.Row);
this.View.UpdateView("F_ora_Integer");
entryRows = this.Model.GetEntryRowCount("F_ora_SubEntity");
nRow=0;
nCount=0;
while nRow<entryRows:
nCount+=int(this.Model.GetValue("F_ora_Integer",nRow));#model.getvalue来获取子单据体N行的N列字段值
nRow+=1;
nCurParRow=this.View.Model.GetEntryCurrentRowIndex("FEntity");
this.Model.SetValue("F_ORA_INTEGER1",str(nCount),nCurParRow);
this.View.UpdateView("F_ORA_INTEGER1");
def SetSNEntityRows(e):
#entity=this.View.BillBusinessInfo.GetEntity("FEntity");
nRows=int(e.NewValue.ToString());
nOldRows=this.Model.GetEntryRowCount("F_ora_SubEntity");
#this.View.ShowMessage("rows:"+str(oldRows));
nRow=0;
if(nRows<nOldRows):
nDelRow=nOldRows-1;
#this.View.ShowMessage("oldrows:"+str(nOldRows)+";rows:"+str(nRows)+";delrows:"+str(nDelRow));
for nRow in range(nDelRow,nRows-1,-1):
this.Model.DeleteEntryRow("F_ora_SubEntity",nRow);
else:
while nRow<(nRows-nOldRows):
this.Model.CreateNewEntryRow("F_ora_SubEntity");
nRow+=1;
#this.View.ShowMessage("qty:"+str(row));
#这个事件响应子单据体上的上传按钮事件
def ToolBarItemClick(e):
if(e.BarItemKey=="ora_tbSplitSN"): #理论上这里其实应该用upperinvariant函数
entryRows = this.Model.GetEntryRowCount("F_ora_SubEntity");
strSN=str(this.Model.GetValue("F_ora_Remarks") );
strSNList=strSN.split(','); #使用split来分解字符串,这里需要特别说明一下,原来都是使用的回车,\r\n \n,这两种在客户端和chrome都没有问题,但是在IE中就会有问题,所以最终就改为了逗号
nCount=len(strSNList);#获取分解数组数
nRow=0;
this.Model.SetValue("F_ora_Remarks","");
this.View.UpdateView("F_ora_Remarks");
#this.View.ShowMessage("count:"+str(nCount));
while nRow<entryRows:
if(nRow+1<=nCount):
this.Model.SetValue("F_ora_Text",strSNList[nRow],nRow);
nRow+=1;
this.View.UpdateView("F_ora_Text");

浙公网安备 33010602011771号