neo-cmp-cli 1.2.23 → 1.2.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.
- package/README.md +60 -6
- package/package.json +1 -1
- package/src/template/neo-custom-cmp-template/package.json +1 -1
- package/src/template/neo-custom-cmp-template/src/components/contact-form/index.tsx +20 -17
- package/src/template/neo-custom-cmp-template/src/components/contact-form/model.ts +7 -0
- package/src/template/neo-custom-cmp-template/src/components/object-form/README.md +176 -0
- package/src/template/neo-custom-cmp-template/src/components/object-form/index.tsx +621 -0
- package/src/template/neo-custom-cmp-template/src/components/object-form/model.ts +107 -0
- package/src/template/neo-custom-cmp-template/src/components/object-form/style.scss +371 -0
- package/src/template/neo-custom-cmp-template/src/components/xobject-table/index.tsx +4 -3
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Object Form 表单组件对接编辑器的描述文件
|
|
3
|
+
* @description 定义组件在 Neo 平台编辑器中的配置信息
|
|
4
|
+
* @author Neo Custom Widget CLI
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
*/
|
|
7
|
+
export class ObjectFormModel {
|
|
8
|
+
/**
|
|
9
|
+
* 组件类型标识
|
|
10
|
+
* 用于标识组件的唯一性,在构建时根据当前组件目录名称自动生成
|
|
11
|
+
* 注意:此字段在构建时会被自动替换,不需要手动设置
|
|
12
|
+
*/
|
|
13
|
+
// cmpType: string = 'object-form';
|
|
14
|
+
|
|
15
|
+
/** 组件名称,用于设置在编辑器左侧组件面板中展示的名称 */
|
|
16
|
+
label: string = '实体对象表单';
|
|
17
|
+
|
|
18
|
+
/** 组件描述,用于设置在编辑器左侧组件面板中展示的描述 */
|
|
19
|
+
description: string = '基于 XObject 的对象表单组件,用于新增数据';
|
|
20
|
+
|
|
21
|
+
/** 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签) */
|
|
22
|
+
tags: string[] = ['自定义组件'];
|
|
23
|
+
|
|
24
|
+
/** 组件图标,用于设置在编辑器左侧组件面板中展示的图标 */
|
|
25
|
+
iconSrc: string = 'https://custom-widgets.bj.bcebos.com/custom-form.svg';
|
|
26
|
+
|
|
27
|
+
/** 初次插入页面的默认属性数据 */
|
|
28
|
+
defaultComProps = {
|
|
29
|
+
formTitle: '新增数据表单',
|
|
30
|
+
showResetButton: true,
|
|
31
|
+
columnCount: 1,
|
|
32
|
+
xObjectDataApi: {
|
|
33
|
+
xObjectApiKey: 'customContact__c',
|
|
34
|
+
fields: ['name', 'entityType', 'phone__c'],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** 设计器端预览时展示的默认数据 */
|
|
39
|
+
previewComProps = {
|
|
40
|
+
formTitle: '新增数据表单',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 组件属性配置模式
|
|
45
|
+
* 支持静态配置:propsSchema,优先级比 propsSchemaCreator 低
|
|
46
|
+
* 定义组件在编辑器中可配置的属性
|
|
47
|
+
*/
|
|
48
|
+
propsSchema = [
|
|
49
|
+
{
|
|
50
|
+
type: 'text',
|
|
51
|
+
name: 'formTitle',
|
|
52
|
+
label: '表单标题',
|
|
53
|
+
value: '新增数据表单',
|
|
54
|
+
placeholder: '请输入表单标题',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'xObjectDataApi', // 用于获取实体业务数据列表的配置项
|
|
58
|
+
name: 'xObjectDataApi',
|
|
59
|
+
label: '实体数据源',
|
|
60
|
+
/*
|
|
61
|
+
value: {
|
|
62
|
+
xObjectApiKey: 'customContact__c',
|
|
63
|
+
fields: ['name', 'entityType', 'phone__c'],
|
|
64
|
+
},
|
|
65
|
+
*/
|
|
66
|
+
placeholder: '请选择实体数据源',
|
|
67
|
+
custom: true,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: 'select',
|
|
71
|
+
name: 'columnCount',
|
|
72
|
+
label: '表单列数',
|
|
73
|
+
value: 1,
|
|
74
|
+
placeholder: '请选择表单列数',
|
|
75
|
+
options: [
|
|
76
|
+
{
|
|
77
|
+
label: '单列',
|
|
78
|
+
value: 1,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
label: '双列',
|
|
82
|
+
value: 2,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: 'switch',
|
|
88
|
+
name: 'showResetButton',
|
|
89
|
+
label: '显示重置按钮',
|
|
90
|
+
value: true,
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 支持函数式写法:propsSchemaCreator
|
|
96
|
+
* com 为组件实例,优先级比 propsSchema 高
|
|
97
|
+
* 可以根据组件实例动态生成属性配置
|
|
98
|
+
*/
|
|
99
|
+
/*
|
|
100
|
+
propsSchemaCreator = (com: any) => {
|
|
101
|
+
return [];
|
|
102
|
+
};
|
|
103
|
+
*/
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default ObjectFormModel;
|
|
107
|
+
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
.object-form-container {
|
|
2
|
+
.form-header {
|
|
3
|
+
margin-bottom: 24px;
|
|
4
|
+
padding-bottom: 16px;
|
|
5
|
+
border-bottom: 1px solid #f0f0f0;
|
|
6
|
+
|
|
7
|
+
.form-title {
|
|
8
|
+
margin: 0;
|
|
9
|
+
font-size: 18px;
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
color: #262626;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.form-content {
|
|
16
|
+
.ant-form {
|
|
17
|
+
.ant-form-item {
|
|
18
|
+
margin-bottom: 20px;
|
|
19
|
+
|
|
20
|
+
.ant-form-item-label {
|
|
21
|
+
padding-bottom: 6px;
|
|
22
|
+
|
|
23
|
+
label {
|
|
24
|
+
font-weight: 500;
|
|
25
|
+
color: #262626;
|
|
26
|
+
font-size: 14px;
|
|
27
|
+
|
|
28
|
+
&::before {
|
|
29
|
+
display: inline-block;
|
|
30
|
+
margin-right: 4px;
|
|
31
|
+
color: #ff4d4f;
|
|
32
|
+
font-size: 14px;
|
|
33
|
+
font-family: SimSun, sans-serif;
|
|
34
|
+
line-height: 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ant-input,
|
|
40
|
+
.ant-select-selector,
|
|
41
|
+
.ant-input-number,
|
|
42
|
+
.ant-picker {
|
|
43
|
+
border-radius: 4px;
|
|
44
|
+
border: 1px solid #d9d9d9;
|
|
45
|
+
transition: all 0.3s;
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
border-color: #40a9ff;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:focus,
|
|
52
|
+
&.ant-input-focused,
|
|
53
|
+
&.ant-select-focused .ant-select-selector,
|
|
54
|
+
&.ant-picker-focused {
|
|
55
|
+
border-color: #40a9ff;
|
|
56
|
+
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.ant-input-number {
|
|
61
|
+
width: 100%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.ant-input-textarea {
|
|
65
|
+
textarea {
|
|
66
|
+
resize: vertical;
|
|
67
|
+
min-height: 80px;
|
|
68
|
+
border-radius: 4px;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ant-picker {
|
|
73
|
+
width: 100%;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ant-select {
|
|
77
|
+
width: 100%;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 错误提示样式
|
|
82
|
+
.ant-form-item-has-error {
|
|
83
|
+
.ant-input,
|
|
84
|
+
.ant-select-selector,
|
|
85
|
+
.ant-input-number,
|
|
86
|
+
.ant-picker {
|
|
87
|
+
border-color: #ff4d4f;
|
|
88
|
+
|
|
89
|
+
&:focus {
|
|
90
|
+
border-color: #ff4d4f;
|
|
91
|
+
box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.submit-success-message {
|
|
98
|
+
margin: 16px 0;
|
|
99
|
+
padding: 12px 16px;
|
|
100
|
+
background-color: #f6ffed;
|
|
101
|
+
border: 1px solid #b7eb8f;
|
|
102
|
+
border-radius: 4px;
|
|
103
|
+
color: #52c41a;
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
animation: fadeIn 0.3s ease-in;
|
|
108
|
+
|
|
109
|
+
.anticon {
|
|
110
|
+
margin-right: 8px;
|
|
111
|
+
font-size: 16px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.form-actions {
|
|
116
|
+
margin-top: 32px;
|
|
117
|
+
padding-top: 24px;
|
|
118
|
+
border-top: 1px solid #f0f0f0;
|
|
119
|
+
text-align: center;
|
|
120
|
+
|
|
121
|
+
.ant-space {
|
|
122
|
+
.ant-btn {
|
|
123
|
+
min-width: 100px;
|
|
124
|
+
height: 40px;
|
|
125
|
+
font-size: 15px;
|
|
126
|
+
border-radius: 4px;
|
|
127
|
+
font-weight: 500;
|
|
128
|
+
transition: all 0.3s;
|
|
129
|
+
|
|
130
|
+
&.ant-btn-primary {
|
|
131
|
+
background: #1890ff;
|
|
132
|
+
border-color: #1890ff;
|
|
133
|
+
|
|
134
|
+
&:hover {
|
|
135
|
+
background: #40a9ff;
|
|
136
|
+
border-color: #40a9ff;
|
|
137
|
+
transform: translateY(-2px);
|
|
138
|
+
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&:active {
|
|
142
|
+
background: #096dd9;
|
|
143
|
+
border-color: #096dd9;
|
|
144
|
+
transform: translateY(0);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&:disabled {
|
|
148
|
+
background: #f5f5f5;
|
|
149
|
+
border-color: #d9d9d9;
|
|
150
|
+
color: rgba(0, 0, 0, 0.25);
|
|
151
|
+
transform: none;
|
|
152
|
+
box-shadow: none;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&:not(.ant-btn-primary) {
|
|
157
|
+
&:hover {
|
|
158
|
+
color: #40a9ff;
|
|
159
|
+
border-color: #40a9ff;
|
|
160
|
+
transform: translateY(-2px);
|
|
161
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
&:active {
|
|
165
|
+
color: #096dd9;
|
|
166
|
+
border-color: #096dd9;
|
|
167
|
+
transform: translateY(0);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.ant-empty {
|
|
175
|
+
padding: 40px 0;
|
|
176
|
+
|
|
177
|
+
.ant-empty-description {
|
|
178
|
+
color: #8c8c8c;
|
|
179
|
+
font-size: 14px;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// 动画效果
|
|
185
|
+
@keyframes fadeIn {
|
|
186
|
+
from {
|
|
187
|
+
opacity: 0;
|
|
188
|
+
transform: translateY(-10px);
|
|
189
|
+
}
|
|
190
|
+
to {
|
|
191
|
+
opacity: 1;
|
|
192
|
+
transform: translateY(0);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 响应式设计
|
|
197
|
+
@media (max-width: 768px) {
|
|
198
|
+
.form-header {
|
|
199
|
+
margin-bottom: 16px;
|
|
200
|
+
padding-bottom: 12px;
|
|
201
|
+
|
|
202
|
+
.form-title {
|
|
203
|
+
font-size: 16px;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.form-content {
|
|
208
|
+
.ant-form {
|
|
209
|
+
.ant-form-item {
|
|
210
|
+
margin-bottom: 16px;
|
|
211
|
+
|
|
212
|
+
.ant-form-item-label {
|
|
213
|
+
label {
|
|
214
|
+
font-size: 13px;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.ant-input,
|
|
219
|
+
.ant-select-selector,
|
|
220
|
+
.ant-input-number,
|
|
221
|
+
.ant-picker {
|
|
222
|
+
font-size: 14px;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.form-actions {
|
|
228
|
+
margin-top: 24px;
|
|
229
|
+
padding-top: 16px;
|
|
230
|
+
|
|
231
|
+
.ant-space {
|
|
232
|
+
.ant-btn {
|
|
233
|
+
min-width: 80px;
|
|
234
|
+
height: 36px;
|
|
235
|
+
font-size: 14px;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@media (max-width: 576px) {
|
|
243
|
+
.form-header {
|
|
244
|
+
.form-title {
|
|
245
|
+
font-size: 15px;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.form-content {
|
|
250
|
+
.ant-form {
|
|
251
|
+
// 在小屏幕上强制单列显示
|
|
252
|
+
.ant-row {
|
|
253
|
+
.ant-col {
|
|
254
|
+
max-width: 100% !important;
|
|
255
|
+
flex: 0 0 100% !important;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.ant-form-item {
|
|
260
|
+
margin-bottom: 14px;
|
|
261
|
+
|
|
262
|
+
.ant-form-item-label {
|
|
263
|
+
label {
|
|
264
|
+
font-size: 13px;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.form-actions {
|
|
271
|
+
.ant-space {
|
|
272
|
+
width: 100%;
|
|
273
|
+
|
|
274
|
+
.ant-space-item {
|
|
275
|
+
flex: 1;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.ant-btn {
|
|
279
|
+
width: 100%;
|
|
280
|
+
min-width: auto;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 全局样式覆盖
|
|
289
|
+
.ant-card {
|
|
290
|
+
border-radius: 6px;
|
|
291
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
292
|
+
|
|
293
|
+
.ant-card-body {
|
|
294
|
+
padding: 24px;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Spin 加载样式
|
|
299
|
+
.ant-spin {
|
|
300
|
+
.ant-spin-dot {
|
|
301
|
+
font-size: 20px;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.ant-spin-text {
|
|
305
|
+
color: #8c8c8c;
|
|
306
|
+
font-size: 14px;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Select 下拉样式优化
|
|
311
|
+
.ant-select-dropdown {
|
|
312
|
+
border-radius: 4px;
|
|
313
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
314
|
+
|
|
315
|
+
.ant-select-item {
|
|
316
|
+
padding: 8px 12px;
|
|
317
|
+
|
|
318
|
+
&:hover {
|
|
319
|
+
background-color: #f5f5f5;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
&.ant-select-item-option-selected {
|
|
323
|
+
background-color: #e6f7ff;
|
|
324
|
+
color: #1890ff;
|
|
325
|
+
font-weight: 500;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// DatePicker 日期选择器样式优化
|
|
331
|
+
.ant-picker-dropdown {
|
|
332
|
+
.ant-picker-panel-container {
|
|
333
|
+
border-radius: 4px;
|
|
334
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.ant-picker-cell-selected {
|
|
338
|
+
.ant-picker-cell-inner {
|
|
339
|
+
background-color: #1890ff;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.ant-picker-cell:hover:not(.ant-picker-cell-selected) {
|
|
344
|
+
.ant-picker-cell-inner {
|
|
345
|
+
background-color: #f5f5f5;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// InputNumber 数字输入框样式优化
|
|
351
|
+
.ant-input-number {
|
|
352
|
+
.ant-input-number-handler-wrap {
|
|
353
|
+
opacity: 0;
|
|
354
|
+
transition: opacity 0.3s;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
&:hover {
|
|
358
|
+
.ant-input-number-handler-wrap {
|
|
359
|
+
opacity: 1;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.ant-input-number-handler {
|
|
364
|
+
border-left: 1px solid #d9d9d9;
|
|
365
|
+
|
|
366
|
+
&:hover {
|
|
367
|
+
background-color: #f5f5f5;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
@@ -248,8 +248,9 @@ export default class XObjectTable extends React.PureComponent<
|
|
|
248
248
|
generateColumns() {
|
|
249
249
|
const { showEditButton, showDeleteButton, xObjectDataApi } = this.props;
|
|
250
250
|
const { fieldList } = this.state;
|
|
251
|
-
const { fields } = xObjectDataApi || {};
|
|
252
|
-
let curFieldList =
|
|
251
|
+
const { fields, fieldDescList } = xObjectDataApi || {};
|
|
252
|
+
let curFieldList =
|
|
253
|
+
fieldDescList && fieldDescList.length > 0 ? fieldDescList : fieldList;
|
|
253
254
|
|
|
254
255
|
if (fields && fields.length > 0) {
|
|
255
256
|
// 如果 fields 存在,则过滤掉 fieldList 中不存在的字段
|
|
@@ -681,7 +682,7 @@ export default class XObjectTable extends React.PureComponent<
|
|
|
681
682
|
const systemInfo = curAmisData.__NeoSystemInfo || {};
|
|
682
683
|
const { xObjectApiKey } = this.props.xObjectDataApi || {};
|
|
683
684
|
const columns = this.generateColumns();
|
|
684
|
-
console.log('this.props:', this.props);
|
|
685
|
+
console.log('this.props:', this.props, columns);
|
|
685
686
|
|
|
686
687
|
return (
|
|
687
688
|
<div className="xobject-table-container">
|