ydb-components-material 0.1.93 → 0.1.94

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.
@@ -5,17 +5,13 @@ export interface FileListPreviewProps {
5
5
  * 列表数据
6
6
  */
7
7
  fileList: Array<object>;
8
- token: string;
9
8
  tokenTY: string;
10
9
  accessToken: string;
11
- userInfo: object;
12
10
  baseUrl: string;
13
11
  env: string;
14
12
  isPC?: boolean;
15
- disabled?: boolean;
16
13
  style?: object;
17
14
  download: (value: any) => void;
18
- valChange: (value: any) => void;
19
15
  }
20
16
  declare const FileListPreview: React.FC<FileListPreviewProps>;
21
17
  export default FileListPreview;
@@ -1,6 +1,5 @@
1
1
  import _Balloon from "@alifd/next/es/balloon";
2
2
  import React from 'react';
3
- var Tooltip = _Balloon.Tooltip;
4
3
  import FileItem from "./item";
5
4
  import "./index.scss";
6
5
  var MATERIAL_TYPE = {
@@ -30,18 +29,13 @@ var MATERIAL_FORMAT = {
30
29
  };
31
30
  var FileListPreview = function FileListPreview(_ref) {
32
31
  var fileList = _ref.fileList,
33
- token = _ref.token,
34
32
  tokenTY = _ref.tokenTY,
35
33
  accessToken = _ref.accessToken,
36
- userInfo = _ref.userInfo,
37
34
  baseUrl = _ref.baseUrl,
38
35
  env = _ref.env,
39
36
  isPC = _ref.isPC,
40
- disabled = _ref.disabled,
41
- isShowLib = _ref.isShowLib,
42
37
  style = _ref.style,
43
- download = _ref.download,
44
- valChange = _ref.valChange;
38
+ download = _ref.download;
45
39
  var convertNumbersToChinese = function convertNumbersToChinese(str) {
46
40
  // 定义基础映射关系
47
41
  var digitMap = {
@@ -104,58 +98,6 @@ var FileListPreview = function FileListPreview(_ref) {
104
98
  console.log('text', sizeText);
105
99
  return text + "\u9700\u4E0A\u4F20\u3010" + MATERIAL_TYPE[materialType] + "\u3011\uFF0C\u652F\u6301\u3010" + formatText + "\u3011\u683C\u5F0F\u3002" + sizeText;
106
100
  };
107
- var handleChange = function handleChange(value, fileIndex, index, subIndex) {
108
- console.log('handleChange', value, fileIndex, index, subIndex);
109
- // 先找到一级目录
110
- var oneLevelItem = fileList[index];
111
- // 如果subIndex有值。再去找一下二级目录
112
- if (subIndex !== undefined) {
113
- // value为空,说明删除了
114
- if (!value) {
115
- oneLevelItem.subMaterials[subIndex].isSmart = false;
116
- oneLevelItem.subMaterials[subIndex].isShareFile = false;
117
- // 如果当前文件list中只有一个文件,还得补个空的
118
- if (oneLevelItem.subMaterials[subIndex].fileList.length === 1) {
119
- oneLevelItem.subMaterials[subIndex].fileList = [{
120
- fileId: ''
121
- }];
122
- } else {
123
- oneLevelItem.subMaterials[subIndex].fileList.splice(fileIndex, 1);
124
- }
125
- } else {
126
- // 如果当前这个位置的fileId是空的。说明这次修改是新增
127
- var isAdd = !oneLevelItem.subMaterials[subIndex].fileList[fileIndex].fileId;
128
- oneLevelItem.subMaterials[subIndex].fileList[fileIndex] = value;
129
- if (isAdd && oneLevelItem.subMaterials[subIndex].fileList.length < 10) {
130
- oneLevelItem.subMaterials[subIndex].fileList.push({
131
- fileId: ''
132
- });
133
- }
134
- }
135
- } else {
136
- if (!value) {
137
- oneLevelItem.isSmart = false;
138
- oneLevelItem.isShareFile = false;
139
- oneLevelItem.fileList.splice(fileIndex, 1);
140
- if (oneLevelItem.fileList.length === 0) {
141
- oneLevelItem.fileList.push({
142
- fileId: ''
143
- });
144
- }
145
- } else {
146
- // 如果当前这个位置的fileId是空的。说明这次修改是新增
147
- var _isAdd = !oneLevelItem.fileList[fileIndex].fileId;
148
- oneLevelItem.fileList[fileIndex] = value;
149
- if (_isAdd && oneLevelItem.fileList.length < 10) {
150
- oneLevelItem.fileList.push({
151
- fileId: ''
152
- });
153
- }
154
- }
155
- }
156
- console.log('fileList--------res', fileList);
157
- valChange(fileList);
158
- };
159
101
  var trigger = function trigger(child) {
160
102
  return /*#__PURE__*/React.createElement("div", {
161
103
  className: "tag",
@@ -207,42 +149,36 @@ var FileListPreview = function FileListPreview(_ref) {
207
149
  align: "t",
208
150
  title: "",
209
151
  delay: 20
210
- }, child.isSmart ? '本材料为智能生成材料,系统将根据您填写的信息自动生成申报材料。' : child.isShareFile ? '本材料为共享材料,数据由大数据共享获取,无需用户自行准备。' : '需要用户自行准备申报材料')), child.fileList.length > 0 && child.fileList[0].fileId && child.fileList.map(function (file, i) {
211
- return /*#__PURE__*/React.createElement(FileItem, {
212
- file: file,
213
- fileConfig: child,
214
- maxFileSize: item.materialSize,
215
- token: token,
216
- tokenTY: tokenTY,
217
- accessToken: accessToken,
218
- baseUrl: baseUrl,
219
- env: env,
220
- isPC: isPC,
221
- disabled: disabled,
222
- download: download,
223
- style: {
224
- marginBottom: '12px',
225
- marginTop: '12px'
226
- }
227
- });
228
- }));
229
- })) : /*#__PURE__*/React.createElement(React.Fragment, null, item.fileList.length > 0 && item.fileList[0].fileId && item.fileList.map(function (file, i) {
230
- return /*#__PURE__*/React.createElement(FileItem, {
231
- file: file,
232
- fileConfig: item,
233
- maxFileSize: item.materialSize,
234
- token: token,
152
+ }, child.isSmart ? '本材料为智能生成材料,系统将根据您填写的信息自动生成申报材料。' : child.isShareFile ? '本材料为共享材料,数据由大数据共享获取,无需用户自行准备。' : '需要用户自行准备申报材料')), /*#__PURE__*/React.createElement("p", {
153
+ className: "tip"
154
+ }, getTipTextForSubMaterial(item, index, subIndex)), child.fileObj && /*#__PURE__*/React.createElement(FileItem, {
155
+ file: child.fileObj,
156
+ fileConfig: child,
235
157
  tokenTY: tokenTY,
236
158
  accessToken: accessToken,
237
159
  baseUrl: baseUrl,
238
160
  env: env,
239
161
  isPC: isPC,
240
- disabled: disabled,
241
162
  download: download,
242
163
  style: {
243
- marginBottom: '12px'
164
+ marginBottom: '12px',
165
+ marginTop: '12px'
244
166
  }
245
- });
167
+ }));
168
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
169
+ className: "tip"
170
+ }, getTipText(item)), item.fileObj && /*#__PURE__*/React.createElement(FileItem, {
171
+ file: item.fileObj,
172
+ fileConfig: item,
173
+ tokenTY: tokenTY,
174
+ accessToken: accessToken,
175
+ baseUrl: baseUrl,
176
+ env: env,
177
+ isPC: isPC,
178
+ download: download,
179
+ style: {
180
+ marginBottom: '12px'
181
+ }
246
182
  })));
247
183
  }));
248
184
  };
@@ -3,14 +3,11 @@ import './item.scss';
3
3
  export interface FileItemProps {
4
4
  file: object;
5
5
  fileConfig: object;
6
- token: string;
7
6
  tokenTY: string;
8
7
  accessToken: string;
9
8
  baseUrl: string;
10
9
  env: string;
11
10
  isPC?: boolean;
12
- disabled?: boolean;
13
- maxFileSize: number;
14
11
  style?: object;
15
12
  download: (value: any) => void;
16
13
  }
@@ -14,20 +14,18 @@ import "./item.scss";
14
14
  var FileItem = function FileItem(_ref) {
15
15
  var file = _ref.file,
16
16
  fileConfig = _ref.fileConfig,
17
- maxFileSize = _ref.maxFileSize,
18
- token = _ref.token,
19
17
  tokenTY = _ref.tokenTY,
20
18
  accessToken = _ref.accessToken,
21
19
  baseUrl = _ref.baseUrl,
22
20
  env = _ref.env,
23
21
  isPC = _ref.isPC,
24
- disabled = _ref.disabled,
25
22
  style = _ref.style,
26
23
  download = _ref.download;
27
- console.log('fileItem', file, maxFileSize);
24
+ console.log('fileItem', file);
28
25
  var fileName = file.fileName,
29
- fileUrl = file.fileUrl,
30
- fileId = file.fileId;
26
+ downloadFileId = file.downloadFileId,
27
+ previewFileId = file.previewFileId,
28
+ fileUrl = file.fileUrl;
31
29
  var signGuidFileId = fileConfig.signGuidFileId,
32
30
  keyPoint = fileConfig.keyPoint;
33
31
  var _useState = useState(false),
@@ -66,7 +64,6 @@ var FileItem = function FileItem(_ref) {
66
64
  id: signGuidFileId,
67
65
  effectiveTime: 3600000
68
66
  }, {
69
- token: token,
70
67
  tokenTY: tokenTY,
71
68
  baseUrl: baseUrl,
72
69
  env: env,
@@ -89,71 +86,79 @@ var FileItem = function FileItem(_ref) {
89
86
  return _ref2.apply(this, arguments);
90
87
  };
91
88
  }();
92
- var onDownload = function onDownload() {
93
- var fileName = file.fileName,
94
- fileId = file.fileId;
95
- if (disabled) return;
96
- var format = getFileExtension(fileName);
97
- download({
98
- fileId: fileId,
99
- format: format
100
- });
101
- };
102
- var extractImageUrls = /*#__PURE__*/function () {
103
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(previewUrl) {
104
- var response, htmlText, parser, doc, imgElements, srcList;
89
+ var onDownload = /*#__PURE__*/function () {
90
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
91
+ var format;
105
92
  return _regeneratorRuntime.wrap(function (_context2) {
106
93
  while (1) switch (_context2.prev = _context2.next) {
107
94
  case 0:
108
- _context2.next = 1;
95
+ format = getFileExtension(fileName);
96
+ download({
97
+ fileId: downloadFileId,
98
+ format: format
99
+ });
100
+ case 1:
101
+ case "end":
102
+ return _context2.stop();
103
+ }
104
+ }, _callee2);
105
+ }));
106
+ return function onDownload() {
107
+ return _ref3.apply(this, arguments);
108
+ };
109
+ }();
110
+ var extractImageUrls = /*#__PURE__*/function () {
111
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(previewUrl) {
112
+ var response, htmlText, parser, doc, imgElements, srcList;
113
+ return _regeneratorRuntime.wrap(function (_context3) {
114
+ while (1) switch (_context3.prev = _context3.next) {
115
+ case 0:
116
+ _context3.next = 1;
109
117
  return fetch(previewUrl);
110
118
  case 1:
111
- response = _context2.sent;
112
- _context2.next = 2;
119
+ response = _context3.sent;
120
+ _context3.next = 2;
113
121
  return response.text();
114
122
  case 2:
115
- htmlText = _context2.sent;
123
+ htmlText = _context3.sent;
116
124
  parser = new DOMParser();
117
125
  doc = parser.parseFromString(htmlText, 'text/html');
118
126
  imgElements = doc.querySelectorAll('img');
119
127
  srcList = Array.from(imgElements).map(function (img) {
120
128
  return img.getAttribute('data-src');
121
129
  });
122
- return _context2.abrupt("return", srcList);
130
+ return _context3.abrupt("return", srcList);
123
131
  case 3:
124
132
  case "end":
125
- return _context2.stop();
133
+ return _context3.stop();
126
134
  }
127
- }, _callee2);
135
+ }, _callee3);
128
136
  }));
129
137
  return function extractImageUrls(_x) {
130
- return _ref3.apply(this, arguments);
138
+ return _ref4.apply(this, arguments);
131
139
  };
132
140
  }();
133
141
 
134
142
  // 预览材料
135
143
  var preview = /*#__PURE__*/function () {
136
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
144
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
137
145
  var urlRes, res;
138
- return _regeneratorRuntime.wrap(function (_context3) {
139
- while (1) switch (_context3.prev = _context3.next) {
146
+ return _regeneratorRuntime.wrap(function (_context4) {
147
+ while (1) switch (_context4.prev = _context4.next) {
140
148
  case 0:
141
- if (fileUrl) {
142
- _context3.next = 1;
149
+ if (previewFileId) {
150
+ _context4.next = 1;
143
151
  break;
144
152
  }
145
- return _context3.abrupt("return");
153
+ return _context4.abrupt("return");
146
154
  case 1:
147
- console.log('fileUrl', fileUrl, fileId);
148
- setPreviewIframeUrl(fileUrl);
149
- setIsShowPreview(true);
150
- // if (!fileId) return;
151
- _context3.next = 2;
155
+ console.log('fileUrl', previewFileId);
156
+ // if (!previewFileId) return;
157
+ _context4.next = 2;
152
158
  return getUrlById({
153
- id: fileId,
159
+ id: previewFileId,
154
160
  effectiveTime: 3600000
155
161
  }, {
156
- token: token,
157
162
  tokenTY: tokenTY,
158
163
  baseUrl: baseUrl,
159
164
  env: env,
@@ -161,16 +166,15 @@ var FileItem = function FileItem(_ref) {
161
166
  accessToken: accessToken
162
167
  });
163
168
  case 2:
164
- urlRes = _context3.sent;
169
+ urlRes = _context4.sent;
165
170
  if (!(urlRes.presignedUrlList && urlRes.presignedUrlList.length > 0)) {
166
- _context3.next = 4;
171
+ _context4.next = 4;
167
172
  break;
168
173
  }
169
- _context3.next = 3;
174
+ _context4.next = 3;
170
175
  return onlinePreview({
171
176
  url: urlRes.presignedUrlList[2]
172
177
  }, {
173
- token: token,
174
178
  tokenTY: tokenTY,
175
179
  baseUrl: baseUrl,
176
180
  env: env,
@@ -178,44 +182,43 @@ var FileItem = function FileItem(_ref) {
178
182
  accessToken: accessToken
179
183
  });
180
184
  case 3:
181
- res = _context3.sent;
185
+ res = _context4.sent;
182
186
  setPreviewIframeUrl(res.url);
183
187
  setIsShowPreview(true);
184
188
  case 4:
185
189
  case "end":
186
- return _context3.stop();
190
+ return _context4.stop();
187
191
  }
188
- }, _callee3);
192
+ }, _callee4);
189
193
  }));
190
194
  return function preview() {
191
- return _ref4.apply(this, arguments);
195
+ return _ref5.apply(this, arguments);
192
196
  };
193
197
  }();
194
198
  var getViewUrl = /*#__PURE__*/function () {
195
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id) {
199
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id) {
196
200
  var type, urlRes, res, list;
197
- return _regeneratorRuntime.wrap(function (_context4) {
198
- while (1) switch (_context4.prev = _context4.next) {
201
+ return _regeneratorRuntime.wrap(function (_context5) {
202
+ while (1) switch (_context5.prev = _context5.next) {
199
203
  case 0:
200
204
  type = getFileExtension(fileName);
201
205
  if (!['png', 'jpg', 'jpeg'].includes(type)) {
202
- _context4.next = 1;
206
+ _context5.next = 1;
203
207
  break;
204
208
  }
205
- return _context4.abrupt("return", fileUrl);
209
+ return _context5.abrupt("return", fileUrl);
206
210
  case 1:
207
211
  if (!(type !== 'pdf')) {
208
- _context4.next = 2;
212
+ _context5.next = 2;
209
213
  break;
210
214
  }
211
- return _context4.abrupt("return", '');
215
+ return _context5.abrupt("return", '');
212
216
  case 2:
213
- _context4.next = 3;
217
+ _context5.next = 3;
214
218
  return getUrlById({
215
219
  id: id,
216
220
  effectiveTime: 3600000
217
221
  }, {
218
- token: token,
219
222
  tokenTY: tokenTY,
220
223
  baseUrl: baseUrl,
221
224
  env: env,
@@ -223,17 +226,16 @@ var FileItem = function FileItem(_ref) {
223
226
  accessToken: accessToken
224
227
  });
225
228
  case 3:
226
- urlRes = _context4.sent;
229
+ urlRes = _context5.sent;
227
230
  if (!(urlRes.presignedUrlList && urlRes.presignedUrlList.length > 0)) {
228
- _context4.next = 6;
231
+ _context5.next = 6;
229
232
  break;
230
233
  }
231
234
  console.log('urlRes', urlRes);
232
- _context4.next = 4;
235
+ _context5.next = 4;
233
236
  return onlinePreview({
234
237
  url: urlRes.presignedUrlList[2]
235
238
  }, {
236
- token: token,
237
239
  tokenTY: tokenTY,
238
240
  baseUrl: baseUrl,
239
241
  env: env,
@@ -241,36 +243,34 @@ var FileItem = function FileItem(_ref) {
241
243
  accessToken: accessToken
242
244
  });
243
245
  case 4:
244
- res = _context4.sent;
245
- _context4.next = 5;
246
+ res = _context5.sent;
247
+ _context5.next = 5;
246
248
  return extractImageUrls(res.url);
247
249
  case 5:
248
- list = _context4.sent;
250
+ list = _context5.sent;
249
251
  console.log('list---', list);
250
- return _context4.abrupt("return", list[0]);
252
+ return _context5.abrupt("return", list[0]);
251
253
  case 6:
252
254
  case "end":
253
- return _context4.stop();
255
+ return _context5.stop();
254
256
  }
255
- }, _callee4);
257
+ }, _callee5);
256
258
  }));
257
259
  return function getViewUrl(_x2) {
258
- return _ref5.apply(this, arguments);
260
+ return _ref6.apply(this, arguments);
259
261
  };
260
262
  }();
261
263
  useEffect(function () {
262
- if (fileId) {
263
- getViewUrl(fileId).then(function (url) {
264
+ if (previewFileId) {
265
+ getViewUrl(previewFileId).then(function (url) {
264
266
  setThumbnail(url);
265
267
  });
266
268
  }
267
- }, [fileId]);
269
+ }, [previewFileId]);
268
270
  return /*#__PURE__*/React.createElement("div", {
269
271
  className: "file_item",
270
272
  style: style
271
- }, /*#__PURE__*/React.createElement("p", {
272
- className: "file_name"
273
- }, fileName), /*#__PURE__*/React.createElement("div", {
273
+ }, /*#__PURE__*/React.createElement("div", {
274
274
  className: "file"
275
275
  }, /*#__PURE__*/React.createElement("div", {
276
276
  className: "file_img"
@@ -286,21 +286,21 @@ var FileItem = function FileItem(_ref) {
286
286
  alt: ""
287
287
  }))), isPC && /*#__PURE__*/React.createElement("div", {
288
288
  className: "blocks"
289
- }, fileUrl && /*#__PURE__*/React.createElement("div", {
289
+ }, downloadFileId && previewFileId && /*#__PURE__*/React.createElement("div", {
290
290
  className: "btns"
291
- }, /*#__PURE__*/React.createElement("div", {
291
+ }, previewFileId && /*#__PURE__*/React.createElement("div", {
292
292
  className: "btn",
293
293
  onClick: preview
294
294
  }, /*#__PURE__*/React.createElement("img", {
295
295
  src: previewIconPC,
296
296
  alt: ""
297
- }), "\u9884\u89C8"), !disabled && /*#__PURE__*/React.createElement("div", {
297
+ }), "\u9884\u89C8"), downloadFileId && /*#__PURE__*/React.createElement("div", {
298
298
  className: "btn",
299
299
  onClick: onDownload
300
300
  }, /*#__PURE__*/React.createElement("img", {
301
301
  src: downloadIconPC,
302
302
  alt: ""
303
- }), "\u4E0B\u8F7D"))), !disabled && /*#__PURE__*/React.createElement("div", {
303
+ }), "\u4E0B\u8F7D"))), /*#__PURE__*/React.createElement("div", {
304
304
  className: isPC ? 'operation_pc' : 'operation'
305
305
  }, /*#__PURE__*/React.createElement("div", {
306
306
  className: "btn"
@@ -315,17 +315,17 @@ var FileItem = function FileItem(_ref) {
315
315
  }, "\u5BA1\u67E5\u8981\u70B9")))), !isPC && /*#__PURE__*/React.createElement("div", {
316
316
  className: "file_item_bottom",
317
317
  style: {
318
- justifyContent: disabled ? 'center' : 'space-evenly'
318
+ justifyContent: previewFileId && downloadFileId ? 'space-evenly' : 'center'
319
319
  }
320
- }, /*#__PURE__*/React.createElement("div", {
320
+ }, previewFileId && /*#__PURE__*/React.createElement("div", {
321
321
  className: "icon_text",
322
322
  onClick: preview
323
323
  }, /*#__PURE__*/React.createElement("img", {
324
324
  src: previewIcon,
325
325
  alt: ""
326
- }), "\u9884\u89C8"), !disabled && /*#__PURE__*/React.createElement("div", {
326
+ }), "\u9884\u89C8"), previewFileId && downloadFileId && /*#__PURE__*/React.createElement("div", {
327
327
  className: "line"
328
- }), !disabled && /*#__PURE__*/React.createElement("div", {
328
+ }), downloadFileId && /*#__PURE__*/React.createElement("div", {
329
329
  className: "icon_text",
330
330
  onClick: onDownload
331
331
  }, /*#__PURE__*/React.createElement("img", {
@@ -5,17 +5,13 @@ export interface FileListPreviewProps {
5
5
  * 列表数据
6
6
  */
7
7
  fileList: Array<object>;
8
- token: string;
9
8
  tokenTY: string;
10
9
  accessToken: string;
11
- userInfo: object;
12
10
  baseUrl: string;
13
11
  env: string;
14
12
  isPC?: boolean;
15
- disabled?: boolean;
16
13
  style?: object;
17
14
  download: (value: any) => void;
18
- valChange: (value: any) => void;
19
15
  }
20
16
  declare const FileListPreview: React.FC<FileListPreviewProps>;
21
17
  export default FileListPreview;