amis-editor 4.1.0-beta.2 → 4.1.0-beta.22
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/component/Breadcrumb.d.ts +23 -2
- package/dist/component/Editor.d.ts +19 -0
- package/dist/component/Panel/RenderersPanel.d.ts +1 -2
- package/dist/component/RegionWrapper.d.ts +4 -0
- package/dist/component/VRenderer.d.ts +4 -0
- package/dist/component/base/SearchCustomRendererPanel.d.ts +15 -0
- package/dist/component/base/SearchPanel.d.ts +83 -0
- package/dist/component/base/SearchRendererPanel.d.ts +2 -42
- package/dist/exports.min.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.min.js +1 -1
- package/dist/manager.d.ts +14 -3
- package/dist/plugin/Card.d.ts +1 -0
- package/dist/plugin/Cards.d.ts +1 -0
- package/dist/plugin/Carousel.d.ts +1 -0
- package/dist/plugin/Chart.d.ts +1 -0
- package/dist/plugin/Collapse.d.ts +1 -0
- package/dist/plugin/Custom.d.ts +3 -0
- package/dist/plugin/CustomRegion.d.ts +43 -0
- package/dist/plugin/Flex.d.ts +1 -0
- package/dist/plugin/Form/Control.d.ts +1 -0
- package/dist/plugin/Form/Form.d.ts +19 -3
- package/dist/plugin/Form/InputURL.d.ts +1 -0
- package/dist/plugin/Form/Switch.d.ts +2 -0
- package/dist/plugin/Grid.d.ts +1 -0
- package/dist/plugin/HBox.d.ts +1 -0
- package/dist/plugin/Json.d.ts +1 -0
- package/dist/plugin/List.d.ts +1 -0
- package/dist/plugin/Mapping.d.ts +1 -0
- package/dist/plugin/Markdown.d.ts +1 -0
- package/dist/plugin/Nav.d.ts +1 -0
- package/dist/plugin/Panel/Outline.d.ts +8 -0
- package/dist/plugin/Progress.d.ts +1 -0
- package/dist/plugin/QRCode.d.ts +1 -0
- package/dist/plugin/Reset.d.ts +0 -1
- package/dist/plugin/Service.d.ts +1 -0
- package/dist/plugin/Sparkline.d.ts +1 -0
- package/dist/plugin/Status.d.ts +1 -0
- package/dist/plugin/Steps.d.ts +1 -0
- package/dist/plugin/Submit.d.ts +0 -1
- package/dist/plugin/TableView.d.ts +1 -0
- package/dist/plugin/Tasks.d.ts +1 -0
- package/dist/plugin/TooltipWrapper.d.ts +1 -0
- package/dist/plugin/Video.d.ts +1 -0
- package/dist/plugin/WebComponent.d.ts +1 -0
- package/dist/plugin/Wizard.d.ts +11 -2
- package/dist/plugin/Wrapper.d.ts +1 -0
- package/dist/plugin.d.ts +2 -2
- package/dist/store/editor.d.ts +20 -2
- package/dist/store/node.d.ts +6 -0
- package/dist/style.css +1 -1
- package/dist/util.d.ts +7 -2
- package/package.json +6 -3
- package/src/component/schemaTpl.tsx +2157 -0
- package/src/plugin/Alert.tsx +87 -0
- package/src/plugin/AnchorNav.tsx +233 -0
- package/src/plugin/Audio.tsx +161 -0
- package/src/plugin/Avatar.tsx +77 -0
- package/src/plugin/Breadcrumb.tsx +107 -0
- package/src/plugin/Button.tsx +283 -0
- package/src/plugin/ButtonGroup.tsx +88 -0
- package/src/plugin/ButtonToolbar.tsx +89 -0
- package/src/plugin/CRUD.tsx +1835 -0
- package/src/plugin/Card.tsx +290 -0
- package/src/plugin/Cards.tsx +315 -0
- package/src/plugin/Carousel.tsx +386 -0
- package/src/plugin/Chart.tsx +218 -0
- package/src/plugin/CodeView.tsx +60 -0
- package/src/plugin/Collapse.tsx +143 -0
- package/src/plugin/CollapseGroup.tsx +167 -0
- package/src/plugin/Container.tsx +44 -0
- package/src/plugin/Custom.tsx +128 -0
- package/src/plugin/CustomRegion.tsx +150 -0
- package/src/plugin/Date.tsx +81 -0
- package/src/plugin/Datetime.tsx +75 -0
- package/src/plugin/Dialog.tsx +178 -0
- package/src/plugin/Divider.tsx +36 -0
- package/src/plugin/Drawer.tsx +217 -0
- package/src/plugin/DropDownButton.tsx +234 -0
- package/src/plugin/Each.tsx +152 -0
- package/src/plugin/ErrorRenderer.tsx +15 -0
- package/src/plugin/Flex.tsx +156 -0
- package/src/plugin/Form/ButtonGroupSelect.tsx +86 -0
- package/src/plugin/Form/ButtonToolbar.tsx +121 -0
- package/src/plugin/Form/ChainedSelect.tsx +70 -0
- package/src/plugin/Form/Checkbox.tsx +87 -0
- package/src/plugin/Form/Checkboxes.tsx +167 -0
- package/src/plugin/Form/CodeEditor.tsx +91 -0
- package/src/plugin/Form/Combo.tsx +582 -0
- package/src/plugin/Form/ConditionBuilder.tsx +324 -0
- package/src/plugin/Form/Control.tsx +139 -0
- package/src/plugin/Form/DiffEditor.tsx +117 -0
- package/src/plugin/Form/FieldSet.tsx +175 -0
- package/src/plugin/Form/Form.tsx +692 -0
- package/src/plugin/Form/Formula.tsx +91 -0
- package/src/plugin/Form/Group.tsx +300 -0
- package/src/plugin/Form/Hidden.tsx +56 -0
- package/src/plugin/Form/InputArray.tsx +228 -0
- package/src/plugin/Form/InputCity.tsx +93 -0
- package/src/plugin/Form/InputColor.tsx +123 -0
- package/src/plugin/Form/InputDate.tsx +175 -0
- package/src/plugin/Form/InputDateRange.tsx +225 -0
- package/src/plugin/Form/InputDateTime.tsx +183 -0
- package/src/plugin/Form/InputDateTimeRange.tsx +221 -0
- package/src/plugin/Form/InputEmail.tsx +33 -0
- package/src/plugin/Form/InputExcel.tsx +85 -0
- package/src/plugin/Form/InputFile.tsx +228 -0
- package/src/plugin/Form/InputGroup.tsx +105 -0
- package/src/plugin/Form/InputImage.tsx +277 -0
- package/src/plugin/Form/InputKV.tsx +72 -0
- package/src/plugin/Form/InputMonth.tsx +35 -0
- package/src/plugin/Form/InputMonthRange.tsx +195 -0
- package/src/plugin/Form/InputNumber.tsx +97 -0
- package/src/plugin/Form/InputPassword.tsx +33 -0
- package/src/plugin/Form/InputQuarter.tsx +35 -0
- package/src/plugin/Form/InputQuarterRange.tsx +195 -0
- package/src/plugin/Form/InputRange.tsx +121 -0
- package/src/plugin/Form/InputRating.tsx +78 -0
- package/src/plugin/Form/InputRepeat.tsx +69 -0
- package/src/plugin/Form/InputRichText.tsx +197 -0
- package/src/plugin/Form/InputSubForm.tsx +198 -0
- package/src/plugin/Form/InputTable.tsx +434 -0
- package/src/plugin/Form/InputTag.tsx +81 -0
- package/src/plugin/Form/InputText.tsx +186 -0
- package/src/plugin/Form/InputTime.tsx +95 -0
- package/src/plugin/Form/InputTree.tsx +240 -0
- package/src/plugin/Form/InputURL.tsx +34 -0
- package/src/plugin/Form/InputYear.tsx +35 -0
- package/src/plugin/Form/Item.tsx +327 -0
- package/src/plugin/Form/ListSelect.tsx +84 -0
- package/src/plugin/Form/LocationPicker.tsx +75 -0
- package/src/plugin/Form/MatrixCheckboxes.tsx +147 -0
- package/src/plugin/Form/NestedSelect.tsx +222 -0
- package/src/plugin/Form/Picker.tsx +217 -0
- package/src/plugin/Form/Radios.tsx +130 -0
- package/src/plugin/Form/Select.tsx +233 -0
- package/src/plugin/Form/Static.tsx +335 -0
- package/src/plugin/Form/Switch.tsx +118 -0
- package/src/plugin/Form/TabsTransfer.tsx +270 -0
- package/src/plugin/Form/Textarea.tsx +94 -0
- package/src/plugin/Form/Transfer.tsx +379 -0
- package/src/plugin/Form/TreeSelect.tsx +263 -0
- package/src/plugin/Form/UUID.tsx +48 -0
- package/src/plugin/Grid.tsx +799 -0
- package/src/plugin/HBox.tsx +727 -0
- package/src/plugin/IFrame.tsx +72 -0
- package/src/plugin/Image.tsx +318 -0
- package/src/plugin/Images.tsx +238 -0
- package/src/plugin/Json.tsx +76 -0
- package/src/plugin/Link.tsx +95 -0
- package/src/plugin/List.tsx +278 -0
- package/src/plugin/ListItem.tsx +233 -0
- package/src/plugin/Log.tsx +52 -0
- package/src/plugin/Mapping.tsx +156 -0
- package/src/plugin/Markdown.tsx +47 -0
- package/src/plugin/Nav.tsx +186 -0
- package/src/plugin/Operation.tsx +97 -0
- package/src/plugin/Others/Action.tsx +428 -0
- package/src/plugin/Others/BasicToolbar.tsx +591 -0
- package/src/plugin/Others/DataDebug.tsx +134 -0
- package/src/plugin/Others/TableCell.tsx +480 -0
- package/src/plugin/Others/Unknown.tsx +37 -0
- package/src/plugin/Page.tsx +308 -0
- package/src/plugin/Panel/AvailableRenderers.tsx +41 -0
- package/src/plugin/Panel/Code.tsx +44 -0
- package/src/plugin/Panel/Name.tsx +26 -0
- package/src/plugin/Panel/Outline.tsx +40 -0
- package/src/plugin/Panel.tsx +243 -0
- package/src/plugin/Plain.tsx +91 -0
- package/src/plugin/Progress.tsx +132 -0
- package/src/plugin/Property.tsx +139 -0
- package/src/plugin/QRCode.tsx +98 -0
- package/src/plugin/Reset.tsx +23 -0
- package/src/plugin/Service.tsx +167 -0
- package/src/plugin/Sparkline.tsx +40 -0
- package/src/plugin/Status.tsx +78 -0
- package/src/plugin/Steps.tsx +140 -0
- package/src/plugin/Submit.tsx +23 -0
- package/src/plugin/Table.tsx +440 -0
- package/src/plugin/TableView.tsx +711 -0
- package/src/plugin/Tabs.tsx +364 -0
- package/src/plugin/Tasks.tsx +276 -0
- package/src/plugin/Time.tsx +75 -0
- package/src/plugin/TooltipWrapper.tsx +193 -0
- package/src/plugin/Tpl.tsx +162 -0
- package/src/plugin/Video.tsx +160 -0
- package/src/plugin/WebComponent.tsx +56 -0
- package/src/plugin/Wizard.tsx +743 -0
- package/src/plugin/Wrapper.tsx +107 -0
- package/src/plugin.ts +1046 -0
- package/dist/150a58f3318ca7541ed9.png +0 -0
- package/dist/471adb97c322b226e589.png +0 -0
- package/dist/4de5f42360bc5946c3c2.png +0 -0
- package/dist/4e9968bba3855f088fed.png +0 -0
- package/dist/7f09c38ebc687fea847a.png +0 -0
- package/dist/c94073576487510314ea.png +0 -0
@@ -0,0 +1,233 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {Button} from 'amis';
|
3
|
+
import {defaultValue, getSchemaTpl} from '../../component/schemaTpl';
|
4
|
+
import {registerEditorPlugin} from '../../manager';
|
5
|
+
import {
|
6
|
+
BasePlugin,
|
7
|
+
BasicSubRenderInfo,
|
8
|
+
RendererEventContext,
|
9
|
+
SubRendererInfo
|
10
|
+
} from '../../plugin';
|
11
|
+
import isArray from 'lodash/isArray';
|
12
|
+
|
13
|
+
export class SelectControlPlugin extends BasePlugin {
|
14
|
+
// 关联渲染器名字
|
15
|
+
rendererName = 'select';
|
16
|
+
$schema = '/schemas/SelectControlSchema.json';
|
17
|
+
|
18
|
+
order = -480;
|
19
|
+
|
20
|
+
// 组件名称
|
21
|
+
name = '下拉框';
|
22
|
+
isBaseComponent = true;
|
23
|
+
icon = 'fa fa-th-list';
|
24
|
+
description = `支持多选,输入提示,可使用<code>source</code>获取选项`;
|
25
|
+
docLink = '/amis/zh-CN/components/form/select';
|
26
|
+
tags = ['表单项'];
|
27
|
+
scaffold = {
|
28
|
+
type: 'select',
|
29
|
+
label: '选项',
|
30
|
+
name: 'select',
|
31
|
+
options: [
|
32
|
+
{
|
33
|
+
label: '选项A',
|
34
|
+
value: 'A'
|
35
|
+
},
|
36
|
+
|
37
|
+
{
|
38
|
+
label: '选项B',
|
39
|
+
value: 'B'
|
40
|
+
}
|
41
|
+
]
|
42
|
+
};
|
43
|
+
previewSchema: any = {
|
44
|
+
type: 'form',
|
45
|
+
className: 'text-left',
|
46
|
+
mode: 'horizontal',
|
47
|
+
wrapWithPanel: false,
|
48
|
+
body: [
|
49
|
+
{
|
50
|
+
...this.scaffold
|
51
|
+
}
|
52
|
+
]
|
53
|
+
};
|
54
|
+
|
55
|
+
panelTitle = '下拉框';
|
56
|
+
panelBody = [
|
57
|
+
getSchemaTpl('switchDefaultValue'),
|
58
|
+
|
59
|
+
{
|
60
|
+
type: 'select',
|
61
|
+
name: 'value',
|
62
|
+
label: '默认值',
|
63
|
+
source: '${options}',
|
64
|
+
visibleOn: '!data.multiple && typeof this.value !== "undefined"'
|
65
|
+
},
|
66
|
+
|
67
|
+
{
|
68
|
+
type: 'select',
|
69
|
+
name: 'value',
|
70
|
+
label: '默认值',
|
71
|
+
source: '${options}',
|
72
|
+
multiple: true,
|
73
|
+
visibleOn: ' data.multiple && typeof this.value !== "undefined"'
|
74
|
+
},
|
75
|
+
|
76
|
+
getSchemaTpl('clearable'),
|
77
|
+
{
|
78
|
+
label: '可检索',
|
79
|
+
name: 'searchable',
|
80
|
+
type: 'switch',
|
81
|
+
mode: 'inline',
|
82
|
+
className: 'w-full'
|
83
|
+
},
|
84
|
+
|
85
|
+
{
|
86
|
+
label: '是否默认选择第一个',
|
87
|
+
name: 'selectFirst',
|
88
|
+
type: 'switch',
|
89
|
+
mode: 'inline',
|
90
|
+
className: 'w-full'
|
91
|
+
},
|
92
|
+
|
93
|
+
getSchemaTpl('fieldSet', {
|
94
|
+
title: '选项',
|
95
|
+
body: [
|
96
|
+
getSchemaTpl('multiple'),
|
97
|
+
{
|
98
|
+
label: '选中内容以单行模式显示',
|
99
|
+
name: 'valuesNoWrap',
|
100
|
+
type: 'switch',
|
101
|
+
mode: 'inline',
|
102
|
+
className: 'w-full',
|
103
|
+
visibleOn: 'this.multiple'
|
104
|
+
},
|
105
|
+
{
|
106
|
+
label: '可全选',
|
107
|
+
name: 'checkAll',
|
108
|
+
type: 'switch',
|
109
|
+
mode: 'inline',
|
110
|
+
value: false,
|
111
|
+
className: 'w-full',
|
112
|
+
onChange: (value: any, origin: any, item: any, form: any) => {
|
113
|
+
// 开启 “可全选” 时,需关联开启多选模式
|
114
|
+
value && form.setValueByName('multiple', true);
|
115
|
+
}
|
116
|
+
},
|
117
|
+
{
|
118
|
+
label: '自定义菜单模板',
|
119
|
+
name: 'menuTpl',
|
120
|
+
type: 'input-text'
|
121
|
+
},
|
122
|
+
{
|
123
|
+
label: '默认全选',
|
124
|
+
name: 'defaultCheckAll',
|
125
|
+
type: 'switch',
|
126
|
+
value: false,
|
127
|
+
visibleOn: 'this.checkAll',
|
128
|
+
mode: 'inline',
|
129
|
+
className: 'w-full'
|
130
|
+
},
|
131
|
+
{
|
132
|
+
type: 'input-text',
|
133
|
+
name: 'checkAllLabel',
|
134
|
+
label: '默认为 "全选" 的文字',
|
135
|
+
visibleOn: 'this.checkAll',
|
136
|
+
value: '全选'
|
137
|
+
},
|
138
|
+
getSchemaTpl('options'),
|
139
|
+
getSchemaTpl('source'),
|
140
|
+
getSchemaTpl('api', {
|
141
|
+
name: 'autoComplete',
|
142
|
+
label: '自动完成接口',
|
143
|
+
description:
|
144
|
+
'每次输入新内容后,将调用接口,根据接口返回更新选项。当前用户输入值在 <code>\\${term}</code> 中。'
|
145
|
+
}),
|
146
|
+
getSchemaTpl('joinValues'),
|
147
|
+
getSchemaTpl('delimiter'),
|
148
|
+
getSchemaTpl('extractValue'),
|
149
|
+
getSchemaTpl('autoFill'),
|
150
|
+
|
151
|
+
getSchemaTpl('creatable'),
|
152
|
+
getSchemaTpl('createBtnLabel', {
|
153
|
+
visibleOn: 'data.creatable'
|
154
|
+
}),
|
155
|
+
getSchemaTpl('api', {
|
156
|
+
label: '新增选项接口',
|
157
|
+
name: 'addApi',
|
158
|
+
visibleOn: 'data.creatable'
|
159
|
+
}),
|
160
|
+
{
|
161
|
+
name: 'addControls',
|
162
|
+
visibleOn: 'data.creatable',
|
163
|
+
pipeIn: defaultValue([
|
164
|
+
{
|
165
|
+
type: 'input-text',
|
166
|
+
name: 'label',
|
167
|
+
label: false,
|
168
|
+
placeholder: '请输入名称'
|
169
|
+
}
|
170
|
+
]),
|
171
|
+
asFormItem: true,
|
172
|
+
children: (params: any) => ( // params: {value, onChange, data}
|
173
|
+
<Button
|
174
|
+
size="sm"
|
175
|
+
level="danger"
|
176
|
+
className="m-b"
|
177
|
+
onClick={() => {
|
178
|
+
let defaultValue = {
|
179
|
+
type: 'dialog',
|
180
|
+
body: [
|
181
|
+
{
|
182
|
+
type: 'input-text',
|
183
|
+
name: 'label',
|
184
|
+
label: false,
|
185
|
+
placeholder: '请输入名称'
|
186
|
+
}
|
187
|
+
]
|
188
|
+
};
|
189
|
+
if (params.value && params.value.body && isArray(params.value.body)) {
|
190
|
+
defaultValue.body = params.value.body;
|
191
|
+
} else if (params.value && isArray(params.value)) {
|
192
|
+
defaultValue.body = params.value;
|
193
|
+
}
|
194
|
+
this.manager.openSubEditor({
|
195
|
+
title: '配置新建选项表单项',
|
196
|
+
value: defaultValue,
|
197
|
+
onChange: (curValue: any) => {
|
198
|
+
if (curValue && curValue.body && isArray(curValue.body)) {
|
199
|
+
/**
|
200
|
+
* 备注: 需要确保 addControls 为数组类型 才会生效。
|
201
|
+
* 详细使用说明:https://aisuda.bce.baidu.com/amis/zh-CN/components/form/options#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%96%B0%E5%A2%9E%E8%A1%A8%E5%8D%95%E9%A1%B9-addcontrols
|
202
|
+
*/
|
203
|
+
return params.onChange(curValue.body, 'addControls');
|
204
|
+
} else {
|
205
|
+
return params.onChange([], 'addControls');
|
206
|
+
}
|
207
|
+
}
|
208
|
+
});
|
209
|
+
}}
|
210
|
+
block
|
211
|
+
>
|
212
|
+
配置新建选项表单项
|
213
|
+
</Button>
|
214
|
+
)
|
215
|
+
},
|
216
|
+
|
217
|
+
getSchemaTpl('editable'),
|
218
|
+
getSchemaTpl('api', {
|
219
|
+
label: '编辑选项接口',
|
220
|
+
name: 'editApi'
|
221
|
+
}),
|
222
|
+
|
223
|
+
getSchemaTpl('removable'),
|
224
|
+
getSchemaTpl('api', {
|
225
|
+
label: '删除选项接口',
|
226
|
+
name: 'deleteApi'
|
227
|
+
})
|
228
|
+
]
|
229
|
+
})
|
230
|
+
];
|
231
|
+
}
|
232
|
+
|
233
|
+
registerEditorPlugin(SelectControlPlugin);
|
@@ -0,0 +1,335 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import {Button} from 'amis';
|
3
|
+
import {availableLanguages} from 'amis/lib/renderers/Form/Editor';
|
4
|
+
import {
|
5
|
+
defaultValue,
|
6
|
+
getSchemaTpl,
|
7
|
+
valuePipeOut
|
8
|
+
} from '../../component/schemaTpl';
|
9
|
+
import {registerEditorPlugin} from '../../manager';
|
10
|
+
import {
|
11
|
+
BaseEventContext,
|
12
|
+
BasePlugin,
|
13
|
+
BasicSubRenderInfo,
|
14
|
+
PluginEvent,
|
15
|
+
RendererEventContext,
|
16
|
+
ReplaceEventContext,
|
17
|
+
SubRendererInfo
|
18
|
+
} from '../../plugin';
|
19
|
+
import {EditorNodeType} from '../../store/node';
|
20
|
+
import {mockValue} from '../../mocker';
|
21
|
+
|
22
|
+
export class StaticControlPlugin extends BasePlugin {
|
23
|
+
// 关联渲染器名字
|
24
|
+
rendererName = 'static';
|
25
|
+
$schema = '/schemas/StaticControlSchema.json';
|
26
|
+
|
27
|
+
order = -390;
|
28
|
+
|
29
|
+
// 组件名称
|
30
|
+
name = '静态展示框';
|
31
|
+
isBaseComponent = true;
|
32
|
+
icon = 'fa fa-info';
|
33
|
+
description = `纯用来展示数据,可用来展示<code>json、date、image、progress</code>等数据`;
|
34
|
+
docLink = '/amis/zh-CN/components/form/static';
|
35
|
+
tags = ['表单项'];
|
36
|
+
scaffold = {
|
37
|
+
type: 'static',
|
38
|
+
label: '描述'
|
39
|
+
};
|
40
|
+
previewSchema: any = {
|
41
|
+
type: 'form',
|
42
|
+
className: 'text-left',
|
43
|
+
mode: 'horizontal',
|
44
|
+
wrapWithPanel: false,
|
45
|
+
body: [
|
46
|
+
{
|
47
|
+
...this.scaffold,
|
48
|
+
value: '静态值'
|
49
|
+
}
|
50
|
+
]
|
51
|
+
};
|
52
|
+
multifactor = true;
|
53
|
+
|
54
|
+
panelTitle = '静态展示';
|
55
|
+
panelBodyCreator = (context: BaseEventContext) => {
|
56
|
+
return [
|
57
|
+
/*{
|
58
|
+
children: (
|
59
|
+
<Button
|
60
|
+
size="sm"
|
61
|
+
level="info"
|
62
|
+
className="m-b"
|
63
|
+
block
|
64
|
+
onClick={this.exchangeRenderer.bind(this, context.id)}
|
65
|
+
>
|
66
|
+
更改渲染器类型
|
67
|
+
</Button>
|
68
|
+
)
|
69
|
+
},*/
|
70
|
+
getSchemaTpl('switchDefaultValue'),
|
71
|
+
|
72
|
+
{
|
73
|
+
type: 'input-text',
|
74
|
+
name: 'value',
|
75
|
+
label: '默认值',
|
76
|
+
visibleOn: 'typeof this.value !== "undefined"'
|
77
|
+
},
|
78
|
+
|
79
|
+
{
|
80
|
+
name: 'quickEdit',
|
81
|
+
label: '启用快速编辑',
|
82
|
+
type: 'switch',
|
83
|
+
pipeIn: (value: any) => !!value,
|
84
|
+
mode: 'inline',
|
85
|
+
className: 'w-full'
|
86
|
+
},
|
87
|
+
|
88
|
+
{
|
89
|
+
visibleOn: 'data.quickEdit',
|
90
|
+
name: 'quickEdit.mode',
|
91
|
+
type: 'button-group-select',
|
92
|
+
value: 'popOver',
|
93
|
+
label: '快速编辑模式',
|
94
|
+
size: 'xs',
|
95
|
+
mode: 'inline',
|
96
|
+
className: 'w-full',
|
97
|
+
options: [
|
98
|
+
{
|
99
|
+
label: '下拉',
|
100
|
+
value: 'popOver'
|
101
|
+
},
|
102
|
+
{
|
103
|
+
label: '内嵌',
|
104
|
+
value: 'inline'
|
105
|
+
}
|
106
|
+
]
|
107
|
+
},
|
108
|
+
|
109
|
+
{
|
110
|
+
visibleOn: 'data.quickEdit',
|
111
|
+
name: 'quickEdit.saveImmediately',
|
112
|
+
label: '是否立即保存',
|
113
|
+
type: 'switch',
|
114
|
+
mode: 'inline',
|
115
|
+
className: 'w-full',
|
116
|
+
description: '开启后修改即提交,而不是标记修改批量提交。',
|
117
|
+
descriptionClassName: 'help-block m-b-none',
|
118
|
+
pipeIn: (value: any) => !!value
|
119
|
+
},
|
120
|
+
|
121
|
+
getSchemaTpl('api', {
|
122
|
+
label: '立即保存接口',
|
123
|
+
description:
|
124
|
+
'是否单独给立即保存配置接口,如果不配置,则默认使用quickSaveItemApi。',
|
125
|
+
name: 'quickEdit.saveImmediately.api',
|
126
|
+
visibleOn: 'this.quickEdit && this.quickEdit.saveImmediately'
|
127
|
+
}),
|
128
|
+
|
129
|
+
{
|
130
|
+
visibleOn: 'data.quickEdit',
|
131
|
+
name: 'quickEdit',
|
132
|
+
asFormItem: true,
|
133
|
+
children: ({value, onChange, data}: any) => {
|
134
|
+
if (value === true) {
|
135
|
+
value = {};
|
136
|
+
}
|
137
|
+
|
138
|
+
const originMode = value.mode;
|
139
|
+
|
140
|
+
value = {
|
141
|
+
type: 'input-text',
|
142
|
+
name: data.name,
|
143
|
+
...value
|
144
|
+
};
|
145
|
+
delete value.mode;
|
146
|
+
|
147
|
+
// todo 多个快速编辑表单模式看来只能代码模式编辑了。
|
148
|
+
|
149
|
+
return (
|
150
|
+
<Button
|
151
|
+
level="info"
|
152
|
+
className="m-b"
|
153
|
+
size="sm"
|
154
|
+
block
|
155
|
+
onClick={() => {
|
156
|
+
this.manager.openSubEditor({
|
157
|
+
title: '配置快速编辑类型',
|
158
|
+
value: value,
|
159
|
+
slot: {
|
160
|
+
type: 'form',
|
161
|
+
mode: 'normal',
|
162
|
+
body: ['$$'],
|
163
|
+
wrapWithPanel: false
|
164
|
+
},
|
165
|
+
onChange: value =>
|
166
|
+
onChange(
|
167
|
+
{
|
168
|
+
...value,
|
169
|
+
mode: originMode
|
170
|
+
},
|
171
|
+
'quickEdit'
|
172
|
+
)
|
173
|
+
});
|
174
|
+
}}
|
175
|
+
>
|
176
|
+
配置快速编辑
|
177
|
+
</Button>
|
178
|
+
);
|
179
|
+
}
|
180
|
+
},
|
181
|
+
|
182
|
+
{
|
183
|
+
name: 'popOver',
|
184
|
+
label: '启用查看更多展示',
|
185
|
+
type: 'switch',
|
186
|
+
pipeIn: (value: any) => !!value,
|
187
|
+
mode: 'inline',
|
188
|
+
className: 'w-full'
|
189
|
+
},
|
190
|
+
|
191
|
+
{
|
192
|
+
name: 'popOver.mode',
|
193
|
+
label: '查看更多弹出模式',
|
194
|
+
type: 'select',
|
195
|
+
visibleOn: 'data.popOver',
|
196
|
+
pipeIn: defaultValue('popOver'),
|
197
|
+
options: [
|
198
|
+
{
|
199
|
+
label: '默认',
|
200
|
+
value: 'popOver'
|
201
|
+
},
|
202
|
+
|
203
|
+
{
|
204
|
+
label: '弹框',
|
205
|
+
value: 'dialog'
|
206
|
+
},
|
207
|
+
|
208
|
+
{
|
209
|
+
label: '抽出式弹框',
|
210
|
+
value: 'drawer'
|
211
|
+
}
|
212
|
+
]
|
213
|
+
},
|
214
|
+
|
215
|
+
{
|
216
|
+
name: 'popOver.position',
|
217
|
+
label: '查看更多弹出模式',
|
218
|
+
type: 'select',
|
219
|
+
visibleOn: 'data.popOver && data.popOver.mode === "popOver"',
|
220
|
+
pipeIn: defaultValue('center'),
|
221
|
+
options: [
|
222
|
+
{
|
223
|
+
label: '目标中部',
|
224
|
+
value: 'center'
|
225
|
+
},
|
226
|
+
|
227
|
+
{
|
228
|
+
label: '目标左上角',
|
229
|
+
value: 'left-top'
|
230
|
+
},
|
231
|
+
|
232
|
+
{
|
233
|
+
label: '目标右上角',
|
234
|
+
value: 'right-top'
|
235
|
+
},
|
236
|
+
|
237
|
+
{
|
238
|
+
label: '目标左下角',
|
239
|
+
value: 'left-bottom'
|
240
|
+
},
|
241
|
+
|
242
|
+
{
|
243
|
+
label: '目标右下角',
|
244
|
+
value: 'right-bottom'
|
245
|
+
},
|
246
|
+
|
247
|
+
{
|
248
|
+
label: '页面左上角',
|
249
|
+
value: 'fixed-left-top'
|
250
|
+
},
|
251
|
+
|
252
|
+
{
|
253
|
+
label: '页面右上角',
|
254
|
+
value: 'fixed-right-top'
|
255
|
+
},
|
256
|
+
|
257
|
+
{
|
258
|
+
label: '页面左下角',
|
259
|
+
value: 'fixed-left-bottom'
|
260
|
+
},
|
261
|
+
|
262
|
+
{
|
263
|
+
label: '页面右下角',
|
264
|
+
value: 'fixed-right-bottom'
|
265
|
+
}
|
266
|
+
]
|
267
|
+
},
|
268
|
+
|
269
|
+
{
|
270
|
+
visibleOn: 'data.popOver',
|
271
|
+
name: 'popOver',
|
272
|
+
asFormItem: true,
|
273
|
+
children: ({value, onChange}: any) => {
|
274
|
+
value = {
|
275
|
+
type: 'panel',
|
276
|
+
title: '查看详情',
|
277
|
+
body: '内容详情',
|
278
|
+
...value
|
279
|
+
};
|
280
|
+
|
281
|
+
return (
|
282
|
+
<Button
|
283
|
+
level="info"
|
284
|
+
className="m-b"
|
285
|
+
size="sm"
|
286
|
+
block
|
287
|
+
onClick={() => {
|
288
|
+
this.manager.openSubEditor({
|
289
|
+
title: '配置查看更多展示内容',
|
290
|
+
value: value,
|
291
|
+
onChange: value => onChange(value, 'quickEdit')
|
292
|
+
});
|
293
|
+
}}
|
294
|
+
>
|
295
|
+
查看更多内容配置
|
296
|
+
</Button>
|
297
|
+
);
|
298
|
+
}
|
299
|
+
},
|
300
|
+
|
301
|
+
getSchemaTpl('borderMode'),
|
302
|
+
{
|
303
|
+
name: 'copyable',
|
304
|
+
label: '启用内容复制功能',
|
305
|
+
type: 'switch',
|
306
|
+
pipeIn: (value: any) => !!value,
|
307
|
+
mode: 'inline',
|
308
|
+
className: 'w-full'
|
309
|
+
},
|
310
|
+
|
311
|
+
{
|
312
|
+
visibleOn: 'data.copyable',
|
313
|
+
name: 'copyable.content',
|
314
|
+
type: 'textarea',
|
315
|
+
label: '复制内容模板',
|
316
|
+
description: '默认为当前字段值,可定制。'
|
317
|
+
}
|
318
|
+
];
|
319
|
+
};
|
320
|
+
|
321
|
+
filterProps(props: any, node: EditorNodeType) {
|
322
|
+
props.$$id = node.id;
|
323
|
+
|
324
|
+
if (typeof props.value === 'undefined') {
|
325
|
+
props.value = mockValue(props);
|
326
|
+
}
|
327
|
+
return props;
|
328
|
+
}
|
329
|
+
|
330
|
+
/*exchangeRenderer(id: string) {
|
331
|
+
this.manager.showReplacePanel(id, '展示');
|
332
|
+
}*/
|
333
|
+
}
|
334
|
+
|
335
|
+
registerEditorPlugin(StaticControlPlugin);
|
@@ -0,0 +1,118 @@
|
|
1
|
+
import {relativeValueRe} from 'amis';
|
2
|
+
import {availableLanguages} from 'amis/lib/renderers/Form/Editor';
|
3
|
+
import {
|
4
|
+
defaultValue,
|
5
|
+
getSchemaTpl,
|
6
|
+
valuePipeOut
|
7
|
+
} from '../../component/schemaTpl';
|
8
|
+
import {registerEditorPlugin} from '../../manager';
|
9
|
+
import {
|
10
|
+
BasePlugin,
|
11
|
+
BasicSubRenderInfo,
|
12
|
+
RendererEventContext,
|
13
|
+
SubRendererInfo
|
14
|
+
} from '../../plugin';
|
15
|
+
|
16
|
+
export class SwitchControlPlugin extends BasePlugin {
|
17
|
+
// 关联渲染器名字
|
18
|
+
rendererName = 'switch';
|
19
|
+
$schema = '/schemas/SwitchControlSchema.json';
|
20
|
+
|
21
|
+
order = -400;
|
22
|
+
|
23
|
+
// 组件名称
|
24
|
+
name = '开关';
|
25
|
+
isBaseComponent = true;
|
26
|
+
icon = 'fa fa-toggle-on';
|
27
|
+
description = `开关控件`;
|
28
|
+
docLink = '/amis/zh-CN/components/form/switch';
|
29
|
+
tags = ['表单项'];
|
30
|
+
scaffold = {
|
31
|
+
type: 'switch',
|
32
|
+
option: '开关',
|
33
|
+
name: 'switch',
|
34
|
+
falseValue: false,
|
35
|
+
trueValue: true
|
36
|
+
};
|
37
|
+
previewSchema: any = {
|
38
|
+
type: 'form',
|
39
|
+
className: 'text-left',
|
40
|
+
mode: 'horizontal',
|
41
|
+
wrapWithPanel: false,
|
42
|
+
body: [
|
43
|
+
{
|
44
|
+
...this.scaffold,
|
45
|
+
label: '开关表单'
|
46
|
+
}
|
47
|
+
]
|
48
|
+
};
|
49
|
+
|
50
|
+
panelTitle = '开关';
|
51
|
+
panelBody = [
|
52
|
+
getSchemaTpl('switchDefaultValue', {
|
53
|
+
pipeOut: (value: any, origin: any, data: any) =>
|
54
|
+
value ? data.trueValue : undefined
|
55
|
+
}),
|
56
|
+
{
|
57
|
+
type: 'switch',
|
58
|
+
name: 'value',
|
59
|
+
label: '默认勾选',
|
60
|
+
mode: 'inline',
|
61
|
+
className: 'w-full',
|
62
|
+
visibleOn: 'typeof this.value !== "undefined"',
|
63
|
+
pipeOut: (value: any, origin: any, data: any) =>
|
64
|
+
value ? data.trueValue : data.falseValue
|
65
|
+
},
|
66
|
+
{
|
67
|
+
name: 'option',
|
68
|
+
type: 'input-text',
|
69
|
+
label: '选项说明'
|
70
|
+
},
|
71
|
+
{
|
72
|
+
label: '选项位置',
|
73
|
+
name: 'optionAtLeft',
|
74
|
+
type: 'button-group-select',
|
75
|
+
size: 'sm',
|
76
|
+
value: false,
|
77
|
+
options: [
|
78
|
+
{
|
79
|
+
label: '左',
|
80
|
+
value: true
|
81
|
+
},
|
82
|
+
|
83
|
+
{
|
84
|
+
label: '右',
|
85
|
+
value: false
|
86
|
+
}
|
87
|
+
]
|
88
|
+
},
|
89
|
+
{
|
90
|
+
type: 'input-text',
|
91
|
+
label: '勾选后的值',
|
92
|
+
name: 'trueValue',
|
93
|
+
value: true,
|
94
|
+
pipeOut: valuePipeOut
|
95
|
+
},
|
96
|
+
{
|
97
|
+
type: 'input-text',
|
98
|
+
label: '未勾选的值',
|
99
|
+
name: 'falseValue',
|
100
|
+
value: false,
|
101
|
+
pipeOut: valuePipeOut
|
102
|
+
},
|
103
|
+
|
104
|
+
{
|
105
|
+
name: 'onText',
|
106
|
+
type: 'input-text',
|
107
|
+
label: '开启时的文本'
|
108
|
+
},
|
109
|
+
|
110
|
+
{
|
111
|
+
name: 'offText',
|
112
|
+
type: 'input-text',
|
113
|
+
label: '关闭时的文本'
|
114
|
+
}
|
115
|
+
];
|
116
|
+
}
|
117
|
+
|
118
|
+
registerEditorPlugin(SwitchControlPlugin);
|