@byteluck-fe/model-driven-engine 2.3.1-beta.25 → 2.3.1-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/esm/common/ActionManager.js +273 -0
  2. package/dist/esm/common/DataManager.js +213 -0
  3. package/dist/esm/common/Engine.js +1584 -0
  4. package/dist/esm/common/OkWorker.js +134 -0
  5. package/dist/esm/common/Plugin.js +10 -0
  6. package/dist/esm/common/Runtime.js +306 -0
  7. package/dist/esm/common/Store.js +377 -0
  8. package/dist/esm/common/checkerValue.js +622 -0
  9. package/dist/esm/common/index.js +2 -0
  10. package/dist/esm/common/proxyState.js +315 -0
  11. package/dist/esm/index.js +3 -0
  12. package/dist/esm/plugins/CalcPlugin.js +482 -0
  13. package/dist/esm/plugins/ControlsEventPlugin.js +315 -0
  14. package/dist/esm/plugins/ES6ModulePlugin.js +181 -0
  15. package/dist/esm/plugins/LifecycleEventPlugin.js +320 -0
  16. package/dist/esm/plugins/StylePlugin.js +59 -0
  17. package/dist/esm/plugins/index.js +5 -0
  18. package/dist/esm/utils/index.js +1 -0
  19. package/dist/esm/utils/runtimeUtils.js +43 -0
  20. package/dist/index.umd.js +28 -0
  21. package/dist/types/common/ActionManager.d.ts +14 -0
  22. package/dist/types/common/DataManager.d.ts +10 -0
  23. package/dist/types/common/Engine.d.ts +180 -0
  24. package/dist/types/common/OkWorker.d.ts +13 -0
  25. package/dist/types/common/Plugin.d.ts +6 -0
  26. package/dist/types/common/Runtime.d.ts +25 -0
  27. package/dist/types/common/Store.d.ts +49 -0
  28. package/dist/types/common/checkerValue.d.ts +3 -0
  29. package/dist/types/common/index.d.ts +2 -0
  30. package/dist/types/common/proxyState.d.ts +30 -0
  31. package/dist/types/index.d.ts +3 -0
  32. package/dist/types/plugins/CalcPlugin.d.ts +121 -0
  33. package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -0
  34. package/dist/types/plugins/ES6ModulePlugin.d.ts +26 -0
  35. package/dist/types/plugins/LifecycleEventPlugin.d.ts +14 -0
  36. package/dist/types/plugins/StylePlugin.d.ts +12 -0
  37. package/dist/types/plugins/index.d.ts +5 -0
  38. package/dist/types/utils/index.d.ts +1 -0
  39. package/dist/types/utils/runtimeUtils.d.ts +5 -0
  40. package/package.json +3 -3
@@ -0,0 +1,14 @@
1
+ export declare class ActionManager {
2
+ private actionMap;
3
+ private buildinActions;
4
+ /**
5
+ * 执行action的时候,作为第二个参数传递给方法,可以通过外部挂载
6
+ */
7
+ actionUtils: {};
8
+ /**
9
+ * 用于存储es module解析出来的源码,CustomVueControlPlugin
10
+ */
11
+ sources: {};
12
+ execAction(name: string, context: any, ...args: any[]): Promise<any>;
13
+ addAction(name: string, func: Function): void;
14
+ }
@@ -0,0 +1,10 @@
1
+ import { EventPayload } from './Engine';
2
+ export declare class DataManager {
3
+ private _dataStore;
4
+ private executer?;
5
+ constructor(callbackExecuter: (payload: EventPayload) => Promise<any>);
6
+ add(key: string, data: any): void;
7
+ get(key: string): any;
8
+ remove(key: string): void;
9
+ getRemoteData(payload: EventPayload): Promise<any>;
10
+ }
@@ -0,0 +1,180 @@
1
+ import { ControlRuntimeInstance, ControlsInstance, ControlsKeys, DataBind, DeepPartial, LayoutControls, ObjectDataBind, RuntimeControl, RuntimeListControl, Schema } from '@byteluck-fe/model-driven-core';
2
+ import { Callback, Watcher } from '@byteluck-fe/model-driven-shared';
3
+ import { Plugin } from './Plugin';
4
+ import { Runtime, RuntimeProps } from './Runtime';
5
+ import { DataBindMappingFieldItem, dataBindMappingType, DataBindMappingTypeItem, StatesType, StateType } from './Store';
6
+ import { ActionManager } from './ActionManager';
7
+ import { DataManager } from './DataManager';
8
+ export type getDataControlIdMappingType = {
9
+ [controlId: string]: {
10
+ dataBind: any;
11
+ dataView: string;
12
+ children: getDataControlIdMappingType;
13
+ };
14
+ };
15
+ type dataSetType = {
16
+ [dataCode: string]: Record<string, unknown> | Record<string, unknown>[];
17
+ };
18
+ type FieldSetType = {
19
+ [fieldCode: string]: unknown;
20
+ };
21
+ interface EventPayload {
22
+ instance?: RuntimeControl;
23
+ value?: unknown;
24
+ rowIndex?: number;
25
+ options?: {
26
+ [key: string]: any;
27
+ };
28
+ }
29
+ interface SchemaEventPayload {
30
+ instance: RuntimeControl;
31
+ value: unknown;
32
+ props: string;
33
+ rowIndex?: number;
34
+ }
35
+ type EngineProps<T extends keyof LayoutControls = keyof LayoutControls> = {
36
+ schema: RuntimeProps['schema'];
37
+ beforeCreateInstance?: RuntimeProps['beforeCreateInstance'];
38
+ plugins?: Plugin[];
39
+ language?: string;
40
+ autoMount?: boolean;
41
+ debug?: boolean;
42
+ externalParams?: Record<string, unknown>;
43
+ };
44
+ type EventKeys = 'click' | 'click-finish' | 'wps-open' | 'wps-save' | 'wps-rename' | 'change' | 'schema-change' | 'search' | 'checked' | 'input' | 'focus' | 'blur' | 'list-change' | 'list-splice' | 'list-delete' | 'list-before-insert' | 'list-search' | 'list-mounted' | 'list-actions' | 'engine-mounted' | 'engine-submit' | 'engine-submit-params' | 'engine-submitted' | string;
45
+ declare class Engine extends Watcher<EventKeys> {
46
+ private store;
47
+ rawStore: Record<string, any>;
48
+ parent?: Engine;
49
+ runtime: Runtime;
50
+ isMounted: boolean;
51
+ id: string;
52
+ readonly externalParams?: Record<string, any>;
53
+ private __plugins;
54
+ private __pluginsApplied;
55
+ private readonly $options;
56
+ private actionManager;
57
+ private dataManager?;
58
+ private _jobTasks;
59
+ constructor(props: EngineProps);
60
+ private debugLog;
61
+ use(plugin: Plugin): this;
62
+ registerControl(...arg: Parameters<Runtime['register']>): this;
63
+ static register(...arg: Parameters<(typeof Runtime)['register']>): typeof import("@byteluck-fe/model-driven-core").RegisterControls;
64
+ static judgeControlIsRegistered(control: Parameters<(typeof Runtime)['register']>[0]): boolean;
65
+ mount(): void;
66
+ destroy(): void;
67
+ private _handlerProxyState;
68
+ private _proxyStateBeforeSetCallback;
69
+ private _proxyStateCallback;
70
+ private _handlerArrayUpdate;
71
+ private _handlerObjectUpdate;
72
+ private applyPlugins;
73
+ listControlCreateRow<RowType extends ControlsKeys>(instance: RuntimeListControl, rowType: RowType): NonNullable<InstanceType<import("@byteluck-fe/model-driven-core").ControlsConstructor<RowType, "Runtime">>> | undefined;
74
+ listControlAddRow(instance: RuntimeListControl, rowType?: ControlsKeys): void;
75
+ emit(eventKey: EventKeys, payload: EventPayload): Promise<unknown[]>;
76
+ on(key: EventKeys, callback: Callback): void;
77
+ createControl(...args: Parameters<Runtime['createControl']>): never[];
78
+ createInstance<T extends ControlsKeys>(type: T, initSchema?: DeepPartial<Schema<T>>): ControlsInstance<T, 'Runtime'> | undefined;
79
+ createControlInstance: <T extends never>(type: T, initSchema?: DeepPartial<Schema<T, InstanceType<import("@byteluck-fe/model-driven-core").Controls[T]["Property"]>>> | undefined) => InstanceType<import("@byteluck-fe/model-driven-core").ControlsConstructor<T, "Runtime">> | undefined;
80
+ schemaEvent(eventKey: 'schema-change', payload: SchemaEventPayload): void;
81
+ updateInstanceProps(instance: SchemaEventPayload['instance'] | string, props: string, value: unknown, rowIndex?: number): void;
82
+ getAllRules(controlId?: string): {
83
+ rules: import("async-validator").Rules | undefined;
84
+ antdRules: import("async-validator").Rules | undefined;
85
+ };
86
+ getRules(controlId?: string): import("async-validator").Rules | undefined;
87
+ getAntdRules(controlId?: string): import("async-validator").Rules | undefined;
88
+ getState(controlId?: string, rowIndex?: number): unknown;
89
+ getEmptyState(controlId?: string): any;
90
+ /**
91
+ * 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
92
+ * @param options 需要携带的options
93
+ * */
94
+ setPayloadOptions(options: object | null): void;
95
+ setState(controlId: string, value: unknown, rowIndex?: number, options?: any): void;
96
+ /**
97
+ * 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
98
+ * @param states
99
+ */
100
+ setStates(states: StatesType | StateType, rowIndex?: number, options?: any): void;
101
+ /**
102
+ * 通过dataCode和fieldCode来获取控件的值
103
+ * @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
104
+ * @param fieldCode 字段编码 - 控件绑定的数据项的编码
105
+ * @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
106
+ * */
107
+ getField(dataCode: string, fieldCode?: string, rowIndex?: number): unknown;
108
+ getData(dataCode: string): ObjectDataBind | ObjectDataBind[] | undefined;
109
+ /**
110
+ * 通过dataCode和fieldCode来设置控件的值
111
+ * @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
112
+ * @param fieldCode 字段编码 - 控件绑定的数据项的编码
113
+ * @param value 修改的值
114
+ * @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
115
+ * @param options 触发事件携带的参数
116
+ * */
117
+ setField(dataCode: string, fieldCode: string, value: unknown, rowIndex?: number, options?: EventPayload['options']): void;
118
+ /**
119
+ * 通过dataCode和 state来给一组控件赋值,并触发事件携带options
120
+ * @param dataCode 需要赋值的目标模型
121
+ * @param state 赋值对象,以fieldCode为key组成的对象
122
+ * @param rowIndex 行下标,给明细子表赋值时指定赋值某行
123
+ * @param options 触发事件携带的参数
124
+ * */
125
+ setFields(dataCode: string, state: FieldSetType, rowIndex?: number, options?: EventPayload['options']): void;
126
+ /**
127
+ * 通过dataCode来将state转化为标准的state结构
128
+ * @param dataCode 需要转换的目标模型code
129
+ * @param state 值对象,以fieldCode为key组成的对象
130
+ * */
131
+ buildFields(dataCode: string, state: FieldSetType): StateType | undefined;
132
+ /**
133
+ * 向Store设置一组值,并触发事件携带options
134
+ * @param dataSet
135
+ * @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
136
+ */
137
+ setData(dataSet: dataSetType, options?: any): void;
138
+ /**
139
+ * 获取控件的dataBind
140
+ * @param controlId
141
+ * */
142
+ getDataBind(controlId: string): DataBind | ObjectDataBind | undefined;
143
+ /**
144
+ * 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
145
+ * @param controlId
146
+ * @param rowIndex
147
+ */
148
+ getInstance(controlId: string, rowIndex?: number): ControlRuntimeInstance<ControlsKeys> | undefined;
149
+ /**
150
+ * 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
151
+ * @param controlId
152
+ * @param header 明细表内是否获取表头的控件
153
+ */
154
+ getInstances(controlId?: string, header?: boolean): ControlRuntimeInstance<ControlsKeys>[];
155
+ setInstance(instance: SchemaEventPayload['instance'] | string, props: string, value: unknown, rowIndex?: number): void;
156
+ getControlIdMapping(): import("./Store").controlIdMappingType;
157
+ getDataBindMapping(): dataBindMappingType;
158
+ getDataBindMapping(dataCode: string): DataBindMappingTypeItem | undefined;
159
+ getDataBindMapping(dataCode: string, fieldCode: string): DataBindMappingFieldItem | undefined;
160
+ getAction(): ActionManager;
161
+ initDataManager(callbackExecuter: (payload: EventPayload) => Promise<any>): void;
162
+ getDataManager(): DataManager | undefined;
163
+ /**
164
+ * 判断控件的类型,返回当前控件的正确类型
165
+ * */
166
+ assertInstance<T extends ControlsKeys>(instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl, types: T | T[]): instance is ControlRuntimeInstance<T>;
167
+ /**
168
+ * 获取控件在明细子表中的行下标,
169
+ * 如果控件在表头内,则返回-1
170
+ * 如果控件在表内,则返回行下标
171
+ * 如果控件不在明细表内,则返回undefined
172
+ * */
173
+ getInstanceRowIndex(instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl): number | undefined;
174
+ getInstanceParentControl<T extends ControlsKeys>(instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl, controlType: T): ControlRuntimeInstance<T> | undefined;
175
+ getInstanceInSubtableHeader<T extends ControlsKeys>(instance: ControlRuntimeInstance<T> | RuntimeControl): ControlRuntimeInstance<T> | undefined;
176
+ setControlConfig(...args: Parameters<Runtime['registerControlConfig']>): Runtime;
177
+ getControlConfig(control: ControlsKeys): Readonly<Record<string, unknown>> | undefined;
178
+ inList(controlId: string): boolean;
179
+ }
180
+ export { Engine, EventPayload, SchemaEventPayload, EngineProps };
@@ -0,0 +1,13 @@
1
+ interface WorkerMessage {
2
+ action: string;
3
+ payload: unknown;
4
+ }
5
+ declare class OkWorker {
6
+ worker?: Worker;
7
+ run(initState: any): void;
8
+ destroy(): void;
9
+ postMessage(message: WorkerMessage): void;
10
+ private static createWorker;
11
+ private static createWorkerFunction;
12
+ }
13
+ export { OkWorker };
@@ -0,0 +1,6 @@
1
+ import { Engine } from './Engine';
2
+ declare abstract class Plugin {
3
+ abstract pluginName?: string;
4
+ abstract apply(engine: Engine): void;
5
+ }
6
+ export { Plugin };
@@ -0,0 +1,25 @@
1
+ import { RuleItem } from 'async-validator';
2
+ import { ControlRuntimeInstance, ControlsKeys, RegisterControls, BeforeCreateInstance } from '@byteluck-fe/model-driven-core';
3
+ export interface RuntimeProps {
4
+ schema: any;
5
+ beforeCreateInstance?: BeforeCreateInstance;
6
+ }
7
+ export type InstanceMap = Record<string, ControlRuntimeInstance<ControlsKeys>[]>;
8
+ export declare class Runtime extends RegisterControls<'Runtime'> {
9
+ private _schema;
10
+ private _instance;
11
+ private _flatInstances;
12
+ private _instanceMap;
13
+ constructor(props: RuntimeProps);
14
+ getFlatInstances(): ControlRuntimeInstance<ControlsKeys>[];
15
+ get schema(): any;
16
+ get instance(): ControlRuntimeInstance<ControlsKeys>[];
17
+ get flatInstances(): ControlRuntimeInstance<ControlsKeys>[];
18
+ get instanceMap(): InstanceMap;
19
+ get allRules(): {
20
+ rules: Record<string, RuleItem>;
21
+ antdRules: Record<string, RuleItem>;
22
+ };
23
+ get rules(): Record<string, RuleItem>;
24
+ get antdRules(): Record<string, RuleItem>;
25
+ }
@@ -0,0 +1,49 @@
1
+ import { RuntimeControl, DataBind, ObjectDataBind, OptionSetting } from '@byteluck-fe/model-driven-core';
2
+ export type StateType = {
3
+ [controlId: string]: unknown;
4
+ };
5
+ export type StatesType = {
6
+ [dataViewId: string]: StateType;
7
+ };
8
+ export type controlIdMappingType = {
9
+ [controlId: string]: {
10
+ dataBind: DataBind | ObjectDataBind;
11
+ dataView: string;
12
+ children?: controlIdMappingType;
13
+ options: Array<OptionSetting>;
14
+ };
15
+ };
16
+ export interface DataBindMappingTypeItem {
17
+ controlId: string;
18
+ dataViewId: string;
19
+ fields: Array<DataBindMappingFieldItem>;
20
+ }
21
+ export interface DataBindMappingFieldItem {
22
+ fieldCode: string;
23
+ controlId: string;
24
+ dataBind: DataBind | ObjectDataBind;
25
+ dataViewId: string[];
26
+ }
27
+ export type dataBindMappingType = {
28
+ [dataCode: string]: DataBindMappingTypeItem;
29
+ };
30
+ type StoreProps = {
31
+ instance: RuntimeControl[];
32
+ };
33
+ declare class Store {
34
+ readonly emptyState: StatesType;
35
+ state: StatesType;
36
+ dataBindMapping: dataBindMappingType;
37
+ controlIdMapping: controlIdMappingType;
38
+ constructor(props: StoreProps);
39
+ /**
40
+ * 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
41
+ * @param controlId 组件ID
42
+ * @param value
43
+ */
44
+ setState(controlId: string, value: unknown, rowIndex?: number): void;
45
+ getState(controlId: string, rowIndex?: number): unknown;
46
+ getEmptyState(controlId: string): Object | undefined;
47
+ getDataBind(controlId: string): DataBind | ObjectDataBind | undefined;
48
+ }
49
+ export { Store };
@@ -0,0 +1,3 @@
1
+ import { FieldTypes } from '@byteluck-fe/model-driven-shared';
2
+ export declare function checkerValue(fieldType: FieldTypes, key: string, value: unknown, oldValue: unknown): unknown;
3
+ export declare function checkerSubtableValue(fieldTypeMap: Record<string, FieldTypes>, value: Record<string, any>, emptyValue: Record<string, any>): Record<string, any>;
@@ -0,0 +1,2 @@
1
+ export * from './Engine';
2
+ export * from './Plugin';
@@ -0,0 +1,30 @@
1
+ import { RuntimeControl, RuntimeFormControl, ControlRuntimeInstance } from '@byteluck-fe/model-driven-core';
2
+ import { InstanceMap } from './Runtime';
3
+ export type ArrayApi = 'splice' | 'push' | 'shift' | 'pop' | 'unshift' | 'reverse';
4
+ /**
5
+ * @param state 当前正在操作的state数据
6
+ * @param key 当前操作的state的key 这个key是从store.state开始的
7
+ * @param type 如果state是数组,并且直接操作api的话,会携带type参数,代表当前操作的数组的某个api
8
+ * @param args 如果state是数组,并且直接操作api的话,会携带args参数,代表当前操作的api的参数
9
+ */
10
+ type Callback = (state: object, key: string, type?: ArrayApi | unknown, args?: unknown[], result?: unknown) => void;
11
+ type BeforeSetCallback = (state: object, key: string, newValue: unknown, oldValue: unknown) => never | unknown;
12
+ export declare const engineProxyFlag: unique symbol;
13
+ export declare const engineTargetKey: unique symbol;
14
+ export declare const engineArrayBeforeSetCallbackFlag: unique symbol;
15
+ export declare const engineProxyThisKey: unique symbol;
16
+ /**
17
+ * 代理state数据
18
+ * @param state 数据对象
19
+ * @param callback 触发set时候的回调函数
20
+ * @param beforeSetCallback
21
+ * @param prevKey 递归对象的key
22
+ * */
23
+ export declare function proxyState<T extends object>(state: T, callback: Callback, beforeSetCallback: BeforeSetCallback, prevKey?: string): T;
24
+ /**
25
+ * 在flatInstance中通过key查找出对应的instance
26
+ * @param flatInstance 拍平的instance数组
27
+ * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
28
+ * */
29
+ export declare function findItem(flatInstance: RuntimeControl[], key: string, instanceMap: InstanceMap): undefined | RuntimeFormControl | ControlRuntimeInstance<'subtable'>;
30
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './common';
2
+ export * from './plugins';
3
+ export * from './utils';
@@ -0,0 +1,121 @@
1
+ import { Engine, Plugin } from '../common';
2
+ import { Language } from '@byteluck-fe/model-driven-core';
3
+ declare enum DisplayType {
4
+ /**
5
+ * 完全等于
6
+ */
7
+ EQ = "EQ",
8
+ /**
9
+ * 包含
10
+ * */
11
+ IN = "IN"
12
+ }
13
+ interface DisplayItem {
14
+ id: string;
15
+ show_edit: boolean;
16
+ explain: Language;
17
+ control_id: string;
18
+ control_in_subtable: boolean;
19
+ type: DisplayType;
20
+ option_ids: string[];
21
+ is_remember: boolean;
22
+ show_controls: string[];
23
+ hide_controls: string[];
24
+ }
25
+ interface BehaviorItem {
26
+ /**
27
+ * 0: 不控制,走控件 1: 隐藏 2:只读 6:可编辑
28
+ * */
29
+ ctrlBehavior: 0 | 1 | 2 | 6;
30
+ ctrlId: string;
31
+ }
32
+ interface CalcPluginProps {
33
+ displayBoList: DisplayItem[];
34
+ behavior: BehaviorItem[];
35
+ }
36
+ export declare class CalcPlugin implements Plugin {
37
+ private engine;
38
+ private options;
39
+ /**
40
+ * 所有的计算公式控件
41
+ * */
42
+ private calcControls;
43
+ /**
44
+ * key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
45
+ * 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
46
+ * */
47
+ private dependenciesTriggerMap;
48
+ /**
49
+ * 隐藏以后需要被计算的控件
50
+ * */
51
+ private hideNotRememberControlIds;
52
+ private dontHasPermissionControlIds;
53
+ private cacheComputedResult;
54
+ constructor(options: CalcPluginProps);
55
+ /**
56
+ * @description 获取显隐控制的需要被记住值的控件id
57
+ * */
58
+ private getNeedHideRememberControlIds;
59
+ /**
60
+ * @description 获取权限控制的隐藏的字段,不需要参与计算
61
+ * */
62
+ private getDontHasPermissionControlIds;
63
+ /**
64
+ * @description 判断控件是否需要被计算
65
+ * @param control 控件
66
+ * */
67
+ private controlNeedComputedValue;
68
+ /**
69
+ * @description 获取控件是否被隐藏
70
+ * @param control 控件
71
+ * */
72
+ private getControlIsHide;
73
+ apply(engine: Engine): void;
74
+ /**
75
+ * @description 重置依赖,获取所有的计算公式控件,并根据计算公式获取控件依赖关系
76
+ * */
77
+ private resetDependencies;
78
+ /**
79
+ * @description 执行所有计算公式控件的计算
80
+ * */
81
+ private allCalcControlComputed;
82
+ /**
83
+ * @description 获取所有的计算公式控件
84
+ * */
85
+ private getAllCalcControl;
86
+ /**
87
+ * @description 获取计算公式控件依赖,组成 依赖=>[计算公式] 的Map结构
88
+ * */
89
+ private getCalcDependencies;
90
+ private setDependenciesTriggerMapItem;
91
+ private getCalcControlsFromSubtableRows;
92
+ /**
93
+ * @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
94
+ * */
95
+ private watchSchemaHideChange;
96
+ /**
97
+ * @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
98
+ * */
99
+ private watchSubtableChange;
100
+ /**
101
+ * @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
102
+ * */
103
+ private watchControlChange;
104
+ /**
105
+ * @description 控件在明细子表内
106
+ * */
107
+ private controlInSubtable;
108
+ /**
109
+ * @description 执行计算公式的计算
110
+ * */
111
+ private computedCalcValue;
112
+ /**
113
+ * @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
114
+ * */
115
+ private getNumberValue;
116
+ /**
117
+ * 计算明细子表最大值最小值平均值总和
118
+ * */
119
+ private getAggregateTypeValue;
120
+ }
121
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Engine } from '../common/Engine';
2
+ import { Plugin } from '../common/Plugin';
3
+ export type ControlsEvent = {
4
+ [controlId: string]: {
5
+ [eventName: string]: string[];
6
+ };
7
+ };
8
+ export declare class ControlsEventPlugin implements Plugin {
9
+ private config;
10
+ private engine;
11
+ constructor(config: ControlsEvent);
12
+ apply(engine: Engine): void;
13
+ private engineAddEventListener;
14
+ private callControlEvent;
15
+ }
@@ -0,0 +1,26 @@
1
+ import { Engine, Plugin } from '../common';
2
+ export type VariableMap = {
3
+ [key: string]: any;
4
+ };
5
+ export type ActionConfig = {
6
+ module: {
7
+ compiled: string;
8
+ source: string;
9
+ type: 'FUNCTION';
10
+ };
11
+ };
12
+ export type FuncMap = {
13
+ [key: string]: Function;
14
+ };
15
+ export type Module = {
16
+ funcMap: FuncMap;
17
+ variables: VariableMap;
18
+ };
19
+ export declare class ES6ModulePlugin implements Plugin {
20
+ private config;
21
+ private engine;
22
+ private env;
23
+ constructor(config: ActionConfig, env: any);
24
+ apply(engine: Engine): void;
25
+ }
26
+ export declare function parseModule(action: ActionConfig, engine: Engine, env: any): Module | undefined;
@@ -0,0 +1,14 @@
1
+ import { Engine, Plugin } from '../common';
2
+ export type LifecycleEvent = {
3
+ did_mount: string[];
4
+ did_submit: string[];
5
+ will_submit: string[];
6
+ do_submit: string[];
7
+ };
8
+ export declare class LifecycleEventPlugin implements Plugin {
9
+ private config;
10
+ private engine;
11
+ constructor(config: LifecycleEvent);
12
+ apply(engine: Engine): void;
13
+ private callLifecycleEvent;
14
+ }
@@ -0,0 +1,12 @@
1
+ import { Engine, Plugin } from '../common';
2
+ export type StyleConfig = {
3
+ compiled: string;
4
+ source: string;
5
+ type: 'CSS';
6
+ };
7
+ export declare class StylePlugin implements Plugin {
8
+ private config;
9
+ private engine;
10
+ constructor(config: StyleConfig);
11
+ apply(engine: Engine): void;
12
+ }
@@ -0,0 +1,5 @@
1
+ export * from './ES6ModulePlugin';
2
+ export * from './LifecycleEventPlugin';
3
+ export * from './ControlsEventPlugin';
4
+ export * from './CalcPlugin';
5
+ export * from './StylePlugin';
@@ -0,0 +1 @@
1
+ export * from './runtimeUtils';
@@ -0,0 +1,5 @@
1
+ import { ControlRuntimeInstance, ControlsKeys, RuntimeControl, RuntimeFormControl, RuntimeLayoutControl, RuntimeListControl, RuntimeSearchControl } from '@byteluck-fe/model-driven-core';
2
+ export declare function hasChildrenControl(instance: RuntimeControl): instance is RuntimeLayoutControl | RuntimeListControl | RuntimeSearchControl;
3
+ export declare function loopFormControl(control: RuntimeControl[], callback: (item: RuntimeFormControl | ControlRuntimeInstance<'subtable'>, children?: RuntimeFormControl[]) => any): void;
4
+ export declare function loopDataViewControl(control: ControlRuntimeInstance<ControlsKeys>[], callback: (item: ControlRuntimeInstance<'data-view' | 'simple-search'>) => any): void;
5
+ export declare function buildUUID(prefix?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byteluck-fe/model-driven-engine",
3
- "version": "2.3.1-beta.25",
3
+ "version": "2.3.1-beta.26",
4
4
  "description": "> TODO: description",
5
5
  "author": "郝晨光 <2293885211@qq.com>",
6
6
  "homepage": "",
@@ -26,7 +26,7 @@
26
26
  "postpublish": "node ../../scripts/postpublish.js"
27
27
  },
28
28
  "dependencies": {
29
- "@byteluck-fe/model-driven-core": "2.3.1-beta.23",
29
+ "@byteluck-fe/model-driven-core": "2.3.1-beta.26",
30
30
  "@byteluck-fe/model-driven-shared": "2.3.1-beta.23",
31
31
  "@types/mathjs": "^9.4.2",
32
32
  "mathjs": "^11.3.3"
@@ -34,5 +34,5 @@
34
34
  "devDependencies": {
35
35
  "@types/node": "~18.0.6"
36
36
  },
37
- "gitHead": "f709000371a428ee181b1560cc99539d6424b7e5"
37
+ "gitHead": "2dd5344cfff27a67c4fd13f3ca654173e64af4c8"
38
38
  }