ydb-components-material 0.1.115 → 0.1.116

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.
@@ -18,6 +18,7 @@ export interface FileListProps {
18
18
  download: (value: any) => void;
19
19
  openLoading: () => void;
20
20
  closeLoading: () => void;
21
+ applySeal: () => void;
21
22
  valChange: (value: any) => void;
22
23
  saveSignerInfo: (value: any) => boolean;
23
24
  signInfoMap?: object;
@@ -48,6 +48,7 @@ var FileList = function FileList(_ref) {
48
48
  closeLoading = _ref.closeLoading,
49
49
  valChange = _ref.valChange,
50
50
  saveSignerInfo = _ref.saveSignerInfo,
51
+ applySeal = _ref.applySeal,
51
52
  signInfoMap = _ref.signInfoMap;
52
53
  var _useState = useState(false),
53
54
  showMerge = _useState[0],
@@ -295,6 +296,7 @@ var FileList = function FileList(_ref) {
295
296
  signInfoMap: signInfoMap,
296
297
  disabled: disabled,
297
298
  download: download,
299
+ applySeal: applySeal,
298
300
  valChange: handleChange,
299
301
  openLoading: openLoading,
300
302
  closeLoading: closeLoading,
@@ -325,6 +327,7 @@ var FileList = function FileList(_ref) {
325
327
  isPC: isPC,
326
328
  disabled: disabled,
327
329
  download: download,
330
+ applySeal: applySeal,
328
331
  valChange: handleChange,
329
332
  openLoading: openLoading,
330
333
  closeLoading: closeLoading,
@@ -1,3 +1,4 @@
1
+ import _Dialog from "@alifd/next/es/dialog";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _extends from "@babel/runtime/helpers/extends";
3
4
  import _Message from "@alifd/next/es/message";
@@ -19,6 +20,7 @@ import SignPage from "./sign";
19
20
  import SealPage from "./seal";
20
21
  import { getMaterialLib, getGuideImg, getUrlById, onlinePreview } from "../../api";
21
22
  import { initFormat, getFileExtension } from "./file.js";
23
+ import { querySeal } from "./sealUtil";
22
24
  import CheckPoint from "./checkPoint";
23
25
  import SignerInfo from "./signerInfo";
24
26
  import "./item.scss";
@@ -48,7 +50,8 @@ var FileItem = function FileItem(_ref) {
48
50
  openLoading = _ref.openLoading,
49
51
  closeLoading = _ref.closeLoading,
50
52
  saveSignerInfo = _ref.saveSignerInfo,
51
- signInfoMap = _ref.signInfoMap;
53
+ signInfoMap = _ref.signInfoMap,
54
+ applySeal = _ref.applySeal;
52
55
  console.log('fileItem', file, maxFileSize);
53
56
  var fileName = file.fileName,
54
57
  fileUrl = file.fileUrl,
@@ -321,20 +324,112 @@ var FileItem = function FileItem(_ref) {
321
324
 
322
325
  // 手写签批
323
326
  var sign = function sign() {
327
+ if (!signatureEnable) {
328
+ closeLoading();
329
+ return;
330
+ }
331
+ ;
324
332
  openLoading();
325
333
  setIsShowSignPage(true);
326
334
  };
327
335
 
328
336
  // 签章
329
- var seal = function seal() {
330
- var type = getFileExtension(fileName);
331
- if (type !== 'pdf') {
332
- _Message.notice('只有pdf文件才能使用电子签章');
333
- return;
334
- }
335
- openLoading();
336
- setIsShowSealPage(true);
337
- };
337
+ var seal = /*#__PURE__*/function () {
338
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
339
+ var type, sealList;
340
+ return _regeneratorRuntime.wrap(function (_context3) {
341
+ while (1) switch (_context3.prev = _context3.next) {
342
+ case 0:
343
+ type = getFileExtension(fileName);
344
+ if (!(type !== 'pdf')) {
345
+ _context3.next = 1;
346
+ break;
347
+ }
348
+ _Message.notice('只有pdf文件才能使用电子签章');
349
+ return _context3.abrupt("return");
350
+ case 1:
351
+ openLoading();
352
+ // 查询当前用户是否有电子签章
353
+ _context3.next = 2;
354
+ return querySeal(userInfo, {
355
+ token: token,
356
+ tokenTY: tokenTY,
357
+ baseUrl: baseUrl,
358
+ env: env,
359
+ isPC: isPC,
360
+ accessToken: accessToken
361
+ });
362
+ case 2:
363
+ sealList = _context3.sent;
364
+ if (!(userInfo.corpType === 'C04')) {
365
+ _context3.next = 3;
366
+ break;
367
+ }
368
+ if (sealList.length) {
369
+ // 有印章 → 对话框提示,可跳过走签批
370
+ _Dialog.confirm({
371
+ title: '提示',
372
+ footerAlign: 'center',
373
+ content: '检测到您已有电子印章,是否使用电子印章签署?',
374
+ okProps: {
375
+ children: '签署'
376
+ },
377
+ cancelProps: {
378
+ children: '跳过'
379
+ },
380
+ onOk: function onOk() {
381
+ setIsShowSealPage(true);
382
+ },
383
+ onCancel: function onCancel() {
384
+ sign();
385
+ },
386
+ onClose: function onClose() {
387
+ closeLoading();
388
+ }
389
+ });
390
+ } else {
391
+ // 无印章 → 对话框提示,可申请印章或跳过走签批
392
+ _Dialog.confirm({
393
+ title: '提示',
394
+ content: '经检测,本账户暂未申请企业印章,办理时可选择跳过签章流程完成签名;也可办好印章后再来办理此项业务',
395
+ footerAlign: 'center',
396
+ okProps: {
397
+ children: '申请印章'
398
+ },
399
+ cancelProps: {
400
+ children: '跳过签章'
401
+ },
402
+ onOk: function onOk() {
403
+ applySeal();
404
+ },
405
+ onCancel: function onCancel() {
406
+ sign();
407
+ },
408
+ onClose: function onClose() {
409
+ closeLoading();
410
+ }
411
+ });
412
+ }
413
+ return _context3.abrupt("return");
414
+ case 3:
415
+ if (sealList.length) {
416
+ _context3.next = 4;
417
+ break;
418
+ }
419
+ _Message.error('该单位下暂无印章,请前往"山西政务服务网"或"三晋通"小程序申领印章');
420
+ return _context3.abrupt("return");
421
+ case 4:
422
+ setIsShowSealPage(true);
423
+ case 5:
424
+ case "end":
425
+ return _context3.stop();
426
+ }
427
+ }, _callee3);
428
+ }));
429
+ return function seal() {
430
+ return _ref4.apply(this, arguments);
431
+ };
432
+ }();
338
433
  var signAndSeal = function signAndSeal() {
339
434
  // const notNeedSelfSign = !signatureSelfRole.includes(SELF) && !signatureAgentRole.includes(SELF) && !signSelfRole.includes(SELF) && !signAgentRole.includes(SELF)
340
435
  // // 如果不需要自己签署 只需要别人签署 就直接打开维护签署人信息
@@ -406,18 +501,18 @@ var FileItem = function FileItem(_ref) {
406
501
  queryFileLibs();
407
502
  };
408
503
  var showGuide = /*#__PURE__*/function () {
409
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
504
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
410
505
  var guideImgRes;
411
- return _regeneratorRuntime.wrap(function (_context3) {
412
- while (1) switch (_context3.prev = _context3.next) {
506
+ return _regeneratorRuntime.wrap(function (_context4) {
507
+ while (1) switch (_context4.prev = _context4.next) {
413
508
  case 0:
414
509
  if (signGuidFileId) {
415
- _context3.next = 1;
510
+ _context4.next = 1;
416
511
  break;
417
512
  }
418
- return _context3.abrupt("return");
513
+ return _context4.abrupt("return");
419
514
  case 1:
420
- _context3.next = 2;
515
+ _context4.next = 2;
421
516
  return getGuideImg({
422
517
  id: signGuidFileId,
423
518
  effectiveTime: 3600000
@@ -430,26 +525,26 @@ var FileItem = function FileItem(_ref) {
430
525
  accessToken: accessToken
431
526
  });
432
527
  case 2:
433
- guideImgRes = _context3.sent;
528
+ guideImgRes = _context4.sent;
434
529
  if (guideImgRes.presignedUrl) {
435
530
  setGuideurl(guideImgRes.presignedUrl);
436
531
  setIsShowGuide(true);
437
532
  }
438
533
  case 3:
439
534
  case "end":
440
- return _context3.stop();
535
+ return _context4.stop();
441
536
  }
442
- }, _callee3);
537
+ }, _callee4);
443
538
  }));
444
539
  return function showGuide() {
445
- return _ref4.apply(this, arguments);
540
+ return _ref5.apply(this, arguments);
446
541
  };
447
542
  }();
448
543
  var selectMaterialOk = /*#__PURE__*/function () {
449
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
544
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
450
545
  var selectedMaterial, arr, fileFormat, formatFinal, urlRes, m;
451
- return _regeneratorRuntime.wrap(function (_context4) {
452
- while (1) switch (_context4.prev = _context4.next) {
546
+ return _regeneratorRuntime.wrap(function (_context5) {
547
+ while (1) switch (_context5.prev = _context5.next) {
453
548
  case 0:
454
549
  console.log('val', materialId);
455
550
  console.log('materialLib==', materialLib);
@@ -458,7 +553,7 @@ var FileItem = function FileItem(_ref) {
458
553
  });
459
554
  console.log('selectedMaterial', selectedMaterial);
460
555
  if (!spec) {
461
- _context4.next = 1;
556
+ _context5.next = 1;
462
557
  break;
463
558
  }
464
559
  arr = selectedMaterial.fileName.split('.'); //
@@ -467,24 +562,24 @@ var FileItem = function FileItem(_ref) {
467
562
  formatFinal = initFormat(spec); // 限制的文件类型
468
563
  console.log(formatFinal, '限制的格式最后');
469
564
  if (formatFinal.includes(fileFormat)) {
470
- _context4.next = 1;
565
+ _context5.next = 1;
471
566
  break;
472
567
  }
473
568
  _Message.notice("\u8BE5\u6750\u6599\u4E0D\u652F\u6301\u4E0A\u4F20\u3010" + fileFormat + "\u3011\u683C\u5F0F\u7684\u6587\u4EF6");
474
- return _context4.abrupt("return");
569
+ return _context5.abrupt("return");
475
570
  case 1:
476
571
  if (!(selectedMaterial.type === 1)) {
477
- _context4.next = 2;
572
+ _context5.next = 2;
478
573
  break;
479
574
  }
480
575
  _Message.notice('该文件为旧文件, 请先下载后手动上传');
481
- return _context4.abrupt("return");
576
+ return _context5.abrupt("return");
482
577
  case 2:
483
578
  if (selectedMaterial.innerFileUrl) {
484
- _context4.next = 4;
579
+ _context5.next = 4;
485
580
  break;
486
581
  }
487
- _context4.next = 3;
582
+ _context5.next = 3;
488
583
  return getUrlById({
489
584
  id: selectedMaterial.fileId,
490
585
  effectiveTime: 3600000
@@ -497,7 +592,7 @@ var FileItem = function FileItem(_ref) {
497
592
  accessToken: accessToken
498
593
  });
499
594
  case 3:
500
- urlRes = _context4.sent;
595
+ urlRes = _context5.sent;
501
596
  if (urlRes.presignedUrlList && urlRes.presignedUrlList.length > 0) {
502
597
  selectedMaterial.innerFileUrl = urlRes.presignedUrlList[2];
503
598
  }
@@ -510,12 +605,12 @@ var FileItem = function FileItem(_ref) {
510
605
  setIsShowMaterialLib(false);
511
606
  case 5:
512
607
  case "end":
513
- return _context4.stop();
608
+ return _context5.stop();
514
609
  }
515
- }, _callee4);
610
+ }, _callee5);
516
611
  }));
517
612
  return function selectMaterialOk() {
518
- return _ref5.apply(this, arguments);
613
+ return _ref6.apply(this, arguments);
519
614
  };
520
615
  }();
521
616
  var onDownload = function onDownload() {
@@ -545,58 +640,58 @@ var FileItem = function FileItem(_ref) {
545
640
 
546
641
  // 获取缩略图
547
642
  var extractImageUrls = /*#__PURE__*/function () {
548
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(previewUrl) {
643
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(previewUrl) {
549
644
  var response, htmlText, parser, doc, imgElements, srcList;
550
- return _regeneratorRuntime.wrap(function (_context5) {
551
- while (1) switch (_context5.prev = _context5.next) {
645
+ return _regeneratorRuntime.wrap(function (_context6) {
646
+ while (1) switch (_context6.prev = _context6.next) {
552
647
  case 0:
553
- _context5.next = 1;
648
+ _context6.next = 1;
554
649
  return fetch(previewUrl);
555
650
  case 1:
556
- response = _context5.sent;
557
- _context5.next = 2;
651
+ response = _context6.sent;
652
+ _context6.next = 2;
558
653
  return response.text();
559
654
  case 2:
560
- htmlText = _context5.sent;
655
+ htmlText = _context6.sent;
561
656
  parser = new DOMParser();
562
657
  doc = parser.parseFromString(htmlText, 'text/html');
563
658
  imgElements = doc.querySelectorAll('img');
564
659
  srcList = Array.from(imgElements).map(function (img) {
565
660
  return img.getAttribute('data-src');
566
661
  });
567
- return _context5.abrupt("return", srcList);
662
+ return _context6.abrupt("return", srcList);
568
663
  case 3:
569
664
  case "end":
570
- return _context5.stop();
665
+ return _context6.stop();
571
666
  }
572
- }, _callee5);
667
+ }, _callee6);
573
668
  }));
574
669
  return function extractImageUrls(_x3) {
575
- return _ref6.apply(this, arguments);
670
+ return _ref7.apply(this, arguments);
576
671
  };
577
672
  }();
578
673
 
579
674
  // 获取预览图片
580
675
  var getViewUrl = /*#__PURE__*/function () {
581
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id) {
676
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id) {
582
677
  var type, urlRes, res, list;
583
- return _regeneratorRuntime.wrap(function (_context6) {
584
- while (1) switch (_context6.prev = _context6.next) {
678
+ return _regeneratorRuntime.wrap(function (_context7) {
679
+ while (1) switch (_context7.prev = _context7.next) {
585
680
  case 0:
586
681
  type = getFileExtension(fileName);
587
682
  if (!['png', 'jpg', 'jpeg'].includes(type)) {
588
- _context6.next = 1;
683
+ _context7.next = 1;
589
684
  break;
590
685
  }
591
- return _context6.abrupt("return", fileUrl);
686
+ return _context7.abrupt("return", fileUrl);
592
687
  case 1:
593
688
  if (!(type !== 'pdf')) {
594
- _context6.next = 2;
689
+ _context7.next = 2;
595
690
  break;
596
691
  }
597
- return _context6.abrupt("return", '');
692
+ return _context7.abrupt("return", '');
598
693
  case 2:
599
- _context6.next = 3;
694
+ _context7.next = 3;
600
695
  return getUrlById({
601
696
  id: id,
602
697
  effectiveTime: 3600000
@@ -609,13 +704,13 @@ var FileItem = function FileItem(_ref) {
609
704
  accessToken: accessToken
610
705
  });
611
706
  case 3:
612
- urlRes = _context6.sent;
707
+ urlRes = _context7.sent;
613
708
  if (!(urlRes.presignedUrlList && urlRes.presignedUrlList.length > 0)) {
614
- _context6.next = 6;
709
+ _context7.next = 6;
615
710
  break;
616
711
  }
617
712
  console.log('urlRes', urlRes);
618
- _context6.next = 4;
713
+ _context7.next = 4;
619
714
  return onlinePreview({
620
715
  url: urlRes.presignedUrlList[2]
621
716
  }, {
@@ -627,21 +722,21 @@ var FileItem = function FileItem(_ref) {
627
722
  accessToken: accessToken
628
723
  });
629
724
  case 4:
630
- res = _context6.sent;
631
- _context6.next = 5;
725
+ res = _context7.sent;
726
+ _context7.next = 5;
632
727
  return extractImageUrls(res.url);
633
728
  case 5:
634
- list = _context6.sent;
729
+ list = _context7.sent;
635
730
  console.log('list---', list);
636
- return _context6.abrupt("return", list[0]);
731
+ return _context7.abrupt("return", list[0]);
637
732
  case 6:
638
733
  case "end":
639
- return _context6.stop();
734
+ return _context7.stop();
640
735
  }
641
- }, _callee6);
736
+ }, _callee7);
642
737
  }));
643
738
  return function getViewUrl(_x4) {
644
- return _ref7.apply(this, arguments);
739
+ return _ref8.apply(this, arguments);
645
740
  };
646
741
  }();
647
742
  useEffect(function () {
@@ -20,44 +20,37 @@ function _initSealPageMethod() {
20
20
  case 0:
21
21
  fileName = fileObj.fileName;
22
22
  console.log('fileObj', fileObj, userInfo);
23
- // 【第 1 步】判断当前用户是否有印章
23
+
24
+ // 查询印章列表(getSignOrderId 需要)
24
25
  _context.next = 1;
25
26
  return querySeal(userInfo, config);
26
27
  case 1:
27
28
  sealList = _context.sent;
28
- console.log('sealList---', sealList);
29
- if (sealList.length) {
30
- _context.next = 2;
31
- break;
32
- }
33
- _Message.error('该单位下暂无印章,请前往“山西政务服务网”或“三晋通”小程序申领印章');
34
- return _context.abrupt("return", false);
35
- case 2:
36
- _context.next = 3;
29
+ _context.next = 2;
37
30
  return uploadSealFile(fileObj, config);
38
- case 3:
31
+ case 2:
39
32
  fileUrl = _context.sent;
40
33
  console.log('fileUrl---', fileUrl);
41
34
  if (fileUrl) {
42
- _context.next = 4;
35
+ _context.next = 3;
43
36
  break;
44
37
  }
45
38
  return _context.abrupt("return", false);
46
- case 4:
47
- _context.next = 5;
39
+ case 3:
40
+ _context.next = 4;
48
41
  return getSignOrderId(sealList, fileObj, fileUrl, userInfo, config);
49
- case 5:
42
+ case 4:
50
43
  orderId = _context.sent;
51
44
  console.log('orderId---', orderId);
52
45
  if (orderId) {
53
- _context.next = 6;
46
+ _context.next = 5;
54
47
  break;
55
48
  }
56
49
  return _context.abrupt("return", false);
57
- case 6:
58
- _context.next = 7;
50
+ case 5:
51
+ _context.next = 6;
59
52
  return getMobilePageFun(orderId, config, fileObj, fileUrl);
60
- case 7:
53
+ case 6:
61
54
  pageUrl = _context.sent;
62
55
  // 将 电子签章地址/文件名称 返回
63
56
  params = {
@@ -66,7 +59,7 @@ function _initSealPageMethod() {
66
59
  orderId: orderId
67
60
  };
68
61
  return _context.abrupt("return", params);
69
- case 8:
62
+ case 7:
70
63
  case "end":
71
64
  return _context.stop();
72
65
  }
@@ -74,7 +67,7 @@ function _initSealPageMethod() {
74
67
  }));
75
68
  return _initSealPageMethod.apply(this, arguments);
76
69
  }
77
- function querySeal(userInfo, config) {
70
+ export function querySeal(userInfo, config) {
78
71
  console.log('querySeal', userInfo);
79
72
  // uni.showLoading({ title: '查询印章中' })
80
73
  var params = {
@@ -121,7 +121,7 @@ function SignerInfo(props) {
121
121
  }
122
122
  }, [signerInfo]);
123
123
  useEffect(function () {
124
- if (canvasRef.current) {
124
+ if (canvasRef.current && url) {
125
125
  var options = {
126
126
  width: 110,
127
127
  // 二维码的宽度
@@ -136,7 +136,7 @@ function SignerInfo(props) {
136
136
  };
137
137
  QRCode.toCanvas(canvasRef.current, url, options, function () {});
138
138
  }
139
- }, [url]);
139
+ }, [url, showQRcode]);
140
140
  return /*#__PURE__*/React.createElement("div", {
141
141
  className: "signer-info-mask"
142
142
  }, !showQRcode && /*#__PURE__*/React.createElement("div", {
package/es/style.js CHANGED
@@ -4,8 +4,8 @@ import '@alifd/next/es/radio/style';
4
4
  import '@alifd/next/es/checkbox/style';
5
5
  import '@alifd/next/es/balloon/style';
6
6
  import 'antd/es/cascader/style';
7
- import '@alifd/next/es/input/style';
8
7
  import '@alifd/next/es/dialog/style';
8
+ import '@alifd/next/es/input/style';
9
9
  import '@alifd/next/es/loading/style';
10
10
  import '@alifd/next/es/button/style';
11
11
  import './index.scss';
@@ -18,6 +18,7 @@ export interface FileListProps {
18
18
  download: (value: any) => void;
19
19
  openLoading: () => void;
20
20
  closeLoading: () => void;
21
+ applySeal: () => void;
21
22
  valChange: (value: any) => void;
22
23
  saveSignerInfo: (value: any) => boolean;
23
24
  signInfoMap?: object;
@@ -53,6 +53,7 @@ var FileList = function FileList(_ref) {
53
53
  closeLoading = _ref.closeLoading,
54
54
  valChange = _ref.valChange,
55
55
  saveSignerInfo = _ref.saveSignerInfo,
56
+ applySeal = _ref.applySeal,
56
57
  signInfoMap = _ref.signInfoMap;
57
58
  var _useState = (0, _react.useState)(false),
58
59
  showMerge = _useState[0],
@@ -300,6 +301,7 @@ var FileList = function FileList(_ref) {
300
301
  signInfoMap: signInfoMap,
301
302
  disabled: disabled,
302
303
  download: download,
304
+ applySeal: applySeal,
303
305
  valChange: handleChange,
304
306
  openLoading: openLoading,
305
307
  closeLoading: closeLoading,
@@ -330,6 +332,7 @@ var FileList = function FileList(_ref) {
330
332
  isPC: isPC,
331
333
  disabled: disabled,
332
334
  download: download,
335
+ applySeal: applySeal,
333
336
  valChange: handleChange,
334
337
  openLoading: openLoading,
335
338
  closeLoading: closeLoading,