@maxax/ui 1.1.25 → 1.1.27

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.
package/dist/index.mjs CHANGED
@@ -6501,7 +6501,6 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
6501
6501
  const data = ((_a = basicTableRef.value) == null ? void 0 : _a.getDataSource()) || [];
6502
6502
  const records = ((_b = basicTableRef.value) == null ? void 0 : _b.getSelectRows()) || [];
6503
6503
  emit("confirm", { data, records });
6504
- hide();
6505
6504
  }
6506
6505
  __expose({
6507
6506
  show,
@@ -8394,6 +8393,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
8394
8393
  previewTableProps: {},
8395
8394
  previewTitle: {},
8396
8395
  saveApi: {},
8396
+ beforeSaveInterceptor: {},
8397
8397
  beforeFetchSave: {},
8398
8398
  afterFetchSave: {}
8399
8399
  },
@@ -8408,6 +8408,21 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
8408
8408
  const attrs = useAttrs();
8409
8409
  const currentFile = ref(null);
8410
8410
  const currentChecked = ref(false);
8411
+ async function runBeforeSaveGuard(payload) {
8412
+ if (!props.beforeSaveInterceptor || !isFunction$1(props.beforeSaveInterceptor)) return true;
8413
+ try {
8414
+ const result = await props.beforeSaveInterceptor(payload);
8415
+ if (!result) return false;
8416
+ if (isString$1(result) && result) {
8417
+ XBasicNotification.error(result);
8418
+ return false;
8419
+ }
8420
+ return true;
8421
+ } catch (error) {
8422
+ console.error(error);
8423
+ return false;
8424
+ }
8425
+ }
8411
8426
  async function onImport(file, checked, showPreview = false) {
8412
8427
  var _a, _b, _c, _d;
8413
8428
  const { importApi, beforeFetchImport, afterFetchImport } = props;
@@ -8471,12 +8486,15 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
8471
8486
  });
8472
8487
  }
8473
8488
  async function onPreviewConfirm({ data, records }) {
8474
- var _a, _b;
8475
- if (!currentFile.value) return;
8489
+ var _a, _b, _c, _d;
8490
+ if (!currentFile.value) return false;
8491
+ const canSave = await runBeforeSaveGuard({ data, records, checked: currentChecked.value, file: currentFile.value });
8492
+ if (!canSave) return false;
8476
8493
  if (!props.saveApi) {
8477
8494
  emit("preview", { data, checked: currentChecked.value, file: currentFile.value, records });
8478
- (_a = uploadModalRef.value) == null ? void 0 : _a.hide();
8479
- return;
8495
+ (_a = previewModalRef.value) == null ? void 0 : _a.hide();
8496
+ (_b = uploadModalRef.value) == null ? void 0 : _b.hide();
8497
+ return false;
8480
8498
  }
8481
8499
  try {
8482
8500
  const params = props.beforeFetchSave ? props.beforeFetchSave({ data, records }) : { dtoList: data };
@@ -8485,7 +8503,8 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
8485
8503
  } catch (error) {
8486
8504
  console.error(error);
8487
8505
  } finally {
8488
- (_b = uploadModalRef.value) == null ? void 0 : _b.hide();
8506
+ (_c = previewModalRef.value) == null ? void 0 : _c.hide();
8507
+ (_d = uploadModalRef.value) == null ? void 0 : _d.hide();
8489
8508
  }
8490
8509
  }
8491
8510
  function onClickHandler() {