@factoringplus/pl-components-pack-v3 0.1.45 → 0.1.48

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.
@@ -29635,6 +29635,48 @@ var cryptoPro = { exports: {} };
29635
29635
  });
29636
29636
  });
29637
29637
  })(cryptoPro);
29638
+ function $__getDotNetModelValidationErrorMessage(data) {
29639
+ if (_.isObject(data.errors)) {
29640
+ return "\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0437\u0430\u043F\u0440\u043E\u0441\u0430 \u0443\u043A\u0430\u0437\u0430\u043D\u044B \u043D\u0435\u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u043E. \u041F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u043F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u043E\u0441\u0442\u044C \u043F\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043C\u044B\u0445 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0439.";
29641
+ }
29642
+ }
29643
+ function $__getErrorMessages(data) {
29644
+ return _.chain([$__getDotNetModelValidationErrorMessage(data), data.message]).flattenDeep().compact().value();
29645
+ }
29646
+ function getErrorMessage(ex2) {
29647
+ let value = "\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043E\u0448\u0438\u0431\u043A\u0430";
29648
+ const errorResponse = _.get(ex2, "response");
29649
+ if (errorResponse != null) {
29650
+ if (errorResponse.status == 401 || errorResponse.status == 403) {
29651
+ value = "\u041D\u0435\u0434\u043E\u0441\u0442\u0430\u0442\u043E\u0447\u043D\u043E \u043F\u0440\u0430\u0432 \u0434\u043B\u044F \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0438.";
29652
+ } else {
29653
+ value = _.chain([
29654
+ errorResponse.message,
29655
+ errorResponse.data,
29656
+ errorResponse.statusText,
29657
+ errorResponse,
29658
+ value
29659
+ ]).compact().head().value();
29660
+ }
29661
+ } else {
29662
+ if (ex2.status == 401 || ex2.status == 403) {
29663
+ value = "\u041D\u0435\u0434\u043E\u0441\u0442\u0430\u0442\u043E\u0447\u043D\u043E \u043F\u0440\u0430\u0432 \u0434\u043B\u044F \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0438.";
29664
+ } else {
29665
+ value = _.get(ex2, "message", ex2 || value);
29666
+ }
29667
+ if (value === "Network Error") {
29668
+ value = "\u0421\u0435\u0440\u0432\u0435\u0440 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D.";
29669
+ }
29670
+ }
29671
+ if (_.isObject(value)) {
29672
+ return _.head($__getErrorMessages(value));
29673
+ }
29674
+ try {
29675
+ return _.head($__getErrorMessages(JSON.parse(value)));
29676
+ } catch (ex3) {
29677
+ return value;
29678
+ }
29679
+ }
29638
29680
  const _hoisted_1 = /* @__PURE__ */ createElementVNode("div", { class: "sp-dialog__title" }, [
29639
29681
  /* @__PURE__ */ createElementVNode("div", { class: "title-text" }, "\u041F\u043E\u0434\u043F\u0438\u0441\u044C \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430")
29640
29682
  ], -1);
@@ -29645,13 +29687,10 @@ const __default__ = {
29645
29687
  name: "PlCertDialog"
29646
29688
  };
29647
29689
  const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
29648
- props: {
29649
- httpResponseParser: Function
29650
- },
29651
29690
  emits: ["cert-selected"],
29652
- setup(__props, { emit }) {
29691
+ setup(__props, { expose, emit }) {
29653
29692
  const form2 = ref(null);
29654
- const visible = ref(true);
29693
+ const visible = ref(false);
29655
29694
  const loading2 = ref(false);
29656
29695
  const certs = ref([]);
29657
29696
  const fileList = ref([]);
@@ -29675,14 +29714,68 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
29675
29714
  }
29676
29715
  ]
29677
29716
  });
29678
- const validCerts = computed(() => _.filter(certs, "valid"));
29679
- computed(() => !dataForm.thumbprint);
29717
+ const validCerts = computed(() => _.filter(certs.value, "valid"));
29718
+ const formatCertInfo = (item, id) => {
29719
+ var _a2, _b2;
29720
+ const regexCn = new RegExp("CN=([^,]+)", "i");
29721
+ const regexSn = new RegExp("SN=([^,]+)", "i");
29722
+ const regexG = new RegExp("G=([^,]+)", "i");
29723
+ const regexO = new RegExp("O=([^,]+)", "i");
29724
+ const regexInnUl = new RegExp("(?:INNLE|\u0418\u041D\u041D \u042E\u041B|1\\.2\\.643\\.100\\.4)=(\\d{10})", "i");
29725
+ const regexInnFl = new RegExp("(?:INN|\u0418\u041D\u041D|1\\.2\\.643\\.3\\.131\\.1\\.1)=(\\d{10,12})", "i");
29726
+ const matches = (_b2 = (_a2 = regexInnUl.exec(item.subjectName)) != null ? _a2 : regexInnFl.exec(item.subjectName)) != null ? _b2 : [, "\u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442"];
29727
+ const [, inn] = matches;
29728
+ let companyName = item.subjectName;
29729
+ let fio = "";
29730
+ let cn = "";
29731
+ if ((cn = regexCn.exec(item.subjectName)) !== null) {
29732
+ companyName = cn[1];
29733
+ }
29734
+ let owner = "-";
29735
+ let o = "";
29736
+ if ((o = regexO.exec(item.issuerName)) !== null) {
29737
+ owner = o[1];
29738
+ }
29739
+ let sn = "";
29740
+ let g = "";
29741
+ if ((sn = regexSn.exec(item.subjectName)) !== null && (g = regexG.exec(item.subjectName)) !== null) {
29742
+ fio = `${g[1]} ${sn[1]}`;
29743
+ }
29744
+ const text = `${((fio2) => fio2 ? `${fio2} | ` : "")(fio) + companyName} (\u0418\u041D\u041D: ${inn}) - \u0432\u0430\u043B\u0438\u0434\u043D\u044B\u0439 \u0434\u043E: ${hooks(item.validTo).format("DD.MM.YYYY")}`;
29745
+ return {
29746
+ text,
29747
+ companyName,
29748
+ companyInn: `\u0418\u041D\u041D: ${inn}`,
29749
+ owner,
29750
+ fio,
29751
+ validTo: item.validTo,
29752
+ validFrom: item.validFrom,
29753
+ thumbprint: item.thumbprint,
29754
+ valid: hooks().isSameOrBefore(hooks(item.validTo).toISOString())
29755
+ };
29756
+ };
29757
+ const show = (files) => {
29758
+ loading2.value = true;
29759
+ fileList.value = files;
29760
+ cryptoPro.exports.getUserCertificates().then((response2) => {
29761
+ certs.value = _.chain(response2).map(formatCertInfo).filter((cert) => `${_.get(cert, "companyInn", "")}`.indexOf("\u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442") === -1).value();
29762
+ visible.value = true;
29763
+ }).catch((ex2) => {
29764
+ ElMessage.error(getErrorMessage(ex2));
29765
+ }).then(() => {
29766
+ loading2.value = false;
29767
+ nextTick(() => {
29768
+ form2.value.resetFields();
29769
+ form2.value.clearValidate(["file", "thumbprint"]);
29770
+ });
29771
+ });
29772
+ };
29680
29773
  const hide2 = () => visible.value = false;
29681
- const onAppendClick = (form3) => {
29682
- form3.validate((isFormValid) => {
29774
+ const onAppendClick = () => {
29775
+ form2.value.validate((isFormValid) => {
29683
29776
  if (isFormValid) {
29684
29777
  hide2();
29685
- const certInfo = _.find(validCerts, ["thumbprint", dataForm.thumbprint]);
29778
+ const certInfo = _.find(validCerts.value, ["thumbprint", dataForm.thumbprint]);
29686
29779
  if (certInfo == null) {
29687
29780
  ElMessage.error("\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044E \u043E \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u0435.");
29688
29781
  } else {
@@ -29699,6 +29792,7 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
29699
29792
  });
29700
29793
  };
29701
29794
  const onCancelClick = () => hide2();
29795
+ expose({ form: form2, show });
29702
29796
  return (_ctx, _cache) => {
29703
29797
  const _component_el_option = ElOption;
29704
29798
  const _component_el_select = ElSelect;