@farris/cli 2.0.3 → 2.1.1
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.
- package/lib/commands/build.js +6 -7
- package/lib/commands/build.js.map +1 -1
- package/lib/commands/generate/api.js +188 -0
- package/lib/commands/generate/api.js.map +1 -0
- package/lib/commands/generate/common.js +101 -0
- package/lib/commands/generate/common.js.map +1 -0
- package/lib/commands/generate/component.js +164 -0
- package/lib/commands/generate/component.js.map +1 -0
- package/lib/commands/generate/view.js +195 -0
- package/lib/commands/generate/view.js.map +1 -0
- package/lib/commands/workspace/add-app.js +174 -0
- package/lib/commands/workspace/add-app.js.map +1 -0
- package/lib/commands/workspace/create.js +380 -0
- package/lib/commands/workspace/create.js.map +1 -0
- package/lib/commands/workspace/inspect.js +31 -0
- package/lib/commands/workspace/inspect.js.map +1 -0
- package/lib/commands/workspace/verify.js +39 -0
- package/lib/commands/workspace/verify.js.map +1 -0
- package/lib/common/constant.js +42 -1
- package/lib/common/constant.js.map +1 -1
- package/lib/common/get-vite-config.js +66 -9
- package/lib/common/get-vite-config.js.map +1 -1
- package/lib/common/output.js +95 -0
- package/lib/common/output.js.map +1 -0
- package/lib/common/safety.js +172 -0
- package/lib/common/safety.js.map +1 -0
- package/lib/common/template-renderer.js +115 -0
- package/lib/common/template-renderer.js.map +1 -0
- package/lib/common/transaction.js +84 -0
- package/lib/common/transaction.js.map +1 -0
- package/lib/common/verifier.js +147 -0
- package/lib/common/verifier.js.map +1 -0
- package/lib/config/vite-common.js +1 -1
- package/lib/config/vite-common.js.map +1 -1
- package/lib/index.js +124 -30
- package/lib/index.js.map +1 -1
- package/package.json +13 -9
- package/templates/workspace/app/farris.config.mjs +13 -0
- package/templates/{lib → workspace/app}/index.html +12 -12
- package/templates/workspace/app/package.json +22 -0
- package/templates/workspace/app/src/App.tsx +11 -0
- package/templates/workspace/app/src/main.ts +11 -0
- package/templates/workspace/app/src/router/index.ts +16 -0
- package/templates/workspace/app/src/styles/index.css +0 -0
- package/templates/workspace/app/src/styles/index.scss +0 -0
- package/templates/workspace/app/src/views/home/composables/use-home.ts +7 -0
- package/templates/workspace/app/src/views/home/home.component.tsx +15 -0
- package/templates/workspace/app/src/views/home/index.ts +4 -0
- package/templates/workspace/app/tsconfig.json +21 -0
- package/templates/workspace/root/README.md +28 -0
- package/templates/workspace/root/package.json +13 -0
- package/templates/workspace/root/pnpm-workspace.yaml +12 -0
- package/templates/lib/.eslintrc.cjs +0 -15
- package/templates/lib/.prettierrc.json +0 -8
- package/templates/lib/components/button/index.ts +0 -7
- package/templates/lib/components/button/src/button.component.tsx +0 -84
- package/templates/lib/components/button/src/button.props.ts +0 -55
- package/templates/lib/components/button/src/button.scss +0 -179
- package/templates/lib/components/common/index.ts +0 -6
- package/templates/lib/components/common/src/common.scss +0 -4
- package/templates/lib/components/common/src/compositions/index.ts +0 -19
- package/templates/lib/components/common/src/compositions/types.ts +0 -6
- package/templates/lib/components/common/src/compositions/use-bem/index.ts +0 -46
- package/templates/lib/components/common/src/compositions/use-click-away/index.ts +0 -40
- package/templates/lib/components/common/src/compositions/use-context/use-children-contexts.ts +0 -40
- package/templates/lib/components/common/src/compositions/use-context/use-parent-context.ts +0 -24
- package/templates/lib/components/common/src/compositions/use-event-listener/index.ts +0 -45
- package/templates/lib/components/common/src/compositions/use-expose/index.ts +0 -9
- package/templates/lib/components/common/src/compositions/use-lay-render/index.ts +0 -17
- package/templates/lib/components/common/src/compositions/use-link/index.ts +0 -14
- package/templates/lib/components/common/src/compositions/use-lock-scroll/index.ts +0 -25
- package/templates/lib/components/common/src/compositions/use-long-press/index.ts +0 -141
- package/templates/lib/components/common/src/compositions/use-momentum/index.ts +0 -82
- package/templates/lib/components/common/src/compositions/use-mount-component/index.ts +0 -48
- package/templates/lib/components/common/src/compositions/use-rect/index.ts +0 -31
- package/templates/lib/components/common/src/compositions/use-refs/index.ts +0 -21
- package/templates/lib/components/common/src/compositions/use-resize-observer/index.ts +0 -85
- package/templates/lib/components/common/src/compositions/use-resize-observer/utils.ts +0 -37
- package/templates/lib/components/common/src/compositions/use-scroll-parent/index.ts +0 -42
- package/templates/lib/components/common/src/compositions/use-touch/index.ts +0 -82
- package/templates/lib/components/common/src/compositions/use-touch-move/index.ts +0 -120
- package/templates/lib/components/common/src/entity/base-property.ts +0 -129
- package/templates/lib/components/common/src/entity/entity-schema.ts +0 -274
- package/templates/lib/components/common/src/entity/input-base-property.ts +0 -285
- package/templates/lib/components/common/src/style/animation/index.scss +0 -150
- package/templates/lib/components/common/src/style/base.scss +0 -63
- package/templates/lib/components/common/src/style/fonts/farris-mobile-icon.ttf +0 -0
- package/templates/lib/components/common/src/style/icon.scss +0 -6
- package/templates/lib/components/common/src/style/index.scss +0 -4
- package/templates/lib/components/common/src/style/mixins/bem.scss +0 -204
- package/templates/lib/components/common/src/style/mixins/border-radius.scss +0 -13
- package/templates/lib/components/common/src/style/mixins/ellipsis.scss +0 -15
- package/templates/lib/components/common/src/style/mixins/hairline.scss +0 -113
- package/templates/lib/components/common/src/style/mixins/index.scss +0 -6
- package/templates/lib/components/common/src/style/mixins/margin.scss +0 -10
- package/templates/lib/components/common/src/style/mixins/safe-area.scss +0 -9
- package/templates/lib/components/common/src/style/variables.scss +0 -113
- package/templates/lib/components/common/src/utils/index.ts +0 -15
- package/templates/lib/components/common/src/utils/src/common.ts +0 -83
- package/templates/lib/components/common/src/utils/src/date.ts +0 -134
- package/templates/lib/components/common/src/utils/src/dom/event.ts +0 -37
- package/templates/lib/components/common/src/utils/src/hook.ts +0 -18
- package/templates/lib/components/common/src/utils/src/number.ts +0 -26
- package/templates/lib/components/common/src/utils/src/query-filter.ts +0 -40
- package/templates/lib/components/common/src/utils/src/resove-asset.ts +0 -33
- package/templates/lib/components/common/src/utils/src/string.ts +0 -18
- package/templates/lib/components/common/src/utils/src/throttle.ts +0 -41
- package/templates/lib/components/common/src/utils/src/transition.ts +0 -14
- package/templates/lib/components/common/src/utils/src/type.ts +0 -105
- package/templates/lib/components/common/src/utils/src/use-appearance.ts +0 -33
- package/templates/lib/components/common/src/utils/src/with-install.ts +0 -16
- package/templates/lib/components/common/src/utils/src/with-register-designer.ts +0 -16
- package/templates/lib/components/common/src/utils/src/with-register.ts +0 -16
- package/templates/lib/components/common/types.ts +0 -131
- package/templates/lib/components/index.scss +0 -2
- package/templates/lib/components/index.ts +0 -21
- package/templates/lib/farris.config.mjs +0 -56
- package/templates/lib/package.json +0 -32
- package/templates/lib/src/App.vue +0 -80
- package/templates/lib/src/components/TheButton.vue +0 -3
- package/templates/lib/src/main.ts +0 -10
- package/templates/lib/src/router/index.ts +0 -23
- package/templates/lib/src/views/AboutView.vue +0 -15
- package/templates/lib/src/views/HomeView.vue +0 -9
- package/templates/lib/tsconfig.json +0 -20
|
@@ -1,129 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,274 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { BaseControlProperty } from './base-property';
|
|
2
|
-
import { DesignerComponentInstance } from "@/components/designer-canvas";
|
|
3
|
-
import { SchemaDOMMapping } from "@/components/property-panel";
|
|
4
|
-
import { canvasChanged } from "@/components/designer-canvas/src/composition/designer-canvas-changed";
|
|
5
|
-
import { FormSchemaEntityFieldType$Type } from './entity-schema';
|
|
6
|
-
|
|
7
|
-
export class InputBaseProperty extends BaseControlProperty {
|
|
8
|
-
constructor(componentId: string, designerHostService: any) {
|
|
9
|
-
super(componentId, designerHostService);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public getPropertyConfig(propertyData: any, componentInstance: DesignerComponentInstance) {
|
|
13
|
-
// 基本信息
|
|
14
|
-
this.propertyConfig.categories['basic'] = this.getBasicProperties(propertyData, componentInstance);
|
|
15
|
-
// 外观
|
|
16
|
-
this.propertyConfig.categories['appearance'] = this.getAppearanceProperties(propertyData, componentInstance);
|
|
17
|
-
// 编辑器
|
|
18
|
-
this.propertyConfig.categories['editor'] = this.getEditorProperties(propertyData);
|
|
19
|
-
return this.propertyConfig;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public getBasicProperties(propertyData, componentInstance): any {
|
|
23
|
-
const self = this;
|
|
24
|
-
this.setDesignViewModelField(propertyData);
|
|
25
|
-
return {
|
|
26
|
-
description: 'Basic Information',
|
|
27
|
-
title: '基本信息',
|
|
28
|
-
properties: {
|
|
29
|
-
id: {
|
|
30
|
-
description: '组件标识',
|
|
31
|
-
title: '标识',
|
|
32
|
-
type: 'string',
|
|
33
|
-
readonly: true
|
|
34
|
-
},
|
|
35
|
-
type: {
|
|
36
|
-
description: '编辑器类型',
|
|
37
|
-
title: '编辑器类型',
|
|
38
|
-
type: 'string',
|
|
39
|
-
refreshPanelAfterChanged: true,
|
|
40
|
-
$converter: '/converter/change-editor.converter',
|
|
41
|
-
editor: {
|
|
42
|
-
type: 'combo-list',
|
|
43
|
-
textField: 'value',
|
|
44
|
-
valueField: 'key',
|
|
45
|
-
editable: false,
|
|
46
|
-
data: self.designViewModelField ? SchemaDOMMapping.getEditorTypesByMDataType(self.designViewModelField.type?.name) : SchemaDOMMapping.getAllInputTypes()
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
label: {
|
|
50
|
-
title: "标签",
|
|
51
|
-
type: "string",
|
|
52
|
-
$converter: '/converter/form-group-label.converter'
|
|
53
|
-
},
|
|
54
|
-
binding: {
|
|
55
|
-
description: "绑定的表单字段",
|
|
56
|
-
title: "绑定",
|
|
57
|
-
editor: {
|
|
58
|
-
type: "binding-selector",
|
|
59
|
-
bindingType: { "enable": false },
|
|
60
|
-
editorParams: {
|
|
61
|
-
componentSchema: propertyData,
|
|
62
|
-
needSyncToViewModel: true,
|
|
63
|
-
viewModelId: this.viewModelId,
|
|
64
|
-
designerHostService: this.designerHostService,
|
|
65
|
-
disableOccupiedFields: true
|
|
66
|
-
},
|
|
67
|
-
textField: 'bindingField'
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
setPropertyRelates(changeObject, prop) {
|
|
72
|
-
if (!changeObject) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
switch (changeObject && changeObject.propertyID) {
|
|
76
|
-
case 'type': {
|
|
77
|
-
self.changeControlType(propertyData, changeObject, componentInstance);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case 'label': {
|
|
81
|
-
changeObject.needRefreshControlTree = true;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
public getAppearanceProperties(propertyData, componentInstance): any {
|
|
89
|
-
|
|
90
|
-
const self = this;
|
|
91
|
-
return {
|
|
92
|
-
title: "外观",
|
|
93
|
-
description: "Appearance",
|
|
94
|
-
properties: {
|
|
95
|
-
class: {
|
|
96
|
-
title: "class样式",
|
|
97
|
-
type: "string",
|
|
98
|
-
description: "组件的CSS样式",
|
|
99
|
-
$converter: "/converter/appearance.converter"
|
|
100
|
-
},
|
|
101
|
-
style: {
|
|
102
|
-
title: "style样式",
|
|
103
|
-
type: "string",
|
|
104
|
-
description: "组件的样式",
|
|
105
|
-
$converter: "/converter/appearance.converter"
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
setPropertyRelates(changeObject, prop) {
|
|
109
|
-
if (!changeObject) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
switch (changeObject && changeObject.propertyID) {
|
|
113
|
-
case 'class':
|
|
114
|
-
self.updateElementByParentContainer(propertyData.id, componentInstance);
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
public getEditorProperties(propertyData): any {
|
|
123
|
-
return this.getComponentConfig(propertyData);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 卡片控件:切换控件类型后事件
|
|
129
|
-
* @param propertyData 控件DOM属性
|
|
130
|
-
* @param newControlType 新控件类型
|
|
131
|
-
*/
|
|
132
|
-
private changeControlType(propertyData, changeObject, componentInstance: DesignerComponentInstance) {
|
|
133
|
-
const newControlType = changeObject.propertyValue;
|
|
134
|
-
|
|
135
|
-
// 1、定位控件父容器
|
|
136
|
-
const parentContainer = componentInstance && componentInstance.parent && componentInstance.parent['schema'];
|
|
137
|
-
if (!parentContainer) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const index = parentContainer.contents.findIndex(c => c.id === propertyData.id);
|
|
142
|
-
const oldControl = parentContainer.contents[index];
|
|
143
|
-
|
|
144
|
-
let newControl;
|
|
145
|
-
// 2、记录绑定字段viewModel的变更
|
|
146
|
-
if (this.designViewModelField) {
|
|
147
|
-
const dgViewModel = this.designViewModelUtils.getDgViewModel(this.viewModelId);
|
|
148
|
-
dgViewModel.changeField(this.designViewModelField.id, {
|
|
149
|
-
editor: {
|
|
150
|
-
$type: newControlType
|
|
151
|
-
},
|
|
152
|
-
name: this.designViewModelField.name,
|
|
153
|
-
require: this.designViewModelField.require,
|
|
154
|
-
readonly: this.designViewModelField.readonly
|
|
155
|
-
}, false);
|
|
156
|
-
// 3、创建新控件
|
|
157
|
-
newControl = this.controlCreatorUtils.setFormFieldProperty(this.designViewModelField, newControlType);
|
|
158
|
-
}
|
|
159
|
-
if (!newControl) {
|
|
160
|
-
newControl = this.controlCreatorUtils.createFormGroupWithoutField(newControlType);
|
|
161
|
-
}
|
|
162
|
-
// 4、保留原id样式等属性
|
|
163
|
-
Object.assign(newControl, {
|
|
164
|
-
id: oldControl.id,
|
|
165
|
-
appearance: oldControl.appearance,
|
|
166
|
-
size: oldControl.size,
|
|
167
|
-
label: oldControl.label,
|
|
168
|
-
binding: oldControl.binding,
|
|
169
|
-
visible: oldControl.visible
|
|
170
|
-
});
|
|
171
|
-
Object.assign(newControl.editor, {
|
|
172
|
-
isTextArea: newControl.isTextArea && oldControl.isTextArea,
|
|
173
|
-
placeholder: oldControl.editor?.placeholder,
|
|
174
|
-
holdPlace: oldControl.editor?.holdPlace,
|
|
175
|
-
readonly: oldControl.editor?.readonly,
|
|
176
|
-
required: oldControl.editor?.required,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// 5、替换控件
|
|
180
|
-
parentContainer.contents.splice(index, 1);
|
|
181
|
-
parentContainer.contents.splice(index, 0, newControl);
|
|
182
|
-
componentInstance.schema = Object.assign(oldControl, newControl);
|
|
183
|
-
|
|
184
|
-
// 6、暂时移除旧控件的选中样式(后续考虑更好的方式)
|
|
185
|
-
Array.from(document.getElementsByClassName('dgComponentSelected') as HTMLCollectionOf<HTMLElement>).forEach(
|
|
186
|
-
(element: HTMLElement) => element.classList.remove('dgComponentSelected')
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
Array.from(document.getElementsByClassName('dgComponentFocused') as HTMLCollectionOf<HTMLElement>).forEach(
|
|
190
|
-
(element: HTMLElement) => element.classList.remove('dgComponentFocused')
|
|
191
|
-
);
|
|
192
|
-
// 7、触发刷新
|
|
193
|
-
canvasChanged.value++;
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
public getComponentConfig(propertyData, info = {}, properties = {}, setPropertyRelates?: any) {
|
|
198
|
-
const editorBasic = Object.assign({
|
|
199
|
-
description: "编辑器",
|
|
200
|
-
title: "编辑器",
|
|
201
|
-
type: "input-group",
|
|
202
|
-
$converter: "/converter/property-editor.converter"
|
|
203
|
-
}, info);
|
|
204
|
-
|
|
205
|
-
const editorProperties = Object.assign({
|
|
206
|
-
readonly: {
|
|
207
|
-
description: "",
|
|
208
|
-
title: "只读",
|
|
209
|
-
type: "boolean",
|
|
210
|
-
editor: {
|
|
211
|
-
enableClear: true,
|
|
212
|
-
editable: true
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
disabled: {
|
|
216
|
-
description: "",
|
|
217
|
-
title: "禁用",
|
|
218
|
-
type: "boolean",
|
|
219
|
-
visible: false
|
|
220
|
-
},
|
|
221
|
-
required: {
|
|
222
|
-
description: "",
|
|
223
|
-
title: "必填",
|
|
224
|
-
type: "boolean",
|
|
225
|
-
visible: false
|
|
226
|
-
},
|
|
227
|
-
placeholder: {
|
|
228
|
-
description: "空值时,输入控件内的占位文本",
|
|
229
|
-
title: "提示文本",
|
|
230
|
-
type: "string",
|
|
231
|
-
visible: false
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
}, properties);
|
|
235
|
-
|
|
236
|
-
return { ...editorBasic, properties: { ...editorProperties }, setPropertyRelates };
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* 枚举项编辑器
|
|
243
|
-
* @param propertyData
|
|
244
|
-
* @param valueField
|
|
245
|
-
* @param textField
|
|
246
|
-
* @returns
|
|
247
|
-
*/
|
|
248
|
-
protected getItemCollectionEditor(propertyData, valueField, textField) {
|
|
249
|
-
valueField = valueField || 'value';
|
|
250
|
-
textField = textField || 'name';
|
|
251
|
-
return {
|
|
252
|
-
editor: {
|
|
253
|
-
columns: [
|
|
254
|
-
{ field: valueField, title: '值', dataType: 'string' },
|
|
255
|
-
{ field: textField, title: '名称', dataType: 'string' },
|
|
256
|
-
{ field: 'disabled', title: '禁用', visible: false, dataType: 'boolean', editor: { type: 'switch' } },
|
|
257
|
-
],
|
|
258
|
-
type: "item-collection-editor",
|
|
259
|
-
valueField: valueField,
|
|
260
|
-
nameField: textField,
|
|
261
|
-
requiredFields: [valueField, textField],
|
|
262
|
-
uniqueFields: [valueField, textField],
|
|
263
|
-
readonly: this.checkEnumDataReadonly(propertyData)
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* 判断枚举数据是否只读
|
|
269
|
-
* 1、没有绑定信息或者绑定变量,可以新增、删除、修改
|
|
270
|
-
* 2、绑定类型为字段,且字段为枚举字段,则不可新增、删除、修改枚举值。只能从be修改然后同步到表单上。
|
|
271
|
-
* @param propertyData 下拉框控件属性值
|
|
272
|
-
*/
|
|
273
|
-
private checkEnumDataReadonly(propertyData: any): boolean {
|
|
274
|
-
// 没有绑定信息或者绑定变量
|
|
275
|
-
if (!propertyData.binding || propertyData.binding.type !== 'Form') {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
if (this.designViewModelField && this.designViewModelField.type &&
|
|
279
|
-
this.designViewModelField.type.$type === FormSchemaEntityFieldType$Type.EnumType) {
|
|
280
|
-
// 低代码、零代码,枚举字段均不可以改
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
}
|