star-horse-lowcode 3.0.9 → 3.1.0

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 (32) hide show
  1. package/README.md +5 -0
  2. package/dist/api/WebSocketUtils.d.ts +0 -3
  3. package/dist/api/form_utils.d.ts +7 -0
  4. package/dist/api/valid_utils.d.ts +2 -1
  5. package/dist/assets/index.css +1 -1
  6. package/dist/components/comp/StarHorseDataSelector.vue.d.ts +1 -58
  7. package/dist/components/comp/StarHorseTableColumn.vue.d.ts +14 -4
  8. package/dist/components/comp/app/MenuShot.vue.d.ts +15 -0
  9. package/dist/components/comp/items/groupItem.vue.d.ts +23 -0
  10. package/dist/components/comp/items/{tableColumn.vue.d.ts → tableColumnItem.vue.d.ts} +12 -2
  11. package/dist/components/comp/utils/DataPicker.vue.d.ts +1 -1
  12. package/dist/components/comp/utils/DataSelectorUtils.d.ts +23 -0
  13. package/dist/components/formcomp/items/description-item.vue.d.ts +19 -0
  14. package/dist/components/formcomp/items/index.d.ts +6 -0
  15. package/dist/components/formcomp/items/link-item.vue.d.ts +19 -0
  16. package/dist/components/formcomp/items/location-item.vue.d.ts +19 -0
  17. package/dist/components/formcomp/items/org-item.vue.d.ts +19 -0
  18. package/dist/components/formcomp/items/progress-item.vue.d.ts +19 -0
  19. package/dist/components/formcomp/items/starhorse-form-item.vue.d.ts +3 -3
  20. package/dist/components/formcomp/items/tree-select-item.vue.d.ts +19 -0
  21. package/dist/components/formcomp/utils/EditDataDialog.vue.d.ts +2 -2
  22. package/dist/components/formcomp/utils/FormulaEngine.d.ts +129 -0
  23. package/dist/components/formcomp/utils/ItemRelationEventUtils.d.ts +6 -22
  24. package/dist/components/help.vue.d.ts +2 -2
  25. package/dist/components/types/ItemPreps.d.ts +4 -0
  26. package/dist/components/types/PageFieldInfo.d.ts +4 -0
  27. package/dist/index.es.js +6 -6
  28. package/dist/lang/en_US.d.ts +141 -0
  29. package/dist/lang/zh_CN.d.ts +141 -0
  30. package/dist/store/FormDataCache.d.ts +6 -0
  31. package/dist/store/StoreManager.d.ts +12 -0
  32. package/package.json +1 -1
@@ -2,81 +2,24 @@ import { ModelValueType } from './utils/DataPicker.vue';
2
2
  import { CSSProperties } from 'vue';
3
3
  import { SearchParams } from '../types';
4
4
  export interface DataSelectorProps {
5
- /**
6
- * 选中数据
7
- */
8
5
  modelValue: ModelValueType;
9
- /**
10
- * 选中数据
11
- */
12
6
  selectedData?: any;
13
- /**
14
- * 占位符
15
- */
16
7
  placeholder?: string;
17
- /**
18
- * 接口地址
19
- */
20
8
  dataUrl?: string;
21
- /**
22
- * 是否使用代理
23
- */
24
9
  proxy?: boolean;
25
- /**
26
- * 代理地址
27
- */
28
10
  proxyUrl?: string;
29
- /**
30
- * 接口参数
31
- */
32
11
  params?: SearchParams[];
33
- /**
34
- * 数据
35
- */
36
12
  data?: Array<any>;
37
- /**
38
- * 页码
39
- */
40
13
  pageSize?: number;
41
- /**
42
- * 标题
43
- */
44
14
  title?: string;
45
- /**
46
- * 组件大小
47
- */
48
15
  compSize?: string;
49
- /**
50
- * 显示名称
51
- */
52
16
  displayName?: string;
53
- /**
54
- * 显示值
55
- */
56
17
  displayValue?: string;
57
- /**
58
- * 是否多选
59
- */
60
18
  multiple?: boolean;
61
- /**
62
- * 是否禁用
63
- */
64
19
  disabled?: boolean;
65
- /**
66
- * 严格模式
67
- */
68
20
  checkStrictly?: boolean;
69
- /**
70
- * 选择叶子节点
71
- */
72
21
  selectLeaf?: boolean;
73
- /**
74
- * 显示标签长度
75
- */
76
22
  showTagLength?: number;
77
- /**
78
- * 样式
79
- */
80
23
  style?: CSSProperties;
81
24
  tagType: "" | "primary" | "secondary" | "success" | "info" | "warning";
82
25
  tagEffect: "" | "light" | "dark" | "plain";
@@ -97,10 +40,10 @@ declare const __VLS_export: import('vue').DefineComponent<DataSelectorProps, {},
97
40
  displayName: string;
98
41
  compSize: string;
99
42
  pageSize: number;
100
- displayValue: string;
101
43
  multiple: boolean;
102
44
  checkStrictly: boolean;
103
45
  selectLeaf: boolean;
46
+ displayValue: string;
104
47
  showTagLength: number;
105
48
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
106
49
  declare const _default: typeof __VLS_export;
@@ -1,14 +1,15 @@
1
1
  import { PropType } from 'vue';
2
+ import { ApiUrls, FieldInfo } from '../types';
2
3
  declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
3
4
  compUrl: {
4
- type: ObjectConstructor;
5
+ type: PropType<ApiUrls>;
5
6
  };
6
7
  batchName: {
7
8
  type: StringConstructor;
8
9
  default: string;
9
10
  };
10
11
  item: {
11
- type: PropType<any>;
12
+ type: PropType<FieldInfo>;
12
13
  required: true;
13
14
  };
14
15
  dataFormat: {
@@ -27,6 +28,10 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
27
28
  type: BooleanConstructor;
28
29
  default: boolean;
29
30
  };
31
+ showBatchField: {
32
+ type: BooleanConstructor;
33
+ default: boolean;
34
+ };
30
35
  sortable: {
31
36
  type: BooleanConstructor;
32
37
  default: boolean;
@@ -48,14 +53,14 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
48
53
  blurEvent: (...args: any[]) => void;
49
54
  }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
50
55
  compUrl: {
51
- type: ObjectConstructor;
56
+ type: PropType<ApiUrls>;
52
57
  };
53
58
  batchName: {
54
59
  type: StringConstructor;
55
60
  default: string;
56
61
  };
57
62
  item: {
58
- type: PropType<any>;
63
+ type: PropType<FieldInfo>;
59
64
  required: true;
60
65
  };
61
66
  dataFormat: {
@@ -74,6 +79,10 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
74
79
  type: BooleanConstructor;
75
80
  default: boolean;
76
81
  };
82
+ showBatchField: {
83
+ type: BooleanConstructor;
84
+ default: boolean;
85
+ };
77
86
  sortable: {
78
87
  type: BooleanConstructor;
79
88
  default: boolean;
@@ -99,6 +108,7 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
99
108
  batchName: string;
100
109
  compSize: string;
101
110
  commonFormat: Function;
111
+ showBatchField: boolean;
102
112
  isDynamic: boolean;
103
113
  sortable: boolean;
104
114
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -21,6 +21,13 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
21
21
  type: StringConstructor;
22
22
  default: string;
23
23
  };
24
+ prop: {
25
+ type: PropType<Record<string, string>>;
26
+ default: () => {
27
+ label: string;
28
+ iconName: string;
29
+ };
30
+ };
24
31
  position: {
25
32
  type: PropType<Record<string, any>>;
26
33
  default: {};
@@ -49,6 +56,13 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
49
56
  type: StringConstructor;
50
57
  default: string;
51
58
  };
59
+ prop: {
60
+ type: PropType<Record<string, string>>;
61
+ default: () => {
62
+ label: string;
63
+ iconName: string;
64
+ };
65
+ };
52
66
  position: {
53
67
  type: PropType<Record<string, any>>;
54
68
  default: {};
@@ -59,6 +73,7 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
59
73
  icon: string;
60
74
  position: Record<string, any>;
61
75
  menus: any[];
76
+ prop: Record<string, string>;
62
77
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
63
78
  declare const _default: typeof __VLS_export;
64
79
  export default _default;
@@ -0,0 +1,23 @@
1
+ import { ContainerPreps } from '../../types/ItemPreps';
2
+ type __VLS_Props = ContainerPreps;
3
+ type __VLS_ModelProps = {
4
+ "dataForm"?: any;
5
+ };
6
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
7
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:dataForm": (value: any) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:dataForm"?: (value: any) => any;
11
+ }>, {
12
+ source: number;
13
+ batchName: string;
14
+ subFormFlag: string;
15
+ dataIndex: number;
16
+ compSize: string;
17
+ propPrefix: string;
18
+ parentPreps: any;
19
+ batchFieldName: string;
20
+ level: number;
21
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
@@ -1,12 +1,13 @@
1
1
  import { PropType } from 'vue';
2
2
  import { ApiUrls } from '../../types/ApiUrls';
3
+ import { PageFieldInfo } from '../../types';
3
4
  declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
5
  compUrl: {
5
6
  type: PropType<ApiUrls>;
6
7
  required: true;
7
8
  };
8
9
  fieldList: {
9
- type: ObjectConstructor;
10
+ type: PropType<PageFieldInfo>;
10
11
  required: true;
11
12
  };
12
13
  dataFormat: {
@@ -37,13 +38,17 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
37
38
  type: FunctionConstructor;
38
39
  default: () => void;
39
40
  };
41
+ sourceName: {
42
+ type: StringConstructor;
43
+ default: string;
44
+ };
40
45
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
41
46
  compUrl: {
42
47
  type: PropType<ApiUrls>;
43
48
  required: true;
44
49
  };
45
50
  fieldList: {
46
- type: ObjectConstructor;
51
+ type: PropType<PageFieldInfo>;
47
52
  required: true;
48
53
  };
49
54
  dataFormat: {
@@ -74,6 +79,10 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
74
79
  type: FunctionConstructor;
75
80
  default: () => void;
76
81
  };
82
+ sourceName: {
83
+ type: StringConstructor;
84
+ default: string;
85
+ };
77
86
  }>> & Readonly<{}>, {
78
87
  dataFormat: Function;
79
88
  compSize: string;
@@ -81,6 +90,7 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
81
90
  showBatchField: boolean;
82
91
  isDynamic: boolean;
83
92
  sortable: boolean;
93
+ sourceName: string;
84
94
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
85
95
  declare const _default: typeof __VLS_export;
86
96
  export default _default;
@@ -75,10 +75,10 @@ declare const __VLS_export: import('vue').DefineComponent<DataDropdownProps, {
75
75
  displayName: string;
76
76
  compSize: string;
77
77
  pageSize: number;
78
- displayValue: string;
79
78
  multiple: boolean;
80
79
  checkStrictly: boolean;
81
80
  selectLeaf: boolean;
81
+ displayValue: string;
82
82
  autoClose: boolean;
83
83
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
84
84
  declare const _default: typeof __VLS_export;
@@ -0,0 +1,23 @@
1
+ import { SearchParams } from '../../types';
2
+ /**
3
+ * 数据选择器公共工具
4
+ * 抽取 DataPicker 和 StarHorseDataSelector 的共享逻辑
5
+ */
6
+ /** 构建代理/直连请求参数 */
7
+ export declare const buildRequestParams: (dataUrl: string, baseParams: Record<string, any>, proxy?: boolean, proxyUrl?: string) => {
8
+ url: string;
9
+ params: Record<string, any>;
10
+ };
11
+ /** 构建分页查询基础参数 */
12
+ export declare const buildPageParams: (queryParams: SearchParams[], extraParams?: SearchParams[], currentPage?: number, pageSize?: number) => Record<string, any>;
13
+ /** 递归查找树结构数据中匹配指定值的节点 */
14
+ export declare const findNodesInTree: (nodes: any[], targetValue: any, displayValue?: string) => any[];
15
+ /** 处理节点选择/取消选择逻辑 */
16
+ export declare const toggleNodeSelection: (node: any, currentSelection: any[], options: {
17
+ multiple: boolean;
18
+ checkStrictly: boolean;
19
+ selectLeaf: boolean;
20
+ displayValue: string;
21
+ }) => any[];
22
+ /** 通过接口加载选中数据(用于初始化回显) */
23
+ export declare const loadSelectedData: (dataUrl: string, value: any, displayValue?: string, extraParams?: SearchParams[], proxy?: boolean, proxyUrl?: string) => Promise<any[]>;
@@ -0,0 +1,19 @@
1
+ import { ItemPreps } from '../../types/ItemPreps';
2
+ type __VLS_Props = ItemPreps;
3
+ type __VLS_ModelProps = {
4
+ "formData"?: any;
5
+ };
6
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
7
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:formData": (value: any) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:formData"?: (value: any) => any;
11
+ }>, {
12
+ disabled: boolean;
13
+ isDesign: boolean;
14
+ bareFlag: boolean;
15
+ isSearch: boolean;
16
+ showFormItem: boolean;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -46,5 +46,11 @@ export { default as dialogItem } from './dialog-item.vue';
46
46
  export { default as drawerItem } from './drawer-item.vue';
47
47
  export { default as emptyItem } from './empty-item.vue';
48
48
  export { default as inputTagItem } from './input-tag-item.vue';
49
+ export { default as linkItem } from './link-item.vue';
50
+ export { default as locationItem } from './location-item.vue';
51
+ export { default as treeSelectItem } from './tree-select-item.vue';
52
+ export { default as progressItem } from './progress-item.vue';
53
+ export { default as descriptionItem } from './description-item.vue';
54
+ export { default as orgItem } from './org-item.vue';
49
55
  export { default as FieldList } from '../utils/FieldList.vue';
50
56
  export { default as EditDataDialog } from '../utils/EditDataDialog.vue';
@@ -0,0 +1,19 @@
1
+ import { ItemPreps } from '../../types/ItemPreps';
2
+ type __VLS_Props = ItemPreps;
3
+ type __VLS_ModelProps = {
4
+ "formData"?: any;
5
+ };
6
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
7
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:formData": (value: any) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:formData"?: (value: any) => any;
11
+ }>, {
12
+ disabled: boolean;
13
+ isDesign: boolean;
14
+ bareFlag: boolean;
15
+ isSearch: boolean;
16
+ showFormItem: boolean;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { ItemPreps } from '../../types/ItemPreps';
2
+ type __VLS_Props = ItemPreps;
3
+ type __VLS_ModelProps = {
4
+ "formData"?: any;
5
+ };
6
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
7
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:formData": (value: any) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:formData"?: (value: any) => any;
11
+ }>, {
12
+ disabled: boolean;
13
+ isDesign: boolean;
14
+ bareFlag: boolean;
15
+ isSearch: boolean;
16
+ showFormItem: boolean;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { ItemPreps } from '../../types/ItemPreps';
2
+ type __VLS_Props = ItemPreps;
3
+ type __VLS_ModelProps = {
4
+ "formData"?: any;
5
+ };
6
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
7
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:formData": (value: any) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:formData"?: (value: any) => any;
11
+ }>, {
12
+ disabled: boolean;
13
+ isDesign: boolean;
14
+ bareFlag: boolean;
15
+ isSearch: boolean;
16
+ showFormItem: boolean;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { ItemPreps } from '../../types/ItemPreps';
2
+ type __VLS_Props = ItemPreps;
3
+ type __VLS_ModelProps = {
4
+ "formData"?: any;
5
+ };
6
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
7
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:formData": (value: any) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:formData"?: (value: any) => any;
11
+ }>, {
12
+ disabled: boolean;
13
+ isDesign: boolean;
14
+ bareFlag: boolean;
15
+ isSearch: boolean;
16
+ showFormItem: boolean;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -1,11 +1,11 @@
1
1
  import { ItemPreps } from '../../types/ItemPreps';
2
- declare var __VLS_30: {}, __VLS_43: {}, __VLS_50: {};
2
+ declare var __VLS_30: {}, __VLS_55: {}, __VLS_62: {};
3
3
  type __VLS_Slots = {} & {
4
4
  default?: (props: typeof __VLS_30) => any;
5
5
  } & {
6
- default?: (props: typeof __VLS_43) => any;
6
+ default?: (props: typeof __VLS_55) => any;
7
7
  } & {
8
- default?: (props: typeof __VLS_50) => any;
8
+ default?: (props: typeof __VLS_62) => any;
9
9
  };
10
10
  declare const __VLS_base: import('vue').DefineComponent<ItemPreps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ItemPreps> & Readonly<{}>, {
11
11
  disabled: boolean;
@@ -0,0 +1,19 @@
1
+ import { ItemPreps } from '../../types/ItemPreps';
2
+ type __VLS_Props = ItemPreps;
3
+ type __VLS_ModelProps = {
4
+ "formData"?: any;
5
+ };
6
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
7
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
8
+ "update:formData": (value: any) => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
10
+ "onUpdate:formData"?: (value: any) => any;
11
+ }>, {
12
+ disabled: boolean;
13
+ isDesign: boolean;
14
+ bareFlag: boolean;
15
+ isSearch: boolean;
16
+ showFormItem: boolean;
17
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
@@ -2,7 +2,7 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
2
2
  modelValue: BooleanConstructor;
3
3
  title: {
4
4
  type: StringConstructor;
5
- default: string;
5
+ default: any;
6
6
  };
7
7
  boxWidth: {
8
8
  type: StringConstructor;
@@ -25,7 +25,7 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
25
25
  modelValue: BooleanConstructor;
26
26
  title: {
27
27
  type: StringConstructor;
28
- default: string;
28
+ default: any;
29
29
  };
30
30
  boxWidth: {
31
31
  type: StringConstructor;
@@ -0,0 +1,129 @@
1
+ /**
2
+ * 公式计算引擎
3
+ *
4
+ * 统一字段引用语法:${fieldName}
5
+ * 支持 8 种公式类型:
6
+ * - calc: 数学运算 expression = '${price} * ${quantity}'
7
+ * - concat: 字符串拼接 expression = '${lastName}${firstName}'
8
+ * - condition: 多分支条件判断 branches = [{ when, then }]
9
+ * - lookup: 联动回填 lookupMappings = [{ key, values }]
10
+ * - aggregate: 聚合运算 expression = 'sum' / 'avg' / 'count' / 'min' / 'max'
11
+ * - dateCalc: 日期计算 expression = '${start} ~ ${end}', dateUnit = 'day'
12
+ * - format: 格式化 expression = 'thousands' / 'padStart' / 'toFixed' / 'regex'
13
+ * - ternary: 三元表达式 expression = '${score} >= 60 ? ${score} : 0'
14
+ *
15
+ * 配置示例:
16
+ * field: {
17
+ * fieldName: 'totalPrice',
18
+ * preps: {
19
+ * formula: {
20
+ * enable: true,
21
+ * type: 'calc',
22
+ * sourceFields: ['price', 'quantity'],
23
+ * expression: '${price} * ${quantity}',
24
+ * precision: 2,
25
+ * suffix: '元',
26
+ * }
27
+ * }
28
+ * }
29
+ */
30
+ /** 公式类型 */
31
+ export type FormulaType = "calc" | "concat" | "condition" | "lookup" | "aggregate" | "dateCalc" | "format" | "ternary";
32
+ /** 条件分支配置 */
33
+ export interface ConditionBranch {
34
+ /** 匹配表达式,如 '${score} >= 90' */
35
+ when: string;
36
+ /** 匹配时返回的值,支持常量或 ${fieldName} 引用 */
37
+ then: any;
38
+ }
39
+ /** 联动回填映射配置 */
40
+ export interface LookupMapping {
41
+ /** 匹配的源字段值 */
42
+ key: string;
43
+ /** 回填目标字段名 -> 回填值的映射 */
44
+ values: Record<string, any>;
45
+ }
46
+ /** 公式配置 */
47
+ export interface FormulaConfig {
48
+ /** 是否启用 */
49
+ enable: boolean;
50
+ /** 公式类型 */
51
+ type: FormulaType;
52
+ /** 依赖字段列表 */
53
+ sourceFields: string[];
54
+ /** 公式表达式,统一使用 ${fieldName} 引用字段 */
55
+ expression?: string;
56
+ /** 条件分支(type=condition 时使用) */
57
+ branches?: ConditionBranch[];
58
+ /** 联动回填映射(type=lookup 时使用) */
59
+ lookupMappings?: LookupMapping[];
60
+ /** 精度,type=calc/format(toFixed) 时使用 */
61
+ precision?: number;
62
+ /** 前缀,type=calc 时使用,如 '¥' */
63
+ prefix?: string;
64
+ /** 后缀,type=calc 时使用,如 '%'、'元' */
65
+ suffix?: string;
66
+ /** 日期单位,type=dateCalc 时使用:'year'|'month'|'day'|'hour'|'minute'|'second' */
67
+ dateUnit?: "year" | "month" | "day" | "hour" | "minute" | "second";
68
+ /** 日期偏移量,type=dateCalc 且 mode=offset 时使用,正数向后,负数向前 */
69
+ dateOffset?: number;
70
+ /** 日期计算模式:diff(差值) | offset(偏移) | format(格式化) */
71
+ dateMode?: "diff" | "offset" | "format";
72
+ /** 日期输出格式,type=dateCalc 且 mode=format 时使用,如 'YYYY-MM-DD' */
73
+ dateFormat?: string;
74
+ /** 格式化子类型,type=format 时使用 */
75
+ formatType?: "thousands" | "padStart" | "toFixed" | "regex";
76
+ /** 格式化参数:padStart 的目标长度 / regex 的替换模式 */
77
+ formatArg?: string | number;
78
+ /** 格式化参数2:padStart 的填充字符 / regex 的替换值 */
79
+ formatArg2?: string;
80
+ /** 聚合子字段,type=aggregate 时使用,指定子表单中要聚合的字段名 */
81
+ aggregateField?: string;
82
+ /** 条件不匹配时的默认值,type=condition/ternary 时使用 */
83
+ defaultValue?: any;
84
+ }
85
+ /** 字段定义(最小集) */
86
+ export interface FormulaField {
87
+ fieldName: string;
88
+ type?: string;
89
+ formula?: FormulaConfig;
90
+ preps?: Record<string, any>;
91
+ }
92
+ /**
93
+ * 执行公式计算,返回计算结果
94
+ * @param formula 公式配置
95
+ * @param formData 表单数据
96
+ * @returns 计算结果
97
+ */
98
+ export declare const executeFormula: (formula: FormulaConfig, formData: Record<string, any>) => any;
99
+ /**
100
+ * 执行公式并回填表单数据
101
+ * - lookup: 回填多个目标字段
102
+ * - 其他类型: 结果赋值给当前字段
103
+ *
104
+ * @param field 当前字段
105
+ * @param formInfo 所有字段列表
106
+ * @param formData 表单数据(会被直接修改)
107
+ */
108
+ export declare const executeFormulaWithFill: (field: FormulaField, formInfo: FormulaField[], formData: Record<string, any>) => void;
109
+ /**
110
+ * 构建字段级别的 watch 监听器
111
+ * 当依赖字段变化时,自动触发公式计算并回填
112
+ *
113
+ * @param field 当前字段
114
+ * @param formInfo 所有字段列表
115
+ * @param formData 响应式表单数据
116
+ * @param watchFn Vue watch 函数
117
+ * @returns stop 函数数组,用于在 onBeforeUnmount 中清理
118
+ */
119
+ export declare const setupFormulaWatchers: (field: FormulaField, formInfo: FormulaField[], formData: any, watchFn: typeof import('vue').watch) => (() => void)[];
120
+ /**
121
+ * 批量初始化表单中所有带 formula 配置的字段
122
+ * 适合在表单容器组件 onMounted 时调用
123
+ *
124
+ * @param formInfo 所有字段列表
125
+ * @param formData 响应式表单数据
126
+ * @param watchFn Vue watch 函数
127
+ * @returns stop 函数数组,用于在 onBeforeUnmount 中清理
128
+ */
129
+ export declare const initFormFormulaWatchers: (formInfo: FormulaField[], formData: any, watchFn: typeof import('vue').watch) => (() => void)[];
@@ -1,27 +1,11 @@
1
1
  import { RelationDetail } from '../../types';
2
+ import { executeFormulaWithFill, initFormFormulaWatchers, setupFormulaWatchers } from './FormulaEngine';
2
3
  declare const relationEvent: (props: any, relationDetails: RelationDetail[], e: any, actionName: string) => void;
3
- /**
4
- * 所有触发的事件
5
- * @param context
6
- * @param emits
7
- * @param formData
8
- * @param actionName
9
- * @param isInit
10
- */
11
- declare const allAction: (context: any, emits: any, formData: any, actionName: string, isInit?: boolean) => void;
12
- /**
13
- * Button 组件的点击事件
14
- * @param context
15
- * @param emits
16
- * @param formData
17
- * @param code
18
- * @param evtName 时间名称
19
- */
4
+ /** 所有触发的事件 */
5
+ declare const allAction: (context: any, emits: any, formData: any, actionName: string, _isInit?: boolean) => void;
6
+ /** Button 组件的点击事件 */
20
7
  declare const buttonAction: (context: any, emits: any, formData: any, code: string, evtName?: string) => void;
21
- /**
22
- * 检查是否禁用
23
- * @param attrs
24
- */
8
+ /** 检查是否禁用 */
25
9
  declare const checkIsDisabled: (attrs: any) => boolean;
26
10
  declare const useFormField: (context: any, field: any) => {
27
11
  fieldValue: import('vue').WritableComputedRef<any, any>;
@@ -29,4 +13,4 @@ declare const useFormField: (context: any, field: any) => {
29
13
  declare const initCompCallEvent: (props: any, emits: any, formData: any) => void;
30
14
  declare const prepsFilter: (preps: any) => any;
31
15
  declare const convertData: (data: any) => any;
32
- export { allAction, buttonAction, checkIsDisabled, initCompCallEvent, prepsFilter, relationEvent, useFormField, convertData, };
16
+ export { allAction, buttonAction, checkIsDisabled, initCompCallEvent, prepsFilter, relationEvent, useFormField, convertData, executeFormulaWithFill, initFormFormulaWatchers, setupFormulaWatchers, };
@@ -6,7 +6,7 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
6
6
  message: {
7
7
  type: StringConstructor;
8
8
  required: true;
9
- default: string;
9
+ default: any;
10
10
  };
11
11
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
12
12
  width: {
@@ -16,7 +16,7 @@ declare const __VLS_export: import('vue').DefineComponent<import('vue').ExtractP
16
16
  message: {
17
17
  type: StringConstructor;
18
18
  required: true;
19
- default: string;
19
+ default: any;
20
20
  };
21
21
  }>> & Readonly<{}>, {
22
22
  message: string;