@farris/cli 2.0.0-beta.7 → 2.0.0-beta.8

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 (149) hide show
  1. package/bin/index.js +2 -2
  2. package/lib/commands/build-components.js +21 -17
  3. package/lib/commands/build-components.js.map +1 -0
  4. package/lib/commands/build-css.js +30 -2
  5. package/lib/commands/build-css.js.map +1 -0
  6. package/lib/commands/build-lib.js +16 -6
  7. package/lib/commands/build-lib.js.map +1 -0
  8. package/lib/commands/build.js +11 -5
  9. package/lib/commands/build.js.map +1 -0
  10. package/lib/commands/create-app.js +2 -1
  11. package/lib/commands/create-app.js.map +1 -0
  12. package/lib/commands/dev-serve.js +3 -7
  13. package/lib/commands/dev-serve.js.map +1 -0
  14. package/lib/commands/preview-serve.js +1 -0
  15. package/lib/commands/preview-serve.js.map +1 -0
  16. package/lib/common/constant.js +1 -0
  17. package/lib/common/constant.js.map +1 -0
  18. package/lib/common/generate-app.js +1 -0
  19. package/lib/common/generate-app.js.map +1 -0
  20. package/lib/common/get-dependencies.js +1 -0
  21. package/lib/common/get-dependencies.js.map +1 -0
  22. package/lib/common/get-farris-config.js +3 -2
  23. package/lib/common/get-farris-config.js.map +1 -0
  24. package/lib/common/get-version.js +1 -0
  25. package/lib/common/get-version.js.map +1 -0
  26. package/lib/common/get-vite-config.js +16 -8
  27. package/lib/common/get-vite-config.js.map +1 -0
  28. package/lib/config/vite-app.js +10 -10
  29. package/lib/config/vite-app.js.map +1 -0
  30. package/lib/config/vite-common.js +21 -0
  31. package/lib/config/vite-common.js.map +1 -0
  32. package/lib/config/vite-component.js +30 -0
  33. package/lib/config/vite-component.js.map +1 -0
  34. package/lib/config/vite-lib.js +12 -20
  35. package/lib/config/vite-lib.js.map +1 -0
  36. package/lib/index.js +23 -1
  37. package/lib/index.js.map +1 -0
  38. package/lib/plugins/{gen-component-style.js → create-component-style.js} +6 -4
  39. package/lib/plugins/create-component-style.js.map +1 -0
  40. package/lib/plugins/create-package-json.js +34 -0
  41. package/lib/plugins/create-package-json.js.map +1 -0
  42. package/lib/plugins/dts.js +1 -0
  43. package/lib/plugins/dts.js.map +1 -0
  44. package/lib/plugins/html-system.js +1 -0
  45. package/lib/plugins/html-system.js.map +1 -0
  46. package/lib/plugins/replace.js +1 -0
  47. package/lib/plugins/replace.js.map +1 -0
  48. package/lib/plugins/systemjs-bundle.js +16 -0
  49. package/lib/plugins/systemjs-bundle.js.map +1 -0
  50. package/package.json +41 -38
  51. package/templates/lib/.eslintrc.cjs +15 -15
  52. package/templates/lib/.prettierrc.json +7 -7
  53. package/templates/lib/components/button/index.ts +7 -0
  54. package/templates/lib/components/button/src/button.component.tsx +84 -0
  55. package/templates/lib/components/button/src/button.props.ts +55 -0
  56. package/templates/lib/components/button/src/button.scss +179 -0
  57. package/templates/lib/components/common/index.ts +6 -0
  58. package/templates/lib/components/common/src/common.scss +4 -0
  59. package/templates/lib/components/common/src/compositions/index.ts +19 -0
  60. package/templates/lib/components/common/src/compositions/types.ts +6 -0
  61. package/templates/lib/components/common/src/compositions/use-bem/index.ts +46 -0
  62. package/templates/lib/components/common/src/compositions/use-click-away/index.ts +40 -0
  63. package/templates/lib/components/common/src/compositions/use-context/use-children-contexts.ts +40 -0
  64. package/templates/lib/components/common/src/compositions/use-context/use-parent-context.ts +24 -0
  65. package/templates/lib/components/common/src/compositions/use-event-listener/index.ts +45 -0
  66. package/templates/lib/components/common/src/compositions/use-expose/index.ts +9 -0
  67. package/templates/lib/components/common/src/compositions/use-lay-render/index.ts +17 -0
  68. package/templates/lib/components/common/src/compositions/use-link/index.ts +14 -0
  69. package/templates/lib/components/common/src/compositions/use-lock-scroll/index.ts +25 -0
  70. package/templates/lib/components/common/src/compositions/use-long-press/index.ts +141 -0
  71. package/templates/lib/components/common/src/compositions/use-momentum/index.ts +82 -0
  72. package/templates/lib/components/common/src/compositions/use-mount-component/index.ts +48 -0
  73. package/templates/lib/components/common/src/compositions/use-rect/index.ts +31 -0
  74. package/templates/lib/components/common/src/compositions/use-refs/index.ts +21 -0
  75. package/templates/lib/components/common/src/compositions/use-resize-observer/index.ts +85 -0
  76. package/templates/lib/components/common/src/compositions/use-resize-observer/utils.ts +37 -0
  77. package/templates/lib/components/common/src/compositions/use-scroll-parent/index.ts +42 -0
  78. package/templates/lib/components/common/src/compositions/use-touch/index.ts +82 -0
  79. package/templates/lib/components/common/src/compositions/use-touch-move/index.ts +120 -0
  80. package/templates/lib/components/common/src/entity/base-property.ts +129 -0
  81. package/templates/lib/components/common/src/entity/entity-schema.ts +274 -0
  82. package/templates/lib/components/common/src/entity/input-base-property.ts +285 -0
  83. package/templates/lib/components/common/src/style/animation/index.scss +150 -0
  84. package/templates/lib/components/common/src/style/base.scss +63 -0
  85. package/templates/lib/components/common/src/style/fonts/farris-mobile-icon.ttf +0 -0
  86. package/templates/lib/components/common/src/style/icon.scss +6 -0
  87. package/templates/lib/components/common/src/style/index.scss +4 -0
  88. package/templates/lib/components/common/src/style/mixins/bem.scss +204 -0
  89. package/templates/lib/components/common/src/style/mixins/border-radius.scss +13 -0
  90. package/templates/lib/components/common/src/style/mixins/ellipsis.scss +15 -0
  91. package/templates/lib/components/common/src/style/mixins/hairline.scss +113 -0
  92. package/templates/lib/components/common/src/style/mixins/index.scss +6 -0
  93. package/templates/lib/components/common/src/style/mixins/margin.scss +10 -0
  94. package/templates/lib/components/common/src/style/mixins/safe-area.scss +9 -0
  95. package/templates/lib/components/common/src/style/variables.scss +113 -0
  96. package/templates/lib/components/common/src/utils/index.ts +15 -0
  97. package/templates/lib/components/common/src/utils/src/common.ts +83 -0
  98. package/templates/lib/components/common/src/utils/src/date.ts +134 -0
  99. package/templates/lib/components/common/src/utils/src/dom/event.ts +37 -0
  100. package/templates/lib/components/common/src/utils/src/hook.ts +18 -0
  101. package/templates/lib/components/common/src/utils/src/number.ts +26 -0
  102. package/templates/lib/components/common/src/utils/src/query-filter.ts +40 -0
  103. package/templates/lib/components/common/src/utils/src/resove-asset.ts +33 -0
  104. package/templates/lib/components/common/src/utils/src/string.ts +18 -0
  105. package/templates/lib/components/common/src/utils/src/throttle.ts +41 -0
  106. package/templates/lib/components/common/src/utils/src/transition.ts +14 -0
  107. package/templates/lib/components/common/src/utils/src/type.ts +105 -0
  108. package/templates/lib/components/common/src/utils/src/use-appearance.ts +33 -0
  109. package/templates/lib/components/common/src/utils/src/with-install.ts +16 -0
  110. package/templates/lib/components/common/src/utils/src/with-register-designer.ts +16 -0
  111. package/templates/lib/components/common/src/utils/src/with-register.ts +16 -0
  112. package/templates/lib/components/common/types.ts +131 -0
  113. package/templates/lib/components/index.ts +0 -0
  114. package/templates/lib/farris.config.mjs +37 -16
  115. package/templates/lib/index.html +12 -12
  116. package/templates/lib/package.json +28 -28
  117. package/templates/lib/src/App.vue +80 -5
  118. package/templates/lib/src/components/TheButton.vue +3 -0
  119. package/templates/lib/src/main.ts +10 -9
  120. package/templates/lib/src/router/index.ts +23 -0
  121. package/templates/lib/src/views/AboutView.vue +15 -0
  122. package/templates/lib/src/views/HomeView.vue +9 -0
  123. package/templates/lib/tsconfig.json +19 -17
  124. package/templates/mobile/.eslintrc.cjs +15 -15
  125. package/templates/mobile/.prettierrc.json +7 -7
  126. package/templates/mobile/farris.config.mjs +1 -1
  127. package/templates/mobile/index.html +12 -12
  128. package/templates/mobile/package.json +28 -28
  129. package/templates/mobile/src/App.vue +80 -80
  130. package/templates/mobile/src/components/TheButton.vue +3 -3
  131. package/templates/mobile/src/main.ts +12 -12
  132. package/templates/mobile/src/router/index.ts +23 -23
  133. package/templates/mobile/src/views/AboutView.vue +15 -15
  134. package/templates/mobile/src/views/HomeView.vue +9 -9
  135. package/templates/mobile/tsconfig.json +17 -17
  136. package/templates/web/.eslintrc.cjs +15 -0
  137. package/templates/web/.prettierrc.json +8 -0
  138. package/templates/web/farris.config.mjs +24 -0
  139. package/templates/web/index.html +12 -0
  140. package/templates/web/package.json +29 -0
  141. package/templates/web/src/App.vue +80 -0
  142. package/templates/web/src/components/TheButton.vue +3 -0
  143. package/templates/web/src/main.ts +10 -0
  144. package/templates/web/src/router/index.ts +23 -0
  145. package/templates/web/src/views/AboutView.vue +15 -0
  146. package/templates/web/src/views/HomeView.vue +9 -0
  147. package/templates/web/tsconfig.json +18 -0
  148. package/templates/lib/packages/button/src/index.vue +0 -4
  149. package/templates/lib/packages/index.ts +0 -7
@@ -0,0 +1,37 @@
1
+ /* eslint-disable no-use-before-define */
2
+ import { ComponentPublicInstance, Ref, unref, getCurrentScope, onScopeDispose } from 'vue';
3
+ import { inBrowser } from '../../utils';
4
+
5
+ export const defaultWindow = inBrowser ? window : undefined;
6
+
7
+ export type MaybeRef<T> = T | Ref<T>;
8
+ export type MaybeRefOrGetter<T> = MaybeRef<T> | (() => T);
9
+
10
+ export type VueInstance = ComponentPublicInstance;
11
+ export type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
12
+ export type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T>;
13
+ export type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
14
+
15
+ export type UnRefElementReturn<T extends MaybeElement = MaybeElement> =
16
+ T extends VueInstance ? Exclude<MaybeElement, VueInstance> : T | undefined;
17
+
18
+ export type AnyFn = (...args: any[]) => any;
19
+
20
+ export function toValue<T>(r: MaybeRefOrGetter<T>): T {
21
+ return typeof r === 'function'
22
+ ? (r as AnyFn)()
23
+ : unref(r);
24
+ }
25
+
26
+ export function unrefElement<T extends MaybeElement>(elRef: MaybeComputedElementRef<T>): UnRefElementReturn<T> {
27
+ const plain = toValue(elRef);
28
+ return (plain as VueInstance)?.$el ?? plain;
29
+ }
30
+
31
+ export function tryOnScopeDispose(fn: (() => void)) {
32
+ if (getCurrentScope()) {
33
+ onScopeDispose(fn);
34
+ return true;
35
+ }
36
+ return false;
37
+ }
@@ -0,0 +1,42 @@
1
+ import { ref, Ref, onMounted } from 'vue';
2
+ import { inBrowser } from '../../utils';
3
+
4
+ type ScrollElement = HTMLElement | Window;
5
+
6
+ const overflowScrollReg = /scroll|auto|overlay/i;
7
+ const defaultRoot = inBrowser ? window : undefined;
8
+
9
+ function isElement(node: Element) {
10
+ const ELEMENT_NODE_TYPE = 1;
11
+ return (
12
+ node.tagName !== 'HTML' &&
13
+ node.tagName !== 'BODY' &&
14
+ node.nodeType === ELEMENT_NODE_TYPE
15
+ );
16
+ }
17
+
18
+ export function getScrollParent(el: Element, root: ScrollElement | undefined = defaultRoot) {
19
+ let node = el;
20
+
21
+ while (node && node !== root && isElement(node)) {
22
+ const { overflowY } = window.getComputedStyle(node);
23
+ if (overflowScrollReg.test(overflowY)) {
24
+ return node;
25
+ }
26
+ node = node.parentNode as Element;
27
+ }
28
+
29
+ return root;
30
+ }
31
+
32
+ export function useScrollParent(el: Ref<Element | undefined>, root: ScrollElement | undefined = defaultRoot) {
33
+ const scrollParent = ref<Element | Window>();
34
+
35
+ onMounted(() => {
36
+ if (el.value) {
37
+ scrollParent.value = getScrollParent(el.value, root);
38
+ }
39
+ });
40
+
41
+ return scrollParent;
42
+ }
@@ -0,0 +1,82 @@
1
+ import { ref } from 'vue';
2
+
3
+ export const TAP_OFFSET = 5;
4
+
5
+ type Direction = '' | 'vertical' | 'horizontal';
6
+
7
+ function getDirection(x: number, y: number) {
8
+ if (x > y) {
9
+ return 'horizontal';
10
+ }
11
+ if (y > x) {
12
+ return 'vertical';
13
+ }
14
+ return '';
15
+ }
16
+
17
+ export function useTouch() {
18
+ const startX = ref(0);
19
+ const startY = ref(0);
20
+ const deltaX = ref(0);
21
+ const deltaY = ref(0);
22
+ const offsetX = ref(0);
23
+ const offsetY = ref(0);
24
+ const direction = ref<Direction>('');
25
+ const isTap = ref(true);
26
+
27
+ const isVertical = () => direction.value === 'vertical';
28
+ const isHorizontal = () => direction.value === 'horizontal';
29
+
30
+ const reset = () => {
31
+ deltaX.value = 0;
32
+ deltaY.value = 0;
33
+ offsetX.value = 0;
34
+ offsetY.value = 0;
35
+ direction.value = '';
36
+ isTap.value = true;
37
+ };
38
+
39
+ const start = ((event: TouchEvent) => {
40
+ reset();
41
+ startX.value = event.touches[0].clientX;
42
+ startY.value = event.touches[0].clientY;
43
+ }) as EventListener;
44
+
45
+ const move = ((event: TouchEvent) => {
46
+ const touch = event.touches[0];
47
+ // safari back will set clientX to negative number
48
+ deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
49
+ deltaY.value = touch.clientY - startY.value;
50
+ offsetX.value = Math.abs(deltaX.value);
51
+ offsetY.value = Math.abs(deltaY.value);
52
+
53
+ // lock direction when distance is greater than a certain value
54
+ const LOCK_DIRECTION_DISTANCE = 10;
55
+ if (
56
+ !direction.value ||
57
+ (offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE)
58
+ ) {
59
+ direction.value = getDirection(offsetX.value, offsetY.value);
60
+ }
61
+
62
+ if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
63
+ isTap.value = false;
64
+ }
65
+ }) as EventListener;
66
+
67
+ return {
68
+ move,
69
+ start,
70
+ reset,
71
+ startX,
72
+ startY,
73
+ deltaX,
74
+ deltaY,
75
+ offsetX,
76
+ offsetY,
77
+ direction,
78
+ isVertical,
79
+ isHorizontal,
80
+ isTap
81
+ };
82
+ }
@@ -0,0 +1,120 @@
1
+ import { reactive, ref, Ref } from 'vue';
2
+ import { throttle } from '../../utils';
3
+ import { useEventListener } from '../use-event-listener';
4
+
5
+ const MIN_DISTANCE = 10;
6
+
7
+ type TouchDirection = 'horizontal' | 'vertical' | '';
8
+
9
+ export type TouchOffset = {
10
+ startX: number;
11
+ startY: number;
12
+ endX: number;
13
+ endY: number;
14
+ offsetX: number;
15
+ offsetY: number;
16
+ direction: TouchDirection;
17
+ };
18
+
19
+ type TouchListener = {
20
+ onTouchStart?: (event: Event) => void;
21
+ onTouchMove?: (event: Event) => void;
22
+ onTouchEnd?: (event: Event) => void;
23
+ onTouchCancel?: (event: Event) => void;
24
+ };
25
+
26
+ function getDirection(x: number, y: number): TouchDirection {
27
+ if (x > y && x > MIN_DISTANCE) {
28
+ return 'horizontal';
29
+ }
30
+
31
+ if (y > x && y > MIN_DISTANCE) {
32
+ return 'vertical';
33
+ }
34
+ return '';
35
+ }
36
+
37
+ const defaultTouchOffset: () => TouchOffset = () => {
38
+ return {
39
+ startX: 0,
40
+ startY: 0,
41
+ endX: 0,
42
+ endY: 0,
43
+ offsetX: 0,
44
+ offsetY: 0,
45
+ direction: ''
46
+ };
47
+ };
48
+
49
+ export enum DragStatus {
50
+ NotStarted,
51
+ Started,
52
+ Dragging,
53
+ End
54
+ }
55
+
56
+ export function useTouchMove(
57
+ target: Ref<EventTarget | undefined>,
58
+ listener?: TouchListener,
59
+ wait = 0
60
+ ) {
61
+ let beginOffset = { offsetX: 0, offsetY: 0 };
62
+ const offset: TouchOffset = reactive(defaultTouchOffset());
63
+ const dragStatus = ref(DragStatus.NotStarted);
64
+
65
+ const touchStart = (event: any) => {
66
+ if (!event.touches || !event.touches[0]) {
67
+ return;
68
+ }
69
+ offset.startX = event.touches[0].clientX;
70
+ offset.startY = event.touches[0].clientY;
71
+ listener?.onTouchStart && listener.onTouchStart(event);
72
+ dragStatus.value = DragStatus.Started;
73
+ };
74
+
75
+ const touchMove = (event: any) => {
76
+ if (!event.touches || !event.touches[0]) {
77
+ return;
78
+ }
79
+ const touch = event.touches[0];
80
+ offset.offsetX = touch.clientX - offset.startX + beginOffset.offsetX;
81
+ offset.offsetY = touch.clientY - offset.startY + beginOffset.offsetY;
82
+ offset.endX = event.touches[0].clientX;
83
+ offset.endY = event.touches[0].clientY;
84
+ offset.direction = getDirection(offset.offsetX, offset.offsetY);
85
+ listener?.onTouchMove && listener.onTouchMove(event);
86
+ dragStatus.value = DragStatus.Dragging;
87
+ };
88
+
89
+ const touchEnd = (event: Event) => {
90
+ beginOffset = { offsetX: offset.offsetX, offsetY: offset.offsetY };
91
+ listener?.onTouchEnd && listener.onTouchEnd(event);
92
+ listener?.onTouchCancel && listener.onTouchCancel(event);
93
+ dragStatus.value = DragStatus.End;
94
+ };
95
+
96
+ const resetTouchStatus = () => {
97
+ offset.endX = 0;
98
+ offset.endY = 0;
99
+ offset.offsetX = 0;
100
+ offset.offsetY = 0;
101
+ offset.direction = '';
102
+ beginOffset = { offsetX: 0, offsetY: 0 };
103
+ dragStatus.value = DragStatus.NotStarted;
104
+ };
105
+
106
+ if (target) {
107
+ useEventListener('touchstart', touchStart, { target });
108
+ useEventListener('touchmove', wait > 0 ? throttle(touchMove, wait) : touchMove, {
109
+ target,
110
+ passive: false
111
+ });
112
+ useEventListener('touchend', touchEnd, { target });
113
+ }
114
+
115
+ return {
116
+ offset,
117
+ dragStatus,
118
+ resetTouchStatus
119
+ };
120
+ }
@@ -0,0 +1,129 @@
1
+ import { DesignerComponentInstance, DgControl } from "@/components/designer-canvas";
2
+ import { cloneDeep } from "lodash-es";
3
+
4
+ /**
5
+ * 控件属性基类
6
+ */
7
+ export class BaseControlProperty {
8
+ public componentId: string;
9
+
10
+ public viewModelId: string;
11
+
12
+ public eventsEditorUtils: any;
13
+
14
+ public formSchemaUtils: any;
15
+ public formMetadataConverter: any;
16
+ public designViewModelUtils: any;
17
+ public designViewModelField: any;
18
+ public controlCreatorUtils: any;
19
+ public designerHostService: any;
20
+
21
+ schemaService: any = null;
22
+
23
+ metadataService: any = null;
24
+
25
+ protected propertyConfig = {
26
+ type: 'object',
27
+ categories: {}
28
+ };
29
+
30
+ constructor(componentId: string, designerHostService: any) {
31
+ this.componentId = componentId;
32
+ this.designerHostService = designerHostService;
33
+ this.eventsEditorUtils = designerHostService['eventsEditorUtils'];
34
+ this.formSchemaUtils = designerHostService['formSchemaUtils'];
35
+ this.formMetadataConverter = designerHostService['formMetadataConverter'];
36
+ this.viewModelId = this.formSchemaUtils?.getViewModelIdByComponentId(componentId) || '';
37
+ this.designViewModelUtils = designerHostService['designViewModelUtils'];
38
+ this.controlCreatorUtils = designerHostService['controlCreatorUtils'];
39
+ this.metadataService = designerHostService['metadataService'];
40
+ this.schemaService = designerHostService['schemaService'];
41
+ }
42
+
43
+ getTableInfo() {
44
+ return this.schemaService?.getTableInfoByViewModelId(this.viewModelId);
45
+ }
46
+
47
+ setDesignViewModelField(propertyData: any) {
48
+ const bindingFieldId = propertyData.binding && propertyData.binding.type === 'Form' && propertyData.binding.field;
49
+ // 视图模型中[字段更新时机]属性现在要在控件上维护,所以在控件上复制一份属性值
50
+ if (bindingFieldId) {
51
+ if (!this.designViewModelField) {
52
+ const dgViewModel = this.designViewModelUtils.getDgViewModel(this.viewModelId);
53
+ this.designViewModelField = dgViewModel.fields.find(f => f.id === bindingFieldId);
54
+ }
55
+ propertyData.updateOn = this.designViewModelField?.updateOn;
56
+ }
57
+ }
58
+
59
+ getBasicPropConfig(propertyData: any): any {
60
+ return {
61
+ description: 'Basic Information',
62
+ title: '基本信息',
63
+ properties: {
64
+ id: {
65
+ description: '组件标识',
66
+ title: '标识',
67
+ type: 'string',
68
+ readonly: true
69
+ },
70
+ type: {
71
+ description: '组件类型',
72
+ title: '控件类型',
73
+ type: 'select',
74
+ editor: {
75
+ type: 'combo-list',
76
+ textField: 'name',
77
+ valueField: 'value',
78
+ editable: false,
79
+ data: [{ value: propertyData.type, name: DgControl[propertyData.type] && DgControl[propertyData.type].name }]
80
+ }
81
+ }
82
+ }
83
+ };
84
+
85
+ }
86
+
87
+
88
+ protected getAppearanceConfig(propertyData = null): any {
89
+ return {
90
+ title: "外观",
91
+ description: "Appearance",
92
+ properties: {
93
+ class: {
94
+ title: "class样式",
95
+ type: "string",
96
+ description: "组件的CSS样式",
97
+ $converter: "/converter/appearance.converter"
98
+ },
99
+ style: {
100
+ title: "style样式",
101
+ type: "string",
102
+ description: "组件的样式",
103
+ $converter: "/converter/appearance.converter"
104
+ }
105
+ }
106
+ };
107
+ }
108
+
109
+ /**
110
+ *
111
+ * @param propertyId
112
+ * @param componentInstance
113
+ * @returns
114
+ */
115
+ public updateElementByParentContainer(propertyId: string, componentInstance: DesignerComponentInstance) {
116
+ // 1、定位控件父容器
117
+ const parentContainer = componentInstance && componentInstance.parent && componentInstance.parent['schema'];
118
+ if (!parentContainer) {
119
+ return;
120
+ }
121
+ const index = parentContainer.contents.findIndex(c => c.id === propertyId);
122
+ // 通过cloneDeep方式的触发更新
123
+ const controlSchema = cloneDeep(parentContainer.contents[index]);
124
+ // 5、替换控件
125
+ parentContainer.contents.splice(index, 1);
126
+ parentContainer.contents.splice(index, 0, controlSchema);
127
+ }
128
+
129
+ }
@@ -0,0 +1,274 @@
1
+ /* eslint-disable no-use-before-define */
2
+ export interface FormSchema {
3
+ sourceUri: string;
4
+ id: string;
5
+ code: string;
6
+ name: string;
7
+ entities: FormSchemaEntity[];
8
+ variables: FormSchemaEntityField[];
9
+ eapiId: string;
10
+ extendProperties: { enableStdTimeFormat: boolean };
11
+ eapiCode?: string;
12
+ eapiName?: string;
13
+ eapiNameSpace?: string;
14
+ voPath?: string;
15
+ voNameSpace?: string;
16
+ }
17
+
18
+ /**
19
+ * 实体
20
+ */
21
+ export interface FormSchemaEntity {
22
+ id: string;
23
+ code: string;
24
+ name: string;
25
+ label: string;
26
+ type: FormSchemaEntityType;
27
+ }
28
+
29
+ /**
30
+ * 字段类型枚举
31
+ */
32
+ export enum FormSchemaEntityField$Type {
33
+ /**
34
+ * 简单类型字段
35
+ */
36
+ SimpleField = "SimpleField",
37
+ /**
38
+ * 关联/UDT类型字段
39
+ */
40
+ ComplexField = "ComplexField"
41
+ }
42
+ /**
43
+ * 字段编辑器对象
44
+ */
45
+ export interface FormSchemaEntityFieldEditor {
46
+ $type: string;
47
+ [propName: string]: any;
48
+ }
49
+ export interface DesignViewModelField extends FormSchemaEntityField {
50
+ valueChanging: string;
51
+ valueChanged: string;
52
+ groupId: string;
53
+ groupName: string;
54
+ isSchemaRemoved?: boolean;
55
+ updateOn?: string;
56
+ }
57
+ /**
58
+ * 字段
59
+ */
60
+ export interface FormSchemaEntityField {
61
+ $type: FormSchemaEntityField$Type;
62
+ id: string;
63
+ originalId: string;
64
+ code: string;
65
+ label: string;
66
+ bindingField: string;
67
+ name: string;
68
+ defaultValue?: any;
69
+ require?: boolean;
70
+ readonly?: boolean;
71
+ type: FormSchemaEntityFieldType;
72
+ editor?: FormSchemaEntityFieldEditor;
73
+ path?: string;
74
+ bindingPath?: string;
75
+ multiLanguage?: boolean;
76
+ expression?: any;
77
+ }
78
+ /**
79
+ * 字段类型对象中的类型枚举
80
+ */
81
+ export enum FormSchemaEntityFieldType$Type {
82
+ /**
83
+ * 字符串
84
+ */
85
+ StringType = "StringType",
86
+ /**
87
+ * 备注
88
+ */
89
+ TextType = "TextType",
90
+ /**
91
+ * 数字(整数、浮点数)
92
+ */
93
+ NumericType = "NumericType",
94
+ /**
95
+ * 布尔
96
+ */
97
+ BooleanType = "BooleanType",
98
+ /**
99
+ * 日期
100
+ */
101
+ DateType = "DateType",
102
+ /**
103
+ * 日期时间
104
+ */
105
+ DateTimeType = "DateTimeType",
106
+ /**
107
+ * 枚举
108
+ */
109
+ EnumType = "EnumType",
110
+ /**
111
+ * 实体类
112
+ */
113
+ EntityType = "EntityType",
114
+ /**
115
+ * 分级码
116
+ */
117
+ HierarchyType = "HierarchyType",
118
+ /**
119
+ * 对象
120
+ */
121
+ ObjectType = "ObjectType",
122
+ /**
123
+ * 数字(大数据)
124
+ */
125
+ BigNumericType = "BigNumericType"
126
+ }
127
+ /**
128
+ * 字段类型中的名称
129
+ */
130
+ export enum FormSchemaEntityFieldTypeName {
131
+ /**
132
+ * 简单类型字段
133
+ */
134
+ String = "String",
135
+ /**
136
+ * 日期时间
137
+ */
138
+ DateTime = "DateTime",
139
+ /**
140
+ * 日期
141
+ */
142
+ Date = "Date",
143
+ /**
144
+ * 枚举
145
+ */
146
+ Enum = "Enum",
147
+ /**
148
+ * 布尔
149
+ */
150
+ Boolean = "Boolean",
151
+ /**
152
+ * 数字
153
+ */
154
+ Number = "Number",
155
+ /**
156
+ * 备注
157
+ */
158
+ Text = "Text",
159
+ /**
160
+ * 大数字
161
+ */
162
+ BigNumber = "BigNumber"
163
+ /**
164
+ * 人员
165
+ */
166
+ }
167
+ /**
168
+ * 枚举类型
169
+ */
170
+ export interface EnumData {
171
+ value: string;
172
+ name: string;
173
+ }
174
+ /**
175
+ * 实体
176
+ */
177
+ export interface FormSchemaEntity {
178
+ id: string;
179
+ code: string;
180
+ name: string;
181
+ label: string;
182
+ type: FormSchemaEntityType;
183
+ }
184
+ /**
185
+ * 实体类型对象
186
+ */
187
+ export interface FormSchemaEntityType {
188
+ $type: string;
189
+ name: string;
190
+ primary: string;
191
+ fields: FormSchemaEntityField[];
192
+ entities?: FormSchemaEntity[];
193
+ displayName?: string;
194
+ }
195
+ /**
196
+ * 字段类型对象
197
+ */
198
+ export interface FormSchemaEntityFieldType {
199
+ $type: FormSchemaEntityFieldType$Type;
200
+ name: FormSchemaEntityFieldTypeName | any;
201
+ length?: number;
202
+ precision?: number;
203
+ valueType?: FormSchemaEntityFieldType;
204
+ enumValues?: EnumData[];
205
+ fields?: FormSchemaEntityField[];
206
+ displayName?: string;
207
+ primary?: string;
208
+ entities?: FormSchemaEntity[];
209
+ elementType?: GSPElementDataType;
210
+ extendProperty?: any;
211
+ }
212
+ /**
213
+ * 字段数据类型
214
+ */
215
+ export enum GSPElementDataType {
216
+ /**
217
+ * 文本
218
+ */
219
+ String = "String",
220
+ /**
221
+ * 备注
222
+ */
223
+ Text = "Text",
224
+ /**
225
+ * 整数
226
+ */
227
+ Integer = "Integer",
228
+ /**
229
+ * 浮点数
230
+ */
231
+ Decimal = "Decimal",
232
+ /**
233
+ * 布尔型
234
+ */
235
+ Boolean = "Boolean",
236
+ /**
237
+ * 日期型
238
+ */
239
+ Date = "Date",
240
+ /**
241
+ * 日期时间型
242
+ */
243
+ DateTime = "DateTime",
244
+ /**
245
+ * 二进制
246
+ */
247
+ Binary = "Binary"
248
+ }
249
+ /**
250
+ * dom Json ViewModel 节点中states实体
251
+ */
252
+ export interface FormVariable {
253
+ id: string;
254
+ code: string;
255
+ name: string;
256
+ value?: any;
257
+ type: string;
258
+ category: string;
259
+ fields?: any[];
260
+ defaultValue?: any;
261
+ }
262
+ /**
263
+ * 表单变量
264
+ */
265
+ export interface DesignFormVariable extends FormVariable {
266
+ /**
267
+ * 分组ID
268
+ */
269
+ groupId: string;
270
+ /**
271
+ * 分组名称
272
+ */
273
+ groupName: string;
274
+ }