二开案例:弹窗式核算维度快速录入
维度关联字段的部分开发逻辑这里不再说明了,看这个帖子: 维度关联字段(开发向)
2021/01/27:增加py 代码附件
<0>问题:凭证核算维度录入编码后,需要两次回车才能跳转到下一控件问题。
原因:这个问题是系统针对F8类型录入的所有方式的实现,第一次回车是前后端的数据交互,包括把编码告诉服务端,服务端根据编码找对应的资料,然后触发关联的值更新、实体服务规则逻辑,然后返回部分其他更新指令给前端。第二次回车时当前控件的处理以及完成,才会跳转到下一控件。
<1>方案:二开插件实现值更新后的快速跳转
(调整了老论坛示例部分代码【分享】弹窗式辅助属性模糊查询回车定位到下个控件问题)
在值更新事件触发时,当且仅当值有效时跳转到下一个维度。
插件挂设的表单标识:BD_ACCTITEMEDITMETA
C#示例代码:
[Kingdee.BOS.Util.HotUpdate]
[Description("核算维度自动跳转")]
public class KsmDynamicFormPlugIn : AbstractDynamicFormPlugIn
{
public override void DataChanged(DataChangedEventArgs e)
{
base.DataChanged(e);
RelatedFlexGroupField flexGroupField = e.Field as RelatedFlexGroupField;
if (flexGroupField == null || e.FlexField == null || e.NewValue == null)//空值不跳转
return;
//控制仅核算维度录入界面启用快速录入
if (flexGroupField.RelatedBDFlexItemLinkField != FormIdConst.BD_FLEXITEMDETAILV)
return;
var baseDataObj = this.Model.GetValue(flexGroupField.RelatedBaseDataFlexGroupField, e.Row) as DynamicObject;
var baseDataField =
this.View.BillBusinessInfo.GetField(flexGroupField.RelatedBaseDataFlexGroupField) as BaseDataField;
if (baseDataObj == null || baseDataField == null)
return;
int flexItemId, flexItemMasterId;
//获取当前基础资料下的可用维度关联字段(如核算维度关联科目、辅助属性关联物料)
var enableList = baseDataField.Controller.GetInUseFlexItemInfo(this.Context, this.View.BillBusinessInfo,
flexGroupField,
baseDataObj, "", out flexItemId, out flexItemMasterId);
enableList = enableList.OrderBy(x => x["FSEQ"]).ToList();
//找到当前修改的维度
int index = enableList.FindIndex(
x => x["FDataFieldName"].ToString().Equals(e.FlexField.Key, StringComparison.OrdinalIgnoreCase));
if (index == -1)
return;
//跳转到下一个维度,当为最后一个维度时,跳转到确认按钮
if (index + 1 < enableList.Count && enableList[index + 1]["FDataFieldName"] != null)
{
string nextFocusControlKey = "$$" + flexGroupField.Key + "__" + enableList[index + 1]["FDataFieldName"].ToString();
this.View.GetControl(nextFocusControlKey).SetFocus();
}
else
{
string nextFocusControlKey = "$$" + flexGroupField.Key + "__" + FormIdConst.BOS_FlexItemFormMeta + "__" + "__btnOK";
this.View.GetControl(nextFocusControlKey).SetFocus();
}
}
}
python插件代码:
clr.AddReference('System')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.ServiceHelper')
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.ServiceHelper import *
from System import *
def DataChanged(e):
if e.Field is not None and e.FlexField is not None and e.NewValue is not None:
if hasattr(e.Field,"RelatedBaseDataFlexGroupField") and e.Field.RelatedBDFlexItemLinkField == FormIdConst.BD_FLEXITEMDETAILV:
bdObj = this.Model.GetValue(e.Field.RelatedBaseDataFlexGroupField,e.Row);
bdField = this.View.BusinessInfo.GetField(e.Field.RelatedBaseDataFlexGroupField);
flexItemId = clr.Reference[int]()
flexMasterItemId =clr.Reference[int]()
enableList = bdField.Controller.GetInUseFlexItemInfo(this.Model.Context,this.Model.BusinessInfo,e.Field,bdObj,"",flexItemId,flexMasterItemId);
curIdx = enableList.FindIndex(lambda x:True if x["FDataFieldname"].ToString().Equals(e.FlexField.Key,StringComparison.OrdinalIgnoreCase) else False )
if curIdx >=0:
try:
if curIdx +1 < enableList.Count and enableList[curIdx+1]["FDataFieldName"] is not None:
nextFocusControlKey = "$$"+e.Field.Key+"__"+enableList[curIdx+1]["FDataFieldName"].ToString();
this.View.GetControl(nextFocusControlKey).SetFocus();
else:
nextFocusControlKey = "$$"+e.Field.Key+"__"+FormIdConst.BOS_FlexItemFormMeta+"__"+"__btnOK";
this.View.GetControl(nextFocusControlKey).SetFocus();
except:
pass;
else:
pass;
二开案例:弹窗式核算维度快速录入
本文2024-09-23 04:20:26发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164678.html