amis-editor 4.2.0-beta.2 → 5.1.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/6dbcbb49b6fd405190a9.png +0 -0
- package/dist/component/Control/APIControl.d.ts +1101 -447
- package/dist/component/Control/ActionAPIControl.d.ts +1158 -0
- package/dist/component/Control/BadgeControl.d.ts +133 -0
- package/dist/component/Control/BaseControl.d.ts +248 -0
- package/dist/component/Control/DataBindingControl.d.ts +14 -0
- package/dist/component/Control/DataPickerControl.d.ts +13 -0
- package/dist/component/Control/DateShortCutControl.d.ts +83 -0
- package/dist/component/Control/FormulaControl.d.ts +51 -0
- package/dist/component/Control/OptionControl.d.ts +23 -34
- package/dist/component/Control/StatusControl.d.ts +39 -0
- package/dist/component/Control/SwitchMoreControl.d.ts +224 -0
- package/dist/component/Control/ValidationControl.d.ts +50 -15
- package/dist/component/Control/ValidationItem.d.ts +46 -0
- package/dist/component/Control/style-control/Background.d.ts +17 -0
- package/dist/component/Control/style-control/Border.d.ts +18 -0
- package/dist/component/Control/style-control/BoxModel.d.ts +17 -0
- package/dist/component/Control/style-control/BoxShadow.d.ts +18 -0
- package/dist/component/Control/style-control/Display.d.ts +14 -0
- package/dist/component/Control/style-control/Font.d.ts +16 -0
- package/dist/component/Control/style-control/font-family.d.ts +11 -0
- package/dist/component/Control/style-control/transformation.d.ts +29 -0
- package/dist/component/Control/style-control/types.d.ts +8 -0
- package/dist/component/Editor.d.ts +16 -0
- package/dist/component/RegionWrapper.d.ts +10 -0
- package/dist/component/VRenderer.d.ts +10 -0
- package/dist/component/schemaTpl.d.ts +8 -0
- package/dist/component/validator.d.ts +62 -0
- package/dist/dnd/index.d.ts +1 -1
- package/dist/event-action/action-config-panel.d.ts +8 -0
- package/dist/event-action/actions.d.ts +3 -0
- package/dist/event-action/comp-action-select.d.ts +11 -0
- package/dist/event-action/config.d.ts +13 -0
- package/dist/event-action/index.d.ts +459 -0
- package/dist/event-action/schema.d.ts +32 -0
- package/dist/exports.min.js +1 -1
- package/dist/index.d.ts +23 -5
- package/dist/index.min.js +1 -1
- package/dist/manager.d.ts +46 -1
- package/dist/plugin/Alert.d.ts +4 -2
- package/dist/plugin/Button.d.ts +5 -1
- package/dist/plugin/ButtonGroup.d.ts +13 -34
- package/dist/plugin/ButtonToolbar.d.ts +4 -10
- package/dist/plugin/CRUD.d.ts +2 -0
- package/dist/plugin/Chart.d.ts +2 -0
- package/dist/plugin/Collapse.d.ts +1 -0
- package/dist/plugin/CollapseGroup.d.ts +28 -4
- package/dist/plugin/Container.d.ts +2 -1
- package/dist/plugin/Dialog.d.ts +12 -2
- package/dist/plugin/Drawer.d.ts +12 -2
- package/dist/plugin/DropDownButton.d.ts +11 -11
- package/dist/plugin/Form/ButtonGroupSelect.d.ts +7 -2
- package/dist/plugin/Form/ButtonToolbar.d.ts +8 -7
- package/dist/plugin/Form/ChainedSelect.d.ts +3 -0
- package/dist/plugin/Form/Checkbox.d.ts +7 -2
- package/dist/plugin/Form/Checkboxes.d.ts +8 -2
- package/dist/plugin/Form/CodeEditor.d.ts +7 -22
- package/dist/plugin/Form/Combo.d.ts +3 -0
- package/dist/plugin/Form/Control.d.ts +6 -2
- package/dist/plugin/Form/DiffEditor.d.ts +7 -1
- package/dist/plugin/Form/Form.d.ts +6 -0
- package/dist/plugin/Form/Formula.d.ts +1 -25
- package/dist/plugin/Form/InputDate.d.ts +8 -2
- package/dist/plugin/Form/InputDateRange.d.ts +8 -2
- package/dist/plugin/Form/InputDateTime.d.ts +4 -4
- package/dist/plugin/Form/InputDateTimeRange.d.ts +4 -4
- package/dist/plugin/Form/InputEmail.d.ts +1 -0
- package/dist/plugin/Form/InputExcel.d.ts +6 -41
- package/dist/plugin/Form/InputFile.d.ts +7 -3
- package/dist/plugin/Form/InputKV.d.ts +6 -0
- package/dist/plugin/Form/InputMonth.d.ts +1 -0
- package/dist/plugin/Form/InputMonthRange.d.ts +4 -4
- package/dist/plugin/Form/InputPassword.d.ts +1 -0
- package/dist/plugin/Form/InputQuarter.d.ts +1 -0
- package/dist/plugin/Form/InputQuarterRange.d.ts +4 -4
- package/dist/plugin/Form/InputRange.d.ts +3 -0
- package/dist/plugin/Form/InputRating.d.ts +9 -3
- package/dist/plugin/Form/InputText.d.ts +24 -2
- package/dist/plugin/Form/InputTime.d.ts +3 -3
- package/dist/plugin/Form/InputTimeRange.d.ts +20 -0
- package/dist/plugin/Form/InputTree.d.ts +6 -2
- package/dist/plugin/Form/InputURL.d.ts +1 -0
- package/dist/plugin/Form/InputYear.d.ts +1 -0
- package/dist/plugin/Form/InputYearRange.d.ts +20 -0
- package/dist/plugin/Form/ListSelect.d.ts +6 -2
- package/dist/plugin/Form/LocationPicker.d.ts +1 -31
- package/dist/plugin/Form/NestedSelect.d.ts +5 -2
- package/dist/plugin/Form/Radios.d.ts +7 -2
- package/dist/plugin/Form/Select.d.ts +7 -2
- package/dist/plugin/Form/Switch.d.ts +7 -2
- package/dist/plugin/Form/TabsTransfer.d.ts +5 -2
- package/dist/plugin/Form/Textarea.d.ts +7 -1
- package/dist/plugin/Form/Transfer.d.ts +5 -2
- package/dist/plugin/Form/TreeSelect.d.ts +6 -2
- package/dist/plugin/IFrame.d.ts +2 -2
- package/dist/plugin/Nav.d.ts +1 -116
- package/dist/plugin/Others/Action.d.ts +5 -1
- package/dist/plugin/Page.d.ts +5 -2
- package/dist/plugin/Progress.d.ts +5 -1
- package/dist/plugin/Table.d.ts +2 -0
- package/dist/plugin/Tabs.d.ts +33 -2
- package/dist/plugin/TooltipWrapper.d.ts +10 -0
- package/dist/plugin/Tpl.d.ts +2 -1
- package/dist/plugin/Wizard.d.ts +4 -1
- package/dist/plugin.d.ts +37 -1
- package/dist/store/editor.d.ts +65 -38
- package/dist/store/node.d.ts +16 -0
- package/dist/style.css +1 -1
- package/dist/util.d.ts +36 -3
- package/package.json +14 -8
- package/src/component/schemaTpl.tsx +1198 -474
- package/src/plugin/.DS_Store +0 -0
- package/src/plugin/Alert.tsx +69 -48
- package/src/plugin/AnchorNav.tsx +1 -0
- package/src/plugin/Audio.tsx +9 -15
- package/src/plugin/Avatar.tsx +2 -1
- package/src/plugin/Breadcrumb.tsx +2 -1
- package/src/plugin/Button.tsx +257 -188
- package/src/plugin/ButtonGroup.tsx +99 -38
- package/src/plugin/ButtonToolbar.tsx +7 -13
- package/src/plugin/CRUD.tsx +77 -135
- package/src/plugin/Card.tsx +1 -0
- package/src/plugin/Cards.tsx +8 -14
- package/src/plugin/Carousel.tsx +1 -1
- package/src/plugin/Chart.tsx +26 -14
- package/src/plugin/Collapse.tsx +78 -78
- package/src/plugin/CollapseGroup.tsx +165 -83
- package/src/plugin/Container.tsx +59 -6
- package/src/plugin/Custom.tsx +2 -8
- package/src/plugin/CustomRegion.tsx +4 -3
- package/src/plugin/Dialog.tsx +55 -24
- package/src/plugin/Drawer.tsx +65 -35
- package/src/plugin/DropDownButton.tsx +95 -79
- package/src/plugin/Flex.tsx +123 -65
- package/src/plugin/Form/ButtonGroupSelect.tsx +114 -26
- package/src/plugin/Form/ButtonToolbar.tsx +62 -55
- package/src/plugin/Form/ChainedSelect.tsx +45 -0
- package/src/plugin/Form/Checkbox.tsx +122 -33
- package/src/plugin/Form/Checkboxes.tsx +154 -87
- package/src/plugin/Form/CodeEditor.tsx +163 -34
- package/src/plugin/Form/Combo.tsx +104 -65
- package/src/plugin/Form/Control.tsx +16 -70
- package/src/plugin/Form/DiffEditor.tsx +158 -54
- package/src/plugin/Form/FieldSet.tsx +6 -11
- package/src/plugin/Form/Form.tsx +277 -70
- package/src/plugin/Form/Formula.tsx +8 -14
- package/src/plugin/Form/InputArray.tsx +7 -16
- package/src/plugin/Form/InputCity.tsx +1 -1
- package/src/plugin/Form/InputDate.tsx +344 -121
- package/src/plugin/Form/InputDateRange.tsx +303 -161
- package/src/plugin/Form/InputDateTime.tsx +6 -150
- package/src/plugin/Form/InputDateTimeRange.tsx +7 -187
- package/src/plugin/Form/InputEmail.tsx +1 -0
- package/src/plugin/Form/InputExcel.tsx +70 -27
- package/src/plugin/Form/InputFile.tsx +326 -152
- package/src/plugin/Form/InputImage.tsx +1 -1
- package/src/plugin/Form/InputKV.tsx +61 -0
- package/src/plugin/Form/InputMonth.tsx +3 -1
- package/src/plugin/Form/InputMonthRange.tsx +6 -160
- package/src/plugin/Form/InputNumber.tsx +1 -1
- package/src/plugin/Form/InputPassword.tsx +2 -0
- package/src/plugin/Form/InputQuarter.tsx +3 -1
- package/src/plugin/Form/InputQuarterRange.tsx +6 -160
- package/src/plugin/Form/InputRange.tsx +74 -4
- package/src/plugin/Form/InputRating.tsx +347 -35
- package/src/plugin/Form/InputRichText.tsx +2 -3
- package/src/plugin/Form/InputTable.tsx +33 -49
- package/src/plugin/Form/InputTag.tsx +1 -1
- package/src/plugin/Form/InputText.tsx +310 -132
- package/src/plugin/Form/InputTime.tsx +4 -53
- package/src/plugin/Form/InputTimeRange.tsx +41 -0
- package/src/plugin/Form/InputTree.tsx +196 -46
- package/src/plugin/Form/InputURL.tsx +2 -0
- package/src/plugin/Form/InputYear.tsx +2 -0
- package/src/plugin/Form/InputYearRange.tsx +41 -0
- package/src/plugin/Form/Item.tsx +17 -18
- package/src/plugin/Form/ListSelect.tsx +75 -20
- package/src/plugin/Form/LocationPicker.tsx +2 -7
- package/src/plugin/Form/MatrixCheckboxes.tsx +1 -1
- package/src/plugin/Form/NestedSelect.tsx +110 -43
- package/src/plugin/Form/Picker.tsx +2 -5
- package/src/plugin/Form/Radios.tsx +122 -52
- package/src/plugin/Form/Select.tsx +239 -168
- package/src/plugin/Form/Static.tsx +1 -1
- package/src/plugin/Form/Switch.tsx +170 -58
- package/src/plugin/Form/TabsTransfer.tsx +175 -79
- package/src/plugin/Form/Textarea.tsx +146 -36
- package/src/plugin/Form/Transfer.tsx +295 -233
- package/src/plugin/Form/TreeSelect.tsx +287 -146
- package/src/plugin/Grid.tsx +340 -312
- package/src/plugin/HBox.tsx +1 -0
- package/src/plugin/IFrame.tsx +21 -12
- package/src/plugin/Image.tsx +7 -12
- package/src/plugin/Images.tsx +7 -12
- package/src/plugin/Link.tsx +6 -12
- package/src/plugin/List.tsx +6 -10
- package/src/plugin/ListItem.tsx +1 -0
- package/src/plugin/Nav.tsx +7 -9
- package/src/plugin/Others/Action.tsx +16 -10
- package/src/plugin/Others/BasicToolbar.tsx +4 -1
- package/src/plugin/Others/TableCell.tsx +19 -39
- package/src/plugin/Page.tsx +315 -229
- package/src/plugin/Panel.tsx +6 -7
- package/src/plugin/Plain.tsx +3 -6
- package/src/plugin/Progress.tsx +234 -94
- package/src/plugin/Service.tsx +10 -6
- package/src/plugin/Table.tsx +49 -20
- package/src/plugin/TableView.tsx +212 -106
- package/src/plugin/Tabs.tsx +306 -146
- package/src/plugin/TooltipWrapper.tsx +231 -135
- package/src/plugin/Tpl.tsx +68 -52
- package/src/plugin/Video.tsx +9 -20
- package/src/plugin/Wizard.tsx +537 -336
- package/src/plugin/Wrapper.tsx +82 -61
- package/src/plugin.ts +66 -4
- package/static/empty.png +0 -0
package/src/plugin/Form/Form.tsx
CHANGED
@@ -8,6 +8,9 @@ import {
|
|
8
8
|
ScaffoldForm
|
9
9
|
} from '../../plugin';
|
10
10
|
import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
|
11
|
+
import {getEventControlConfig, jsonToJsonSchema} from '../../util';
|
12
|
+
import {EditorNodeType} from '../../store/node';
|
13
|
+
import {RendererAction, RendererEvent} from '../../event-action';
|
11
14
|
import {setVariable} from 'amis-core';
|
12
15
|
|
13
16
|
// 用于脚手架的常用表单控件
|
@@ -204,6 +207,174 @@ export class FormPlugin extends BasePlugin {
|
|
204
207
|
];
|
205
208
|
|
206
209
|
panelTitle = '表单';
|
210
|
+
|
211
|
+
// 事件定义
|
212
|
+
events: RendererEvent[] = [
|
213
|
+
{
|
214
|
+
eventName: 'inited',
|
215
|
+
eventLabel: '初始化完成',
|
216
|
+
description: '远程初始化接口请求成功时触发',
|
217
|
+
// 表单数据为表单变量
|
218
|
+
dataSchema: [
|
219
|
+
{
|
220
|
+
type: 'object',
|
221
|
+
properties: {
|
222
|
+
'event.data': {
|
223
|
+
type: 'object',
|
224
|
+
title: 'initApi 远程请求返回的初始化数据'
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
]
|
229
|
+
},
|
230
|
+
{
|
231
|
+
eventName: 'change',
|
232
|
+
eventLabel: '数值变化',
|
233
|
+
description: '表单值变化时触发',
|
234
|
+
dataSchema: [
|
235
|
+
{
|
236
|
+
type: 'object',
|
237
|
+
properties: {
|
238
|
+
'event.data': {
|
239
|
+
type: 'object',
|
240
|
+
title: '当前表单数据'
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
]
|
245
|
+
},
|
246
|
+
{
|
247
|
+
eventName: 'formItemValidateSucc',
|
248
|
+
eventLabel: '表单项校验成功',
|
249
|
+
description: '表单项校验成功后触发',
|
250
|
+
dataSchema: [
|
251
|
+
{
|
252
|
+
type: 'object',
|
253
|
+
properties: {
|
254
|
+
'event.data': {
|
255
|
+
type: 'object',
|
256
|
+
title: '当前表单数据'
|
257
|
+
}
|
258
|
+
}
|
259
|
+
}
|
260
|
+
]
|
261
|
+
},
|
262
|
+
{
|
263
|
+
eventName: 'formItemValidateError',
|
264
|
+
eventLabel: '表单项校验失败',
|
265
|
+
description: '表单项校验失败后触发',
|
266
|
+
dataSchema: [
|
267
|
+
{
|
268
|
+
type: 'object',
|
269
|
+
properties: {
|
270
|
+
'event.data': {
|
271
|
+
type: 'object',
|
272
|
+
title: '当前表单数据'
|
273
|
+
}
|
274
|
+
}
|
275
|
+
}
|
276
|
+
]
|
277
|
+
},
|
278
|
+
{
|
279
|
+
eventName: 'validateSucc',
|
280
|
+
eventLabel: '表单校验成功',
|
281
|
+
description: '表单校验成功后触发',
|
282
|
+
dataSchema: [
|
283
|
+
{
|
284
|
+
type: 'object',
|
285
|
+
properties: {
|
286
|
+
'event.data': {
|
287
|
+
type: 'object',
|
288
|
+
title: '当前表单数据'
|
289
|
+
}
|
290
|
+
}
|
291
|
+
}
|
292
|
+
]
|
293
|
+
},
|
294
|
+
{
|
295
|
+
eventName: 'validateError',
|
296
|
+
eventLabel: '表单校验失败',
|
297
|
+
description: '表单校验失败后触发',
|
298
|
+
dataSchema: [
|
299
|
+
{
|
300
|
+
type: 'object',
|
301
|
+
properties: {
|
302
|
+
'event.data': {
|
303
|
+
type: 'object',
|
304
|
+
title: '当前表单数据'
|
305
|
+
}
|
306
|
+
}
|
307
|
+
}
|
308
|
+
]
|
309
|
+
},
|
310
|
+
{
|
311
|
+
eventName: 'submitSucc',
|
312
|
+
eventLabel: '提交成功',
|
313
|
+
description: '表单提交请求成功后触发',
|
314
|
+
dataSchema: [
|
315
|
+
{
|
316
|
+
type: 'object',
|
317
|
+
properties: {
|
318
|
+
'event.data.result': {
|
319
|
+
type: 'object',
|
320
|
+
title: '提交成功后返回的数据'
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
]
|
325
|
+
},
|
326
|
+
{
|
327
|
+
eventName: 'submitFail',
|
328
|
+
eventLabel: '提交失败',
|
329
|
+
description: '表单提交请求失败后触发',
|
330
|
+
dataSchema: [
|
331
|
+
{
|
332
|
+
type: 'object',
|
333
|
+
properties: {
|
334
|
+
'event.data.error': {
|
335
|
+
type: 'object',
|
336
|
+
title: '提交失败后返回的错误信息'
|
337
|
+
}
|
338
|
+
}
|
339
|
+
}
|
340
|
+
]
|
341
|
+
}
|
342
|
+
];
|
343
|
+
|
344
|
+
// 动作定义
|
345
|
+
actions: RendererAction[] = [
|
346
|
+
{
|
347
|
+
actionLabel: '提交表单',
|
348
|
+
actionType: 'submit',
|
349
|
+
description: '触发表单提交'
|
350
|
+
},
|
351
|
+
{
|
352
|
+
actionLabel: '重置表单',
|
353
|
+
actionType: 'reset',
|
354
|
+
description: '触发表单重置'
|
355
|
+
},
|
356
|
+
{
|
357
|
+
actionLabel: '清空表单',
|
358
|
+
actionType: 'clear',
|
359
|
+
description: '触发表单清空'
|
360
|
+
},
|
361
|
+
{
|
362
|
+
actionLabel: '校验表单',
|
363
|
+
actionType: 'validate',
|
364
|
+
description: '触发表单校验'
|
365
|
+
},
|
366
|
+
{
|
367
|
+
actionLabel: '重新加载',
|
368
|
+
actionType: 'reload',
|
369
|
+
description: '触发组件数据刷新并重新渲染'
|
370
|
+
},
|
371
|
+
{
|
372
|
+
actionLabel: '更新数据',
|
373
|
+
actionType: 'setValue',
|
374
|
+
description: '触发组件数据更新'
|
375
|
+
}
|
376
|
+
];
|
377
|
+
|
207
378
|
panelBodyCreator = (context: BaseEventContext) => {
|
208
379
|
const isCRUDFilter: boolean = /\/crud\/filter\/form$/.test(context.path);
|
209
380
|
const isInDialog: boolean = /(?:\/|^)dialog\/.+$/.test(context.path);
|
@@ -228,12 +399,9 @@ export class FormPlugin extends BasePlugin {
|
|
228
399
|
description: '当没有自定义按钮时有效。'
|
229
400
|
},
|
230
401
|
|
231
|
-
{
|
402
|
+
getSchemaTpl('switch', {
|
232
403
|
name: 'autoFocus',
|
233
|
-
type: 'switch',
|
234
404
|
label: '自动聚焦',
|
235
|
-
mode: 'inline',
|
236
|
-
className: 'block',
|
237
405
|
labelRemark: {
|
238
406
|
className: 'm-l-xs',
|
239
407
|
trigger: 'click',
|
@@ -241,16 +409,13 @@ export class FormPlugin extends BasePlugin {
|
|
241
409
|
content: '设置后将让表单的第一个可输入的表单项获得焦点',
|
242
410
|
placement: 'left'
|
243
411
|
}
|
244
|
-
},
|
412
|
+
}),
|
245
413
|
|
246
414
|
getSchemaTpl('submitOnChange'),
|
247
415
|
|
248
|
-
{
|
416
|
+
getSchemaTpl('switch', {
|
249
417
|
label: '提交完后重置表单',
|
250
|
-
type: 'switch',
|
251
418
|
name: 'resetAfterSubmit',
|
252
|
-
mode: 'inline',
|
253
|
-
className: 'block',
|
254
419
|
labelRemark: {
|
255
420
|
className: 'm-l-xs',
|
256
421
|
trigger: 'click',
|
@@ -258,16 +423,13 @@ export class FormPlugin extends BasePlugin {
|
|
258
423
|
content: '即表单提交完后,让所有表单项的值还原成初始值',
|
259
424
|
placement: 'left'
|
260
425
|
}
|
261
|
-
},
|
426
|
+
}),
|
262
427
|
|
263
428
|
isCRUDFilter
|
264
429
|
? null
|
265
|
-
: {
|
430
|
+
: getSchemaTpl('switch', {
|
266
431
|
label: '初始化后提交一次',
|
267
|
-
type: 'switch',
|
268
432
|
name: 'submitOnInit',
|
269
|
-
mode: 'inline',
|
270
|
-
className: 'block',
|
271
433
|
labelRemark: {
|
272
434
|
className: 'm-l-xs',
|
273
435
|
trigger: 'click',
|
@@ -275,17 +437,14 @@ export class FormPlugin extends BasePlugin {
|
|
275
437
|
content: '开启后,表单初始完成便会触发一次提交。',
|
276
438
|
placement: 'left'
|
277
439
|
}
|
278
|
-
},
|
440
|
+
}),
|
279
441
|
|
280
442
|
isInDialog
|
281
|
-
? {
|
443
|
+
? getSchemaTpl('switch', {
|
282
444
|
label: '提交后是否关闭对话框',
|
283
|
-
type: 'switch',
|
284
445
|
name: 'closeDialogOnSubmit',
|
285
|
-
mode: 'inline',
|
286
|
-
className: 'block',
|
287
446
|
pipeIn: (value: any) => value !== false
|
288
|
-
}
|
447
|
+
})
|
289
448
|
: null,
|
290
449
|
|
291
450
|
isCRUDFilter
|
@@ -311,22 +470,16 @@ export class FormPlugin extends BasePlugin {
|
|
311
470
|
description: '当设置此值后,表单提交完后跳转到目标地址。'
|
312
471
|
},
|
313
472
|
|
314
|
-
{
|
473
|
+
getSchemaTpl('switch', {
|
315
474
|
name: 'canAccessSuperData',
|
316
475
|
label: '是否自动填充父级同名变量',
|
317
|
-
|
318
|
-
|
319
|
-
mode: 'inline',
|
320
|
-
className: 'block'
|
321
|
-
},
|
476
|
+
pipeIn: defaultValue(true)
|
477
|
+
}),
|
322
478
|
|
323
|
-
{
|
479
|
+
getSchemaTpl('switch', {
|
324
480
|
name: 'persistData',
|
325
481
|
label: '是否开启本地缓存',
|
326
|
-
type: 'switch',
|
327
482
|
pipeIn: defaultValue(false),
|
328
|
-
mode: 'inline',
|
329
|
-
className: 'block',
|
330
483
|
labelRemark: {
|
331
484
|
className: 'm-l-xs',
|
332
485
|
trigger: 'click',
|
@@ -335,15 +488,12 @@ export class FormPlugin extends BasePlugin {
|
|
335
488
|
'开启后,表单的数据会缓存在浏览器中,切换页面或关闭弹框不会清空当前表单内的数据',
|
336
489
|
placement: 'left'
|
337
490
|
}
|
338
|
-
},
|
491
|
+
}),
|
339
492
|
|
340
|
-
{
|
493
|
+
getSchemaTpl('switch', {
|
341
494
|
name: 'clearPersistDataAfterSubmit',
|
342
495
|
label: '提交成功后清空本地缓存',
|
343
|
-
type: 'switch',
|
344
496
|
pipeIn: defaultValue(false),
|
345
|
-
mode: 'inline',
|
346
|
-
className: 'block',
|
347
497
|
visibleOn: 'data.persistData',
|
348
498
|
labelRemark: {
|
349
499
|
className: 'm-l-xs',
|
@@ -353,7 +503,7 @@ export class FormPlugin extends BasePlugin {
|
|
353
503
|
'开启本地缓存并开启本配置项后,表单提交成功后,会自动清除浏览器中当前表单的缓存数据',
|
354
504
|
placement: 'left'
|
355
505
|
}
|
356
|
-
},
|
506
|
+
}),
|
357
507
|
|
358
508
|
{
|
359
509
|
name: 'rules',
|
@@ -395,9 +545,11 @@ export class FormPlugin extends BasePlugin {
|
|
395
545
|
// test: !this.isCRUDFilter
|
396
546
|
}),
|
397
547
|
|
398
|
-
{
|
548
|
+
getSchemaTpl('switch', {
|
549
|
+
name: 'asyncApi',
|
399
550
|
label: '采用异步方式?',
|
400
|
-
|
551
|
+
visibleOn: 'data.api',
|
552
|
+
labelRemark: {
|
401
553
|
trigger: 'click',
|
402
554
|
rootClose: true,
|
403
555
|
title: '什么是异步方式?',
|
@@ -405,14 +557,9 @@ export class FormPlugin extends BasePlugin {
|
|
405
557
|
'异步方式主要用来解决请求超时问题,启用异步方式后,程序会在请求完后,定时轮询请求额外的接口用来咨询操作是否完成。所以接口可以快速的返回,而不需要等待流程真正完成。',
|
406
558
|
placement: 'left'
|
407
559
|
},
|
408
|
-
type: 'switch',
|
409
|
-
name: 'asyncApi',
|
410
|
-
visibleOn: 'data.api',
|
411
560
|
pipeIn: (value: any) => value != null,
|
412
|
-
pipeOut: (value: any) => (value ? '' : undefined)
|
413
|
-
|
414
|
-
className: 'block'
|
415
|
-
},
|
561
|
+
pipeOut: (value: any) => (value ? '' : undefined)
|
562
|
+
}),
|
416
563
|
|
417
564
|
getSchemaTpl('api', {
|
418
565
|
name: 'asyncApi',
|
@@ -458,15 +605,13 @@ export class FormPlugin extends BasePlugin {
|
|
458
605
|
}
|
459
606
|
}),
|
460
607
|
|
461
|
-
{
|
608
|
+
getSchemaTpl('switch', {
|
462
609
|
label: '开启定时刷新',
|
463
|
-
type: 'switch',
|
464
610
|
name: 'interval',
|
465
611
|
visibleOn: 'data.initApi',
|
466
612
|
pipeIn: (value: any) => !!value,
|
467
|
-
pipeOut: (value: any) => (value ? 3000 : undefined)
|
468
|
-
|
469
|
-
},
|
613
|
+
pipeOut: (value: any) => (value ? 3000 : undefined)
|
614
|
+
}),
|
470
615
|
|
471
616
|
{
|
472
617
|
name: 'interval',
|
@@ -477,14 +622,12 @@ export class FormPlugin extends BasePlugin {
|
|
477
622
|
description: '设置后将自动定时刷新,单位 ms'
|
478
623
|
},
|
479
624
|
|
480
|
-
{
|
625
|
+
getSchemaTpl('switch', {
|
481
626
|
name: 'silentPolling',
|
482
627
|
label: '静默刷新',
|
483
|
-
type: 'switch',
|
484
|
-
mode: 'inline',
|
485
628
|
visibleOn: '!!data.interval',
|
486
629
|
description: '设置自动定时刷新时是否显示loading'
|
487
|
-
},
|
630
|
+
}),
|
488
631
|
|
489
632
|
{
|
490
633
|
name: 'stopAutoRefreshWhen',
|
@@ -495,8 +638,10 @@ export class FormPlugin extends BasePlugin {
|
|
495
638
|
'定时刷新一旦设置会一直刷新,除非给出表达式,条件满足后则不刷新了。'
|
496
639
|
},
|
497
640
|
|
498
|
-
{
|
641
|
+
getSchemaTpl('switch', {
|
499
642
|
label: '采用异步方式?',
|
643
|
+
name: 'initAsyncApi',
|
644
|
+
visibleOn: 'data.initApi',
|
500
645
|
remark: {
|
501
646
|
trigger: 'click',
|
502
647
|
rootClose: true,
|
@@ -505,13 +650,9 @@ export class FormPlugin extends BasePlugin {
|
|
505
650
|
'异步方式主要用来解决请求超时问题,启用异步方式后,程序会在请求完后,定时轮询请求额外的接口用来咨询操作是否完成。所以接口可以快速的返回,而不需要等待流程真正完成。',
|
506
651
|
placement: 'left'
|
507
652
|
},
|
508
|
-
type: 'switch',
|
509
|
-
name: 'initAsyncApi',
|
510
|
-
visibleOn: 'data.initApi',
|
511
653
|
pipeIn: (value: any) => value != null,
|
512
|
-
pipeOut: (value: any) => (value ? '' : undefined)
|
513
|
-
|
514
|
-
},
|
654
|
+
pipeOut: (value: any) => (value ? '' : undefined)
|
655
|
+
}),
|
515
656
|
|
516
657
|
getSchemaTpl('api', {
|
517
658
|
name: 'initAsyncApi',
|
@@ -595,11 +736,8 @@ export class FormPlugin extends BasePlugin {
|
|
595
736
|
{
|
596
737
|
title: '外观',
|
597
738
|
body: [
|
598
|
-
{
|
739
|
+
getSchemaTpl('switch', {
|
599
740
|
name: 'wrapWithPanel',
|
600
|
-
type: 'switch',
|
601
|
-
mode: 'inline',
|
602
|
-
className: 'block',
|
603
741
|
label: '用 Panel 包裹',
|
604
742
|
pipeIn: defaultValue(true),
|
605
743
|
labelRemark: {
|
@@ -609,7 +747,7 @@ export class FormPlugin extends BasePlugin {
|
|
609
747
|
content: '关闭后,表单只会展示表单项,标题和操作栏将不会显示。',
|
610
748
|
placement: 'left'
|
611
749
|
}
|
612
|
-
},
|
750
|
+
}),
|
613
751
|
|
614
752
|
{
|
615
753
|
name: 'mode',
|
@@ -650,6 +788,17 @@ export class FormPlugin extends BasePlugin {
|
|
650
788
|
]
|
651
789
|
},
|
652
790
|
|
791
|
+
{
|
792
|
+
title: '事件',
|
793
|
+
className: 'p-none',
|
794
|
+
body: [
|
795
|
+
getSchemaTpl('eventControl', {
|
796
|
+
name: 'onEvent',
|
797
|
+
...getEventControlConfig(this.manager, context)
|
798
|
+
})
|
799
|
+
]
|
800
|
+
},
|
801
|
+
|
653
802
|
{
|
654
803
|
title: '其他',
|
655
804
|
body: [
|
@@ -657,13 +806,12 @@ export class FormPlugin extends BasePlugin {
|
|
657
806
|
getSchemaTpl('name', {
|
658
807
|
test: !isCRUDFilter
|
659
808
|
}),
|
660
|
-
{
|
809
|
+
getSchemaTpl('switch', {
|
661
810
|
name: 'debug',
|
662
811
|
label: '开启调试',
|
663
|
-
type: 'switch',
|
664
|
-
mode: 'inline',
|
665
812
|
labelRemark: '显示当前表单的数据在表单顶部'
|
666
|
-
},
|
813
|
+
}),
|
814
|
+
|
667
815
|
getSchemaTpl('disabled'),
|
668
816
|
getSchemaTpl('visible')
|
669
817
|
]
|
@@ -682,6 +830,65 @@ export class FormPlugin extends BasePlugin {
|
|
682
830
|
this.manager.buildPanels();
|
683
831
|
}
|
684
832
|
}
|
833
|
+
|
834
|
+
async buildDataSchemas(node: EditorNodeType, region: EditorNodeType) {
|
835
|
+
const jsonschema: any = {
|
836
|
+
$id: 'formItems',
|
837
|
+
type: 'object',
|
838
|
+
properties: {}
|
839
|
+
};
|
840
|
+
|
841
|
+
const pool = node.children.concat();
|
842
|
+
while (pool.length) {
|
843
|
+
const current = pool.shift() as EditorNodeType;
|
844
|
+
|
845
|
+
if (current.rendererConfig?.type === 'combo') {
|
846
|
+
const schema = current.schema;
|
847
|
+
if (schema.name) {
|
848
|
+
jsonschema.properties[schema.name] = {
|
849
|
+
type: 'array',
|
850
|
+
title: schema.label || schema.name,
|
851
|
+
items: current.info?.plugin?.buildDataSchemas
|
852
|
+
? await current.info.plugin.buildDataSchemas(current, region)
|
853
|
+
: {
|
854
|
+
type: 'object',
|
855
|
+
properties: {}
|
856
|
+
}
|
857
|
+
};
|
858
|
+
}
|
859
|
+
} else if (current.rendererConfig?.isFormItem) {
|
860
|
+
const schema = current.schema;
|
861
|
+
if (schema.name) {
|
862
|
+
jsonschema.properties[schema.name] = current.info?.plugin
|
863
|
+
?.buildDataSchemas
|
864
|
+
? await current.info.plugin.buildDataSchemas(current, region)
|
865
|
+
: {
|
866
|
+
type: 'string',
|
867
|
+
title: schema.label || schema.name,
|
868
|
+
description: schema.description
|
869
|
+
};
|
870
|
+
}
|
871
|
+
} else {
|
872
|
+
pool.push(...current.children);
|
873
|
+
}
|
874
|
+
}
|
875
|
+
|
876
|
+
return jsonschema;
|
877
|
+
}
|
878
|
+
|
879
|
+
rendererBeforeDispatchEvent(node: EditorNodeType, e: any, data: any) {
|
880
|
+
if (e === 'inited') {
|
881
|
+
// 监听 form 的 inited 事件,把数据加入到上下文中
|
882
|
+
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
|
883
|
+
const jsonschema: any = {
|
884
|
+
$id: 'formInitedData',
|
885
|
+
...jsonToJsonSchema(data)
|
886
|
+
};
|
887
|
+
|
888
|
+
scope.removeSchema(jsonschema.$id);
|
889
|
+
scope.addSchema(jsonschema);
|
890
|
+
}
|
891
|
+
}
|
685
892
|
}
|
686
893
|
|
687
894
|
registerEditorPlugin(FormPlugin);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {defaultValue} from '../../component/schemaTpl';
|
1
|
+
import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
|
2
2
|
import {registerEditorPlugin} from '../../manager';
|
3
3
|
import {BasePlugin} from '../../plugin';
|
4
4
|
|
@@ -50,25 +50,19 @@ export class FormulaControlPlugin extends BasePlugin {
|
|
50
50
|
description:
|
51
51
|
'支持如:<code>\\${xxx}</code>或者<code>data.xxx == "a"</code> 表达式来配置作用条件,当满足该作用条件时,会将计算结果设置到目标变量上。'
|
52
52
|
},
|
53
|
-
{
|
53
|
+
getSchemaTpl('switch', {
|
54
54
|
name: 'initSet',
|
55
|
-
type: 'switch',
|
56
55
|
label: '是否初始应用',
|
57
|
-
pipeIn: defaultValue(true),
|
58
56
|
description: '是否初始化的时候运行公式结果,并设置到目标变量上。',
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
{
|
57
|
+
pipeIn: defaultValue(true)
|
58
|
+
}),
|
59
|
+
getSchemaTpl('switch', {
|
63
60
|
name: 'autoSet',
|
64
|
-
type: 'switch',
|
65
61
|
label: '是否自动应用',
|
66
|
-
pipeIn: defaultValue(true),
|
67
|
-
mode: 'inline',
|
68
|
-
className: 'block',
|
69
62
|
description:
|
70
|
-
'是否自动计算公式结果,有变化时自动设置到目标变量上。<br />关闭后,通过按钮也能触发运算。'
|
71
|
-
|
63
|
+
'是否自动计算公式结果,有变化时自动设置到目标变量上。<br />关闭后,通过按钮也能触发运算。',
|
64
|
+
pipeIn: defaultValue(true)
|
65
|
+
})
|
72
66
|
];
|
73
67
|
|
74
68
|
renderRenderer(props: any) {
|
@@ -82,14 +82,11 @@ export class ArrayControlPlugin extends BasePlugin {
|
|
82
82
|
)
|
83
83
|
},
|
84
84
|
|
85
|
-
{
|
85
|
+
getSchemaTpl('switch', {
|
86
86
|
label: '是否可新增',
|
87
|
-
type: 'switch',
|
88
87
|
name: 'addable',
|
89
|
-
mode: 'inline',
|
90
|
-
className: 'w-full',
|
91
88
|
pipeIn: defaultValue(true)
|
92
|
-
},
|
89
|
+
}),
|
93
90
|
|
94
91
|
{
|
95
92
|
label: '新增按钮文字',
|
@@ -108,14 +105,11 @@ export class ArrayControlPlugin extends BasePlugin {
|
|
108
105
|
pipeIn: defaultValue('')
|
109
106
|
},
|
110
107
|
|
111
|
-
{
|
108
|
+
getSchemaTpl('switch', {
|
112
109
|
label: '是否可删除',
|
113
|
-
type: 'switch',
|
114
110
|
name: 'removable',
|
115
|
-
mode: 'inline',
|
116
|
-
className: 'w-full',
|
117
111
|
pipeIn: defaultValue(true)
|
118
|
-
},
|
112
|
+
}),
|
119
113
|
|
120
114
|
getSchemaTpl('api', {
|
121
115
|
name: 'deleteApi',
|
@@ -131,13 +125,10 @@ export class ArrayControlPlugin extends BasePlugin {
|
|
131
125
|
pipeIn: defaultValue('确认要删除')
|
132
126
|
},
|
133
127
|
|
134
|
-
{
|
128
|
+
getSchemaTpl('switch', {
|
135
129
|
name: 'draggable',
|
136
|
-
label: '启用拖拽排序'
|
137
|
-
|
138
|
-
mode: 'inline',
|
139
|
-
className: 'w-full'
|
140
|
-
},
|
130
|
+
label: '启用拖拽排序'
|
131
|
+
}),
|
141
132
|
|
142
133
|
{
|
143
134
|
name: 'draggableTip',
|