获取业务规则
作者:王书硕
列表
先在Go上查一次,通过列表方案的extraData传到前端。
func ViewTypeMiddleware() query_list.QueryListMiddleware {
return &viewTypeMiddleware{}
}
func (m *viewTypeMiddleware) Register(ctx query_list.QueryListContext) {
ctx.AddResponsePiplineItem(m.appendExtraData)
}
func (m *viewTypeMiddleware) appendExtraData(ctx query_list.QueryDataContext, response *query_list.QueryResponse) {
funcUnit := calendar_entry.FetchFuncUnit("BudgetPlan", []string{"budgetPlanViewTypeProcessor"}, ctx.GetContext())
response.ExtraData["changeViewTypeId"] = funcUnit
}
前端通过列表presenter.listDefController获取,由于列表中可能包含多个单据类型,需要根据单据类型获取
private getChangeViewType = (billTypeId: string) => {
const extraData = this.presenter.listDefController.dataSource.data.extraData
if(extraData && extraData.changeViewTypeId) {
const changeViewTypeId = extraData.changeViewTypeId.find(i => get(i, 'billType.id') === billTypeId)
return get(changeViewTypeId, 'setting');
}
}
表单
方式一:FormPresenter
class ProjectFormPresenter extends EasyBizFormPresenter<IProject>{
private billTypeRules: Array<IBizProcessFuncUnitSetting> = [];
xx() {
const businessRules = this.bizFormPresenter.api.getBusinessRules()
this.billTypeRules = oc(businessRules).rules([])
}
}
方式二:表单顶部按钮MenuButton
import { FuncUnit_Constants } from '@q7/athena-gen/src';
class ProjectPlanButton extends MenuButton {
private checkEnableProjectRule = () => {
const enableProject: IBizProcessFuncUnitSetting = this.presenter.api.getBusinessRuleById(
FuncUnit_Constants.enableProjectScheduleValidator,
);
if (enableProject) {
return enableProject.setting;
}
return;
};
}
其中FuncUnit_Constants
是根据预置数据生成的,可以问后端你要的业务规则的名字。
业务规则的类型
interface IBizProcessFuncUnitSetting {
applyTo?: { [key: string]: any } // 应用的对象,
applyToTypeObject?: IEnumValue // 应用对象类型,
billIoType?: IEnumValue // 单据方向,
billType?: IBillType // 单据类型,
bizObjectInfoWs?: string // 业务对象信息,
businessType?: IBusinessType // 业务类型,
createdTime?: number // 创建时间,
createdUser?: IUser // 创建人,
criteria?: { [key: string]: any } // 条件,
customizedFields?: { [key: string]: any } // 自定义属性,
dataObject?: IObjectType // 对象类型,
dataVersion?: number // 数据版本,
elseSetting?: { [key: string]: any } // 其他的值,
entrySrcSystem?: IEnumValue // 数据来源类型,
externalObjectId?: string // 外部系统唯一标识,
externalObjectType?: string // 外部系统对象类型,
externalSystemCode?: string // 外部系统标识,
funcUnitBillOfBizProcess?: string // 业务过程处理单元,
funcUnit?: IFuncUnit // 功能部件,
id?: string // ID,
isDeleted?: boolean // 是否为删除数据,
isInitData?: boolean // 是否为预置数据,
isSystem?: boolean // 是否为系统数据,
lastModifiedTime?: number // 最后修改时间,
lastModifiedUser?: IUser // 最后修改人,
lastRequestId?: string // 最后一次更新请求的requestId,
listFieldName?: string // 应用的列表字段名,
modifiedTime?: number // 修改时间,
modifiedUser?: IUser // 修改人,
objectTypeObject?: IObjectType // 对象类型,
overrideModeObject?: IEnumValue // 重载模式,
setting?: { [key: string]: any } // 设置,
settingDisplayInfo?: string // 描述,
sourceBillIoType?: IEnumValue // 允许来源的单据方向,
sourceBillType?: IBillType // 允许来源的单据类型,
sourceBusinessType?: IBusinessType // 允许来源的业务类型,
sourceObjectTypeObject?: IObjectType // 允许来源的对象类型,
uiOption?: { [key: string]: any } // 前端保存的值
}