@pisell/materials 1.0.1051 → 1.0.1053
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +2 -2
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +13 -13
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +13 -13
- package/es/components/PisellCards/index.d.ts +6 -6
- package/es/components/appVersionControl/index.js +1 -1
- package/es/components/calendar/index.d.ts +2 -2
- package/es/components/checkbox/index.d.ts +2 -2
- package/es/components/dataSourceComponents/dataSourceForm/BaseForm.js +3 -3
- package/es/components/dataSourceComponents/dataSourceForm/formItem.js +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/index.js +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +2 -2
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +3 -3
- package/es/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +2 -2
- package/es/components/dataSourceComponents/dataSourceSubForm/index.d.ts +16 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/index.js +329 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/index.less +19 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +538 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/schema-simple-example.json +174 -0
- package/es/components/dataSourceComponents/dataSourceSubForm/types.d.ts +121 -0
- package/es/components/dataSourceComponents/dataSourceTable/BaseTable.js +1 -1
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +1 -1
- package/es/components/dataSourceComponents/dataSourceTable/type.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.js +1 -1
- package/es/components/dataSourceComponents/fields/Checkbox/WithMode.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/DateRangePicker/WithMode.js +1 -1
- package/es/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +1 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +1 -1
- package/es/components/dataSourceComponents/fields/Radio/WithMode.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/Radio/WithMode.js +1 -1
- package/es/components/dataSourceComponents/fields/RecordListWrapper/README.md +247 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.js +39 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +84 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/index.d.ts +17 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/index.js +9 -0
- package/es/components/dataSourceComponents/fields/RecordListWrapper/type.d.ts +91 -0
- package/es/components/dataSourceComponents/fields/Select/WithMode.js +1 -1
- package/es/components/dataSourceComponents/fields/Select/index.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/Tabs/ReadPretty.js +16 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.js +75 -0
- package/es/components/dataSourceComponents/fields/Tabs/Tabs.less +55 -0
- package/es/components/dataSourceComponents/fields/Tabs/WithMode.js +13 -0
- package/es/components/dataSourceComponents/fields/Tabs/index.d.ts +19 -0
- package/es/components/dataSourceComponents/fields/Tabs/index.js +10 -0
- package/es/components/dataSourceComponents/fields/Tabs/type.d.ts +36 -0
- package/es/components/dataSourceComponents/fields/index.js +5 -1
- package/es/components/dataSourceComponents/fields/utils.js +3 -0
- package/es/components/dataSourceComponents/hooks/useActions.js +1 -1
- package/es/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +1 -1
- package/es/components/date-picker/index.d.ts +2 -2
- package/es/components/input/index.d.ts +2 -2
- package/es/components/pisell-config-provider/context.d.ts +2 -2
- package/es/components/pisellDataSourceContainer/type.d.ts +1 -1
- package/es/components/pisellDatePicker/index.d.ts +2 -2
- package/es/components/pisellInput/components/Copy/index.js +1 -1
- package/es/components/pisellModal/index.d.ts +6 -6
- package/es/components/pisellMultipleSelect/PisellMultipleSelect.less +15 -7
- package/es/components/pisellQuickFilter/index.d.ts +2 -2
- package/es/components/pisellRecordBoard/PisellRecordBoard.js +10 -3
- package/es/components/pisellRecordBoard/shellFrame/ToolBar/index.js +3 -1
- package/es/components/pisellRecordBoard/shellFrame/ToolBarReset/index.js +4 -2
- package/es/components/pisellRecordBoard/types.d.ts +4 -0
- package/es/components/pisellSingleSelect/PisellSingleSelect.less +15 -0
- package/es/components/pisellWalletPassCard/index.js +1 -1
- package/es/components/radio/index.d.ts +2 -2
- package/es/components/section-footers/index.d.ts +2 -2
- package/es/components/select/index.less +18 -2
- package/es/components/skeleton/index.d.ts +2 -2
- package/es/components/table/Actions/component/ExportImport/index.js +1 -1
- package/es/components/table/Table/fields/select/Edit/index.js +1 -1
- package/es/components/table/Table/tableConfig/SortRow/index.js +1 -1
- package/es/components/table/Table/tableConfig/body/CellProvider/index.js +1 -1
- package/es/components/time-picker/index.d.ts +2 -2
- package/es/components/typography/index.d.ts +2 -2
- package/es/components/upload/index.d.ts +2 -2
- package/es/index.d.ts +5 -1
- package/es/index.js +8 -5
- package/lib/components/PisellCards/index.d.ts +6 -6
- package/lib/components/PisellFields/index.d.ts +12 -12
- package/lib/components/PisellLayouts/index.d.ts +9 -9
- package/lib/components/PisellMetrics/index.d.ts +4 -4
- package/lib/components/appVersionControl/index.js +4 -4
- package/lib/components/calendar/index.d.ts +2 -2
- package/lib/components/checkbox/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/dataSourceForm/BaseForm.js +3 -3
- package/lib/components/dataSourceComponents/dataSourceForm/formItem.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/index.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +2 -2
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +3 -3
- package/lib/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.d.ts +16 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.js +332 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/index.less +19 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/schema-full-example.json +538 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/schema-simple-example.json +174 -0
- package/lib/components/dataSourceComponents/dataSourceSubForm/types.d.ts +121 -0
- package/lib/components/dataSourceComponents/dataSourceTable/BaseTable.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceTable/type.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceWrapper/BaseWrapper.js +1 -1
- package/lib/components/dataSourceComponents/fields/Checkbox/WithMode.d.ts +3 -3
- package/lib/components/dataSourceComponents/fields/DateRangePicker/WithMode.js +1 -1
- package/lib/components/dataSourceComponents/fields/Input.Mobile/WithMode.js +1 -1
- package/lib/components/dataSourceComponents/fields/Input.Password/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +1 -1
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Input.TextArea/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Radio/WithMode.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Radio/WithMode.js +1 -1
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/README.md +247 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/ReadPretty.js +41 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/WithMode.js +86 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/index.d.ts +17 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/index.js +9 -0
- package/lib/components/dataSourceComponents/fields/RecordListWrapper/type.d.ts +91 -0
- package/lib/components/dataSourceComponents/fields/Select/WithMode.js +1 -1
- package/lib/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Tabs/ReadPretty.js +16 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.js +78 -0
- package/lib/components/dataSourceComponents/fields/Tabs/Tabs.less +55 -0
- package/lib/components/dataSourceComponents/fields/Tabs/WithMode.js +13 -0
- package/lib/components/dataSourceComponents/fields/Tabs/index.d.ts +19 -0
- package/lib/components/dataSourceComponents/fields/Tabs/index.js +10 -0
- package/lib/components/dataSourceComponents/fields/Tabs/type.d.ts +35 -0
- package/lib/components/dataSourceComponents/fields/index.js +37 -33
- package/lib/components/dataSourceComponents/fields/utils.js +3 -0
- package/lib/components/dataSourceComponents/hooks/useActions.js +1 -1
- package/lib/components/dataSourceComponents/provider/dataSource/DataSourceProvider.js +1 -1
- package/lib/components/date-picker/index.d.ts +2 -2
- package/lib/components/input/index.d.ts +2 -2
- package/lib/components/pisell-config-provider/context.d.ts +2 -2
- package/lib/components/pisellDataSourceContainer/components/Pagination/index.d.ts +2 -2
- package/lib/components/pisellDataSourceContainer/components/Table/index.d.ts +2 -2
- package/lib/components/pisellDataSourceContainer/type.d.ts +1 -1
- package/lib/components/pisellDatePicker/index.d.ts +2 -2
- package/lib/components/pisellInput/components/Copy/index.js +1 -1
- package/lib/components/pisellMultipleSelect/PisellMultipleSelect.less +15 -7
- package/lib/components/pisellRecordBoard/PisellRecordBoard.js +10 -3
- package/lib/components/pisellRecordBoard/shellFrame/ToolBar/index.js +3 -1
- package/lib/components/pisellRecordBoard/shellFrame/ToolBarReset/index.js +4 -2
- package/lib/components/pisellRecordBoard/types.d.ts +4 -0
- package/lib/components/pisellSingleSelect/PisellSingleSelect.less +15 -0
- package/lib/components/pisellWalletPassCard/index.js +1 -1
- package/lib/components/radio/index.d.ts +2 -2
- package/lib/components/section-footers/index.d.ts +2 -2
- package/lib/components/select/index.less +18 -2
- package/lib/components/skeleton/index.d.ts +2 -2
- package/lib/components/table/Actions/component/ExportImport/index.js +1 -1
- package/lib/components/table/Table/fields/select/Edit/index.js +1 -1
- package/lib/components/table/Table/tableConfig/SortRow/index.js +1 -1
- package/lib/components/table/Table/tableConfig/body/CellProvider/index.js +1 -1
- package/lib/components/time-picker/index.d.ts +2 -2
- package/lib/components/upload/index.d.ts +2 -2
- package/lib/index.d.ts +5 -1
- package/lib/index.js +256 -250
- package/lowcode/data-source-form/constants.ts +3 -0
- package/lowcode/data-source-form/utils.ts +19 -5
- package/lowcode/data-source-sub-form/meta.ts +274 -0
- package/lowcode/data-source-sub-form/snippets.ts +135 -0
- package/lowcode/form-item-record-list-wrapper/meta.ts +246 -0
- package/lowcode/form-item-record-list-wrapper/snippets.ts +24 -0
- package/lowcode/form-item-tabs/meta.ts +172 -0
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ import formItemRadioGroupMeta from '../form-item-radio.group/meta';
|
|
|
17
17
|
import formItemSelectMeta from '../form-item-select/meta';
|
|
18
18
|
import formItemTimePickerMeta from '../form-item-time-picker/meta';
|
|
19
19
|
import formItemUploadMeta from '../form-item-upload/meta';
|
|
20
|
+
import formItemRecordListWrapperMeta from '../form-item-record-list-wrapper/meta';
|
|
20
21
|
|
|
21
22
|
export const metaAll = [
|
|
22
23
|
formItemCheckboxMeta,
|
|
@@ -38,6 +39,7 @@ export const metaAll = [
|
|
|
38
39
|
formItemSelectMeta,
|
|
39
40
|
formItemTimePickerMeta,
|
|
40
41
|
formItemUploadMeta,
|
|
42
|
+
formItemRecordListWrapperMeta,
|
|
41
43
|
]
|
|
42
44
|
|
|
43
45
|
export const formItemMetaMap: Record<string, any> = metaAll.reduce((p, c) => {
|
|
@@ -75,6 +77,7 @@ export const nocobaseCpt2PisellCptMap: Record<string, any> = {
|
|
|
75
77
|
Upload: 'FormItemUpload',
|
|
76
78
|
Translation: "FormItemTranslation",
|
|
77
79
|
IconPicker: "FormItemIconSelect",
|
|
80
|
+
RecordListWrapper: 'FormItemRecordListWrapper',
|
|
78
81
|
};
|
|
79
82
|
|
|
80
83
|
|
|
@@ -30,7 +30,8 @@ type UiSchema = {
|
|
|
30
30
|
dataSource?: any;
|
|
31
31
|
extraParams?: Record<string, any>;
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
'x-record-schema'?: Record<string, any> | Record<string, any>[] | string;
|
|
34
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
// 创建表单组
|
|
@@ -131,6 +132,7 @@ export const createFormItemSchema = (
|
|
|
131
132
|
item: {
|
|
132
133
|
name: string;
|
|
133
134
|
uiSchema: UiSchema;
|
|
135
|
+
schema?: Record<string, any>;
|
|
134
136
|
children?: any[];
|
|
135
137
|
_children?: any[];
|
|
136
138
|
interface?: string;
|
|
@@ -304,11 +306,21 @@ export const createFormItemSchema = (
|
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
// 获取选项配置
|
|
307
|
-
const dataSourceConfig = (uiSchema as any)?.['x-data-source'];
|
|
309
|
+
const dataSourceConfig = (uiSchema as any)?.['x-data-source'] || item?.schema?.['x-data-source'];
|
|
310
|
+
const recordSchemaConfig = (uiSchema as any)?.['x-record-schema'] || item?.schema?.['x-record-schema'];
|
|
311
|
+
const isRecordListWrapper =
|
|
312
|
+
item?.interface === 'RecordListWrapper' || xComponent === 'RecordListWrapper';
|
|
313
|
+
|
|
314
|
+
if (isRecordListWrapper) {
|
|
315
|
+
cptTitle = '记录列表包装器';
|
|
316
|
+
componentName = 'RecordListWrapper';
|
|
317
|
+
props.xRecordSchema = recordSchemaConfig;
|
|
318
|
+
}
|
|
308
319
|
|
|
309
320
|
if (
|
|
310
|
-
['Select', 'Radio.Group', 'Checkbox.Group'].includes(xComponent)
|
|
311
|
-
|
|
321
|
+
(['Select', 'Radio.Group', 'Checkbox.Group'].includes(xComponent) ||
|
|
322
|
+
isRecordListWrapper) &&
|
|
323
|
+
(uiSchema?.enum?.length > 0 || dataSourceConfig || isRecordListWrapper)
|
|
312
324
|
) {
|
|
313
325
|
if (['Radio.Group', 'Checkbox.Group'].includes(xComponent)) {
|
|
314
326
|
props.direction = 'horizontal';
|
|
@@ -343,7 +355,7 @@ export const createFormItemSchema = (
|
|
|
343
355
|
const optionConfig = dataSourceConfig || {};
|
|
344
356
|
|
|
345
357
|
// 设置 optionSourceType
|
|
346
|
-
props.optionSourceType = optionConfig?.type || '
|
|
358
|
+
props.optionSourceType = optionConfig?.type || '';
|
|
347
359
|
|
|
348
360
|
// 根据 sourceType 设置不同的配置
|
|
349
361
|
if (props.optionSourceType === 'default') {
|
|
@@ -427,6 +439,8 @@ export const createFormItemSchema = (
|
|
|
427
439
|
schemaType = type as any;
|
|
428
440
|
} else if (xComponent === 'InputNumber' || xComponent === 'Percent') {
|
|
429
441
|
schemaType = 'number';
|
|
442
|
+
} else if (componentName === 'RecordListWrapper') {
|
|
443
|
+
schemaType = 'array';
|
|
430
444
|
} else if (xComponent === 'Input.JSON' || item?.interface === 'i18nInput') {
|
|
431
445
|
schemaType = 'object';
|
|
432
446
|
} else if (['Checkbox.Group', 'Select'].includes(xComponent) && props.mode === 'multiple') {
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import snippets from './snippets';
|
|
2
|
+
import { createFormItemSchema } from '../data-source-form/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @title 将 xRecordSchema JSON 字段定义转换为低代码子组件 Schema
|
|
6
|
+
* @description
|
|
7
|
+
* 解析 xRecordSchema(支持单对象、数组、字符串),对每个字段补全 uiSchema,
|
|
8
|
+
* 调用 createFormItemSchema 生成低代码引擎可识别的组件 Schema。
|
|
9
|
+
*/
|
|
10
|
+
const parseXRecordSchemaToChildSchemas = (value: any): any[] => {
|
|
11
|
+
let fields = value;
|
|
12
|
+
|
|
13
|
+
// 解析字符串
|
|
14
|
+
if (typeof fields === 'string') {
|
|
15
|
+
try {
|
|
16
|
+
fields = JSON.parse(fields);
|
|
17
|
+
} catch {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!fields) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 处理 properties 格式
|
|
27
|
+
if (fields.properties && typeof fields.properties === 'object') {
|
|
28
|
+
fields = Object.keys(fields.properties).map((name) => ({
|
|
29
|
+
...fields.properties[name],
|
|
30
|
+
name,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 处理 fields 格式
|
|
35
|
+
if (fields.fields && Array.isArray(fields.fields)) {
|
|
36
|
+
fields = fields.fields;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 处理 children 格式
|
|
40
|
+
if (fields.children && Array.isArray(fields.children)) {
|
|
41
|
+
fields = fields.children;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 单对象转数组
|
|
45
|
+
if (!Array.isArray(fields)) {
|
|
46
|
+
fields = [fields];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 补全每个字段的 uiSchema 并生成子组件 Schema
|
|
50
|
+
return fields
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
.map((field: any) => {
|
|
53
|
+
const uiSchema = { ...(field.uiSchema || {}) };
|
|
54
|
+
|
|
55
|
+
// 从 interface 映射 x-component(如 Select、Input 等)
|
|
56
|
+
if (!uiSchema['x-component'] && field.interface) {
|
|
57
|
+
uiSchema['x-component'] = field.interface;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 兼容简单格式(只有 componentName/component,没有 interface 和 uiSchema)
|
|
61
|
+
if (!uiSchema['x-component']) {
|
|
62
|
+
uiSchema['x-component'] =
|
|
63
|
+
field.componentName || field.component || 'Input';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 从 field.type 映射 uiSchema.type
|
|
67
|
+
if (!uiSchema.type && field.type) {
|
|
68
|
+
uiSchema.type = field.type;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 确保 title 存在(用于生成 label)
|
|
72
|
+
if (!uiSchema.title && field.label) {
|
|
73
|
+
uiSchema.title = field.label;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return createFormItemSchema({ ...field, uiSchema }, 'edit');
|
|
77
|
+
})
|
|
78
|
+
.filter((schema: any) => !!schema?.componentName);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default {
|
|
82
|
+
snippets,
|
|
83
|
+
componentName: 'DataSourceSubForm',
|
|
84
|
+
title: '子表单',
|
|
85
|
+
category: '无代码表单',
|
|
86
|
+
group: '无代码组件',
|
|
87
|
+
docUrl: '',
|
|
88
|
+
screenshot: '',
|
|
89
|
+
devMode: 'proCode',
|
|
90
|
+
npm: {
|
|
91
|
+
package: '@pisell/materials',
|
|
92
|
+
version: '1.0.3',
|
|
93
|
+
exportName: 'DataSourceSubForm',
|
|
94
|
+
main: 'src/index.tsx',
|
|
95
|
+
destructuring: true,
|
|
96
|
+
subName: '',
|
|
97
|
+
},
|
|
98
|
+
generalProps: [
|
|
99
|
+
{
|
|
100
|
+
type: 'group',
|
|
101
|
+
title: {
|
|
102
|
+
type: 'i18n',
|
|
103
|
+
'en-US': 'Data',
|
|
104
|
+
'zh-CN': '数据',
|
|
105
|
+
},
|
|
106
|
+
display: 'accordion',
|
|
107
|
+
items: [
|
|
108
|
+
{
|
|
109
|
+
name: 'value',
|
|
110
|
+
title: {
|
|
111
|
+
label: {
|
|
112
|
+
type: 'i18n',
|
|
113
|
+
'en-US': 'Value',
|
|
114
|
+
'zh-CN': '表单值',
|
|
115
|
+
},
|
|
116
|
+
tip: {
|
|
117
|
+
type: 'i18n',
|
|
118
|
+
'en-US': 'Form value object',
|
|
119
|
+
'zh-CN': '表单值对象',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
setter: ['JsonSetter', 'VariableSetter'],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'xRecordSchema',
|
|
126
|
+
title: {
|
|
127
|
+
label: {
|
|
128
|
+
type: 'i18n',
|
|
129
|
+
'en-US': 'Record Schema',
|
|
130
|
+
'zh-CN': '字段配置',
|
|
131
|
+
},
|
|
132
|
+
tip: {
|
|
133
|
+
type: 'i18n',
|
|
134
|
+
'en-US':
|
|
135
|
+
'Define form fields structure, supports JSON string, array, or object format',
|
|
136
|
+
'zh-CN': '定义表单字段结构,支持 JSON 字符串、数组或对象格式',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
setter: ['JsonSetter', 'StringSetter', 'VariableSetter'],
|
|
140
|
+
extraProps: {
|
|
141
|
+
setValue(target: any, value: any) {
|
|
142
|
+
const parsedSchemas = parseXRecordSchemaToChildSchemas(value);
|
|
143
|
+
|
|
144
|
+
// 如果画布为空且有解析出的 Schema,自动导入
|
|
145
|
+
if (
|
|
146
|
+
target.node.children.isEmptyNode &&
|
|
147
|
+
parsedSchemas.length > 0
|
|
148
|
+
) {
|
|
149
|
+
target.node.children.importSchema(parsedSchemas);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 插入schema后 有概率不生效,所以这里手动rerender
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
target.document.project.simulatorHost.rerender();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
return target.getProps().setPropValue('xRecordSchema', value);
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'group',
|
|
165
|
+
title: {
|
|
166
|
+
type: 'i18n',
|
|
167
|
+
'en-US': 'Appearance',
|
|
168
|
+
'zh-CN': '外观',
|
|
169
|
+
},
|
|
170
|
+
display: 'accordion',
|
|
171
|
+
items: [
|
|
172
|
+
{
|
|
173
|
+
name: 'renderMode',
|
|
174
|
+
title: {
|
|
175
|
+
label: {
|
|
176
|
+
type: 'i18n',
|
|
177
|
+
'en-US': 'Render Mode',
|
|
178
|
+
'zh-CN': '渲染模式',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
defaultValue: 'edit',
|
|
182
|
+
setter: [
|
|
183
|
+
{
|
|
184
|
+
componentName: 'RadioGroupSetter',
|
|
185
|
+
props: {
|
|
186
|
+
options: [
|
|
187
|
+
{ title: '编辑', value: 'edit' },
|
|
188
|
+
{ title: '禁用', value: 'disabled' },
|
|
189
|
+
{ title: '预览', value: 'preview' },
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
'VariableSetter',
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'layout',
|
|
198
|
+
title: {
|
|
199
|
+
label: {
|
|
200
|
+
type: 'i18n',
|
|
201
|
+
'en-US': 'Layout',
|
|
202
|
+
'zh-CN': '布局方式',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
defaultValue: 'vertical',
|
|
206
|
+
setter: [
|
|
207
|
+
{
|
|
208
|
+
componentName: 'RadioGroupSetter',
|
|
209
|
+
props: {
|
|
210
|
+
options: [
|
|
211
|
+
{ title: '垂直', value: 'vertical' },
|
|
212
|
+
{ title: '水平', value: 'horizontal' },
|
|
213
|
+
{ title: '行内', value: 'inline' },
|
|
214
|
+
],
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
'VariableSetter',
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
configure: {
|
|
224
|
+
props: [
|
|
225
|
+
{
|
|
226
|
+
name: 'onChange',
|
|
227
|
+
title: {
|
|
228
|
+
label: {
|
|
229
|
+
type: 'i18n',
|
|
230
|
+
'en-US': 'On Change',
|
|
231
|
+
'zh-CN': '值变化回调',
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
setter: {
|
|
235
|
+
componentName: 'FunctionSetter',
|
|
236
|
+
props: {
|
|
237
|
+
template:
|
|
238
|
+
'onChange(value,${extParams}){\n// 表单值变化时触发\nconsole.log("onChange", value);\n}',
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
component: {
|
|
244
|
+
isContainer: true,
|
|
245
|
+
nestingRule: {
|
|
246
|
+
childWhitelist: [
|
|
247
|
+
'FormItemInput',
|
|
248
|
+
'FormItemInputNumber',
|
|
249
|
+
'FormItemSelect',
|
|
250
|
+
'FormItemCheckbox',
|
|
251
|
+
'FormItemSwitch',
|
|
252
|
+
'FormItemDatePicker',
|
|
253
|
+
'FormItemTimePicker',
|
|
254
|
+
'FormItemRadio',
|
|
255
|
+
'FormItemColorPicker',
|
|
256
|
+
'FormItemUpload',
|
|
257
|
+
'FormItemTranslation',
|
|
258
|
+
'FormItemIconSelect',
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
supports: {
|
|
263
|
+
style: true,
|
|
264
|
+
className: true,
|
|
265
|
+
events: [
|
|
266
|
+
{
|
|
267
|
+
name: 'onChange',
|
|
268
|
+
template:
|
|
269
|
+
'onChange(value,${extParams}){\n// 表单值变化时触发\nconsole.log("onChange", value);\n}',
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @title DataSourceSubForm 组件片段
|
|
3
|
+
* @description 定义组件在低代码平台中的初始配置
|
|
4
|
+
*/
|
|
5
|
+
const snippets = [
|
|
6
|
+
{
|
|
7
|
+
title: '子表单',
|
|
8
|
+
screenshot: '',
|
|
9
|
+
schema: {
|
|
10
|
+
componentName: 'DataSourceSubForm',
|
|
11
|
+
props: {
|
|
12
|
+
renderMode: 'edit',
|
|
13
|
+
layout: 'vertical',
|
|
14
|
+
value: {},
|
|
15
|
+
xRecordSchema: [
|
|
16
|
+
{
|
|
17
|
+
name: 'code',
|
|
18
|
+
uiSchema: {
|
|
19
|
+
title: '代码',
|
|
20
|
+
'x-component': 'Input',
|
|
21
|
+
'x-component-props': {
|
|
22
|
+
placeholder: '请输入代码',
|
|
23
|
+
requiredobj: {
|
|
24
|
+
required: true,
|
|
25
|
+
message: '代码不能为空',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'name',
|
|
32
|
+
uiSchema: {
|
|
33
|
+
title: '名称',
|
|
34
|
+
'x-component': 'Input',
|
|
35
|
+
'x-component-props': {
|
|
36
|
+
placeholder: '请输入名称',
|
|
37
|
+
requiredobj: {
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'description',
|
|
45
|
+
uiSchema: {
|
|
46
|
+
title: '描述',
|
|
47
|
+
'x-component': 'Input.TextArea',
|
|
48
|
+
'x-component-props': {
|
|
49
|
+
placeholder: '请输入描述',
|
|
50
|
+
rows: 4,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'priority',
|
|
56
|
+
uiSchema: {
|
|
57
|
+
title: '优先级',
|
|
58
|
+
'x-component': 'InputNumber',
|
|
59
|
+
type: 'integer',
|
|
60
|
+
'x-component-props': {
|
|
61
|
+
placeholder: '请输入优先级(0-100)',
|
|
62
|
+
min: 0,
|
|
63
|
+
max: 100,
|
|
64
|
+
precision: 0,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'status',
|
|
70
|
+
uiSchema: {
|
|
71
|
+
title: '状态',
|
|
72
|
+
'x-component': 'Select',
|
|
73
|
+
'x-component-props': {
|
|
74
|
+
placeholder: '请选择状态',
|
|
75
|
+
},
|
|
76
|
+
'x-data-source': {
|
|
77
|
+
type: 'default',
|
|
78
|
+
options: [
|
|
79
|
+
{
|
|
80
|
+
label: '启用',
|
|
81
|
+
value: 'active',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
label: '禁用',
|
|
85
|
+
value: 'inactive',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: '待审核',
|
|
89
|
+
value: 'pending',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'isEnabled',
|
|
97
|
+
uiSchema: {
|
|
98
|
+
title: '是否启用',
|
|
99
|
+
'x-component': 'Switch',
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
'x-component-props': {
|
|
102
|
+
checkedChildren: '是',
|
|
103
|
+
unCheckedChildren: '否',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'startDate',
|
|
109
|
+
uiSchema: {
|
|
110
|
+
title: '开始日期',
|
|
111
|
+
'x-component': 'DatePicker',
|
|
112
|
+
'x-component-props': {
|
|
113
|
+
placeholder: '请选择开始日期',
|
|
114
|
+
format: 'YYYY-MM-DD',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'remarks',
|
|
120
|
+
uiSchema: {
|
|
121
|
+
title: '备注',
|
|
122
|
+
'x-component': 'Input.TextArea',
|
|
123
|
+
'x-component-props': {
|
|
124
|
+
placeholder: '请输入备注',
|
|
125
|
+
rows: 3,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
export default snippets;
|