ydb-components-material 0.1.22 → 0.1.24

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.
Files changed (46) hide show
  1. package/build/docs/404.html +3 -3
  2. package/build/docs/_demos/:uuid +3 -3
  3. package/build/docs/colorful-button.html +3 -3
  4. package/build/docs/colorful-input.html +3 -3
  5. package/build/docs/index.html +3 -3
  6. package/build/docs/umi.0ca7fca9.js +1 -0
  7. package/build/docs/{umi.1ef21448.css → umi.e536bfab.css} +1 -1
  8. package/build/docs/~demos/:uuid.html +3 -3
  9. package/build/docs/~demos/colorful-button-demo.html +3 -3
  10. package/build/docs/~demos/colorful-input-demo.html +3 -3
  11. package/build/lowcode/assets-daily.json +11 -11
  12. package/build/lowcode/assets-dev.json +2 -2
  13. package/build/lowcode/assets-prod.json +11 -11
  14. package/build/lowcode/index.js +1 -1
  15. package/build/lowcode/meta.js +1 -1
  16. package/build/lowcode/preview.js +6 -6
  17. package/build/lowcode/render/default/view.css +1 -1
  18. package/build/lowcode/render/default/view.js +1 -1
  19. package/build/lowcode/view.css +1 -1
  20. package/build/lowcode/view.js +1 -1
  21. package/dist/BizComps.css +1 -1
  22. package/dist/BizComps.js +1 -1
  23. package/dist/BizComps.js.map +1 -1
  24. package/es/api.js +8 -1
  25. package/es/components/file-item/file.js +62 -1
  26. package/es/components/file-item/index.d.ts +1 -2
  27. package/es/components/file-item/index.js +217 -15
  28. package/es/components/file-item/index.scss +4 -2
  29. package/es/components/file-item/seal.js +63 -22
  30. package/es/components/file-item/sealUtil.js +2 -1
  31. package/es/utils.js +0 -0
  32. package/lib/api.js +9 -2
  33. package/lib/components/file-item/file.js +63 -1
  34. package/lib/components/file-item/index.d.ts +1 -2
  35. package/lib/components/file-item/index.js +218 -16
  36. package/lib/components/file-item/index.scss +4 -2
  37. package/lib/components/file-item/seal.js +60 -19
  38. package/lib/components/file-item/sealUtil.js +2 -1
  39. package/lib/utils.js +1 -0
  40. package/lowcode/file-item/meta.ts +17 -2
  41. package/lowcode_es/file-item/meta.js +16 -2
  42. package/lowcode_es/meta.js +1 -1
  43. package/lowcode_lib/file-item/meta.js +16 -2
  44. package/lowcode_lib/meta.js +1 -1
  45. package/package.json +3 -3
  46. package/build/docs/umi.0ec80fbb.js +0 -1
package/es/api.js CHANGED
@@ -114,10 +114,17 @@ export var getSealUrlApi = function getSealUrlApi(params, config) {
114
114
 
115
115
  // 电子签章-下载文件
116
116
  export var signFileDownApi = function signFileDownApi(params, config) {
117
- return post(config.baseUrl + "declaration/center/sign/api/fileDownloadBySign", params, config);
117
+ return post(config.baseUrl + "/declaration/center/sign/api/fileDownloadBySign", params, config);
118
118
  };
119
119
 
120
120
  // 预览
121
121
  export var previewApi = function previewApi(params, config) {
122
122
  return post("https://zwfwpt.sxzwfw.gov.cn/DeclarationAPI/declaration/center/sign/api/preview", params, config);
123
+ };
124
+ // 材料库
125
+ export var getMaterialLib = function getMaterialLib(params, config) {
126
+ return post("https://zwfwpt.sxzwfw.gov.cn/DeclarationAPI/declaration/material/queryFileByCardNo", params, config);
127
+ };
128
+ export var getSignFileApi = function getSignFileApi(params, config) {
129
+ return post(config.baseUrl + "/declaration/center/sign/api/getSignFileList", params, config);
123
130
  };
@@ -160,4 +160,65 @@ export function uploadFilePromise(url, baseUrl, token) {
160
160
  // }
161
161
  // })
162
162
  });
163
- }
163
+ }
164
+
165
+ // 初始化材料格式 [方法]
166
+ export var initFormat = function initFormat(materialSpec) {
167
+ var materialSpecArr = materialSpec.split(',');
168
+ var arr = [{
169
+ key: '1',
170
+ value: 'doc'
171
+ }, {
172
+ key: '2',
173
+ value: 'docx'
174
+ }, {
175
+ key: '3',
176
+ value: 'pdf'
177
+ }, {
178
+ key: '4',
179
+ value: 'ofd'
180
+ }, {
181
+ key: '5',
182
+ value: 'xlsx'
183
+ }, {
184
+ key: '6',
185
+ value: 'xls'
186
+ }, {
187
+ key: '7',
188
+ value: 'png'
189
+ }, {
190
+ key: '8',
191
+ value: 'jpg'
192
+ }, {
193
+ key: '9',
194
+ value: 'jpeg'
195
+ }, {
196
+ key: '10',
197
+ value: 'gif'
198
+ }, {
199
+ key: '11',
200
+ value: 'bmp'
201
+ }, {
202
+ key: '12',
203
+ value: 'zip'
204
+ }, {
205
+ key: '13',
206
+ value: 'rar'
207
+ }, {
208
+ key: '14',
209
+ value: 'mp3'
210
+ }, {
211
+ key: '15',
212
+ value: 'mp4'
213
+ }, {
214
+ key: '16',
215
+ value: 'xml'
216
+ }];
217
+ var formatArr = [];
218
+ arr.forEach(function (ele) {
219
+ if (materialSpecArr.includes(ele.key)) {
220
+ formatArr.push(ele.value);
221
+ }
222
+ });
223
+ return formatArr;
224
+ };
@@ -18,13 +18,12 @@ export interface FileItemProps {
18
18
  isSealed: boolean;
19
19
  materialList: any[];
20
20
  maxFileSize: number;
21
+ spec: string;
21
22
  isInValid: boolean;
22
23
  isShowLib: boolean;
23
24
  userInfo: any;
24
25
  baseUrl: string;
25
26
  del: () => void;
26
- handleSeal: () => void;
27
- handleSign: () => void;
28
27
  valChange: (value: any) => void;
29
28
  download: (value: any) => void;
30
29
  }
@@ -2,7 +2,7 @@ import _Icon from "@alifd/next/es/icon";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _Message from "@alifd/next/es/message";
4
4
  import _Radio from "@alifd/next/es/radio";
5
- import React, { useState } from 'react';
5
+ import React, { useEffect, useState } from 'react';
6
6
  import CheckedIcon from "./icon/checked.svg";
7
7
  import delIcon from "./icon/del.svg";
8
8
  import previewIcon from "./icon/preview.svg";
@@ -14,6 +14,8 @@ import uploadIcon from "./icon/upload.svg";
14
14
  import closeIcon from "./icon/close.svg";
15
15
  import SignPage from "./sign";
16
16
  import SealPage from "./seal";
17
+ import { getMaterialLib } from "../../api";
18
+ import { initFormat, getFileExtension } from "./file.js";
17
19
  import "./index.scss";
18
20
  var RadioGroup = _Radio.Group;
19
21
  var FileItem = function FileItem(_ref) {
@@ -27,6 +29,7 @@ var FileItem = function FileItem(_ref) {
27
29
  isSealed = _ref.isSealed,
28
30
  materialList = _ref.materialList,
29
31
  maxFileSize = _ref.maxFileSize,
32
+ spec = _ref.spec,
30
33
  isInValid = _ref.isInValid,
31
34
  isShowLib = _ref.isShowLib,
32
35
  userInfo = _ref.userInfo,
@@ -48,8 +51,8 @@ var FileItem = function FileItem(_ref) {
48
51
  isShowMaterialLib = _useState3[0],
49
52
  setIsShowMaterialLib = _useState3[1];
50
53
  var _useState4 = useState(),
51
- material = _useState4[0],
52
- setMaterial = _useState4[1];
54
+ materialId = _useState4[0],
55
+ setMaterial = _useState4[1]; // 在材料库中的材料
53
56
  var _useState5 = useState(false),
54
57
  isShowSignPage = _useState5[0],
55
58
  setIsShowSignPage = _useState5[1];
@@ -62,6 +65,53 @@ var FileItem = function FileItem(_ref) {
62
65
  var _useState8 = useState(''),
63
66
  previewIframeUrl = _useState8[0],
64
67
  setPreviewIframeUrl = _useState8[1];
68
+ var _useState9 = useState({}),
69
+ materialUrlMap = _useState9[0],
70
+ setMaterialUrlMap = _useState9[1];
71
+ var _useState0 = useState(''),
72
+ materialPreviewUrl = _useState0[0],
73
+ setMaterialPreviewUrl = _useState0[1];
74
+ var _useState1 = useState(false),
75
+ isShowMaterialPreview = _useState1[0],
76
+ setIsShowMaterialPreview = _useState1[1];
77
+ var _useState10 = useState([{
78
+ "fileId": "1753419199903092737",
79
+ "fileName": "javaScript.jpg",
80
+ "uploadTime": "2024-02-03 17:09:34",
81
+ "type": 0,
82
+ "innerFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419199903092737/javaScript.jpg",
83
+ "internetFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419199903092737/javaScript.jpg"
84
+ }, {
85
+ "fileId": "1753419376331853826",
86
+ "fileName": "LQ_z-fynmzrs7874917.jpg",
87
+ "uploadTime": "2024-02-03 17:09:34",
88
+ "type": 0,
89
+ "innerFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419376331853826/LQ_z-fynmzrs7874917.jpg",
90
+ "internetFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419376331853826/LQ_z-fynmzrs7874917.jpg"
91
+ }, {
92
+ "fileId": "1753419180202446850",
93
+ "fileName": "mayun.jpg",
94
+ "uploadTime": "2024-02-03 17:09:34",
95
+ "type": 0,
96
+ "innerFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419180202446850/mayun.jpg",
97
+ "internetFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419180202446850/mayun.jpg"
98
+ }, {
99
+ "fileId": "1753419356975140866",
100
+ "fileName": "find.png",
101
+ "uploadTime": "2024-02-03 17:09:33",
102
+ "type": 0,
103
+ "innerFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419356975140866/find.png",
104
+ "internetFileUrl": "https://zwfwpt.sxzwfw.gov.cn/FS//18a78d3d407-true/master/18b4752f107/2024/2/1753419356975140866/find.png"
105
+ }]),
106
+ materialLib = _useState10[0],
107
+ setMaterialLib = _useState10[1];
108
+ // const [materialLib, setMaterialLib] = useState([]);
109
+ var _useState11 = useState(''),
110
+ guideurl = _useState11[0],
111
+ setGuideurl = _useState11[1];
112
+ var _useState12 = useState(false),
113
+ isShowGuide = _useState12[0],
114
+ setIsShowGuide = _useState12[1];
65
115
  var list = materialList || [{
66
116
  name: '图片1',
67
117
  value: 1
@@ -95,6 +145,13 @@ var FileItem = function FileItem(_ref) {
95
145
  _Message.notice("\u6587\u4EF6 \"" + fileData.name + "\" \u8D85\u8FC7" + maxFileSize + "MB\u9650\u5236");
96
146
  return;
97
147
  }
148
+ if (spec) {
149
+ var type = getFileExtension(fileData.name);
150
+ if (!initFormat(spec).includes(type)) {
151
+ _Message.notice("\u6587\u4EF6 \"" + fileData.name + "\" \u683C\u5F0F\u4E0D\u6B63\u786E");
152
+ return;
153
+ }
154
+ }
98
155
  var formData = new FormData();
99
156
  formData.append('file', fileData);
100
157
  formData.append('open', true);
@@ -120,8 +177,14 @@ var FileItem = function FileItem(_ref) {
120
177
  });
121
178
  });
122
179
  };
180
+
181
+ // 预览材料
123
182
  var preview = function preview() {
124
183
  if (!fileUrl) return;
184
+ if (previewIframeUrl) {
185
+ setIsShowPreview(true);
186
+ return;
187
+ }
125
188
  fetch(baseUrl + "/declaration/material/onlinePreview?url=" + fileUrl, {
126
189
  method: 'GET'
127
190
  }).then(function (response) {
@@ -131,13 +194,37 @@ var FileItem = function FileItem(_ref) {
131
194
  setIsShowPreview(true);
132
195
  });
133
196
  };
197
+
198
+ // 预览材料中的材料
199
+ var previewMaterial = function previewMaterial(id, url) {
200
+ if (materialUrlMap[id]) {
201
+ setIsShowMaterialPreview(true);
202
+ setMaterialPreviewUrl(materialUrlMap[id]);
203
+ return;
204
+ }
205
+ fetch(baseUrl + "/declaration/material/onlinePreview?url=" + url, {
206
+ method: 'GET'
207
+ }).then(function (response) {
208
+ return response.json();
209
+ }).then(function (res) {
210
+ var _extends2;
211
+ setMaterialPreviewUrl(res.url);
212
+ setIsShowMaterialPreview(true);
213
+ setMaterialUrlMap(_extends({}, materialUrlMap, (_extends2 = {}, _extends2[id] = res.url, _extends2)));
214
+ });
215
+ };
216
+
217
+ // 手写签批
134
218
  var sign = function sign() {
135
219
  // handleSign()
136
220
  setIsShowSignPage(true);
137
221
  };
222
+
223
+ // 签章
138
224
  var seal = function seal() {
139
225
  console.log('fileType', fileType);
140
- if (fileType !== 'application/pdf') {
226
+ var type = getFileExtension(fileName);
227
+ if (type !== 'pdf') {
141
228
  _Message.notice('只有pdf文件才能使用电子签章');
142
229
  return;
143
230
  }
@@ -152,6 +239,86 @@ var FileItem = function FileItem(_ref) {
152
239
  console.log('sealval---', val);
153
240
  valChange(val);
154
241
  };
242
+ var queryFileLibs = function queryFileLibs() {
243
+ console.log('queryFileLibs');
244
+ var certNo = userInfo.certNo,
245
+ certificateSno = userInfo.certificateSno,
246
+ acctType = userInfo.acctType;
247
+ var params = {
248
+ // cardno: acctType === '10' ? certNo : certificateSno, // 个人传身份证号、法人传社会统一信用代码
249
+ cardno: '140110199504131013',
250
+ // 个人传身份证号、法人传社会统一信用代码
251
+ type: acctType === '10' ? '11' : '21',
252
+ pageNum: 1,
253
+ pageSize: 10
254
+ };
255
+ getMaterialLib(params, {
256
+ token: token
257
+ }).then(function (res) {
258
+ if (res.code === 200) {
259
+ var records = res.data.records;
260
+ setMaterialLib(records);
261
+ }
262
+ // if (+total === this.fileList.length) {
263
+ // this.loadStatus = 'nomore'
264
+ // } else {
265
+ // this.loadStatus = 'loadmore'
266
+ // }
267
+ })["catch"](function () {
268
+ // this.loadStatus = 'nomore'
269
+ });
270
+ };
271
+ var showGuide = function showGuide() {
272
+ if (!guideImg) return;
273
+ if (guideurl) {
274
+ setIsShowGuide(true);
275
+ return;
276
+ }
277
+ fetch(baseUrl + "/declaration/material/file/files/api/presigned-url?id=" + guideImg + "&effectiveTime=3600000", {
278
+ method: 'GET'
279
+ }).then(function (response) {
280
+ return response.json();
281
+ }).then(function (res) {
282
+ if (res.presignedUrl) {
283
+ setGuideurl(res.presignedUrl);
284
+ setIsShowGuide(true);
285
+ }
286
+ });
287
+ };
288
+ var selectMaterialOk = function selectMaterialOk() {
289
+ console.log('val', materialId);
290
+ var selectedMaterial = materialLib.find(function (item) {
291
+ return item.fileId === materialId;
292
+ });
293
+ console.log('selectedMaterial', selectedMaterial);
294
+ if (spec) {
295
+ var arr = selectedMaterial.fileName.split('.'); //
296
+ var fileFormat = arr[arr.length - 1]; // 获取当前材料库材料的文件类型
297
+ console.log(fileFormat, '材料库当前选择的文件格式');
298
+ var formatFinal = initFormat(spec); // 限制的文件类型
299
+ console.log(formatFinal, '限制的格式最后');
300
+ if (!formatFinal.includes(fileFormat)) {
301
+ _Message.notice("\u8BE5\u6750\u6599\u4E0D\u652F\u6301\u4E0A\u4F20\u3010" + fileFormat + "\u3011\u683C\u5F0F\u7684\u6587\u4EF6");
302
+ return;
303
+ }
304
+ }
305
+ if (selectedMaterial.type === 1) {
306
+ _Message.notice('该文件为旧文件, 请先下载后手动上传');
307
+ return;
308
+ }
309
+ var m = _extends({}, selectedMaterial, {
310
+ fileUrl: selectedMaterial.innerFileUrl
311
+ });
312
+ console.log('m', m);
313
+ valChange(m);
314
+ setIsShowMaterialLib(false);
315
+ };
316
+ useEffect(function () {
317
+ if (userInfo && isShowLib) {
318
+ console.log('userInfo', userInfo);
319
+ queryFileLibs();
320
+ }
321
+ }, [userInfo, isShowLib]);
155
322
  return /*#__PURE__*/React.createElement("div", {
156
323
  className: "file_item"
157
324
  }, /*#__PURE__*/React.createElement("div", {
@@ -167,7 +334,10 @@ var FileItem = function FileItem(_ref) {
167
334
  }), "\u6587\u4EF6", /*#__PURE__*/React.createElement("img", {
168
335
  className: "del",
169
336
  src: delIcon,
170
- alt: ""
337
+ alt: "",
338
+ onClick: function onClick() {
339
+ return del();
340
+ }
171
341
  }), isInValid && /*#__PURE__*/React.createElement("img", {
172
342
  className: "error_msg",
173
343
  src: errorMsgIcon,
@@ -205,7 +375,7 @@ var FileItem = function FileItem(_ref) {
205
375
  }, guideImg && /*#__PURE__*/React.createElement("div", {
206
376
  className: "img_btn",
207
377
  onClick: function onClick() {
208
- return showViewImg(guideImg);
378
+ return showGuide(guideImg);
209
379
  }
210
380
  }, "\u7B7E\u7AE0\u5F15\u5BFC"), checkImg && /*#__PURE__*/React.createElement("div", {
211
381
  className: "img_btn",
@@ -228,7 +398,7 @@ var FileItem = function FileItem(_ref) {
228
398
  onClick: seal
229
399
  }, isSealed ? '重新签章' : '电子签章')) :
230
400
  // 展示材料库
231
- isShowLib && /*#__PURE__*/React.createElement("div", {
401
+ isShowLib && !!materialLib.length && /*#__PURE__*/React.createElement("div", {
232
402
  className: "operation_btn",
233
403
  style: {
234
404
  marginTop: '20px'
@@ -277,19 +447,22 @@ var FileItem = function FileItem(_ref) {
277
447
  alt: ""
278
448
  }), "\u4E3A\u907F\u514D\u529E\u4EF6\u4E0D\u901A\u8FC7\uFF0C\u9009\u62E9\u6750\u6599\u65F6\uFF0C\u8BF7\u60A8\u6CE8\u610F\u6750\u6599\u6709\u6548\u671F\uFF01"), /*#__PURE__*/React.createElement(RadioGroup, {
279
449
  className: "list",
280
- value: material,
450
+ value: materialId,
281
451
  onChange: function onChange(val) {
282
452
  return setMaterial(val);
283
453
  }
284
- }, list.map(function (item) {
454
+ }, materialLib.map(function (item) {
285
455
  return /*#__PURE__*/React.createElement("div", {
286
456
  className: "item",
287
- key: item.value
457
+ key: item.fileId
288
458
  }, /*#__PURE__*/React.createElement(_Radio, {
289
- id: item.value,
290
- value: item.value
291
- }, item.name), /*#__PURE__*/React.createElement("div", {
292
- className: "preview_icon"
459
+ id: item.fileId,
460
+ value: item.fileId
461
+ }, item.fileName), /*#__PURE__*/React.createElement("div", {
462
+ className: "preview_icon",
463
+ onClick: function onClick() {
464
+ return previewMaterial(item.fileId, item.innerFileUrl);
465
+ }
293
466
  }, /*#__PURE__*/React.createElement("img", {
294
467
  src: previewIcon,
295
468
  alt: ""
@@ -302,7 +475,8 @@ var FileItem = function FileItem(_ref) {
302
475
  return setIsShowMaterialLib(false);
303
476
  }
304
477
  }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement("div", {
305
- className: "btn ok"
478
+ className: "btn ok",
479
+ onClick: selectMaterialOk
306
480
  }, "\u786E\u5B9A")))), isShowSignPage && /*#__PURE__*/React.createElement(SignPage, {
307
481
  isShowSignPage: isShowSignPage,
308
482
  userInfo: userInfo,
@@ -347,6 +521,34 @@ var FileItem = function FileItem(_ref) {
347
521
  frameborder: "0",
348
522
  height: "500px",
349
523
  width: "100%"
524
+ })), isShowMaterialPreview && /*#__PURE__*/React.createElement("div", {
525
+ className: "preview"
526
+ }, /*#__PURE__*/React.createElement("img", {
527
+ className: "close",
528
+ src: closeIcon,
529
+ alt: "",
530
+ onClick: function onClick() {
531
+ return setIsShowMaterialPreview(false);
532
+ }
533
+ }), /*#__PURE__*/React.createElement("iframe", {
534
+ src: materialPreviewUrl,
535
+ frameborder: "0",
536
+ height: "90%",
537
+ width: "100%"
538
+ })), isShowGuide && /*#__PURE__*/React.createElement("div", {
539
+ className: "preview"
540
+ }, /*#__PURE__*/React.createElement("img", {
541
+ className: "close",
542
+ src: closeIcon,
543
+ alt: "",
544
+ onClick: function onClick() {
545
+ return setIsShowGuide(false);
546
+ }
547
+ }), /*#__PURE__*/React.createElement("iframe", {
548
+ src: guideurl,
549
+ frameborder: "0",
550
+ height: "90%",
551
+ width: "100%"
350
552
  })));
351
553
  };
352
554
  FileItem.displayName = 'FileItem';
@@ -100,6 +100,7 @@
100
100
  .btn {
101
101
  display: flex;
102
102
  flex-direction: row;
103
+ justify-content: end;
103
104
 
104
105
  .img_btn {
105
106
  margin-left: 8px;
@@ -195,7 +196,7 @@
195
196
  position: absolute;
196
197
  top: 0;
197
198
  left: 0;
198
- z-index: 999;
199
+ z-index: 88;
199
200
  background-color: rgba(0, 0, 0, 0.5);
200
201
 
201
202
  .material_lib_content {
@@ -307,7 +308,7 @@
307
308
  display: flex;
308
309
  justify-content: center;
309
310
  align-items: center;
310
-
311
+ z-index: 99;
311
312
  .close {
312
313
  position: absolute;
313
314
  top: 20px;
@@ -333,4 +334,5 @@
333
334
  z-index: 99;
334
335
  background: rgba(0, 0, 0, 0.5);
335
336
  }
337
+
336
338
  }
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import React, { useEffect, useState } from 'react';
4
+ import React, { useEffect, useState, useRef } from 'react';
5
5
  import { initSealPageMethod } from "./sealUtil";
6
- import { signFileDownApi } from "../../api";
7
- import { uploadFilePromise } from "./file.js";
6
+ import { signFileDownApi, getSignFileApi } from "../../api";
7
+ import { uploadFilePromise, dataURLtoBlob } from "./file.js";
8
8
  function SealPage(props) {
9
9
  var userInfo = props.userInfo,
10
10
  file = props.file,
@@ -16,9 +16,13 @@ function SealPage(props) {
16
16
  var _useState = useState(''),
17
17
  srcUrl = _useState[0],
18
18
  setSrcUrl = _useState[1];
19
+ var _useState2 = useState(''),
20
+ orderId = _useState2[0],
21
+ setOrderId = _useState2[1];
22
+ var timerRef = useRef(null);
19
23
  var handleRes = /*#__PURE__*/function () {
20
24
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
21
- var res, pageUrl;
25
+ var res, pageUrl, orderIdVal;
22
26
  return _regeneratorRuntime.wrap(function (_context) {
23
27
  while (1) switch (_context.prev = _context.next) {
24
28
  case 0:
@@ -27,9 +31,10 @@ function SealPage(props) {
27
31
  return initSealPageMethod(file, userInfo, token, accessToken, baseUrl);
28
32
  case 1:
29
33
  res = _context.sent;
30
- pageUrl = res.pageUrl;
34
+ pageUrl = res.pageUrl, orderIdVal = res.orderId;
31
35
  console.log('pageUrl', pageUrl);
32
36
  setSrcUrl(pageUrl);
37
+ setOrderId(orderIdVal);
33
38
  // console.log(res)
34
39
  case 2:
35
40
  case "end":
@@ -45,21 +50,20 @@ function SealPage(props) {
45
50
  // 将返回的文件重新上传
46
51
  var uploadNewFile = /*#__PURE__*/function () {
47
52
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fileData) {
48
- var uploadedFileObj, finalFile;
53
+ var blob, uploadedFileObj, finalFile;
49
54
  return _regeneratorRuntime.wrap(function (_context2) {
50
55
  while (1) switch (_context2.prev = _context2.next) {
51
56
  case 0:
57
+ blob = dataURLtoBlob('data:application/pdf;base64,' + fileData);
52
58
  _context2.next = 1;
53
- return uploadFilePromise('data:application/pdf;base64,' + fileData, baseUrl, token);
59
+ return uploadFilePromise(blob, baseUrl, token);
54
60
  case 1:
55
61
  uploadedFileObj = _context2.sent;
56
62
  console.log('重新上传的文件', uploadedFileObj);
57
63
  handleClose();
58
64
  finalFile = _extends({
59
65
  name: file.name,
60
- url: uploadedFileObj.fileUrlList[0],
61
- status: 'success',
62
- message: '上传成功'
66
+ url: uploadedFileObj.fileUrl
63
67
  }, uploadedFileObj);
64
68
  getSealRes(finalFile);
65
69
  case 2:
@@ -77,25 +81,62 @@ function SealPage(props) {
77
81
  var signFileDown = function signFileDown(filePath) {
78
82
  signFileDownApi({
79
83
  fileUrl: filePath
84
+ }, {
85
+ baseUrl: baseUrl,
86
+ token: token
80
87
  }).then(function (res) {
81
- uploadNewFile(res);
88
+ if (res.code === 200) {
89
+ uploadNewFile(res.data);
90
+ }
82
91
  });
83
92
  };
84
- // 监听子页面数据
85
- var getMessage = function getMessage(e) {
86
- console.log('子页面数据', e);
87
- if (e.data.type === 'signal' && e.data.data && e.data.data.length) {
88
- console.log(e.data.data[0]); // 文件路径
89
- var filePath = e.data.data[0];
90
- signFileDown(filePath);
91
- }
93
+
94
+ // 电子签章-移动端签批 获取移动端签章结果(文件地址)
95
+ var getSignFileFun = function getSignFileFun() {
96
+ // uni.showLoading({ title: '加载中' })
97
+
98
+ var params = {
99
+ orderId: orderId
100
+ };
101
+ getSignFileApi(params, {
102
+ baseUrl: baseUrl,
103
+ token: token
104
+ }).then(function (res) {
105
+ if (!res) {
106
+ return;
107
+ }
108
+ console.log(res, '签章之后的数据');
109
+ var _res$data = res.data,
110
+ signStatus = _res$data.signStatus,
111
+ signFiles = _res$data.signFiles;
112
+ if (signStatus === 6) {
113
+ // 签署成功
114
+ handleClearInterval();
115
+ if (signFiles && signFiles.length) {
116
+ // 下载该文件
117
+ signFileDown(signFiles[0].filePath);
118
+ }
119
+ }
120
+ // uni.hideLoading()
121
+ })["catch"](function (err) {
122
+ console.log(err);
123
+ });
124
+ };
125
+ var handleClearInterval = function handleClearInterval() {
126
+ clearInterval(timerRef.current);
127
+ timerRef.current = null;
92
128
  };
93
129
  useEffect(function () {
94
- window.addEventListener('message', getMessage);
130
+ if (orderId) {
131
+ handleClearInterval();
132
+ timerRef.current = setInterval(function () {
133
+ getSignFileFun();
134
+ }, 3000);
135
+ }
95
136
  return function () {
96
- window.removeEventListener('message', getMessage);
137
+ handleClearInterval();
97
138
  };
98
- }, []);
139
+ }, [orderId]);
99
140
  useEffect(function () {
100
141
  handleRes();
101
142
  }, [userInfo, file, token, accessToken, baseUrl]);
@@ -61,7 +61,8 @@ function _initSealPageMethod() {
61
61
  // 将 电子签章地址/文件名称 返回
62
62
  params = {
63
63
  pageUrl: pageUrl,
64
- name: name
64
+ name: name,
65
+ orderId: orderId
65
66
  };
66
67
  return _context.abrupt("return", params);
67
68
  case 8:
package/es/utils.js ADDED
File without changes
package/lib/api.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  exports.__esModule = true;
5
- exports.signurl = exports.signFileDownApi = exports.qrySealApi = exports.previewApi = exports.post = exports.getSignOrderIdApi = exports.getSealUrlApi = exports.get = exports.documentDownload = exports.createbycategory = exports.contractSignUrl = exports.contractFinish = exports.checkSignState = void 0;
5
+ exports.signurl = exports.signFileDownApi = exports.qrySealApi = exports.previewApi = exports.post = exports.getSignOrderIdApi = exports.getSignFileApi = exports.getSealUrlApi = exports.getMaterialLib = exports.get = exports.documentDownload = exports.createbycategory = exports.contractSignUrl = exports.contractFinish = exports.checkSignState = void 0;
6
6
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
7
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
8
  var post = exports.post = /*#__PURE__*/function () {
@@ -119,10 +119,17 @@ var getSealUrlApi = exports.getSealUrlApi = function getSealUrlApi(params, confi
119
119
 
120
120
  // 电子签章-下载文件
121
121
  var signFileDownApi = exports.signFileDownApi = function signFileDownApi(params, config) {
122
- return post(config.baseUrl + "declaration/center/sign/api/fileDownloadBySign", params, config);
122
+ return post(config.baseUrl + "/declaration/center/sign/api/fileDownloadBySign", params, config);
123
123
  };
124
124
 
125
125
  // 预览
126
126
  var previewApi = exports.previewApi = function previewApi(params, config) {
127
127
  return post("https://zwfwpt.sxzwfw.gov.cn/DeclarationAPI/declaration/center/sign/api/preview", params, config);
128
+ };
129
+ // 材料库
130
+ var getMaterialLib = exports.getMaterialLib = function getMaterialLib(params, config) {
131
+ return post("https://zwfwpt.sxzwfw.gov.cn/DeclarationAPI/declaration/material/queryFileByCardNo", params, config);
132
+ };
133
+ var getSignFileApi = exports.getSignFileApi = function getSignFileApi(params, config) {
134
+ return post(config.baseUrl + "/declaration/center/sign/api/getSignFileList", params, config);
128
135
  };