amis 1.3.5-beta.7 → 1.4.0
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/lib/components/Badge.d.ts +13 -1
- package/lib/components/Badge.js +16 -2
- package/lib/components/Badge.js.map +2 -2
- package/lib/components/Checkbox.d.ts +1 -1
- package/lib/components/Checkbox.js +1 -1
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/Drawer.js +1 -1
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/Modal.js +1 -1
- package/lib/components/Modal.js.map +2 -2
- package/lib/components/Select.d.ts +7 -0
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Steps.d.ts +3 -3
- package/lib/components/Steps.js.map +1 -1
- package/lib/components/WithRemoteConfig.d.ts +8 -0
- package/lib/components/WithRemoteConfig.js +28 -2
- package/lib/components/WithRemoteConfig.js.map +2 -2
- package/lib/components/condition-builder/Field.js +0 -1
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Value.js +2 -1
- package/lib/components/condition-builder/Value.js.map +2 -2
- package/lib/components/condition-builder/types.d.ts +5 -0
- package/lib/components/condition-builder/types.js.map +1 -1
- package/lib/factory.d.ts +5 -1
- package/lib/factory.js +9 -4
- package/lib/factory.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +1 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +2 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +2 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/CRUD.js +5 -15
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Collapse.d.ts +1 -1
- package/lib/renderers/Collapse.js +5 -1
- package/lib/renderers/Collapse.js.map +2 -2
- package/lib/renderers/Dialog.d.ts +0 -252
- package/lib/renderers/Dialog.js +1 -1
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/DropDownButton.d.ts +4 -0
- package/lib/renderers/DropDownButton.js +2 -2
- package/lib/renderers/DropDownButton.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +0 -2
- package/lib/renderers/Form/Editor.d.ts +0 -2
- package/lib/renderers/Form/Editor.js +1 -1
- package/lib/renderers/Form/Editor.js.map +2 -2
- package/lib/renderers/Form/InputExcel.d.ts +5 -0
- package/lib/renderers/Form/InputExcel.js +24 -3
- package/lib/renderers/Form/InputExcel.js.map +2 -2
- package/lib/renderers/Form/InputImage.d.ts +8 -0
- package/lib/renderers/Form/InputImage.js +2 -1
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputTable.d.ts +23 -5
- package/lib/renderers/Form/InputTable.js +32 -3
- package/lib/renderers/Form/InputTable.js.map +2 -2
- package/lib/renderers/Json.js +5 -1
- package/lib/renderers/Json.js.map +2 -2
- package/lib/renderers/Page.js +3 -0
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.d.ts +10 -1
- package/lib/renderers/Service.js +85 -3
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Steps.d.ts +4 -4
- package/lib/renderers/Steps.js +5 -2
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table/TableBody.d.ts +1 -1
- package/lib/renderers/Table/TableBody.js.map +1 -1
- package/lib/renderers/Table/TableContent.d.ts +1 -1
- package/lib/renderers/Table/TableContent.js.map +1 -1
- package/lib/renderers/Table/index.d.ts +8 -3
- package/lib/renderers/Table/index.js +80 -45
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/store/app.d.ts +0 -1
- package/lib/store/combo.d.ts +0 -2
- package/lib/store/crud.d.ts +0 -1
- package/lib/store/form.d.ts +0 -1
- package/lib/store/modal.d.ts +1 -1
- package/lib/store/modal.js +4 -0
- package/lib/store/modal.js.map +2 -2
- package/lib/store/root.d.ts +0 -1
- package/lib/store/service.d.ts +0 -1
- package/lib/store/service.js +0 -13
- package/lib/store/service.js.map +2 -2
- package/lib/store/table.d.ts +1 -2
- package/lib/store/table.js +44 -3
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +247 -3
- package/lib/themes/ang.css +247 -3
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +247 -3
- package/lib/themes/antd.css +247 -3
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +247 -3
- package/lib/themes/cxd.css +247 -3
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +247 -3
- package/lib/themes/dark.css +247 -3
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +247 -3
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/api.js +12 -0
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/attachmentAdpator.d.ts +7 -0
- package/lib/utils/attachmentAdpator.js +82 -0
- package/lib/utils/attachmentAdpator.js.map +13 -0
- package/lib/utils/validations.js +62 -5
- package/lib/utils/validations.js.map +2 -2
- package/package.json +1 -1
- package/schema.json +150 -36
- package/scss/_properties.scss +4 -0
- package/scss/components/_badge.scss +15 -1
- package/scss/components/_markdown.scss +266 -0
- package/scss/components/_spinner.scss +6 -2
- package/scss/components/form/_group.scss +4 -0
- package/scss/themes/_common.scss +1 -0
- package/sdk/ang-ie11.css +292 -3
- package/sdk/ang.css +296 -3
- package/sdk/antd-ie11.css +292 -3
- package/sdk/antd.css +296 -3
- package/sdk/charts.js +13 -13
- package/sdk/color-picker.js +65 -69
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +292 -3
- package/sdk/cxd.css +296 -3
- package/sdk/dark-ie11.css +292 -3
- package/sdk/dark.css +296 -3
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +1 -0
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +27 -23
- package/sdk/rich-text.js +63 -63
- package/sdk/sdk-ie11.css +292 -3
- package/sdk/sdk.css +296 -3
- package/sdk/sdk.js +1144 -1142
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/components/Badge.tsx +41 -6
- package/src/components/Checkbox.tsx +5 -2
- package/src/components/Drawer.tsx +3 -2
- package/src/components/Modal.tsx +3 -2
- package/src/components/Select.tsx +1 -0
- package/src/components/Steps.tsx +3 -3
- package/src/components/WithRemoteConfig.tsx +37 -2
- package/src/components/condition-builder/Field.tsx +1 -2
- package/src/components/condition-builder/Value.tsx +3 -0
- package/src/components/condition-builder/types.ts +6 -0
- package/src/factory.tsx +13 -3
- package/src/locale/de-DE.ts +1 -0
- package/src/locale/en-US.ts +2 -1
- package/src/locale/zh-CN.ts +2 -1
- package/src/renderers/CRUD.tsx +7 -28
- package/src/renderers/Collapse.tsx +5 -1
- package/src/renderers/Dialog.tsx +1 -1
- package/src/renderers/DropDownButton.tsx +8 -0
- package/src/renderers/Form/Editor.tsx +19 -20
- package/src/renderers/Form/InputExcel.tsx +28 -3
- package/src/renderers/Form/InputImage.tsx +23 -8
- package/src/renderers/Form/InputTable.tsx +88 -9
- package/src/renderers/Json.tsx +10 -1
- package/src/renderers/Page.tsx +2 -0
- package/src/renderers/Service.tsx +101 -3
- package/src/renderers/Steps.tsx +12 -9
- package/src/renderers/Table/TableBody.tsx +1 -1
- package/src/renderers/Table/TableContent.tsx +1 -1
- package/src/renderers/Table/index.tsx +61 -13
- package/src/store/modal.ts +4 -0
- package/src/store/service.ts +0 -19
- package/src/store/table.ts +48 -0
- package/src/utils/api.ts +11 -0
- package/src/utils/attachmentAdpator.ts +90 -0
- package/src/utils/validations.ts +80 -12
@@ -110,6 +110,16 @@ export interface ImageControlSchema extends FormBaseControl {
|
|
110
110
|
scalable?: boolean;
|
111
111
|
};
|
112
112
|
|
113
|
+
/**
|
114
|
+
* 裁剪后的图片类型
|
115
|
+
*/
|
116
|
+
cropFormat?: string;
|
117
|
+
|
118
|
+
/**
|
119
|
+
* 裁剪后的质量
|
120
|
+
*/
|
121
|
+
cropQuality?: number;
|
122
|
+
|
113
123
|
/**
|
114
124
|
* 是否允许二次裁剪。
|
115
125
|
*/
|
@@ -862,14 +872,19 @@ export default class ImageControl extends React.Component<
|
|
862
872
|
}
|
863
873
|
|
864
874
|
handleCrop() {
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
875
|
+
const {cropFormat, cropQuality} = this.props;
|
876
|
+
this.cropper.getCroppedCanvas().toBlob(
|
877
|
+
(file: File) => {
|
878
|
+
this.addFiles([file]);
|
879
|
+
this.setState({
|
880
|
+
cropFile: undefined,
|
881
|
+
locked: false,
|
882
|
+
lockedReason: ''
|
883
|
+
});
|
884
|
+
},
|
885
|
+
cropFormat || 'image/png',
|
886
|
+
cropQuality || 1
|
887
|
+
);
|
873
888
|
}
|
874
889
|
|
875
890
|
cancelCrop() {
|
@@ -30,6 +30,26 @@ export interface TableControlSchema
|
|
30
30
|
*/
|
31
31
|
addable?: boolean;
|
32
32
|
|
33
|
+
/**
|
34
|
+
* 可复制新增
|
35
|
+
*/
|
36
|
+
copyable?: boolean;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* 复制按钮文字
|
40
|
+
*/
|
41
|
+
copyBtnLabel?: string;
|
42
|
+
|
43
|
+
/**
|
44
|
+
* 复制按钮图标
|
45
|
+
*/
|
46
|
+
copyBtnIcon?: string;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* 是否显示复制按钮
|
50
|
+
*/
|
51
|
+
copyAddBtn?: boolean;
|
52
|
+
|
33
53
|
/**
|
34
54
|
* 是否可以拖拽排序
|
35
55
|
*/
|
@@ -41,12 +61,12 @@ export interface TableControlSchema
|
|
41
61
|
addApi?: SchemaApi;
|
42
62
|
|
43
63
|
/**
|
44
|
-
*
|
64
|
+
* 新增按钮文字
|
45
65
|
*/
|
46
66
|
addBtnLabel?: string;
|
47
67
|
|
48
68
|
/**
|
49
|
-
*
|
69
|
+
* 新增按钮图标
|
50
70
|
*/
|
51
71
|
addBtnIcon?: string;
|
52
72
|
|
@@ -73,12 +93,12 @@ export interface TableControlSchema
|
|
73
93
|
/**
|
74
94
|
* 更新按钮名称
|
75
95
|
*/
|
76
|
-
|
96
|
+
editBtnLabel?: string;
|
77
97
|
|
78
98
|
/**
|
79
99
|
* 更新按钮图标
|
80
100
|
*/
|
81
|
-
|
101
|
+
editBtnIcon?: string;
|
82
102
|
|
83
103
|
/**
|
84
104
|
* 确认按钮文字
|
@@ -172,7 +192,8 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
|
172
192
|
placeholder: '空',
|
173
193
|
scaffold: {},
|
174
194
|
addBtnIcon: 'plus',
|
175
|
-
|
195
|
+
copyBtnIcon: 'copy',
|
196
|
+
editBtnIcon: 'pencil',
|
176
197
|
deleteBtnIcon: 'minus',
|
177
198
|
confirmBtnIcon: 'check',
|
178
199
|
cancelBtnIcon: 'close',
|
@@ -188,6 +209,7 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
|
188
209
|
'showAddBtn',
|
189
210
|
'addable',
|
190
211
|
'removable',
|
212
|
+
'copyable',
|
191
213
|
'editable',
|
192
214
|
'addApi',
|
193
215
|
'updateApi',
|
@@ -423,6 +445,26 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
|
423
445
|
return onAction && onAction(action, ctx, ...rest);
|
424
446
|
}
|
425
447
|
|
448
|
+
copyItem(index: number) {
|
449
|
+
const {needConfirm} = this.props;
|
450
|
+
const items = this.state.items.concat();
|
451
|
+
|
452
|
+
items.splice(index + 1, 0, items[index]);
|
453
|
+
index = Math.min(index + 1, items.length - 1);
|
454
|
+
this.setState(
|
455
|
+
{
|
456
|
+
items
|
457
|
+
},
|
458
|
+
() => {
|
459
|
+
if (needConfirm === false) {
|
460
|
+
this.emitValue();
|
461
|
+
} else {
|
462
|
+
this.startEdit(index, true);
|
463
|
+
}
|
464
|
+
}
|
465
|
+
);
|
466
|
+
}
|
467
|
+
|
426
468
|
addItem(index: number) {
|
427
469
|
const {needConfirm, scaffold, columns} = this.props;
|
428
470
|
const items = this.state.items.concat();
|
@@ -653,6 +695,38 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
|
653
695
|
});
|
654
696
|
}
|
655
697
|
|
698
|
+
if (props.copyable && props.showCopyBtn !== false) {
|
699
|
+
btns.push({
|
700
|
+
children: ({
|
701
|
+
key,
|
702
|
+
rowIndex,
|
703
|
+
offset
|
704
|
+
}: {
|
705
|
+
key: any;
|
706
|
+
rowIndex: number;
|
707
|
+
offset: number;
|
708
|
+
}) =>
|
709
|
+
~this.state.editIndex && needConfirm !== false ? null : (
|
710
|
+
<Button
|
711
|
+
classPrefix={ns}
|
712
|
+
size="sm"
|
713
|
+
key={key}
|
714
|
+
level="link"
|
715
|
+
tooltip={__('Table.copyRow')}
|
716
|
+
tooltipContainer={
|
717
|
+
env && env.getModalContainer ? env.getModalContainer : undefined
|
718
|
+
}
|
719
|
+
onClick={this.copyItem.bind(this, rowIndex + offset, undefined)}
|
720
|
+
>
|
721
|
+
{props.copyBtnLabel ? <span>{props.copyBtnLabel}</span> : null}
|
722
|
+
{props.copyBtnIcon ? (
|
723
|
+
<Icon icon={props.copyBtnIcon} className="icon" />
|
724
|
+
) : null}
|
725
|
+
</Button>
|
726
|
+
)
|
727
|
+
});
|
728
|
+
}
|
729
|
+
|
656
730
|
if (props.needConfirm === false) {
|
657
731
|
columns = columns.map(column => {
|
658
732
|
const quickEdit = column.quickEdit;
|
@@ -716,11 +790,16 @@ export default class FormTable extends React.Component<TableProps, TableState> {
|
|
716
790
|
}
|
717
791
|
onClick={() => this.startEdit(rowIndex + offset)}
|
718
792
|
>
|
719
|
-
{props.updateBtnLabel ? (
|
720
|
-
<span>{props.updateBtnLabel}</span>
|
793
|
+
{props.updateBtnLabel || props.editBtnLabel ? (
|
794
|
+
<span>{props.updateBtnLabel || props.editBtnLabel}</span>
|
721
795
|
) : null}
|
722
|
-
{
|
723
|
-
|
796
|
+
{/* 兼容之前的写法 */}
|
797
|
+
{typeof props.updateBtnIcon !== 'undefined' ? (
|
798
|
+
props.updateBtnIcon ? (
|
799
|
+
<Icon icon={props.updateBtnIcon} className="icon" />
|
800
|
+
) : null
|
801
|
+
) : props.editBtnIcon ? (
|
802
|
+
<Icon icon={props.editBtnIcon} className="icon" />
|
724
803
|
) : null}
|
725
804
|
</Button>
|
726
805
|
)
|
package/src/renderers/Json.tsx
CHANGED
@@ -97,6 +97,15 @@ export class JSONField extends React.Component<JSONProps, object> {
|
|
97
97
|
}
|
98
98
|
}
|
99
99
|
|
100
|
+
let jsonThemeValue = jsonTheme;
|
101
|
+
if (isPureVariable(jsonTheme)) {
|
102
|
+
jsonThemeValue = resolveVariableAndFilter(
|
103
|
+
jsonTheme,
|
104
|
+
this.props.data,
|
105
|
+
'| raw'
|
106
|
+
);
|
107
|
+
}
|
108
|
+
|
100
109
|
// JsonView 只支持对象,所以不是对象格式需要转成对象格式。
|
101
110
|
if (data && ~['string', 'number'].indexOf(typeof data)) {
|
102
111
|
data = {
|
@@ -112,7 +121,7 @@ export class JSONField extends React.Component<JSONProps, object> {
|
|
112
121
|
<JsonView
|
113
122
|
name={false}
|
114
123
|
src={data}
|
115
|
-
theme={(
|
124
|
+
theme={(jsonThemeValue as any) ?? 'rjv-default'}
|
116
125
|
shouldCollapse={this.shouldExpandNode}
|
117
126
|
enableClipboard={false}
|
118
127
|
iconStyle="square"
|
package/src/renderers/Page.tsx
CHANGED
@@ -371,6 +371,8 @@ export default class Page extends React.Component<PageProps> {
|
|
371
371
|
JSON.stringify(props.cssVars) !== JSON.stringify(prevProps.cssVars)
|
372
372
|
) {
|
373
373
|
this.updateVarStyle();
|
374
|
+
} else if (props.defaultData !== prevProps.defaultData) {
|
375
|
+
store.reInitData(props.defaultData);
|
374
376
|
}
|
375
377
|
}
|
376
378
|
|
@@ -7,7 +7,12 @@ import {filter, evalExpression} from '../utils/tpl';
|
|
7
7
|
import cx from 'classnames';
|
8
8
|
import Scoped, {ScopedContext, IScopedContext} from '../Scoped';
|
9
9
|
import {observer} from 'mobx-react';
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
buildApi,
|
12
|
+
isApiOutdated,
|
13
|
+
isEffectiveApi,
|
14
|
+
str2AsyncFunction
|
15
|
+
} from '../utils/api';
|
11
16
|
import {Spinner} from '../components';
|
12
17
|
import {autobind, isEmpty, isVisible, qsstringify} from '../utils/helper';
|
13
18
|
import {
|
@@ -40,6 +45,11 @@ export interface ServiceSchema extends BaseSchema {
|
|
40
45
|
*/
|
41
46
|
ws?: string;
|
42
47
|
|
48
|
+
/**
|
49
|
+
* 通过调用外部函数来获取数据
|
50
|
+
*/
|
51
|
+
dataProvider?: string | Function;
|
52
|
+
|
43
53
|
/**
|
44
54
|
* 内容区域
|
45
55
|
*/
|
@@ -111,6 +121,8 @@ export default class Service extends React.Component<ServiceProps> {
|
|
111
121
|
// 主要是用于关闭 socket
|
112
122
|
socket: any;
|
113
123
|
|
124
|
+
dataProviderUnsubscribe?: Function;
|
125
|
+
|
114
126
|
static defaultProps: Partial<ServiceProps> = {
|
115
127
|
messages: {
|
116
128
|
fetchFailed: 'fetchFailed'
|
@@ -130,6 +142,8 @@ export default class Service extends React.Component<ServiceProps> {
|
|
130
142
|
this.initInterval = this.initInterval.bind(this);
|
131
143
|
this.afterDataFetch = this.afterDataFetch.bind(this);
|
132
144
|
this.afterSchemaFetch = this.afterSchemaFetch.bind(this);
|
145
|
+
this.runDataProvider = this.runDataProvider.bind(this);
|
146
|
+
this.dataProviderSetData = this.dataProviderSetData.bind(this);
|
133
147
|
}
|
134
148
|
|
135
149
|
componentDidMount() {
|
@@ -168,12 +182,21 @@ export default class Service extends React.Component<ServiceProps> {
|
|
168
182
|
if (this.socket) {
|
169
183
|
this.socket.close();
|
170
184
|
}
|
171
|
-
this.socket =
|
185
|
+
this.socket = this.fetchWSData(props.ws, store.data);
|
186
|
+
}
|
187
|
+
|
188
|
+
if (props.defaultData !== prevProps.defaultData) {
|
189
|
+
store.reInitData(props.defaultData);
|
190
|
+
}
|
191
|
+
|
192
|
+
if (props.dataProvider !== prevProps.dataProvider) {
|
193
|
+
this.runDataProvider();
|
172
194
|
}
|
173
195
|
}
|
174
196
|
|
175
197
|
componentWillUnmount() {
|
176
198
|
this.mounted = false;
|
199
|
+
this.runDataProviderUnsubscribe();
|
177
200
|
clearTimeout(this.timer);
|
178
201
|
if (this.socket && this.socket.close) {
|
179
202
|
this.socket.close();
|
@@ -189,6 +212,7 @@ export default class Service extends React.Component<ServiceProps> {
|
|
189
212
|
ws,
|
190
213
|
initFetch,
|
191
214
|
initFetchOn,
|
215
|
+
dataProvider,
|
192
216
|
store,
|
193
217
|
messages: {fetchSuccess, fetchFailed}
|
194
218
|
} = this.props;
|
@@ -212,8 +236,82 @@ export default class Service extends React.Component<ServiceProps> {
|
|
212
236
|
}
|
213
237
|
|
214
238
|
if (ws) {
|
215
|
-
this.socket =
|
239
|
+
this.socket = this.fetchWSData(ws, store.data);
|
216
240
|
}
|
241
|
+
|
242
|
+
if (dataProvider) {
|
243
|
+
this.runDataProvider();
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
// 使用外部函数获取数据
|
248
|
+
async runDataProvider() {
|
249
|
+
this.runDataProviderUnsubscribe();
|
250
|
+
const {dataProvider, store} = this.props;
|
251
|
+
let dataProviderFunc = dataProvider;
|
252
|
+
|
253
|
+
if (typeof dataProvider === 'string' && dataProvider) {
|
254
|
+
dataProviderFunc = str2AsyncFunction(dataProvider, 'data', 'setData')!;
|
255
|
+
}
|
256
|
+
if (typeof dataProviderFunc === 'function') {
|
257
|
+
const unsubscribe = await dataProviderFunc(
|
258
|
+
store.data,
|
259
|
+
this.dataProviderSetData
|
260
|
+
);
|
261
|
+
if (typeof unsubscribe === 'function') {
|
262
|
+
this.dataProviderUnsubscribe = unsubscribe;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
// 运行销毁外部函数的方法
|
268
|
+
runDataProviderUnsubscribe() {
|
269
|
+
if (typeof this.dataProviderUnsubscribe === 'function') {
|
270
|
+
try {
|
271
|
+
this.dataProviderUnsubscribe();
|
272
|
+
} catch (error) {
|
273
|
+
console.error(error);
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
// 外部函数回调更新数据
|
279
|
+
dataProviderSetData(data: any) {
|
280
|
+
if (!this.mounted) {
|
281
|
+
return;
|
282
|
+
}
|
283
|
+
const {store} = this.props;
|
284
|
+
store.updateData(data, undefined, false);
|
285
|
+
store.setHasRemoteData();
|
286
|
+
}
|
287
|
+
|
288
|
+
// 使用 websocket 获取使用,因为有异步所以放这里而不是 store 实现
|
289
|
+
fetchWSData(ws: string | Api, data: any) {
|
290
|
+
const {env, store} = this.props;
|
291
|
+
const wsApi = buildApi(ws, data);
|
292
|
+
|
293
|
+
env.wsFetcher(
|
294
|
+
wsApi,
|
295
|
+
(data: any) => {
|
296
|
+
let returndata = data;
|
297
|
+
if ('status' in data && 'data' in data) {
|
298
|
+
returndata = data.data;
|
299
|
+
if (data.status !== 0) {
|
300
|
+
store.updateMessage(data.msg, true);
|
301
|
+
env.notify('error', data.msg);
|
302
|
+
return;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
store.updateData(returndata, undefined, false);
|
306
|
+
store.setHasRemoteData();
|
307
|
+
// 因为 WebSocket 只会获取纯数据,所以没有 msg 之类的
|
308
|
+
this.afterDataFetch({ok: true, data: returndata});
|
309
|
+
},
|
310
|
+
(error: any) => {
|
311
|
+
store.updateMessage(error, true);
|
312
|
+
env.notify('error', error);
|
313
|
+
}
|
314
|
+
);
|
217
315
|
}
|
218
316
|
|
219
317
|
afterDataFetch(result: any) {
|
package/src/renderers/Steps.tsx
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import {Renderer, RendererProps} from '../factory';
|
3
|
-
import {BaseSchema} from '../Schema';
|
3
|
+
import {BaseSchema, SchemaCollection} from '../Schema';
|
4
4
|
import Steps, {StepStatus} from '../components/Steps';
|
5
5
|
import {
|
6
6
|
RemoteOptionsProps,
|
@@ -14,12 +14,12 @@ export type StepSchema = {
|
|
14
14
|
/**
|
15
15
|
* 标题
|
16
16
|
*/
|
17
|
-
title: string;
|
17
|
+
title: string | SchemaCollection;
|
18
18
|
|
19
19
|
/**
|
20
20
|
* 子标题
|
21
21
|
*/
|
22
|
-
subTitle?: string;
|
22
|
+
subTitle?: string | SchemaCollection;
|
23
23
|
|
24
24
|
/**
|
25
25
|
* 图标
|
@@ -31,7 +31,7 @@ export type StepSchema = {
|
|
31
31
|
/**
|
32
32
|
* 描述
|
33
33
|
*/
|
34
|
-
description?: string;
|
34
|
+
description?: string | SchemaCollection;
|
35
35
|
} & Omit<BaseSchema, 'type'>;
|
36
36
|
|
37
37
|
export interface StepsSchema extends BaseSchema {
|
@@ -82,7 +82,8 @@ export function StepsCmpt(props: StepsProps) {
|
|
82
82
|
mode,
|
83
83
|
data,
|
84
84
|
source,
|
85
|
-
config
|
85
|
+
config,
|
86
|
+
render
|
86
87
|
} = props;
|
87
88
|
|
88
89
|
const stepsRow =
|
@@ -90,7 +91,9 @@ export function StepsCmpt(props: StepsProps) {
|
|
90
91
|
config ||
|
91
92
|
steps ||
|
92
93
|
[];
|
93
|
-
|
94
|
+
const resolveRender = (val?: string | SchemaCollection) => typeof val === 'string'
|
95
|
+
? filter(val, data)
|
96
|
+
: val && render('inner', val);
|
94
97
|
const value = getPropValue(props) ?? 0;
|
95
98
|
const resolveValue =
|
96
99
|
typeof value === 'string' && isNaN(+value)
|
@@ -105,9 +108,9 @@ export function StepsCmpt(props: StepsProps) {
|
|
105
108
|
return {
|
106
109
|
...step,
|
107
110
|
status: stepStatus,
|
108
|
-
title:
|
109
|
-
subTitle:
|
110
|
-
description:
|
111
|
+
title: resolveRender(step.title),
|
112
|
+
subTitle: resolveRender(step.subTitle),
|
113
|
+
description: resolveRender(step.description)
|
111
114
|
}
|
112
115
|
});
|
113
116
|
|
@@ -24,7 +24,7 @@ export interface TableBodyProps extends LocaleProps {
|
|
24
24
|
item: IRow,
|
25
25
|
props: any
|
26
26
|
) => React.ReactNode;
|
27
|
-
onCheck: (item: IRow) => void;
|
27
|
+
onCheck: (item: IRow, value: boolean, shift?: boolean) => void;
|
28
28
|
onQuickChange?: (
|
29
29
|
item: IRow,
|
30
30
|
values: object,
|
@@ -32,7 +32,7 @@ export interface TableContentProps extends LocaleProps {
|
|
32
32
|
item: IRow,
|
33
33
|
props: any
|
34
34
|
) => React.ReactNode;
|
35
|
-
onCheck: (item: IRow) => void;
|
35
|
+
onCheck: (item: IRow, value: boolean, shift?: boolean) => void;
|
36
36
|
onQuickChange?: (
|
37
37
|
item: IRow,
|
38
38
|
values: object,
|
@@ -35,6 +35,7 @@ import {HeadCellSearchDropDown} from './HeadCellSearchDropdown';
|
|
35
35
|
import {TableContent} from './TableContent';
|
36
36
|
import {
|
37
37
|
BaseSchema,
|
38
|
+
SchemaApi,
|
38
39
|
SchemaClassName,
|
39
40
|
SchemaObject,
|
40
41
|
SchemaTokenizeableString,
|
@@ -346,6 +347,12 @@ export interface TableProps extends RendererProps {
|
|
346
347
|
reUseRow?: boolean;
|
347
348
|
}
|
348
349
|
|
350
|
+
type ExportExcelToolbar = SchemaNode & {
|
351
|
+
api?: SchemaApi;
|
352
|
+
columns?: string[];
|
353
|
+
filename?: string;
|
354
|
+
};
|
355
|
+
|
349
356
|
/**
|
350
357
|
* 将 url 转成绝对地址
|
351
358
|
*/
|
@@ -682,8 +689,14 @@ export default class Table extends React.Component<TableProps, object> {
|
|
682
689
|
onAction(e, action, ctx);
|
683
690
|
}
|
684
691
|
|
685
|
-
handleCheck(item: IRow) {
|
686
|
-
|
692
|
+
handleCheck(item: IRow, value: boolean, shift?: boolean) {
|
693
|
+
const {store} = this.props;
|
694
|
+
if (shift) {
|
695
|
+
store.toggleShift(item);
|
696
|
+
} else {
|
697
|
+
item.toggle();
|
698
|
+
}
|
699
|
+
|
687
700
|
this.syncSelected();
|
688
701
|
}
|
689
702
|
|
@@ -2004,7 +2017,7 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2004
2017
|
);
|
2005
2018
|
}
|
2006
2019
|
|
2007
|
-
renderExportExcel(toolbar:
|
2020
|
+
renderExportExcel(toolbar: ExportExcelToolbar) {
|
2008
2021
|
const {
|
2009
2022
|
store,
|
2010
2023
|
env,
|
@@ -2028,8 +2041,8 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2028
2041
|
let tmpStore;
|
2029
2042
|
let filename = 'data';
|
2030
2043
|
// 支持配置 api 远程获取
|
2031
|
-
if (typeof toolbar === 'object' &&
|
2032
|
-
const res = await env.fetcher(
|
2044
|
+
if (typeof toolbar === 'object' && toolbar.api) {
|
2045
|
+
const res = await env.fetcher(toolbar.api, data);
|
2033
2046
|
if (!res.data) {
|
2034
2047
|
env.notify('warning', __('placeholder.noData'));
|
2035
2048
|
return;
|
@@ -2047,8 +2060,8 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2047
2060
|
rows = store.rows;
|
2048
2061
|
}
|
2049
2062
|
|
2050
|
-
if (typeof toolbar === 'object' &&
|
2051
|
-
filename = filter(
|
2063
|
+
if (typeof toolbar === 'object' && toolbar.filename) {
|
2064
|
+
filename = filter(toolbar.filename, data, '| raw');
|
2052
2065
|
}
|
2053
2066
|
|
2054
2067
|
if (rows.length === 0) {
|
@@ -2062,7 +2075,17 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2062
2075
|
});
|
2063
2076
|
worksheet.views = [{state: 'frozen', xSplit: 0, ySplit: 1}];
|
2064
2077
|
|
2065
|
-
const
|
2078
|
+
const filteredColumns = toolbar.columns
|
2079
|
+
? columns.filter(column => {
|
2080
|
+
const filterColumnsNames = toolbar.columns!;
|
2081
|
+
if (filterColumnsNames.indexOf(column.name) !== -1) {
|
2082
|
+
return true;
|
2083
|
+
}
|
2084
|
+
return false;
|
2085
|
+
})
|
2086
|
+
: columns;
|
2087
|
+
|
2088
|
+
const firstRowLabels = filteredColumns.map(column => {
|
2066
2089
|
return column.label;
|
2067
2090
|
});
|
2068
2091
|
const firstRow = worksheet.getRow(1);
|
@@ -2077,14 +2100,15 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2077
2100
|
column: firstRowLabels.length
|
2078
2101
|
}
|
2079
2102
|
};
|
2103
|
+
// 用于 mapping source 的情况
|
2104
|
+
const remoteMappingCache: any = {};
|
2080
2105
|
// 数据从第二行开始
|
2081
2106
|
let rowIndex = 1;
|
2082
2107
|
for (const row of rows) {
|
2083
2108
|
rowIndex += 1;
|
2084
2109
|
const sheetRow = worksheet.getRow(rowIndex);
|
2085
2110
|
let columIndex = 0;
|
2086
|
-
const
|
2087
|
-
for (const column of cols) {
|
2111
|
+
for (const column of filteredColumns) {
|
2088
2112
|
columIndex += 1;
|
2089
2113
|
const name = column.name!;
|
2090
2114
|
const value = getVariable(row.data, name);
|
@@ -2170,7 +2194,30 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2170
2194
|
};
|
2171
2195
|
} else if (type === 'mapping') {
|
2172
2196
|
// 拷贝自 Mapping.tsx
|
2173
|
-
|
2197
|
+
let map = (column as MappingSchema).map;
|
2198
|
+
const source = (column as MappingSchema).source;
|
2199
|
+
if (source) {
|
2200
|
+
let sourceValue = source;
|
2201
|
+
if (isPureVariable(source)) {
|
2202
|
+
sourceValue = resolveVariableAndFilter(
|
2203
|
+
source as string,
|
2204
|
+
data,
|
2205
|
+
'| raw'
|
2206
|
+
);
|
2207
|
+
}
|
2208
|
+
|
2209
|
+
const mapKey = JSON.stringify(source);
|
2210
|
+
if (mapKey in remoteMappingCache) {
|
2211
|
+
map = remoteMappingCache[mapKey];
|
2212
|
+
} else {
|
2213
|
+
const res = await env.fetcher(sourceValue, data);
|
2214
|
+
if (res.data) {
|
2215
|
+
remoteMappingCache[mapKey] = res.data;
|
2216
|
+
map = res.data;
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
|
2174
2221
|
if (
|
2175
2222
|
typeof value !== 'undefined' &&
|
2176
2223
|
map &&
|
@@ -2183,9 +2230,10 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2183
2230
|
: value === false && map['0']
|
2184
2231
|
? map['0']
|
2185
2232
|
: map['*']); // 兼容平台旧用法:即 value 为 true 时映射 1 ,为 false 时映射 0
|
2186
|
-
sheetRow.getCell(columIndex).value =
|
2233
|
+
sheetRow.getCell(columIndex).value =
|
2234
|
+
removeHTMLTag(viewValue);
|
2187
2235
|
} else {
|
2188
|
-
sheetRow.getCell(columIndex).value = value;
|
2236
|
+
sheetRow.getCell(columIndex).value = removeHTMLTag(value);
|
2189
2237
|
}
|
2190
2238
|
} else {
|
2191
2239
|
if ((column as TplSchema).tpl) {
|
package/src/store/modal.ts
CHANGED
package/src/store/service.ts
CHANGED
@@ -140,24 +140,6 @@ export const ServiceStore = iRendererStore
|
|
140
140
|
}
|
141
141
|
});
|
142
142
|
|
143
|
-
const fetchWSData = (ws: string, afterDataFetch: (data: any) => any) => {
|
144
|
-
const env = getEnv(self);
|
145
|
-
|
146
|
-
env.wsFetcher(
|
147
|
-
ws,
|
148
|
-
(data: any) => {
|
149
|
-
self.updateData(data, undefined, false);
|
150
|
-
setHasRemoteData();
|
151
|
-
// 因为 WebSocket 只会获取纯数据,所以没有 msg 之类的
|
152
|
-
afterDataFetch({ok: true, data: data});
|
153
|
-
},
|
154
|
-
(error: any) => {
|
155
|
-
updateMessage(error, true);
|
156
|
-
env.notify('error', error);
|
157
|
-
}
|
158
|
-
);
|
159
|
-
};
|
160
|
-
|
161
143
|
const setHasRemoteData = () => {
|
162
144
|
self.hasRemoteData = true;
|
163
145
|
};
|
@@ -505,7 +487,6 @@ export const ServiceStore = iRendererStore
|
|
505
487
|
markBusying,
|
506
488
|
fetchInitData,
|
507
489
|
fetchData,
|
508
|
-
fetchWSData,
|
509
490
|
reInitData,
|
510
491
|
updateMessage,
|
511
492
|
clearMessage,
|