ronds-metadata 1.1.65 → 1.1.67
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/es/api/index.js +2 -2
- package/es/comps/Editable/index.d.ts +8 -0
- package/es/comps/Editable/index.js +6 -2
- package/es/comps/FileView/index.d.ts +4 -1
- package/es/comps/FileView/index.js +119 -12
- package/es/comps/MetadataForm/DataCell/Array.js +3 -1
- package/es/comps/MetadataForm/DataCell/Number.js +25 -4
- package/es/comps/MetadataForm/DataCell/Select.js +2 -2
- package/es/comps/MetadataForm/DataCell/layout/TableArray.d.ts +2 -0
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +9 -5
- package/package.json +4 -3
package/es/api/index.js
CHANGED
@@ -6,12 +6,12 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
6
|
/*
|
7
7
|
* @Author:wangxian
|
8
8
|
* @Date: 2021-09-18 14:15:04
|
9
|
-
* @LastEditTime: 2022-
|
9
|
+
* @LastEditTime: 2022-12-07 15:45:18
|
10
10
|
*/
|
11
11
|
import { guid, md5 } from '../utils';
|
12
12
|
import { addInterceptor, HttpHelper } from '../framework/http';
|
13
13
|
var http = new HttpHelper();
|
14
|
-
var token = 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IkNBMzFBMEJDMkQ5M0I3RkVFOTBDMDkwMDI4MUVBMTlEIiwidHlwIjoiYXQrand0In0.
|
14
|
+
var token = 'Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IkNBMzFBMEJDMkQ5M0I3RkVFOTBDMDkwMDI4MUVBMTlEIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE2NzAyODgzMTksImV4cCI6MTcwMTgyNDMxOSwiaXNzIjoiaHR0cDovLzE5Mi4xNjguMS4xNzk6MzEwMDIiLCJhdWQiOiJlcG0iLCJjbGllbnRfaWQiOiJlcG0iLCJzdWIiOiIzYTAyZTY3Zi1mYzNjLWU2YjQtYTFjNC1jOTEzOWE1NjM3OTUiLCJhdXRoX3RpbWUiOjE2NzAyODgzMTksImlkcCI6ImxvY2FsIiwicm9sZSI6InBobV9hZG1pbiIsInBob25lX251bWJlciI6IjEyMzQ1NiIsInBob25lX251bWJlcl92ZXJpZmllZCI6IkZhbHNlIiwiZW1haWwiOiJwaG1AYWJwLmlvIiwiZW1haWxfdmVyaWZpZWQiOiJGYWxzZSIsIm5hbWUiOiJwaG0iLCJpYXQiOjE2NzAyODgzMTksInNjb3BlIjpbImFkZHJlc3MiLCJlbWFpbCIsImVwbSIsIm9wZW5pZCIsInBob25lIiwicHJvZmlsZSIsInJvbGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.J1FKumhVm8zRAAqk61-4_LxjIz7gSehrAWhTKj0BPExZytQhLe8vLjGpXtLL-n_j3JE2eDz8____0afXdC5LaD_b6z-Wxyowe0BdCgGCRxAZDVjHUF-J5PnGPTYpjBTnbQ0g2lpTLTNPCb3AmEKj172okXm_3jRKj3FYYB7delG4ZDNPFKu4VtSoH8B4PubAliSAuBifcDtMYYPv83_mb6zipFbb_S1CgI-IZLNV5c5dMIz6jPpooYyKkOu1B0bcCE31R40V4NcARlomO41nfJiJ3PdwwVfmrOe1OHeFkwLwyG_rersTYVLF1nACT2cOMT9VRWzofkWjhRbW1iz_3w';
|
15
15
|
addInterceptor(function (httpClient) {
|
16
16
|
httpClient.interceptors.request.use(function (_config) {
|
17
17
|
if (!_config.headers) {
|
@@ -32,6 +32,10 @@ var Editable = function Editable(props) {
|
|
32
32
|
addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition,
|
33
33
|
_props$isAddColumn = props.isAddColumn,
|
34
34
|
isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
|
35
|
+
_props$isAddRow = props.isAddRow,
|
36
|
+
isAddRow = _props$isAddRow === void 0 ? true : _props$isAddRow,
|
37
|
+
_props$isAction = props.isAction,
|
38
|
+
isAction = _props$isAction === void 0 ? true : _props$isAction,
|
35
39
|
tableProps = props.tableProps,
|
36
40
|
onRowClick = props.onRowClick,
|
37
41
|
onButtonCellClick = props.onButtonCellClick,
|
@@ -243,7 +247,7 @@ var Editable = function Editable(props) {
|
|
243
247
|
|
244
248
|
var res = __columns__.map(getEditColumn);
|
245
249
|
|
246
|
-
if (!readonly) {
|
250
|
+
if (!readonly && isAction) {
|
247
251
|
var _aciton_ = {
|
248
252
|
dataKey: '_aciton_',
|
249
253
|
title: tr('操作'),
|
@@ -357,7 +361,7 @@ var Editable = function Editable(props) {
|
|
357
361
|
index: index
|
358
362
|
};
|
359
363
|
}
|
360
|
-
})), (type === 'multiple' || type === 'freedom') && !readonly && defaultValue && /*#__PURE__*/React.createElement(_Button, {
|
364
|
+
})), (type === 'multiple' || type === 'freedom') && !readonly && isAddRow && defaultValue && /*#__PURE__*/React.createElement(_Button, {
|
361
365
|
block: true,
|
362
366
|
type: "dashed",
|
363
367
|
style: {
|
@@ -1,18 +1,125 @@
|
|
1
|
-
import
|
1
|
+
import "antd/es/empty/style";
|
2
|
+
import _Empty from "antd/es/empty";
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
5
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
7
|
+
import React from 'react';
|
8
|
+
import { ReactJexcel } from 'react-jexcel';
|
9
|
+
import * as XLSX from 'xlsx';
|
2
10
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
*/
|
8
|
-
import FileViewer from 'react-file-viewer';
|
11
|
+
var FileView = function FileView(props) {
|
12
|
+
var path = props.path;
|
13
|
+
var ref = React.useRef(null);
|
14
|
+
var firstLoadRef = React.useRef(true);
|
9
15
|
|
10
|
-
var
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
filePath: 'http://192.168.1.186:9006/experiment//1fc9b9e3-51a3-79c0-de28-5ddff261d8fd/%E8%A1%A8%E6%A0%BC/%E6%B5%8B%E8%AF%95/test.xlsx?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minio%2F20221125%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221125T061952Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=97b63c66f7d2e9181d3b1486e360bdd7000e3104fc486a1d8fafd8db3d0623b4' //文件地址(后台给返的二进制流也可以)
|
16
|
+
var _React$useState = React.useState(),
|
17
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
18
|
+
title = _React$useState2[0],
|
19
|
+
setTitle = _React$useState2[1];
|
15
20
|
|
21
|
+
var _React$useState3 = React.useState(),
|
22
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
23
|
+
value = _React$useState4[0],
|
24
|
+
setValue = _React$useState4[1];
|
25
|
+
|
26
|
+
var processDataToExcel = React.useCallback(function (data) {
|
27
|
+
var _title = [];
|
28
|
+
var _value = [];
|
29
|
+
var p = data[0];
|
30
|
+
var f = Object.keys(p);
|
31
|
+
_title = f.map(function (it) {
|
32
|
+
return {
|
33
|
+
title: it,
|
34
|
+
width: 150,
|
35
|
+
align: 'left'
|
36
|
+
};
|
37
|
+
});
|
38
|
+
setTitle(_toConsumableArray(_title));
|
39
|
+
|
40
|
+
var _loop = function _loop(i) {
|
41
|
+
var arr = f.map(function (it) {
|
42
|
+
return data[i][it];
|
43
|
+
});
|
44
|
+
|
45
|
+
_value.push(arr);
|
46
|
+
};
|
47
|
+
|
48
|
+
for (var i = 0; i < data.length; i++) {
|
49
|
+
_loop(i);
|
50
|
+
}
|
51
|
+
|
52
|
+
setValue([].concat(_value));
|
53
|
+
firstLoadRef.current = false;
|
54
|
+
}, []);
|
55
|
+
var getFileData = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
56
|
+
var res, blob, fileReader;
|
57
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
58
|
+
while (1) {
|
59
|
+
switch (_context.prev = _context.next) {
|
60
|
+
case 0:
|
61
|
+
if (!(path && firstLoadRef.current)) {
|
62
|
+
_context.next = 10;
|
63
|
+
break;
|
64
|
+
}
|
65
|
+
|
66
|
+
_context.next = 3;
|
67
|
+
return fetch(path);
|
68
|
+
|
69
|
+
case 3:
|
70
|
+
res = _context.sent;
|
71
|
+
_context.next = 6;
|
72
|
+
return res.blob();
|
73
|
+
|
74
|
+
case 6:
|
75
|
+
blob = _context.sent;
|
76
|
+
fileReader = new FileReader();
|
77
|
+
fileReader.readAsBinaryString(blob); //二进制
|
78
|
+
|
79
|
+
fileReader.onload = function (event) {
|
80
|
+
try {
|
81
|
+
var data = [];
|
82
|
+
var result = event.target.result; // 以二进制流方式读取得到整份excel表格对象
|
83
|
+
|
84
|
+
var workbook = XLSX.read(result, {
|
85
|
+
type: 'binary'
|
86
|
+
}); // 遍历每张工作表进行读取(这里默认只读取第一张表)
|
87
|
+
|
88
|
+
for (var sheet in workbook.Sheets) {
|
89
|
+
if (workbook.Sheets.hasOwnProperty(sheet)) {
|
90
|
+
// 利用 sheet_to_json 方法将 excel 转成 json 数据
|
91
|
+
data = data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet])); // break; // 如果只取第一张表,就取消注释这行
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
processDataToExcel(data);
|
96
|
+
} catch (e) {
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
};
|
100
|
+
|
101
|
+
case 10:
|
102
|
+
case "end":
|
103
|
+
return _context.stop();
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}, _callee);
|
107
|
+
})), []);
|
108
|
+
React.useEffect(function () {
|
109
|
+
if (path && firstLoadRef.current) {
|
110
|
+
getFileData();
|
111
|
+
}
|
112
|
+
}, [getFileData, path]);
|
113
|
+
|
114
|
+
if (!value) {
|
115
|
+
return /*#__PURE__*/React.createElement(_Empty, null);
|
116
|
+
}
|
117
|
+
|
118
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReactJexcel, {
|
119
|
+
ref: ref,
|
120
|
+
data: value,
|
121
|
+
columns: title,
|
122
|
+
rowResize: true
|
16
123
|
}));
|
17
124
|
};
|
18
125
|
|
@@ -8,7 +8,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
8
|
/*
|
9
9
|
* @Author: wangxian
|
10
10
|
* @Date: 2021-09-18 14:15:04
|
11
|
-
* @LastEditTime: 2022-
|
11
|
+
* @LastEditTime: 2022-12-05 09:45:03
|
12
12
|
*/
|
13
13
|
import React from 'react';
|
14
14
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
@@ -75,6 +75,8 @@ function Index(props) {
|
|
75
75
|
}, help || (items === null || items === void 0 ? void 0 : items.type))), extraInfo.layout === 'table' && items.type === 'ref' ? /*#__PURE__*/React.createElement(TableArray, {
|
76
76
|
initValue: formContext.initialValues,
|
77
77
|
readonly: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
|
78
|
+
addButtonHidden: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.addButtonHidden,
|
79
|
+
rowNumber: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rowNumber) || 10,
|
78
80
|
refId: items.refId,
|
79
81
|
form: formContext.form,
|
80
82
|
name: id
|
@@ -4,11 +4,12 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import "antd/es/input-number/style";
|
5
5
|
import _InputNumber from "antd/es/input-number";
|
6
6
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
7
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
7
8
|
|
8
9
|
/*
|
9
10
|
* @Author: wangxian
|
10
11
|
* @Date: 2021-09-18 14:15:04
|
11
|
-
* @LastEditTime: 2022-
|
12
|
+
* @LastEditTime: 2022-12-08 13:45:40
|
12
13
|
*/
|
13
14
|
import React from 'react';
|
14
15
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
@@ -27,6 +28,26 @@ function Index(props) {
|
|
27
28
|
var formRefContext = React.useContext(MetadataRefContext);
|
28
29
|
var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
|
29
30
|
|
31
|
+
var _React$useState = React.useState([]),
|
32
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
33
|
+
rules = _React$useState2[0],
|
34
|
+
setRules = _React$useState2[1];
|
35
|
+
|
36
|
+
React.useEffect(function () {
|
37
|
+
var _rules = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rules;
|
38
|
+
|
39
|
+
if (_rules) {
|
40
|
+
var _ = _rules.map(function (it) {
|
41
|
+
return {
|
42
|
+
pattern: new RegExp(eval(it === null || it === void 0 ? void 0 : it.regExp), 'g'),
|
43
|
+
message: it.message
|
44
|
+
};
|
45
|
+
});
|
46
|
+
|
47
|
+
setRules(_toConsumableArray(_));
|
48
|
+
}
|
49
|
+
}, [extraInfo]);
|
50
|
+
|
30
51
|
if (isObj && isRefForm && field) {
|
31
52
|
var _extraInfo$disabled;
|
32
53
|
|
@@ -40,7 +61,7 @@ function Index(props) {
|
|
40
61
|
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
41
62
|
rules: [{
|
42
63
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
43
|
-
}],
|
64
|
+
}].concat(_toConsumableArray(rules)),
|
44
65
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
45
66
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
46
67
|
}), /*#__PURE__*/React.createElement(_InputNumber, {
|
@@ -59,7 +80,7 @@ function Index(props) {
|
|
59
80
|
name: name,
|
60
81
|
rules: [{
|
61
82
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
62
|
-
}],
|
83
|
+
}].concat(_toConsumableArray(rules)),
|
63
84
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
64
85
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
65
86
|
}, /*#__PURE__*/React.createElement(_InputNumber, {
|
@@ -74,7 +95,7 @@ function Index(props) {
|
|
74
95
|
fieldKey: [field === null || field === void 0 ? void 0 : field.fieldKey],
|
75
96
|
rules: [{
|
76
97
|
required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
|
77
|
-
}],
|
98
|
+
}].concat(_toConsumableArray(rules)),
|
78
99
|
help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
|
79
100
|
tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
|
80
101
|
}), /*#__PURE__*/React.createElement(_InputNumber, {
|
@@ -26,7 +26,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
26
26
|
/*
|
27
27
|
* @Author:wangxian
|
28
28
|
* @Date: 2021-09-18 14:15:04
|
29
|
-
* @LastEditTime: 2022-
|
29
|
+
* @LastEditTime: 2022-12-08 14:37:13
|
30
30
|
*/
|
31
31
|
import React from 'react';
|
32
32
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
@@ -82,7 +82,7 @@ function Index(props) {
|
|
82
82
|
var _watch = extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http = extraInfo.http) === null || _extraInfo$http === void 0 ? void 0 : _extraInfo$http.watch;
|
83
83
|
|
84
84
|
if (_watch) {
|
85
|
-
var _value = p.payload[_watch];
|
85
|
+
var _value = p === null || p === void 0 ? void 0 : p.payload[_watch];
|
86
86
|
|
87
87
|
if (_value) {
|
88
88
|
setWatchValue(_value);
|
@@ -18,6 +18,8 @@ import { deepClone } from '../../../../utils';
|
|
18
18
|
var TableArray = function TableArray(props) {
|
19
19
|
var initValue = props.initValue,
|
20
20
|
readonly = props.readonly,
|
21
|
+
rowNumber = props.rowNumber,
|
22
|
+
addButtonHidden = props.addButtonHidden,
|
21
23
|
name = props.name,
|
22
24
|
form = props.form,
|
23
25
|
refId = props.refId;
|
@@ -52,7 +54,7 @@ var TableArray = function TableArray(props) {
|
|
52
54
|
setList = _React$useState10[1];
|
53
55
|
|
54
56
|
useObservable(function (p) {
|
55
|
-
if ((p === null || p === void 0 ? void 0 : p.type) === 'setFieldsValue') {
|
57
|
+
if ((p === null || p === void 0 ? void 0 : p.type) === 'setFieldsValue' && p.payload[name]) {
|
56
58
|
setList(_toConsumableArray(p.payload[name]));
|
57
59
|
}
|
58
60
|
}, [formContext.stream$]);
|
@@ -183,7 +185,7 @@ var TableArray = function TableArray(props) {
|
|
183
185
|
var _columns = [];
|
184
186
|
|
185
187
|
for (var i = 0; i < _properties.length; i++) {
|
186
|
-
var _extraInfo$
|
188
|
+
var _extraInfo$common;
|
187
189
|
|
188
190
|
var it = _properties[i];
|
189
191
|
var extraInfo = refFieldsRef.current.get(it.id);
|
@@ -192,7 +194,7 @@ var TableArray = function TableArray(props) {
|
|
192
194
|
key: it.id,
|
193
195
|
dataIndex: it.id,
|
194
196
|
width: processColumnType(it, extraInfo) === 'buttonCell' ? 60 : 100,
|
195
|
-
editable: (_extraInfo$
|
197
|
+
editable: !((_extraInfo$common = extraInfo.common) === null || _extraInfo$common === void 0 ? void 0 : _extraInfo$common.disabled),
|
196
198
|
type: processColumnType(it, extraInfo),
|
197
199
|
enum: it.type === 'enum' ? processEnumData(it, extraInfo) : undefined
|
198
200
|
};
|
@@ -230,7 +232,7 @@ var TableArray = function TableArray(props) {
|
|
230
232
|
return /*#__PURE__*/React.createElement("div", {
|
231
233
|
style: {
|
232
234
|
width: '100%',
|
233
|
-
height:
|
235
|
+
height: "".concat(rowNumber * 40 + 40, "px")
|
234
236
|
}
|
235
237
|
}, /*#__PURE__*/React.createElement(_Form.Item, {
|
236
238
|
name: name,
|
@@ -242,6 +244,8 @@ var TableArray = function TableArray(props) {
|
|
242
244
|
readonly: readonly,
|
243
245
|
defaultValue: defaultValue,
|
244
246
|
addPosition: "bottom",
|
247
|
+
isAddRow: !addButtonHidden,
|
248
|
+
isAction: !addButtonHidden,
|
245
249
|
columns: columns,
|
246
250
|
dataSource: list,
|
247
251
|
onMulChange: onTableChange,
|
@@ -252,7 +256,7 @@ var TableArray = function TableArray(props) {
|
|
252
256
|
tableProps: {
|
253
257
|
scroll: {
|
254
258
|
x: '100%',
|
255
|
-
y:
|
259
|
+
y: "".concat(rowNumber * 40, "px")
|
256
260
|
}
|
257
261
|
}
|
258
262
|
})));
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"public": true,
|
3
3
|
"name": "ronds-metadata",
|
4
|
-
"version": "1.1.
|
4
|
+
"version": "1.1.67",
|
5
5
|
"scripts": {
|
6
6
|
"start": "dumi dev",
|
7
7
|
"docs:build": "dumi build",
|
@@ -52,14 +52,15 @@
|
|
52
52
|
"react": "^17.0.2",
|
53
53
|
"react-dnd": "^11.1.3",
|
54
54
|
"react-dnd-html5-backend": "^11.1.3",
|
55
|
-
"react-
|
55
|
+
"react-jexcel": "^1.0.2",
|
56
56
|
"react-markdown": "^8.0.3",
|
57
57
|
"react-markdown-editor-lite": "^1.3.2",
|
58
58
|
"react-popper": "^2.2.3",
|
59
59
|
"react-syntax-highlighter": "^15.5.0",
|
60
60
|
"rehype-raw": "^6.1.1",
|
61
61
|
"remark-gfm": "^3.0.1",
|
62
|
-
"rxjs": "^7.5.4"
|
62
|
+
"rxjs": "^7.5.4",
|
63
|
+
"xlsx": "^0.18.5"
|
63
64
|
},
|
64
65
|
"peerDependencies": {
|
65
66
|
"antd": ">=4.1.5",
|