ronds-metadata 1.2.8 → 1.2.10
Sign up to get free protection for your applications and to get access to all the features.
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/index.less +23 -23
- package/es/comps/FormGenerator/index.d.ts +4 -0
- package/es/comps/FormGenerator/settings/index.d.ts +668 -49
- package/es/comps/JsonEdit/index.d.ts +5 -1
- package/es/comps/MetadataForm/index.less +1 -1
- package/es/comps/MetadataForm/utils.d.ts +1 -1
- package/package.json +1 -1
- package/es/api/index.js +0 -249
- package/es/comps/DynamicPorts/comps/ContextMenu.js +0 -44
- package/es/comps/DynamicPorts/comps/DragNode.js +0 -55
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +0 -51
- package/es/comps/DynamicPorts/comps/NodeElement.js +0 -30
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +0 -42
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +0 -40
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +0 -55
- package/es/comps/DynamicPorts/comps/shape/connector.js +0 -19
- package/es/comps/DynamicPorts/comps/shape/edge.js +0 -91
- package/es/comps/DynamicPorts/comps/shape/node.js +0 -190
- package/es/comps/DynamicPorts/constant/index.js +0 -19
- package/es/comps/DynamicPorts/graph.js +0 -697
- package/es/comps/DynamicPorts/index.js +0 -143
- package/es/comps/DynamicPorts/interface.js +0 -6
- package/es/comps/DynamicPorts/utils.js +0 -127
- package/es/comps/Editable/DataCell/ButtonCell.js +0 -45
- package/es/comps/Editable/DataCell/ColorPicker.js +0 -33
- package/es/comps/Editable/DataCell/Input.js +0 -54
- package/es/comps/Editable/DataCell/Number.js +0 -44
- package/es/comps/Editable/DataCell/Select.js +0 -48
- package/es/comps/Editable/DataCell/Switch.js +0 -33
- package/es/comps/Editable/comps/EditableAction.js +0 -110
- package/es/comps/Editable/comps/EditableCell.js +0 -108
- package/es/comps/Editable/comps/EditableHeardCell.js +0 -172
- package/es/comps/Editable/comps/EditableRow.js +0 -118
- package/es/comps/Editable/comps/Texty.js +0 -277
- package/es/comps/Editable/index.js +0 -385
- package/es/comps/Editable/interface.js +0 -8
- package/es/comps/Editable/utils.js +0 -46
- package/es/comps/FileView/index.js +0 -198
- package/es/comps/FormGenerator/Provider.js +0 -8
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +0 -16
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +0 -55
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +0 -14
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +0 -50
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +0 -55
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +0 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +0 -14
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +0 -250
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +0 -60
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +0 -313
- package/es/comps/FormGenerator/comps/Canvas/index.js +0 -216
- package/es/comps/FormGenerator/comps/Settings/index.js +0 -150
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +0 -48
- package/es/comps/FormGenerator/comps/Sidebar/index.js +0 -37
- package/es/comps/FormGenerator/index.js +0 -56
- package/es/comps/FormGenerator/settings/index.js +0 -303
- package/es/comps/FormGenerator/settings/ruleConfig.js +0 -557
- package/es/comps/FormGenerator/transformer.js +0 -214
- package/es/comps/Icons/index.js +0 -23
- package/es/comps/JsonEdit/constant/index.js +0 -87
- package/es/comps/JsonEdit/index.js +0 -217
- package/es/comps/JsonView/index.js +0 -109
- package/es/comps/MdEdit/index.js +0 -41
- package/es/comps/MdNavbar/index.js +0 -180
- package/es/comps/MdNavbar/utils.js +0 -34
- package/es/comps/MdView/index.js +0 -70
- package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +0 -419
- package/es/comps/MetadataEdit/components/MetaPropsEdit.js +0 -368
- package/es/comps/MetadataEdit/constant/index.js +0 -69
- package/es/comps/MetadataEdit/hooks/index.js +0 -43
- package/es/comps/MetadataEdit/index.js +0 -255
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +0 -237
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +0 -367
- package/es/comps/MetadataEditV2/constant/index.js +0 -69
- package/es/comps/MetadataEditV2/hooks/index.js +0 -43
- package/es/comps/MetadataEditV2/index.js +0 -298
- package/es/comps/MetadataForm/DataCell/Array.js +0 -157
- package/es/comps/MetadataForm/DataCell/Input.js +0 -197
- package/es/comps/MetadataForm/DataCell/Number.js +0 -130
- package/es/comps/MetadataForm/DataCell/Ref.js +0 -323
- package/es/comps/MetadataForm/DataCell/Select.js +0 -517
- package/es/comps/MetadataForm/DataCell/Switch.js +0 -115
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +0 -359
- package/es/comps/MetadataForm/HOC/index.js +0 -111
- package/es/comps/MetadataForm/constants.js +0 -11
- package/es/comps/MetadataForm/hooks/index.js +0 -128
- package/es/comps/MetadataForm/index.js +0 -268
- package/es/comps/MetadataForm/interface.js +0 -8
- package/es/comps/MetadataForm/utils.js +0 -108
- package/es/comps/locales/en-US.js +0 -24
- package/es/comps/locales/index.js +0 -8
- package/es/comps/locales/zh-CN.js +0 -24
- package/es/config.js +0 -50
- package/es/framework/graph/index.js +0 -515
- package/es/framework/hooks/use-async-memo.js +0 -32
- package/es/framework/hooks/use-sync-scroll.js +0 -106
- package/es/framework/http/cache.js +0 -137
- package/es/framework/http/cancel.js +0 -44
- package/es/framework/http/index.js +0 -392
- package/es/framework/http/msgpack.js +0 -34
- package/es/framework/http/msgpack5/index.js +0 -84
- package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +0 -71
- package/es/framework/http/msgpack5/lib/decoder.js +0 -287
- package/es/framework/http/msgpack5/lib/encoder.js +0 -252
- package/es/framework/http/msgpack5/lib/helpers.js +0 -23
- package/es/framework/http/msgpack5/lib/streams.js +0 -93
- package/es/framework/http/types.js +0 -1
- package/es/framework/libs/jquery.min.js +0 -4022
- package/es/framework/locale/dil8/di18n.js +0 -132
- package/es/framework/locale/dil8/index.js +0 -3
- package/es/framework/locale/dil8/translate.js +0 -76
- package/es/framework/locale/dil8/util.js +0 -17
- package/es/framework/locale/index.js +0 -26
- package/es/framework/metadata/MetadataService.js +0 -169
- package/es/framework/metadata/index.js +0 -384
- package/es/framework/rxjs-hooks/useMemoSubject.js +0 -16
- package/es/framework/rxjs-hooks/useObservable.js +0 -22
- package/es/framework/rxjs-hooks/useObservableState.js +0 -45
- package/es/index.js +0 -27
- package/es/utils.js +0 -138
@@ -1,385 +0,0 @@
|
|
1
|
-
import "antd/es/button/style";
|
2
|
-
import _Button from "antd/es/button";
|
3
|
-
import "antd/es/table/style";
|
4
|
-
import _Table from "antd/es/table";
|
5
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
6
|
-
import "antd/es/message/style";
|
7
|
-
import _message from "antd/es/message";
|
8
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
9
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
10
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
11
|
-
import React from 'react';
|
12
|
-
import { pick, isArray } from 'lodash';
|
13
|
-
import { DndProvider } from 'react-dnd';
|
14
|
-
import { HTML5Backend } from 'react-dnd-html5-backend';
|
15
|
-
import EditableCell from './comps/EditableCell';
|
16
|
-
import EditableRow from './comps/EditableRow';
|
17
|
-
import { EditableContext } from './interface';
|
18
|
-
import EditableAction from './comps/EditableAction';
|
19
|
-
import { isFreeEditRow, removeCurKeyFromEditRow } from './utils';
|
20
|
-
import EditableHeardCell from './comps/EditableHeardCell';
|
21
|
-
import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
|
22
|
-
import useObservable from '../../framework/rxjs-hooks/useObservable';
|
23
|
-
import { tr } from '../../framework/locale';
|
24
|
-
import './index.less';
|
25
|
-
|
26
|
-
var Editable = function Editable(props) {
|
27
|
-
var _props$type = props.type,
|
28
|
-
type = _props$type === void 0 ? 'single' : _props$type,
|
29
|
-
readonly = props.readonly,
|
30
|
-
columns = props.columns,
|
31
|
-
dataSource = props.dataSource,
|
32
|
-
defaultValue = props.defaultValue,
|
33
|
-
_props$addPosition = props.addPosition,
|
34
|
-
addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition,
|
35
|
-
_props$isAddColumn = props.isAddColumn,
|
36
|
-
isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
|
37
|
-
_props$isAddRow = props.isAddRow,
|
38
|
-
isAddRow = _props$isAddRow === void 0 ? true : _props$isAddRow,
|
39
|
-
_props$isAction = props.isAction,
|
40
|
-
isAction = _props$isAction === void 0 ? true : _props$isAction,
|
41
|
-
tableProps = props.tableProps,
|
42
|
-
onMove = props.onMove,
|
43
|
-
onRowClick = props.onRowClick,
|
44
|
-
onButtonCellClick = props.onButtonCellClick,
|
45
|
-
onRowConfirm = props.onRowConfirm,
|
46
|
-
onRowDelete = props.onRowDelete,
|
47
|
-
onMulChange = props.onMulChange,
|
48
|
-
getStreamInstance = props.getStreamInstance;
|
49
|
-
|
50
|
-
var _React$useState = React.useState([]),
|
51
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
52
|
-
records = _React$useState2[0],
|
53
|
-
setRecords = _React$useState2[1];
|
54
|
-
|
55
|
-
var recordsRef = React.useRef([]); // 当type为single的时候 只能编辑该行数据
|
56
|
-
|
57
|
-
var _React$useState3 = React.useState(),
|
58
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
59
|
-
editRowKey = _React$useState4[0],
|
60
|
-
setEditRowkey = _React$useState4[1];
|
61
|
-
|
62
|
-
var _React$useState5 = React.useState('add'),
|
63
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
64
|
-
editType = _React$useState6[0],
|
65
|
-
setEditType = _React$useState6[1];
|
66
|
-
|
67
|
-
var editRowKeyRef = React.useRef(); // 当type为freedom的时候可以编辑指定cell
|
68
|
-
|
69
|
-
var _React$useState7 = React.useState(),
|
70
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
71
|
-
editCellKey = _React$useState8[0],
|
72
|
-
setEditCellkey = _React$useState8[1]; // 添加一列表头
|
73
|
-
|
74
|
-
|
75
|
-
var _React$useState9 = React.useState(),
|
76
|
-
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
77
|
-
editHeardCellKey = _React$useState10[0],
|
78
|
-
setEditHeardCellkey = _React$useState10[1]; // 记录上一次发生改变的行值
|
79
|
-
|
80
|
-
|
81
|
-
var lastValueRef = React.useRef(); // 记录上一次的datasource
|
82
|
-
|
83
|
-
var lastDataSourceRef = React.useRef();
|
84
|
-
var firstLoadRef = React.useRef(true); // 定义处理编辑表格的数据流
|
85
|
-
|
86
|
-
var editableStream = useMemoSubject();
|
87
|
-
var processStreamFactory = React.useCallback(function (data) {
|
88
|
-
switch (data === null || data === void 0 ? void 0 : data.type) {
|
89
|
-
case 'onValuesChange':
|
90
|
-
lastValueRef.current = data.payload; // type为multiple时候处理records
|
91
|
-
|
92
|
-
if (type === 'multiple') {
|
93
|
-
var _records = recordsRef.current;
|
94
|
-
_records[data.payload.rowIdx] = _objectSpread(_objectSpread({}, _records[data.payload.rowIdx]), data.payload.allValues);
|
95
|
-
onMulChange && onMulChange(_records);
|
96
|
-
} // type为freedom时候处理records
|
97
|
-
|
98
|
-
|
99
|
-
if (type === 'freedom') {
|
100
|
-
var _records2 = recordsRef.current;
|
101
|
-
_records2[data.payload.rowIdx] = _objectSpread(_objectSpread({}, _records2[data.payload.rowIdx]), data.payload.allValues);
|
102
|
-
setRecords(_toConsumableArray(_records2));
|
103
|
-
onMulChange && onMulChange(_objectSpread(_objectSpread({}, data.payload), {}, {
|
104
|
-
records: _records2
|
105
|
-
}));
|
106
|
-
}
|
107
|
-
|
108
|
-
break;
|
109
|
-
|
110
|
-
case 'editRowKey':
|
111
|
-
if (Object.keys(data.payload).length > 1) {
|
112
|
-
setEditType('edit');
|
113
|
-
} else {
|
114
|
-
setEditType('add');
|
115
|
-
}
|
116
|
-
|
117
|
-
setEditRowkey(data.payload._rowKey_);
|
118
|
-
editRowKeyRef.current = data.payload._rowKey_;
|
119
|
-
break;
|
120
|
-
|
121
|
-
case 'editCellKey':
|
122
|
-
setEditCellkey({
|
123
|
-
dataIndex: data.payload.dataIndex,
|
124
|
-
rowIndex: data.payload.rowIndex
|
125
|
-
});
|
126
|
-
break;
|
127
|
-
|
128
|
-
case 'editHeardCellKey':
|
129
|
-
setEditHeardCellkey(data.payload);
|
130
|
-
break;
|
131
|
-
|
132
|
-
case 'onRowClick':
|
133
|
-
onRowClick && onRowClick(data.payload);
|
134
|
-
break;
|
135
|
-
|
136
|
-
case 'onButtonCellClick':
|
137
|
-
onButtonCellClick && onButtonCellClick(data.payload);
|
138
|
-
break;
|
139
|
-
|
140
|
-
case 'onSingleSave':
|
141
|
-
if (lastValueRef.current && lastValueRef.current.rowIdx === data.payload._rowKey_) {
|
142
|
-
onRowConfirm && onRowConfirm({
|
143
|
-
rowIdx: lastValueRef.current.rowIdx,
|
144
|
-
values: lastValueRef.current.values,
|
145
|
-
allValues: _objectSpread(_objectSpread({}, recordsRef.current[lastValueRef.current.rowIdx]), lastValueRef.current.allValues)
|
146
|
-
});
|
147
|
-
editRowKeyRef.current = undefined;
|
148
|
-
setEditRowkey(undefined);
|
149
|
-
} else {
|
150
|
-
_message.warn(tr('当前值无修改'));
|
151
|
-
}
|
152
|
-
|
153
|
-
break;
|
154
|
-
|
155
|
-
case 'onDelete':
|
156
|
-
if (type === 'single') {
|
157
|
-
// 如果删除的 是正在编辑的 重置状态
|
158
|
-
if (editRowKeyRef.current === data.payload._rowKey_) {
|
159
|
-
setEditRowkey(undefined);
|
160
|
-
editRowKeyRef.current = undefined;
|
161
|
-
}
|
162
|
-
|
163
|
-
onRowDelete && onRowDelete(data.payload);
|
164
|
-
}
|
165
|
-
|
166
|
-
if (type === 'multiple') {
|
167
|
-
var _records3 = recordsRef.current;
|
168
|
-
|
169
|
-
_records3.splice(data.payload._rowKey_, 1);
|
170
|
-
|
171
|
-
setRecords(_toConsumableArray(_records3));
|
172
|
-
recordsRef.current = _records3;
|
173
|
-
onMulChange && onMulChange(_records3);
|
174
|
-
}
|
175
|
-
|
176
|
-
if (type === 'freedom') {
|
177
|
-
// 正在全行编辑的直接删除,不需要回调
|
178
|
-
if (isFreeEditRow(editRowKeyRef.current, data.payload._rowKey_)) {
|
179
|
-
var _records4 = recordsRef.current;
|
180
|
-
|
181
|
-
_records4.splice(data.payload._rowKey_, 1);
|
182
|
-
|
183
|
-
setRecords(_toConsumableArray(_records4));
|
184
|
-
recordsRef.current = _records4; // 移除当前的行的编辑状态
|
185
|
-
|
186
|
-
var _editRowKey = removeCurKeyFromEditRow(editRowKeyRef.current, data.payload._rowKey_);
|
187
|
-
|
188
|
-
setEditRowkey(_editRowKey);
|
189
|
-
editRowKeyRef.current = _editRowKey;
|
190
|
-
editableStream.next({
|
191
|
-
type: 'editRowKey',
|
192
|
-
payload: {
|
193
|
-
_rowkey_: undefined
|
194
|
-
}
|
195
|
-
});
|
196
|
-
return;
|
197
|
-
}
|
198
|
-
|
199
|
-
onRowDelete && onRowDelete(data.payload);
|
200
|
-
}
|
201
|
-
|
202
|
-
break;
|
203
|
-
}
|
204
|
-
}, [type]); // 集中处理数据流
|
205
|
-
|
206
|
-
useObservable(processStreamFactory, [editableStream]); // 返回stream的实例
|
207
|
-
|
208
|
-
React.useEffect(function () {
|
209
|
-
if (firstLoadRef && editableStream) {
|
210
|
-
getStreamInstance && getStreamInstance(editableStream);
|
211
|
-
firstLoadRef.current = false;
|
212
|
-
}
|
213
|
-
}, [editableStream]); // 定义内部的record
|
214
|
-
|
215
|
-
React.useEffect(function () {
|
216
|
-
if (dataSource) {
|
217
|
-
setRecords(_toConsumableArray(dataSource));
|
218
|
-
recordsRef.current = dataSource;
|
219
|
-
}
|
220
|
-
}, [dataSource]);
|
221
|
-
var getEditColumn = React.useCallback(function (column) {
|
222
|
-
var _column = _objectSpread(_objectSpread({}, column), {}, {
|
223
|
-
children: isArray(column === null || column === void 0 ? void 0 : column.children) ? column.children.map(getEditColumn) : undefined
|
224
|
-
});
|
225
|
-
|
226
|
-
if (column.editable && !readonly) {
|
227
|
-
_column.onCell = function (record, rowIndex) {
|
228
|
-
return _objectSpread(_objectSpread({
|
229
|
-
record: record,
|
230
|
-
editableType: type,
|
231
|
-
isAddColumn: isAddColumn
|
232
|
-
}, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'mode', 'disabled'])), {}, {
|
233
|
-
rowIndex: rowIndex
|
234
|
-
});
|
235
|
-
};
|
236
|
-
|
237
|
-
_column.onHeaderCell = function (col) {
|
238
|
-
return _objectSpread({
|
239
|
-
width: col.width,
|
240
|
-
isAddColumn: isAddColumn
|
241
|
-
}, pick(column, ['title', 'dataIndex']));
|
242
|
-
};
|
243
|
-
}
|
244
|
-
|
245
|
-
return _column;
|
246
|
-
}, [readonly, type]); // 处理一下编辑表格的数据
|
247
|
-
|
248
|
-
var _columns = React.useMemo(function () {
|
249
|
-
var __columns__ = columns;
|
250
|
-
|
251
|
-
var res = __columns__.map(getEditColumn);
|
252
|
-
|
253
|
-
if (!readonly && isAction) {
|
254
|
-
var _aciton_ = {
|
255
|
-
dataKey: '_aciton_',
|
256
|
-
title: tr('操作'),
|
257
|
-
width: type === 'multiple' ? 50 : 100,
|
258
|
-
ellipsis: true,
|
259
|
-
fixed: 'right',
|
260
|
-
render: function render(val, record) {
|
261
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditableAction, {
|
262
|
-
type: type,
|
263
|
-
record: record
|
264
|
-
}));
|
265
|
-
}
|
266
|
-
};
|
267
|
-
|
268
|
-
if (type === 'single') {
|
269
|
-
res.push(_aciton_);
|
270
|
-
} else if (defaultValue) {
|
271
|
-
res.push(_aciton_);
|
272
|
-
}
|
273
|
-
}
|
274
|
-
|
275
|
-
return res;
|
276
|
-
}, [columns, readonly, type]); // 主要是自己加一层rowkey
|
277
|
-
|
278
|
-
|
279
|
-
var _dataSource = React.useMemo(function () {
|
280
|
-
var res = records.map(function (it, idx) {
|
281
|
-
return _objectSpread({
|
282
|
-
_rowKey_: idx
|
283
|
-
}, it);
|
284
|
-
});
|
285
|
-
|
286
|
-
if (res.length > 0) {
|
287
|
-
firstLoadRef.current = false;
|
288
|
-
}
|
289
|
-
|
290
|
-
lastDataSourceRef.current = res;
|
291
|
-
return res;
|
292
|
-
}, [records, type]);
|
293
|
-
|
294
|
-
var onAddRow = function onAddRow() {
|
295
|
-
if (defaultValue) {
|
296
|
-
if (type === 'freedom' && editRowKey) {
|
297
|
-
_message.warn(tr('请先保存正在编辑的行'));
|
298
|
-
|
299
|
-
return;
|
300
|
-
}
|
301
|
-
|
302
|
-
var _records = recordsRef.current;
|
303
|
-
|
304
|
-
if (addPosition === 'top') {
|
305
|
-
_records.unshift(defaultValue);
|
306
|
-
} else {
|
307
|
-
_records.push(defaultValue);
|
308
|
-
}
|
309
|
-
|
310
|
-
if (type === 'freedom') {
|
311
|
-
var _editRowKeyRef$curren;
|
312
|
-
|
313
|
-
var _editRowKeyArr = ((_editRowKeyRef$curren = editRowKeyRef.current) === null || _editRowKeyRef$curren === void 0 ? void 0 : _editRowKeyRef$curren.toString().split(',')) || ['undefined'];
|
314
|
-
|
315
|
-
var _curKey = addPosition === 'top' ? _editRowKeyArr.length - 1 : _records.length - 1;
|
316
|
-
|
317
|
-
var _editRowKey = "".concat(editRowKeyRef.current, ",").concat(_curKey);
|
318
|
-
|
319
|
-
setEditRowkey(_editRowKey);
|
320
|
-
editRowKeyRef.current = _editRowKey;
|
321
|
-
}
|
322
|
-
|
323
|
-
setRecords(_toConsumableArray(_records));
|
324
|
-
recordsRef.current = _records;
|
325
|
-
}
|
326
|
-
};
|
327
|
-
|
328
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditableContext.Provider, {
|
329
|
-
value: {
|
330
|
-
editableStream: editableStream,
|
331
|
-
editConfig: {
|
332
|
-
curRow: editRowKey,
|
333
|
-
type: editType,
|
334
|
-
editCellKey: editCellKey,
|
335
|
-
editHeardCellKey: editHeardCellKey
|
336
|
-
}
|
337
|
-
}
|
338
|
-
}, /*#__PURE__*/React.createElement(DndProvider, {
|
339
|
-
backend: HTML5Backend
|
340
|
-
}, /*#__PURE__*/React.createElement("div", {
|
341
|
-
style: {
|
342
|
-
height: "".concat((type === 'multiple' || type === 'freedom') && !readonly && isAddRow && defaultValue ? 'calc(100% - 40px)' : '100%')
|
343
|
-
}
|
344
|
-
}, /*#__PURE__*/React.createElement(_Table, _extends({
|
345
|
-
key: _columns.length,
|
346
|
-
className: "ronds-edit-table",
|
347
|
-
bordered: true,
|
348
|
-
scroll: {
|
349
|
-
x: '100%',
|
350
|
-
y: 'calc(100% - 40px)'
|
351
|
-
}
|
352
|
-
}, tableProps, {
|
353
|
-
pagination: false,
|
354
|
-
rowKey: "_rowKey_",
|
355
|
-
size: "small",
|
356
|
-
columns: _columns,
|
357
|
-
dataSource: _dataSource,
|
358
|
-
components: {
|
359
|
-
header: {
|
360
|
-
cell: EditableHeardCell
|
361
|
-
},
|
362
|
-
body: {
|
363
|
-
row: EditableRow,
|
364
|
-
cell: EditableCell
|
365
|
-
}
|
366
|
-
},
|
367
|
-
onRow: function onRow(record, index) {
|
368
|
-
return {
|
369
|
-
record: record,
|
370
|
-
index: index,
|
371
|
-
onMove: onMove
|
372
|
-
};
|
373
|
-
}
|
374
|
-
})))), (type === 'multiple' || type === 'freedom') && !readonly && isAddRow && defaultValue && /*#__PURE__*/React.createElement(_Button, {
|
375
|
-
block: true,
|
376
|
-
type: "dashed",
|
377
|
-
style: {
|
378
|
-
marginBottom: '5px',
|
379
|
-
marginTop: '5px'
|
380
|
-
},
|
381
|
-
onClick: onAddRow
|
382
|
-
}, tr('添加一行'))));
|
383
|
-
};
|
384
|
-
|
385
|
-
export default Editable;
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: wangxian
|
3
|
-
* @Date: 2022-03-04 14:59:04
|
4
|
-
* @LastEditTime: 2022-07-07 08:35:35
|
5
|
-
*/
|
6
|
-
import React from 'react';
|
7
|
-
import Input from './DataCell/Input';
|
8
|
-
import Number from './DataCell/Number';
|
9
|
-
import Select from './DataCell/Select';
|
10
|
-
import Switch from './DataCell/Switch';
|
11
|
-
import ColorPicker from './DataCell/ColorPicker';
|
12
|
-
import ButtonCell from './DataCell/ButtonCell';
|
13
|
-
var DataCellMap = {
|
14
|
-
text: Input,
|
15
|
-
number: Number,
|
16
|
-
enum: Select,
|
17
|
-
bool: Switch,
|
18
|
-
colorPicker: ColorPicker,
|
19
|
-
buttonCell: ButtonCell
|
20
|
-
};
|
21
|
-
export function getDataCell(item) {
|
22
|
-
if (item.type && DataCellMap[item.type]) {
|
23
|
-
var Comm = DataCellMap[item.type];
|
24
|
-
return /*#__PURE__*/React.createElement(Comm, item);
|
25
|
-
}
|
26
|
-
|
27
|
-
return null;
|
28
|
-
}
|
29
|
-
export function isFreeEditRow(curRow, rowIndex) {
|
30
|
-
return (curRow === null || curRow === void 0 ? void 0 : curRow.toString().split(',').indexOf("".concat(rowIndex))) > -1;
|
31
|
-
}
|
32
|
-
export function isFreeEditCell(editCellKey, dataIndex, rowIndex) {
|
33
|
-
return (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.dataIndex) === dataIndex && (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.rowIndex) === rowIndex;
|
34
|
-
}
|
35
|
-
export function removeCurKeyFromEditRow(editRowKey, curKey) {
|
36
|
-
var keys = editRowKey.toString().split(',');
|
37
|
-
var res = [];
|
38
|
-
keys.forEach(function (v) {
|
39
|
-
if (parseInt(v) > curKey) {
|
40
|
-
res.push(parseInt(v) - 1);
|
41
|
-
} else if (v !== "".concat(curKey)) {
|
42
|
-
res.push(v);
|
43
|
-
}
|
44
|
-
});
|
45
|
-
return res.toString();
|
46
|
-
}
|
@@ -1,198 +0,0 @@
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
3
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
5
|
-
import React from 'react';
|
6
|
-
import { ReactJexcel } from 'react-jexcel';
|
7
|
-
import * as XLSX from 'xlsx';
|
8
|
-
|
9
|
-
var FileView = function FileView(props) {
|
10
|
-
var path = props.path,
|
11
|
-
data = props.data,
|
12
|
-
file = props.file,
|
13
|
-
_props$limit = props.limit,
|
14
|
-
limit = _props$limit === void 0 ? 1000 : _props$limit;
|
15
|
-
var ref = React.useRef(null);
|
16
|
-
var firstLoadRef = React.useRef(true);
|
17
|
-
|
18
|
-
var _React$useState = React.useState(),
|
19
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
20
|
-
title = _React$useState2[0],
|
21
|
-
setTitle = _React$useState2[1];
|
22
|
-
|
23
|
-
var _React$useState3 = React.useState(),
|
24
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
25
|
-
value = _React$useState4[0],
|
26
|
-
setValue = _React$useState4[1];
|
27
|
-
|
28
|
-
var processDataToExcel = React.useCallback(function (data) {
|
29
|
-
var _title = [];
|
30
|
-
var _value = [];
|
31
|
-
|
32
|
-
if (data && data.length > 0) {
|
33
|
-
var p = data[0];
|
34
|
-
var f = Object.keys(p);
|
35
|
-
_title = f.map(function (it) {
|
36
|
-
return {
|
37
|
-
title: it,
|
38
|
-
width: 100,
|
39
|
-
align: 'left'
|
40
|
-
};
|
41
|
-
});
|
42
|
-
setTitle(_toConsumableArray(_title));
|
43
|
-
|
44
|
-
var _loop = function _loop(i) {
|
45
|
-
var arr = f.map(function (it) {
|
46
|
-
return data[i][it];
|
47
|
-
});
|
48
|
-
|
49
|
-
_value.push(arr);
|
50
|
-
|
51
|
-
if (i === limit - 1) return "break";
|
52
|
-
};
|
53
|
-
|
54
|
-
for (var i = 0; i < data.length; i++) {
|
55
|
-
var _ret = _loop(i);
|
56
|
-
|
57
|
-
if (_ret === "break") break;
|
58
|
-
}
|
59
|
-
|
60
|
-
setValue([].concat(_value));
|
61
|
-
firstLoadRef.current = false;
|
62
|
-
}
|
63
|
-
}, []); // 文件流转 base64
|
64
|
-
|
65
|
-
var fixdata = function fixdata(data) {
|
66
|
-
var o = '',
|
67
|
-
l = 0,
|
68
|
-
w = 10240;
|
69
|
-
|
70
|
-
for (; l < data.byteLength / w; ++l) {
|
71
|
-
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
|
72
|
-
}
|
73
|
-
|
74
|
-
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
|
75
|
-
return o;
|
76
|
-
};
|
77
|
-
|
78
|
-
var getFileData = React.useCallback( /*#__PURE__*/function () {
|
79
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_file) {
|
80
|
-
var blob, res, fileReader;
|
81
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
82
|
-
while (1) {
|
83
|
-
switch (_context.prev = _context.next) {
|
84
|
-
case 0:
|
85
|
-
if (!firstLoadRef.current) {
|
86
|
-
_context.next = 14;
|
87
|
-
break;
|
88
|
-
}
|
89
|
-
|
90
|
-
if (!path) {
|
91
|
-
_context.next = 10;
|
92
|
-
break;
|
93
|
-
}
|
94
|
-
|
95
|
-
_context.next = 4;
|
96
|
-
return fetch(path);
|
97
|
-
|
98
|
-
case 4:
|
99
|
-
res = _context.sent;
|
100
|
-
_context.next = 7;
|
101
|
-
return res.blob();
|
102
|
-
|
103
|
-
case 7:
|
104
|
-
blob = _context.sent;
|
105
|
-
_context.next = 11;
|
106
|
-
break;
|
107
|
-
|
108
|
-
case 10:
|
109
|
-
blob = _file;
|
110
|
-
|
111
|
-
case 11:
|
112
|
-
fileReader = new FileReader(); //二进制
|
113
|
-
// fileReader.readAsBinaryString(blob);
|
114
|
-
|
115
|
-
fileReader.onload = function (event) {
|
116
|
-
try {
|
117
|
-
var _data = []; // 以二进制流方式读取得到整份excel表格对象
|
118
|
-
|
119
|
-
var result = event.target.result; // 遍历每张工作表进行读取(这里默认只读取第一张表)
|
120
|
-
|
121
|
-
var workbook = XLSX.read(fixdata(result), {
|
122
|
-
type: 'binary',
|
123
|
-
codepage: 65001
|
124
|
-
});
|
125
|
-
|
126
|
-
for (var sheet in workbook.Sheets) {
|
127
|
-
if (workbook.Sheets.hasOwnProperty(sheet)) {
|
128
|
-
// 利用 sheet_to_json 方法将 excel 转成 json 数据
|
129
|
-
_data = _data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet])); // 如果只取第一张表,就取消注释这行
|
130
|
-
|
131
|
-
break;
|
132
|
-
}
|
133
|
-
}
|
134
|
-
|
135
|
-
processDataToExcel(_data);
|
136
|
-
} catch (e) {
|
137
|
-
return;
|
138
|
-
}
|
139
|
-
};
|
140
|
-
|
141
|
-
fileReader.readAsArrayBuffer(blob);
|
142
|
-
|
143
|
-
case 14:
|
144
|
-
case "end":
|
145
|
-
return _context.stop();
|
146
|
-
}
|
147
|
-
}
|
148
|
-
}, _callee);
|
149
|
-
}));
|
150
|
-
|
151
|
-
return function (_x) {
|
152
|
-
return _ref.apply(this, arguments);
|
153
|
-
};
|
154
|
-
}(), []);
|
155
|
-
React.useEffect(function () {
|
156
|
-
if (path && firstLoadRef.current) {
|
157
|
-
getFileData();
|
158
|
-
return function () {
|
159
|
-
ref.current = null;
|
160
|
-
};
|
161
|
-
}
|
162
|
-
|
163
|
-
return function () {};
|
164
|
-
}, [getFileData, path]);
|
165
|
-
React.useEffect(function () {
|
166
|
-
if (file && firstLoadRef.current) {
|
167
|
-
getFileData(file);
|
168
|
-
return function () {
|
169
|
-
ref.current = null;
|
170
|
-
};
|
171
|
-
}
|
172
|
-
|
173
|
-
return function () {};
|
174
|
-
}, [getFileData, file]);
|
175
|
-
React.useEffect(function () {
|
176
|
-
if (data && firstLoadRef.current) {
|
177
|
-
processDataToExcel(data);
|
178
|
-
return function () {
|
179
|
-
ref.current = null;
|
180
|
-
};
|
181
|
-
}
|
182
|
-
|
183
|
-
return function () {};
|
184
|
-
}, [getFileData, data]);
|
185
|
-
|
186
|
-
if (!value) {
|
187
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
188
|
-
}
|
189
|
-
|
190
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReactJexcel, {
|
191
|
-
ref: ref,
|
192
|
-
data: value,
|
193
|
-
columns: title,
|
194
|
-
rowResize: true
|
195
|
-
}));
|
196
|
-
};
|
197
|
-
|
198
|
-
export default FileView;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import "antd/es/input/style";
|
2
|
-
import _Input from "antd/es/input";
|
3
|
-
import React from "react";
|
4
|
-
import { withFieldCellWrapper } from '../HOC';
|
5
|
-
|
6
|
-
var Index = function Index(props) {
|
7
|
-
var data = props.data,
|
8
|
-
fgStream = props.fgStream,
|
9
|
-
setting = props.setting;
|
10
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Input, {
|
11
|
-
disabled: setting === null || setting === void 0 ? void 0 : setting.disabled,
|
12
|
-
placeholder: setting === null || setting === void 0 ? void 0 : setting.placeholder,
|
13
|
-
allowClear: true
|
14
|
-
}));
|
15
|
-
};
|
16
|
-
|
17
|
-
export default withFieldCellWrapper(Index);
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import "antd/es/input/style";
|
2
|
-
import _Input from "antd/es/input";
|
3
|
-
import React from "react";
|
4
|
-
import { withFieldCellWrapper } from '../HOC';
|
5
|
-
|
6
|
-
var Index = function Index(props) {
|
7
|
-
var data = props.data,
|
8
|
-
fgStream = props.fgStream,
|
9
|
-
setting = props.setting;
|
10
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Input, {
|
11
|
-
disabled: setting === null || setting === void 0 ? void 0 : setting.disabled,
|
12
|
-
placeholder: setting === null || setting === void 0 ? void 0 : setting.placeholder,
|
13
|
-
allowClear: true
|
14
|
-
}));
|
15
|
-
};
|
16
|
-
|
17
|
-
export default withFieldCellWrapper(Index);
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import "antd/es/date-picker/style";
|
2
|
-
import _DatePicker from "antd/es/date-picker";
|
3
|
-
import React from "react";
|
4
|
-
import { withFieldCellWrapper } from '../HOC';
|
5
|
-
import { DEFAULT_DATE_FORMAT } from '../../../../../../../comps/MetadataForm/DataCell/Input';
|
6
|
-
|
7
|
-
var Index = function Index(props) {
|
8
|
-
var setting = props.setting;
|
9
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_DatePicker, {
|
10
|
-
showTime: true,
|
11
|
-
format: DEFAULT_DATE_FORMAT,
|
12
|
-
disabled: setting === null || setting === void 0 ? void 0 : setting.disabled
|
13
|
-
}));
|
14
|
-
};
|
15
|
-
|
16
|
-
export default withFieldCellWrapper(Index);
|