昏喽喽

vuePress-theme-reco Lio    2020 - 2025
昏喽喽

Choose mode

  • dark
  • auto
  • light
Home
Category
  • CentOS
  • Csharp
  • DataBase
  • DesignMode
  • Vue
  • FrontEnd
  • GLD
  • Kingdee
  • NetWork
Tags
TimeLine
Tools
  • Http请求
  • 日志配置
  • 加密解密
  • 验证码
  • Git命令
About
author-avatar

Lio

103

Articles

15

Tags

Home
Category
  • CentOS
  • Csharp
  • DataBase
  • DesignMode
  • Vue
  • FrontEnd
  • GLD
  • Kingdee
  • NetWork
Tags
TimeLine
Tools
  • Http请求
  • 日志配置
  • 加密解密
  • 验证码
  • Git命令
About
  • 2023年提单复盘
  • 2022年提单复盘
  • 2021年提单复盘
  • BOS常用方法类库记录
  • 单据状态
  • 常用表名
  • 插件常用方法
  • 客户端常用方法
  • 服务端常用方法
  • 生产用料清单数量计算

客户端常用方法

vuePress-theme-reco Lio    2020 - 2025

客户端常用方法

Lio 2021-02-24 学习笔记

# 1、根据单据ID获取单据的信息

FormMetadata bomFormMetadata = MetaDataServiceHelper.GetFormMetaData(this.Context, "ENG_BOM");
DynamicObject bomData = BusinessDataServiceHelper.LoadSingle(this.Context, bomId, bomFormMetadata.BusinessInfo.GetDynamicObjectType());
1
2

# 2、加载引用属性

Entity entity=this.View.BusinessInfo.GetEntity("FEntity");
DBServiceHelper.LoadReferenceObject(this.Context,this.View.Model.DataObject.GetDynamicValue<DynamicObjectCollection>("Entity").ToArray(),entity.DynamicObjectType);
1
2

# 3、验证权限

验证是否具有某一类单据的操作权限

PermissionAuthResult isViewAuthResult = PermissionServiceHelper.FuncPermissionAuth(this.View.Context,
  new BusinessObject() 
  { 
      Id = "ENG_BOM", SubSystemId = this.View.Model.SubSytemId 
  },
  PermissionConst.Modify);
  if (isViewAuthResult.Passed == false)
  {
      this.View.ShowMessage(string.Format("您在【{0}】组织下没有【物料清单】的【修改】权限,请联系系统管理员", this.View.Context.CurrentOrganizationInfo.Name));
      e.Cancel = true;
      return;
  }
1
2
3
4
5
6
7
8
9
10
11
12

验证是否具有某一单据的操作权限

BillShowParameter bp = MFGCommonUtil.CreateBillShowParameterByPermission(this.Context, formid, moId, out msg);
1

# 4、根据数据包设置字段锁定

//1、因数据包中具有表体行信息,固锁定表体中确定某个值的单元格
this.View.StyleManager.SetEnabled(cloumnName, dynamicObject, CONST_ENG_BOM.CONST_FTreeEntity.ENTITY_FTreeEntity, true);
//2、
FormUtils.StdLockField(this.View, "FSupplyMode");
1
2
3
4

# 5、设置字段隐藏

//1、因数据包中具有表体行信息,固锁定表体中确定某个值的单元格
this.View.StyleManager.SetEnabled(cloumnName, dynamicObject, CONST_ENG_BOM.CONST_FTreeEntity.ENTITY_FTreeEntity, true);
//2、锁定字段
FormUtils.StdLockField(this.View, "FSupplyMode");
//设置字段隐藏
FormUtils.StdHideField(this.View, "FSupplyMode");
1
2
3
4
5
6

# 6、辅助属性字段

RelatedFlexGroupField auxPropField = this.View.BusinessInfo.GetField(CONST_ENG_BOM.CONST_FTreeEntity.KEY_FAuxPropId) as RelatedFlexGroupField;
1

# 6、单据体数据包整体填充

在插件中使用this.Model.BeginIniti()和this.Model.EndIniti()包起来的部分不会触发实体服务规则

FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.GetFormMetaData(this.Context, "ENG_SIMBOMENTRYLIST");
DynamicObjectCollection simBomEntrys = this.Model.GetEntityDataObject(this.View.BusinessInfo.GetEntity("FTreeEntity"));
OperateOption operateOption = OperateOption.Create();
operateOption.SetVariableValue("FormMetadata", formMetadata);
simBomEntrys.FromDataSource(bomEntityData, true, null, null, operateOption);
1
2
3
4
5

# 7、查询单据数据

QueryBuilderParemeter

QueryBuilderParemeter param = new QueryBuilderParemeter
{
    FormId = "BD_MATERIAL",
    SelectItems = SelectorItemInfo.CreateItems("FMaterialId,FMasterId"),
    FilterClauseWihtKey = string.Format("FUseOrgId=@FUseOrgId")
};
param.ExtJoinTables.Add(new ExtJoinTableDescription
{
    FieldName = "FID",
    ScourceKey = "FMasterId",
    TableName = StringUtils.GetSqlWithCardinality(materialDatas.Keys.Distinct().Count(), "@id", 1),
    TableNameAs = "ts"
});
List<SqlParam> sqlParams = new List<SqlParam>()
{
    new SqlParam("@FUseOrgId",KDDbType.Int64,prdOrgId),
    new SqlParam("@id",KDDbType.udt_inttable,materialDatas.Keys.Distinct().ToArray())
};
var materialId = QueryServiceHelper.GetDynamicObjectCollection(this.Context, param, sqlParams);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# 8、代码加实体服务规则

public override void OnInitialize(BOS.Core.DynamicForm.PlugIn.Args.InitializeEventArgs e)
{
    base.OnInitialize(e);
    this.View.RuleContainer.AddPluginRule(CONST_ENG_BOM.CONST_FTreeEntity.ENTITY_FTreeEntity,
        RaiseEventType.Initialized | RaiseEventType.ItemAdded | RaiseEventType.ItemAdding | RaiseEventType.ValueChanged,
        this.SetIsabledAuxProp, new string[] { CONST_ENG_BOM.CONST_FTreeEntity.KEY_FMATERIALIDCHILD });
}
1
2
3
4
5
6
7

# 单据体

  • 获取单据体当前行索引:this.Model.CurrentRowIndex(key);//key:单据体标识

  • 获取单据体分录行数:this.Model.GetEntryRowCount(key);

  • 获取单据体类型:Entity entity=this.Model.BillBusinessInfo.GetEntryEntity(entityKey);

  • 获取单据体分录数据包集合:DynamicObjectCollection datas=this.Model.GetEntityDataObject(entity);

  • 创建单据体一行数据对象:

    • DynamicObject addRow=new DynamicObject(datas.DynamicCollectionItemPropertyType);

    • DynamicObject addRow=new DynamicObject(entity.DynamicObjectType);

  • 单据体数据包整体填充

FormMetadata formMetadata = (FormMetadata)MetaDataServiceHelper.GetFormMetaData(this.Context, "ENG_SIMBOMENTRYLIST");
DynamicObjectCollection simBomEntrys = this.Model.GetEntityDataObject(this.View.BusinessInfo.GetEntity("FTreeEntity"));
OperateOption operateOption = OperateOption.Create();
operateOption.SetVariableValue("FormMetadata", formMetadata);
simBomEntrys.FromDataSource(bomEntityData, true, null, null, operateOption);
1
2
3
4
5
  • 获取单据主键:this.View.Model.GetPKValue();

  • 获取列表当前选中行的主键:this.ListView.SelectedRowsInfo.GetPrimaryKeyValues();

  • 打开界面

单据 列表 动态表单
BillShowParameter ListShowParameter DynamicFormShowParameter
  • 加载界面元数据:FormMetadata formMeta = MetaDataServiceHelper.GetFormMetaData(this.Context,formId);

  • 单据数据包类型:DynamicObjectType dataType=formMeta.BusinessInfo.GetDynamicObjectType();

  • 根据单据ID和数据包类型加载单据数据包:DynamicObject formData=BusinessDataServiceHelper.LoadSingle(this.Context,Id,dataType);