ronds-metadata 1.1.66 → 1.1.68

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 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-08-29 19:24:38
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.eyJuYmYiOjE2Mzg1MTM1NzMsImV4cCI6MTY3MDA0OTU3MywiaXNzIjoiaHR0cDovLzE5Mi4xNjguMS4xNzk6MzEwMDIiLCJhdWQiOiJlcG0iLCJjbGllbnRfaWQiOiJlcG0iLCJzdWIiOiIzYTAwMjYxOS1kNGRjLTY5NGMtYjUzNi0xNzM3YzVjZjRlM2UiLCJhdXRoX3RpbWUiOjE2Mzg1MTM1NzMsImlkcCI6ImxvY2FsIiwicGhvbmVfbnVtYmVyIjoiMTgxNjQ0NjI0MDAiLCJwaG9uZV9udW1iZXJfdmVyaWZpZWQiOiJGYWxzZSIsImVtYWlsIjoieGlhbi53YW5nQHJvbmRzLmNvbS5jbiIsImVtYWlsX3ZlcmlmaWVkIjoiRmFsc2UiLCJuYW1lIjoid2FuZ3hpYW4iLCJpYXQiOjE2Mzg1MTM1NzMsInNjb3BlIjpbImFkZHJlc3MiLCJlbWFpbCIsImVwbSIsIm9wZW5pZCIsInBob25lIiwicHJvZmlsZSIsInJvbGUiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicHdkIl19.FI4lIbjLwCn0sF9iZ1aaJ9vXLEi8Tx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6z-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) {
@@ -1,2 +1,5 @@
1
- declare const FileView: () => JSX.Element;
1
+ interface IFileViewProps {
2
+ path: string;
3
+ }
4
+ declare const FileView: (props: IFileViewProps) => JSX.Element;
2
5
  export default FileView;
@@ -1,18 +1,125 @@
1
- import React from "react";
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
- * @Author: wangxian
5
- * @Date: 2022-11-25 14:14:50
6
- * @LastEditTime: 2022-11-25 14:30:35
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 FileView = function FileView() {
11
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FileViewer, {
12
- fileType: "xslx" //文件类型
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
 
@@ -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-10-10 11:27:22
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-11-28 16:28:25
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);
@@ -232,7 +232,7 @@ var TableArray = function TableArray(props) {
232
232
  return /*#__PURE__*/React.createElement("div", {
233
233
  style: {
234
234
  width: '100%',
235
- height: "".concat(rowNumber * 40 + 40, "px")
235
+ height: addButtonHidden ? "".concat(rowNumber * 33 + 50, "px") : "".concat(rowNumber * 33 + 50 + 40, "px")
236
236
  }
237
237
  }, /*#__PURE__*/React.createElement(_Form.Item, {
238
238
  name: name,
@@ -256,7 +256,7 @@ var TableArray = function TableArray(props) {
256
256
  tableProps: {
257
257
  scroll: {
258
258
  x: '100%',
259
- y: "".concat(rowNumber * 40, "px")
259
+ y: "".concat(rowNumber * 33 + 50, "px")
260
260
  }
261
261
  }
262
262
  })));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.1.66",
4
+ "version": "1.1.68",
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-file-viewer": "^1.2.1",
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",