tnx-shared 5.3.409 → 5.3.411

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.
@@ -1357,6 +1357,7 @@
1357
1357
  this.hiddenKySoSimCaNhan = false;
1358
1358
  this.hiddenKySoUsbCaNhan = false;
1359
1359
  this.hiddenKySoDonVi = false;
1360
+ this.hiddenKySoSmartCA = false;
1360
1361
  this.hiddenButPhe = false;
1361
1362
  this.arrFieldMustValidate = [];
1362
1363
  this.getCustomDataTrinhKy = function (rowData) { return ({}); };
@@ -35768,7 +35769,8 @@
35768
35769
  command: function () {
35769
35770
  _this.signFileSmartCA(item);
35770
35771
  },
35771
- visible: item.extension == '.PDF'
35772
+ visible: (this._fileObjectService.isTypeFileKySo(item.name)
35773
+ && this.layout !== exports.EnumFileLayout.SIMPLE_FOR_LIST && !this.parentSetting.hiddenKySoSmartCA),
35772
35774
  },
35773
35775
  {
35774
35776
  label: 'Ký số cá nhân (USB)', icon: 'fas fa-signature',
@@ -36819,20 +36821,49 @@
36819
36821
  };
36820
36822
  FileManagerComponent.prototype.signFileSmartCA = function (rowData) {
36821
36823
  return __awaiter(this, void 0, void 0, function () {
36822
- var dataKySo;
36824
+ var sourceFileId, sourceFile, rsConvert, e_5, dataKySo;
36823
36825
  return __generator(this, function (_b) {
36824
36826
  switch (_b.label) {
36825
- case 0: return [4 /*yield*/, this._userChuKySoService.getDetailByFilter([
36827
+ case 0:
36828
+ sourceFileId = rowData.id;
36829
+ sourceFile = rowData;
36830
+ if (!this._fileExplorerService.needConvertBeforeSign(rowData.name)) return [3 /*break*/, 4];
36831
+ _b.label = 1;
36832
+ case 1:
36833
+ _b.trys.push([1, 3, , 4]);
36834
+ return [4 /*yield*/, this._fileExplorerService.convertDocumentToPdfAndSave({
36835
+ instanceId: sourceFileId,
36836
+ name: this._fileExplorerService.changeFileExtension(rowData.name, 'pdf'),
36837
+ folderInstanceId: rowData.parentFolderId,
36838
+ ownerType: this._userService.getCurrentUser().userId.toString(),
36839
+ })];
36840
+ case 2:
36841
+ rsConvert = _b.sent();
36842
+ if (!rsConvert || !rsConvert.success) {
36843
+ this._notifierService.showWarning("C\u00F3 l\u1ED7i x\u1EA3y ra khi chuy\u1EC3n \u0111\u1ED5i t\u00E0i li\u1EC7u " + rowData.name + " th\u00E0nh pdf \u0111\u1EC3 k\u00FD. Vui l\u00F2ng th\u1EED l\u1EA1i sau");
36844
+ return [2 /*return*/];
36845
+ }
36846
+ else {
36847
+ this._notifierService.showSuccess("Chuy\u1EC3n \u0111\u1ED5i t\u00E0i li\u1EC7u " + rowData.name + " th\u00E0nh pdf th\u00E0nh c\u00F4ng");
36848
+ sourceFileId = rsConvert.data;
36849
+ sourceFile = { id: sourceFileId };
36850
+ }
36851
+ return [3 /*break*/, 4];
36852
+ case 3:
36853
+ e_5 = _b.sent();
36854
+ this._notifierService.showWarning("C\u00F3 l\u1ED7i x\u1EA3y ra khi chuy\u1EC3n \u0111\u1ED5i t\u00E0i li\u1EC7u " + rowData.name + " th\u00E0nh pdf \u0111\u1EC3 k\u00FD. Vui l\u00F2ng th\u1EED l\u1EA1i sau");
36855
+ return [2 /*return*/];
36856
+ case 4: return [4 /*yield*/, this._userChuKySoService.getDetailByFilter([
36826
36857
  this.newFilter('provider', exports.Operator.equal, 'SmartCA'),
36827
36858
  this.newFilter('userId', exports.Operator.equal, this._userService.getCurrentUser().userId),
36828
36859
  ])];
36829
- case 1:
36860
+ case 5:
36830
36861
  dataKySo = (_b.sent()).data;
36831
36862
  if (!dataKySo) {
36832
36863
  this._notifierService.showWarning('Người dùng chưa cấu hình thông tin ký số');
36833
36864
  }
36834
36865
  this.forms.fileViewer.formData.data = {
36835
- fileId: rowData.id,
36866
+ fileId: sourceFileId,
36836
36867
  isFileVersion: false,
36837
36868
  fileName: rowData.name,
36838
36869
  service: rowData.serviceCode,
@@ -37022,7 +37053,7 @@
37022
37053
  });
37023
37054
  };
37024
37055
  FileManagerComponent.prototype.buildTreeData = function (data, rootFolderId) {
37025
- var e_5, _b;
37056
+ var e_6, _b;
37026
37057
  var result = [];
37027
37058
  var rootData = data.filter(function (x) { return x.parentFolderId == rootFolderId; });
37028
37059
  if (rootData.length > 0) {
@@ -37038,12 +37069,12 @@
37038
37069
  });
37039
37070
  }
37040
37071
  }
37041
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
37072
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
37042
37073
  finally {
37043
37074
  try {
37044
37075
  if (rootData_1_1 && !rootData_1_1.done && (_b = rootData_1.return)) _b.call(rootData_1);
37045
37076
  }
37046
- finally { if (e_5) throw e_5.error; }
37077
+ finally { if (e_6) throw e_6.error; }
37047
37078
  }
37048
37079
  }
37049
37080
  return result;
@@ -50555,6 +50586,9 @@
50555
50586
  return __generator(this, function (_b) {
50556
50587
  switch (_b.label) {
50557
50588
  case 0:
50589
+ if (!this.model.data.signatureLocation) {
50590
+ return [2 /*return*/, this._notifierService.showWarning('Vui lòng chọn vị trí chữ ký trước khi thực hiện ký số')];
50591
+ }
50558
50592
  this.showWaitBox('Đang thực hiện ký số, vui lòng kiểm tra ứng dụng SmartCA');
50559
50593
  return [4 /*yield*/, this._fileObjectService.kySoSmartCA(this.model.data)];
50560
50594
  case 1:
@@ -50567,6 +50601,7 @@
50567
50601
  }
50568
50602
  this.hideWaitBox();
50569
50603
  this.show = false;
50604
+ this.onClose.next();
50570
50605
  return [2 /*return*/];
50571
50606
  }
50572
50607
  });
@@ -50579,11 +50614,33 @@
50579
50614
  var _a;
50580
50615
  var pdfViewer = (_a = window.PDFViewerApplication) === null || _a === void 0 ? void 0 : _a.pdfViewer;
50581
50616
  if (pdfViewer) {
50582
- // Add click listener to each page canvas
50583
- var container = document.querySelector('#viewerContainer');
50584
- container === null || container === void 0 ? void 0 : container.addEventListener('click', function (e) {
50585
- _this.handlePageClick(e, pdfViewer);
50617
+ // Lấy tất cả canvas elements
50618
+ var canvases = document.querySelectorAll('#viewerContainer canvas');
50619
+ canvases.forEach(function (canvas) {
50620
+ canvas.addEventListener('click', function (e) {
50621
+ _this.handlePageClick(e, pdfViewer);
50622
+ });
50623
+ });
50624
+ // Optional: Theo dõi khi có canvas mới được render (khi scroll PDF)
50625
+ var observer = new MutationObserver(function () {
50626
+ var newCanvases = document.querySelectorAll('#viewerContainer canvas');
50627
+ newCanvases.forEach(function (canvas) {
50628
+ // Kiểm tra nếu chưa có listener (tránh thêm duplicate)
50629
+ if (!canvas._hasClickListener) {
50630
+ canvas.addEventListener('click', function (e) {
50631
+ _this.handlePageClick(e, pdfViewer);
50632
+ });
50633
+ canvas._hasClickListener = true;
50634
+ }
50635
+ });
50586
50636
  });
50637
+ var container = document.querySelector('#viewerContainer');
50638
+ if (container) {
50639
+ observer.observe(container, {
50640
+ childList: true,
50641
+ subtree: true
50642
+ });
50643
+ }
50587
50644
  }
50588
50645
  }, 1000);
50589
50646
  };
@@ -50593,29 +50650,37 @@
50593
50650
  if (marker) {
50594
50651
  marker.remove();
50595
50652
  }
50596
- if (target.classList.contains('canvasWrapper') ||
50597
- target.tagName === 'CANVAS') {
50598
- // Get page number and coordinates
50653
+ if (target.tagName === 'CANVAS') {
50599
50654
  var pageDiv = target.closest('.page');
50600
50655
  var pageNumber = parseInt((pageDiv === null || pageDiv === void 0 ? void 0 : pageDiv.getAttribute('data-page-number')) || '1');
50601
- var rect = target.getBoundingClientRect();
50602
- var x = event.clientX - rect.left;
50603
- var y = event.clientY - rect.top;
50656
+ // Dùng offsetX/Y với scale adjustment
50657
+ var x = event.offsetX;
50658
+ var y = event.offsetY;
50659
+ // Điều chỉnh theo scale của canvas
50660
+ var scaleX = target.width / target.clientWidth;
50661
+ var scaleY = target.height / target.clientHeight;
50662
+ x = x * scaleX;
50663
+ y = y * scaleY;
50604
50664
  var WIDTH = this.model.data.width || 100;
50605
50665
  var HEIGHT = this.model.data.height || 100;
50606
- // Convert pixel sang point TRƯỚC
50666
+ // Convert pixel sang point
50607
50667
  var clickXPoint = this.pixelToPoint(x);
50608
50668
  var clickYPoint = this.pixelToPoint(y);
50609
50669
  var widthPoint = this.pixelToPoint(WIDTH);
50610
50670
  var heightPoint = this.pixelToPoint(HEIGHT);
50611
- // SAU ĐÓ mới tính toán như C#
50671
+ var canvasHeightPoint = this.pixelToPoint(target.height);
50672
+ // Chuyển đổi Y coordinate (PDF origin ở dưới)
50673
+ var pdfY = canvasHeightPoint - clickYPoint;
50612
50674
  var x1 = clickXPoint;
50613
- var y1 = clickYPoint - heightPoint;
50675
+ var y1 = pdfY - heightPoint;
50614
50676
  var x2 = clickXPoint + widthPoint;
50615
- var y2 = clickYPoint;
50616
- var rectangle = x1 + "," + y1 + "," + x2 + "," + y2;
50677
+ var y2 = pdfY;
50678
+ var rectangle = Math.floor(x1) + "," + Math.floor(y1) + "," + Math.floor(x2) + "," + Math.floor(y2);
50679
+ console.log('PDF Rectangle:', rectangle);
50680
+ console.log('==================');
50617
50681
  this.model.data.signatureLocation = rectangle;
50618
- this.createMarker(target, x, y, pageNumber);
50682
+ // Tạo marker với tọa độ đã điều chỉnh (nhưng hiển thị theo display size)
50683
+ this.createMarker(target, event.offsetX, event.offsetY, pageNumber);
50619
50684
  }
50620
50685
  };
50621
50686
  FileViewerComponent.prototype.createMarker = function (parent, x, y, page) {
@@ -50628,7 +50693,7 @@
50628
50693
  };
50629
50694
  FileViewerComponent.prototype.pixelToPoint = function (pixel, dpi) {
50630
50695
  if (dpi === void 0) { dpi = 96; }
50631
- return Math.round(pixel * 72 / dpi * 100); // Làm tròn 2 chữ số thập phân
50696
+ return pixel * 72 / dpi;
50632
50697
  };
50633
50698
  return FileViewerComponent;
50634
50699
  }(ComponentBase));