amis-editor 4.0.2-beta.16 → 4.1.0-beta.19
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 +15 -8
- package/dist/component/RendererThumb.d.ts +5 -5
- package/dist/component/VRenderer.d.ts +5 -1
- 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 +3 -43
- 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/InputURL.d.ts +1 -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 +2 -0
- package/dist/plugin/Video.d.ts +1 -0
- package/dist/plugin/WebComponent.d.ts +1 -0
- 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 +2155 -0
- package/src/plugin/.DS_Store +0 -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 +1832 -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 +325 -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 +216 -0
- package/src/plugin/Form/Static.tsx +335 -0
- package/src/plugin/Form/Switch.tsx +116 -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,364 @@
|
|
1
|
+
import {Button, SchemaObject} from 'amis';
|
2
|
+
import React from 'react';
|
3
|
+
import {registerEditorPlugin} from '../manager';
|
4
|
+
import {
|
5
|
+
BaseEventContext,
|
6
|
+
BasePlugin,
|
7
|
+
BasicToolbarItem,
|
8
|
+
PluginEvent,
|
9
|
+
PreventClickEventContext,
|
10
|
+
RegionConfig,
|
11
|
+
RendererInfo,
|
12
|
+
VRendererConfig
|
13
|
+
} from '../plugin';
|
14
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
15
|
+
import {mapReactElement} from '../component/factory';
|
16
|
+
import {VRenderer} from '../component/VRenderer';
|
17
|
+
import findIndex from 'lodash/findIndex';
|
18
|
+
import {RegionWrapper as Region} from '../component/RegionWrapper';
|
19
|
+
import {Tab} from 'amis';
|
20
|
+
|
21
|
+
export class TabsPlugin extends BasePlugin {
|
22
|
+
// 关联渲染器名字
|
23
|
+
rendererName = 'tabs';
|
24
|
+
$schema = '/schemas/TabsSchema.json';
|
25
|
+
|
26
|
+
// 组件名称
|
27
|
+
name = '选项卡';
|
28
|
+
isBaseComponent = true;
|
29
|
+
description = '选项卡,可以将内容分组用选项卡的形式展示,降低用户使用成本。';
|
30
|
+
docLink = '/amis/zh-CN/components/tabs';
|
31
|
+
tags = ['容器'];
|
32
|
+
icon = 'fa fa-folder-o';
|
33
|
+
scaffold = {
|
34
|
+
type: 'tabs',
|
35
|
+
tabs: [
|
36
|
+
{
|
37
|
+
title: '选项卡1',
|
38
|
+
body: '内容1'
|
39
|
+
},
|
40
|
+
|
41
|
+
{
|
42
|
+
title: '选项卡2',
|
43
|
+
body: '内容2'
|
44
|
+
}
|
45
|
+
]
|
46
|
+
};
|
47
|
+
previewSchema = {
|
48
|
+
...this.scaffold
|
49
|
+
};
|
50
|
+
|
51
|
+
panelTitle = '选项卡';
|
52
|
+
panelBody = [
|
53
|
+
getSchemaTpl('tabs', [
|
54
|
+
{
|
55
|
+
title: '常规',
|
56
|
+
body: [
|
57
|
+
{
|
58
|
+
name: 'tabs',
|
59
|
+
type: 'combo',
|
60
|
+
label: '选项卡管理',
|
61
|
+
multiple: true,
|
62
|
+
draggable: true,
|
63
|
+
minLength: 1,
|
64
|
+
items: [{type: 'input-text', name: 'title', required: true}],
|
65
|
+
scaffold: {
|
66
|
+
title: '选项卡',
|
67
|
+
body: {
|
68
|
+
type: 'tpl',
|
69
|
+
tpl: '内容',
|
70
|
+
inline: false
|
71
|
+
}
|
72
|
+
},
|
73
|
+
addButtonText: '新增选项卡',
|
74
|
+
draggableTip: ''
|
75
|
+
}
|
76
|
+
]
|
77
|
+
},
|
78
|
+
{
|
79
|
+
title: '外观',
|
80
|
+
body: [
|
81
|
+
{
|
82
|
+
name: 'tabsMode',
|
83
|
+
label: '样式',
|
84
|
+
type: 'select',
|
85
|
+
className: 'block',
|
86
|
+
pipeIn: defaultValue(''),
|
87
|
+
options: [
|
88
|
+
{
|
89
|
+
label: '默认',
|
90
|
+
value: ''
|
91
|
+
},
|
92
|
+
{
|
93
|
+
label: '线型',
|
94
|
+
value: 'line'
|
95
|
+
},
|
96
|
+
{
|
97
|
+
label: '卡片',
|
98
|
+
value: 'card'
|
99
|
+
},
|
100
|
+
{
|
101
|
+
label: '仿 Chrome',
|
102
|
+
value: 'chrome'
|
103
|
+
},
|
104
|
+
{
|
105
|
+
label: '水平铺满',
|
106
|
+
value: 'tiled'
|
107
|
+
},
|
108
|
+
{
|
109
|
+
label: '选择器',
|
110
|
+
value: 'radio'
|
111
|
+
},
|
112
|
+
{
|
113
|
+
label: '垂直',
|
114
|
+
value: 'vertical'
|
115
|
+
}
|
116
|
+
]
|
117
|
+
},
|
118
|
+
getSchemaTpl('className'),
|
119
|
+
getSchemaTpl('className', {
|
120
|
+
name: 'contentClassName',
|
121
|
+
label: '选项卡成员 CSS 类名'
|
122
|
+
}),
|
123
|
+
|
124
|
+
getSchemaTpl('subFormItemMode'),
|
125
|
+
getSchemaTpl('subFormHorizontalMode'),
|
126
|
+
getSchemaTpl('subFormHorizontal')
|
127
|
+
]
|
128
|
+
},
|
129
|
+
{
|
130
|
+
title: '显隐',
|
131
|
+
body: [
|
132
|
+
{
|
133
|
+
type: 'switch',
|
134
|
+
name: 'mountOnEnter',
|
135
|
+
label: '激活时才渲染',
|
136
|
+
mode: 'inline',
|
137
|
+
className: 'block',
|
138
|
+
description:
|
139
|
+
'设置后选项卡的内容只有点开才会渲染,如果有选项卡放的可拉取接口的组件,那么这个接口只有在点开的时候才会拉取。'
|
140
|
+
},
|
141
|
+
|
142
|
+
{
|
143
|
+
type: 'switch',
|
144
|
+
name: 'unmountOnExit',
|
145
|
+
label: '隐藏即销毁',
|
146
|
+
mode: 'inline',
|
147
|
+
className: 'block',
|
148
|
+
description:
|
149
|
+
'设置后,如果选项卡内容关闭则销毁,配置「激活时才渲染」选项可以做到卡片内容每次点开都重新加载的效果。'
|
150
|
+
},
|
151
|
+
getSchemaTpl('visible')
|
152
|
+
]
|
153
|
+
}
|
154
|
+
])
|
155
|
+
];
|
156
|
+
|
157
|
+
patchContainers = ['tabs.body'];
|
158
|
+
|
159
|
+
vRendererConfig: VRendererConfig = {
|
160
|
+
regions: {
|
161
|
+
body: {
|
162
|
+
key: 'body',
|
163
|
+
label: '内容区'
|
164
|
+
}
|
165
|
+
},
|
166
|
+
panelTitle: '卡片',
|
167
|
+
panelBody: [
|
168
|
+
getSchemaTpl('tabs', [
|
169
|
+
{
|
170
|
+
title: '常规',
|
171
|
+
body: [
|
172
|
+
{
|
173
|
+
name: 'title',
|
174
|
+
label: '标题',
|
175
|
+
type: 'input-text',
|
176
|
+
required: true
|
177
|
+
},
|
178
|
+
getSchemaTpl('icon'),
|
179
|
+
{
|
180
|
+
label: 'Hash',
|
181
|
+
name: 'hash',
|
182
|
+
type: 'input-text',
|
183
|
+
description: '设置后,会同步更新地址栏的 Hash。'
|
184
|
+
}
|
185
|
+
]
|
186
|
+
},
|
187
|
+
{
|
188
|
+
title: '外观',
|
189
|
+
body: [getSchemaTpl('className')]
|
190
|
+
},
|
191
|
+
{
|
192
|
+
title: '显隐',
|
193
|
+
body: [getSchemaTpl('visible'), getSchemaTpl('disabled')]
|
194
|
+
},
|
195
|
+
{
|
196
|
+
title: '其他',
|
197
|
+
body: [
|
198
|
+
{
|
199
|
+
type: 'switch',
|
200
|
+
name: 'reload',
|
201
|
+
label: '内容刷新',
|
202
|
+
mode: 'inline',
|
203
|
+
className: 'block',
|
204
|
+
description:
|
205
|
+
'配置后,每次点开内容都会重新刷新,如果配置了,下面两个选项就不用配置了。'
|
206
|
+
},
|
207
|
+
{
|
208
|
+
type: 'switch',
|
209
|
+
name: 'mountOnEnter',
|
210
|
+
visibleOn: '!this.reload',
|
211
|
+
label: '激活时才渲染',
|
212
|
+
mode: 'inline',
|
213
|
+
className: 'block',
|
214
|
+
description:
|
215
|
+
'设置后选项卡的内容只有点开才会渲染,如果有选项卡放的可拉取接口的组件,那么这个接口只有在点开的时候才会拉取。'
|
216
|
+
},
|
217
|
+
{
|
218
|
+
visibleOn: '!this.reload',
|
219
|
+
type: 'switch',
|
220
|
+
name: 'unmountOnExit',
|
221
|
+
label: '隐藏即销毁',
|
222
|
+
mode: 'inline',
|
223
|
+
className: 'block',
|
224
|
+
description:
|
225
|
+
'设置后,如果选项卡内容关闭则销毁,配置「激活时才渲染」选项可以做到卡片内容每次点开都重新加载的效果。'
|
226
|
+
}
|
227
|
+
]
|
228
|
+
}
|
229
|
+
])
|
230
|
+
]
|
231
|
+
};
|
232
|
+
|
233
|
+
wrapperProps = {
|
234
|
+
unmountOnExit: true,
|
235
|
+
mountOnEnter: true
|
236
|
+
};
|
237
|
+
|
238
|
+
tabWrapperResolve = (dom: HTMLElement) => dom.parentElement!;
|
239
|
+
overrides = {
|
240
|
+
renderTabs(this: any) {
|
241
|
+
const dom = this.super();
|
242
|
+
|
243
|
+
if (!this.renderTab && this.props.$$editor && dom) {
|
244
|
+
const tabs = this.props.tabs;
|
245
|
+
return mapReactElement(dom, item => {
|
246
|
+
if (item.type === Tab && item.props.$$id) {
|
247
|
+
const id = item.props.$$id;
|
248
|
+
const index = findIndex(tabs, (tab: any) => tab.$$id === id);
|
249
|
+
const info: RendererInfo = this.props.$$editor;
|
250
|
+
const plugin: TabsPlugin = info.plugin as any;
|
251
|
+
|
252
|
+
if (~index) {
|
253
|
+
const region = plugin.vRendererConfig?.regions?.body;
|
254
|
+
|
255
|
+
if (!region) {
|
256
|
+
return item;
|
257
|
+
}
|
258
|
+
|
259
|
+
return React.cloneElement(item, {
|
260
|
+
children: (
|
261
|
+
<VRenderer
|
262
|
+
key={id}
|
263
|
+
plugin={info.plugin}
|
264
|
+
renderer={info.renderer}
|
265
|
+
$schema="/schemas/TabSchema.json"
|
266
|
+
hostId={info.id}
|
267
|
+
memberIndex={index}
|
268
|
+
name={`${item.props.title || `卡片${index + 1}`}`}
|
269
|
+
id={id}
|
270
|
+
draggable={false}
|
271
|
+
wrapperResolve={plugin.tabWrapperResolve}
|
272
|
+
schemaPath={`${info.schemaPath}/tabs/${index}`}
|
273
|
+
path={`${this.props.$path}/${index}`} // 好像没啥用
|
274
|
+
data={this.props.data} // 好像没啥用
|
275
|
+
>
|
276
|
+
<Region
|
277
|
+
key={region.key}
|
278
|
+
preferTag={region.preferTag}
|
279
|
+
name={region.key}
|
280
|
+
label={region.label}
|
281
|
+
regionConfig={region}
|
282
|
+
placeholder={region.placeholder}
|
283
|
+
editorStore={plugin.manager.store}
|
284
|
+
manager={plugin.manager}
|
285
|
+
children={item.props.children}
|
286
|
+
wrapperResolve={region.wrapperResolve}
|
287
|
+
rendererName={info.renderer.name}
|
288
|
+
/>
|
289
|
+
</VRenderer>
|
290
|
+
)
|
291
|
+
});
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
return item;
|
296
|
+
});
|
297
|
+
}
|
298
|
+
|
299
|
+
return dom;
|
300
|
+
}
|
301
|
+
};
|
302
|
+
|
303
|
+
/**
|
304
|
+
* 补充切换的 toolbar
|
305
|
+
* @param context
|
306
|
+
* @param toolbars
|
307
|
+
*/
|
308
|
+
buildEditorToolbar(
|
309
|
+
context: BaseEventContext,
|
310
|
+
toolbars: Array<BasicToolbarItem>
|
311
|
+
) {
|
312
|
+
if (
|
313
|
+
context.info.plugin === this &&
|
314
|
+
context.info.renderer.name === 'tabs' &&
|
315
|
+
!context.info.hostId
|
316
|
+
) {
|
317
|
+
const node = context.node;
|
318
|
+
|
319
|
+
toolbars.push({
|
320
|
+
level: 'secondary',
|
321
|
+
icon: 'fa fa-chevron-left',
|
322
|
+
tooltip: '上个卡片',
|
323
|
+
onClick: () => {
|
324
|
+
const control = node.getComponent();
|
325
|
+
|
326
|
+
if (control?.switchTo) {
|
327
|
+
const currentIndex = control.currentIndex();
|
328
|
+
control.switchTo(currentIndex - 1);
|
329
|
+
}
|
330
|
+
}
|
331
|
+
});
|
332
|
+
|
333
|
+
toolbars.push({
|
334
|
+
level: 'secondary',
|
335
|
+
icon: 'fa fa-chevron-right',
|
336
|
+
tooltip: '下个卡片',
|
337
|
+
onClick: () => {
|
338
|
+
const control = node.getComponent();
|
339
|
+
|
340
|
+
if (control?.switchTo) {
|
341
|
+
const currentIndex = control.currentIndex();
|
342
|
+
control.switchTo(currentIndex + 1);
|
343
|
+
}
|
344
|
+
}
|
345
|
+
});
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
onPreventClick(e: PluginEvent<PreventClickEventContext>) {
|
350
|
+
const mouseEvent = e.context.data;
|
351
|
+
|
352
|
+
if (mouseEvent.defaultPrevented) {
|
353
|
+
return false;
|
354
|
+
} else if (
|
355
|
+
(mouseEvent.target as HTMLElement).closest('[role=tablist]>li')
|
356
|
+
) {
|
357
|
+
return false;
|
358
|
+
}
|
359
|
+
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
registerEditorPlugin(TabsPlugin);
|
@@ -0,0 +1,276 @@
|
|
1
|
+
import {Button, SchemaObject} from 'amis';
|
2
|
+
import React from 'react';
|
3
|
+
import {registerEditorPlugin} from '../manager';
|
4
|
+
import {BasePlugin, RegionConfig, RendererInfo} from '../plugin';
|
5
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
6
|
+
|
7
|
+
export class TasksPlugin extends BasePlugin {
|
8
|
+
// 关联渲染器名字
|
9
|
+
rendererName = 'tasks';
|
10
|
+
$schema = '/schemas/TasksSchema.json';
|
11
|
+
|
12
|
+
// 组件名称
|
13
|
+
name = '异步任务';
|
14
|
+
isBaseComponent = true;
|
15
|
+
description = '用来做异步任务呈现或者操作。';
|
16
|
+
docLink = '/amis/zh-CN/components/tasks';
|
17
|
+
tags = ['功能'];
|
18
|
+
icon = '';
|
19
|
+
scaffold = {
|
20
|
+
type: 'tasks',
|
21
|
+
name: 'tasks',
|
22
|
+
items: [
|
23
|
+
{
|
24
|
+
label: 'hive 任务',
|
25
|
+
key: 'hive',
|
26
|
+
status: 4,
|
27
|
+
remark:
|
28
|
+
'查看详情<a target="_blank" href="http://www.baidu.com">日志</a>。'
|
29
|
+
},
|
30
|
+
{
|
31
|
+
label: '小流量',
|
32
|
+
key: 'partial',
|
33
|
+
status: 4
|
34
|
+
},
|
35
|
+
{
|
36
|
+
label: '全量',
|
37
|
+
key: 'full',
|
38
|
+
status: 4
|
39
|
+
}
|
40
|
+
]
|
41
|
+
};
|
42
|
+
previewSchema = {
|
43
|
+
...this.scaffold
|
44
|
+
};
|
45
|
+
|
46
|
+
panelTitle = '异步任务';
|
47
|
+
panelBody = [
|
48
|
+
getSchemaTpl('tabs', [
|
49
|
+
{
|
50
|
+
title: '常规',
|
51
|
+
body: [
|
52
|
+
{
|
53
|
+
name: 'items',
|
54
|
+
label: '初始任务信息',
|
55
|
+
type: 'combo',
|
56
|
+
multiple: true,
|
57
|
+
multiLine: true,
|
58
|
+
items: [
|
59
|
+
{
|
60
|
+
name: 'label',
|
61
|
+
type: 'input-text',
|
62
|
+
label: '任务名称'
|
63
|
+
},
|
64
|
+
{
|
65
|
+
name: 'key',
|
66
|
+
type: 'input-text',
|
67
|
+
label: '任务ID'
|
68
|
+
},
|
69
|
+
{
|
70
|
+
name: 'status',
|
71
|
+
type: 'input-number',
|
72
|
+
label: '任务状态'
|
73
|
+
},
|
74
|
+
{
|
75
|
+
name: 'remark',
|
76
|
+
type: 'textarea',
|
77
|
+
label: '任务说明'
|
78
|
+
}
|
79
|
+
],
|
80
|
+
addButtonText: '新增任务信息',
|
81
|
+
scaffold: {
|
82
|
+
label: '名称',
|
83
|
+
key: 'key',
|
84
|
+
status: 0,
|
85
|
+
remark: '说明'
|
86
|
+
},
|
87
|
+
description: '可以不设置,如果检测接口返回这些信息的话。'
|
88
|
+
},
|
89
|
+
|
90
|
+
getSchemaTpl('api', {
|
91
|
+
name: 'checkApi',
|
92
|
+
label: '状态检测接口'
|
93
|
+
}),
|
94
|
+
|
95
|
+
{
|
96
|
+
name: 'interval',
|
97
|
+
type: 'input-number',
|
98
|
+
min: 3000,
|
99
|
+
step: 500,
|
100
|
+
visibleOn: 'data.checkApi',
|
101
|
+
pipeIn: defaultValue(3000),
|
102
|
+
label: '定时检测间隔'
|
103
|
+
},
|
104
|
+
|
105
|
+
getSchemaTpl('api', {
|
106
|
+
name: 'submitApi',
|
107
|
+
label: '提交接口'
|
108
|
+
}),
|
109
|
+
|
110
|
+
getSchemaTpl('api', {
|
111
|
+
name: 'reSubmitApi',
|
112
|
+
label: '重试接口'
|
113
|
+
}),
|
114
|
+
|
115
|
+
{
|
116
|
+
name: 'taskNameLabel',
|
117
|
+
type: 'input-text',
|
118
|
+
pipeIn: defaultValue('任务名称'),
|
119
|
+
label: '任务名称栏标题'
|
120
|
+
},
|
121
|
+
|
122
|
+
{
|
123
|
+
name: 'operationLabel',
|
124
|
+
type: 'input-text',
|
125
|
+
pipeIn: defaultValue('操作'),
|
126
|
+
label: '操作栏标题'
|
127
|
+
},
|
128
|
+
|
129
|
+
{
|
130
|
+
name: 'statusLabel',
|
131
|
+
type: 'input-text',
|
132
|
+
pipeIn: defaultValue('状态'),
|
133
|
+
label: '状态栏标题'
|
134
|
+
},
|
135
|
+
|
136
|
+
{
|
137
|
+
name: 'remarkLabel',
|
138
|
+
type: 'input-text',
|
139
|
+
pipeIn: defaultValue('备注说明'),
|
140
|
+
label: '备注栏标题'
|
141
|
+
},
|
142
|
+
|
143
|
+
{
|
144
|
+
name: 'btnText',
|
145
|
+
label: '按钮名称',
|
146
|
+
type: 'input-text',
|
147
|
+
pipeIn: defaultValue('上线')
|
148
|
+
},
|
149
|
+
|
150
|
+
{
|
151
|
+
name: 'retryBtnText',
|
152
|
+
label: '重试按钮名称',
|
153
|
+
type: 'input-text',
|
154
|
+
pipeIn: defaultValue('重试')
|
155
|
+
},
|
156
|
+
|
157
|
+
{
|
158
|
+
name: 'statusTextMap',
|
159
|
+
pipeIn: defaultValue([
|
160
|
+
'未开始',
|
161
|
+
'就绪',
|
162
|
+
'进行中',
|
163
|
+
'出错',
|
164
|
+
'已完成',
|
165
|
+
'出错'
|
166
|
+
]),
|
167
|
+
type: 'input-array',
|
168
|
+
label: '状态标签文字配置',
|
169
|
+
multiple: true,
|
170
|
+
addable: false,
|
171
|
+
removable: false,
|
172
|
+
items: {
|
173
|
+
type: 'input-text',
|
174
|
+
placeholder: '名称'
|
175
|
+
}
|
176
|
+
},
|
177
|
+
|
178
|
+
{
|
179
|
+
name: 'initialStatusCode',
|
180
|
+
label: '初始状态码',
|
181
|
+
pipeIn: defaultValue(0),
|
182
|
+
type: 'input-number'
|
183
|
+
},
|
184
|
+
|
185
|
+
{
|
186
|
+
name: 'readyStatusCode',
|
187
|
+
label: '就绪状态码',
|
188
|
+
pipeIn: defaultValue(1),
|
189
|
+
type: 'input-number'
|
190
|
+
},
|
191
|
+
|
192
|
+
{
|
193
|
+
name: 'loadingStatusCode',
|
194
|
+
label: '进行中状态码',
|
195
|
+
pipeIn: defaultValue(2),
|
196
|
+
type: 'input-number'
|
197
|
+
},
|
198
|
+
|
199
|
+
{
|
200
|
+
name: 'errorStatusCode',
|
201
|
+
label: '错误状态码',
|
202
|
+
pipeIn: defaultValue(3),
|
203
|
+
type: 'input-number'
|
204
|
+
},
|
205
|
+
|
206
|
+
{
|
207
|
+
name: 'finishStatusCode',
|
208
|
+
label: '完成状态码',
|
209
|
+
pipeIn: defaultValue(4),
|
210
|
+
type: 'input-number'
|
211
|
+
},
|
212
|
+
|
213
|
+
{
|
214
|
+
name: 'canRetryStatusCode',
|
215
|
+
label: '出错但可重试状态码',
|
216
|
+
pipeIn: defaultValue(5),
|
217
|
+
type: 'input-number'
|
218
|
+
}
|
219
|
+
]
|
220
|
+
},
|
221
|
+
{
|
222
|
+
title: '外观',
|
223
|
+
body: [
|
224
|
+
getSchemaTpl('className', {
|
225
|
+
pipeIn: defaultValue('b-a bg-white table-responsive')
|
226
|
+
}),
|
227
|
+
|
228
|
+
getSchemaTpl('className', {
|
229
|
+
name: 'tableClassName',
|
230
|
+
label: '表格 CSS 类名',
|
231
|
+
pipeIn: defaultValue('table table-striped m-b-none')
|
232
|
+
}),
|
233
|
+
|
234
|
+
getSchemaTpl('className', {
|
235
|
+
name: 'btnClassName',
|
236
|
+
label: '按钮 CSS 类名',
|
237
|
+
pipeIn: defaultValue('btn-sm btn-default')
|
238
|
+
}),
|
239
|
+
|
240
|
+
getSchemaTpl('className', {
|
241
|
+
name: 'retryBtnClassName',
|
242
|
+
label: '重试按钮 CSS 类名',
|
243
|
+
pipeIn: defaultValue('btn-sm btn-danger')
|
244
|
+
}),
|
245
|
+
|
246
|
+
{
|
247
|
+
name: 'statusLabelMap',
|
248
|
+
pipeIn: defaultValue([
|
249
|
+
'label-warning',
|
250
|
+
'label-info',
|
251
|
+
'label-info',
|
252
|
+
'label-danger',
|
253
|
+
'label-success',
|
254
|
+
'label-danger'
|
255
|
+
]),
|
256
|
+
type: 'input-array',
|
257
|
+
label: '状态标签 CSS 类名配置',
|
258
|
+
multiple: true,
|
259
|
+
addable: false,
|
260
|
+
removable: false,
|
261
|
+
items: {
|
262
|
+
type: 'input-text',
|
263
|
+
placeholder: 'CSS 类名'
|
264
|
+
}
|
265
|
+
}
|
266
|
+
]
|
267
|
+
},
|
268
|
+
{
|
269
|
+
title: '显隐',
|
270
|
+
body: [getSchemaTpl('visible')]
|
271
|
+
}
|
272
|
+
])
|
273
|
+
];
|
274
|
+
}
|
275
|
+
|
276
|
+
registerEditorPlugin(TasksPlugin);
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import {Button, SchemaObject} from 'amis';
|
2
|
+
import React from 'react';
|
3
|
+
import {registerEditorPlugin} from '../manager';
|
4
|
+
import {
|
5
|
+
BaseEventContext,
|
6
|
+
BasePlugin,
|
7
|
+
RegionConfig,
|
8
|
+
RendererInfo
|
9
|
+
} from '../plugin';
|
10
|
+
import {defaultValue, getSchemaTpl} from '../component/schemaTpl';
|
11
|
+
import {DatePlugin} from './Date';
|
12
|
+
|
13
|
+
export class TimePlugin extends DatePlugin {
|
14
|
+
// 关联渲染器名字
|
15
|
+
rendererName = 'time';
|
16
|
+
name = '时间展示';
|
17
|
+
isBaseComponent = true;
|
18
|
+
|
19
|
+
scaffold = {
|
20
|
+
type: 'time',
|
21
|
+
value: Math.round(Date.now() / 1000)
|
22
|
+
};
|
23
|
+
|
24
|
+
previewSchema = {
|
25
|
+
...this.scaffold,
|
26
|
+
format: 'HH:mm:ss',
|
27
|
+
value: Math.round(Date.now() / 1000)
|
28
|
+
};
|
29
|
+
panelBodyCreator = (context: BaseEventContext) => {
|
30
|
+
return [
|
31
|
+
getSchemaTpl('tabs', [
|
32
|
+
{
|
33
|
+
title: '常规',
|
34
|
+
body: [
|
35
|
+
{
|
36
|
+
type: 'input-time',
|
37
|
+
name: 'value',
|
38
|
+
label: '时间数值'
|
39
|
+
},
|
40
|
+
{
|
41
|
+
type: 'input-text',
|
42
|
+
name: 'format',
|
43
|
+
label: '显示时间格式',
|
44
|
+
description: '请参考 moment 中的格式用法。',
|
45
|
+
pipeIn: defaultValue('HH:mm:ss')
|
46
|
+
},
|
47
|
+
{
|
48
|
+
type: 'input-text',
|
49
|
+
name: 'valueFormat',
|
50
|
+
label: '数据日期格式',
|
51
|
+
description: '请参考 moment 中的格式用法。',
|
52
|
+
pipeIn: defaultValue('X')
|
53
|
+
},
|
54
|
+
{
|
55
|
+
name: 'placeholder',
|
56
|
+
type: 'input-text',
|
57
|
+
pipeIn: defaultValue('-'),
|
58
|
+
label: '占位符'
|
59
|
+
}
|
60
|
+
]
|
61
|
+
},
|
62
|
+
{
|
63
|
+
title: '外观',
|
64
|
+
body: [getSchemaTpl('className')]
|
65
|
+
},
|
66
|
+
{
|
67
|
+
title: '显隐',
|
68
|
+
body: [getSchemaTpl('ref'), getSchemaTpl('visible')]
|
69
|
+
}
|
70
|
+
])
|
71
|
+
];
|
72
|
+
};
|
73
|
+
}
|
74
|
+
|
75
|
+
registerEditorPlugin(TimePlugin);
|