@maxax/ui 1.1.71 → 1.1.73

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 (48) hide show
  1. package/dist/_commonjsHelpers-Bc2YnDe1.cjs +8 -0
  2. package/dist/_commonjsHelpers-Bc2YnDe1.cjs.map +1 -0
  3. package/dist/_commonjsHelpers-DWwsNxpa.js +9 -0
  4. package/dist/_commonjsHelpers-DWwsNxpa.js.map +1 -0
  5. package/dist/components/basic-button-import-max/BasicButtonImportMax.vue.d.ts +653 -702
  6. package/dist/components/basic-button-import-max/BasicButtonImportMax.vue.d.ts.map +1 -1
  7. package/dist/components/basic-button-import-max/PreviewModal.vue.d.ts +17 -465
  8. package/dist/components/basic-button-import-max/PreviewModal.vue.d.ts.map +1 -1
  9. package/dist/components/basic-button-import-max/UploadModal.vue.d.ts +4 -1
  10. package/dist/components/basic-button-import-max/UploadModal.vue.d.ts.map +1 -1
  11. package/dist/components/basic-button-import-max/interface.d.ts +36 -0
  12. package/dist/components/basic-button-import-max/interface.d.ts.map +1 -1
  13. package/dist/components/basic-button-import-max/utils.d.ts +16 -0
  14. package/dist/components/basic-button-import-max/utils.d.ts.map +1 -0
  15. package/dist/components/basic-message-box/interface.d.ts.map +1 -1
  16. package/dist/components/basic-table/BasicTable.vue.d.ts +1 -0
  17. package/dist/components/basic-table/BasicTable.vue.d.ts.map +1 -1
  18. package/dist/components/basic-table/export-xlsx.d.ts +28 -0
  19. package/dist/components/basic-table/export-xlsx.d.ts.map +1 -0
  20. package/dist/components/basic-table/index.d.ts +1 -0
  21. package/dist/components/basic-table/index.d.ts.map +1 -1
  22. package/dist/components/basic-table/interface.d.ts +2 -0
  23. package/dist/components/basic-table/interface.d.ts.map +1 -1
  24. package/dist/exceljs.min-Bt5AZfbx.js +23122 -0
  25. package/dist/exceljs.min-Bt5AZfbx.js.map +1 -0
  26. package/dist/exceljs.min-DvM7I02X.cjs +23121 -0
  27. package/dist/exceljs.min-DvM7I02X.cjs.map +1 -0
  28. package/dist/index.cjs +364 -48
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.mjs +364 -48
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/locale/lang/en.d.ts.map +1 -1
  33. package/dist/locale/lang/zh-cn.d.ts.map +1 -1
  34. package/dist/locales.cjs +18 -9
  35. package/dist/locales.cjs.map +1 -1
  36. package/dist/locales.mjs +14 -5
  37. package/dist/locales.mjs.map +1 -1
  38. package/dist/theme-chalk/components/basicButtonImportMax.scss +102 -13
  39. package/dist/theme-chalk/index.css +1 -1
  40. package/dist/theme-chalk/light.css +1 -1
  41. package/dist/theme-chalk/vxe-table/vxe-table.scss +3 -1
  42. package/dist/{zh-cn-C7lMkB1L.cjs → zh-cn-56c_PDSF.cjs} +13 -2
  43. package/dist/zh-cn-56c_PDSF.cjs.map +1 -0
  44. package/dist/{zh-cn-DUJD5NdW.js → zh-cn-BiMi9UU7.js} +13 -2
  45. package/dist/zh-cn-BiMi9UU7.js.map +1 -0
  46. package/package.json +5 -4
  47. package/dist/zh-cn-C7lMkB1L.cjs.map +0 -1
  48. package/dist/zh-cn-DUJD5NdW.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -11,7 +11,7 @@ const dayjs = require("dayjs");
11
11
  const hooks = require("@maxax/hooks");
12
12
  const dateFns = require("date-fns");
13
13
  const elementResizeDetectorMaker = require("element-resize-detector");
14
- const zhCn = require("./zh-cn-C7lMkB1L.cjs");
14
+ const zhCn = require("./zh-cn-56c_PDSF.cjs");
15
15
  function tryOnScopeDispose(fn, failSilently) {
16
16
  if (vue.getCurrentScope()) {
17
17
  vue.onScopeDispose(fn, failSilently);
@@ -8198,6 +8198,121 @@ const FETCH_SETTING$1 = {
8198
8198
  totalField: "totalCount"
8199
8199
  };
8200
8200
  const DEFAULT_SIZE = "small";
8201
+ const defaultHeaderBackgroundColor = "f2f2f2";
8202
+ const defaultCellFontColor = "000000";
8203
+ const defaultCellBorderColor = "e0e0e0";
8204
+ const defaultCellBorderStyle = "thin";
8205
+ async function getExcelJS() {
8206
+ const ExcelJS = await Promise.resolve().then(() => require("./exceljs.min-DvM7I02X.cjs")).then((n) => n.exceljs_min);
8207
+ return ExcelJS.default || ExcelJS;
8208
+ }
8209
+ function getColumnWidth(column) {
8210
+ const width = Number(column.width || ("minWidth" in column ? column.minWidth : void 0));
8211
+ if (Number.isFinite(width) && width > 0) {
8212
+ return Math.max(10, Math.ceil(width / 7.2));
8213
+ }
8214
+ return 18;
8215
+ }
8216
+ function normalizeExportXlsxColumns(columns = []) {
8217
+ return columns.filter((column) => column.field && ("visible" in column ? column.visible !== false : true)).map((column) => ({
8218
+ field: String(column.field),
8219
+ title: String(column.title || column.field),
8220
+ width: getColumnWidth(column)
8221
+ }));
8222
+ }
8223
+ function normalizeExcelCellValue(value) {
8224
+ if (value === null || value === void 0) return "";
8225
+ if (Array.isArray(value) || typeof value === "object") return JSON.stringify(value);
8226
+ return value;
8227
+ }
8228
+ function getDefaultBorderStyle() {
8229
+ return {
8230
+ top: { style: defaultCellBorderStyle, color: { argb: defaultCellBorderColor } },
8231
+ left: { style: defaultCellBorderStyle, color: { argb: defaultCellBorderColor } },
8232
+ bottom: { style: defaultCellBorderStyle, color: { argb: defaultCellBorderColor } },
8233
+ right: { style: defaultCellBorderStyle, color: { argb: defaultCellBorderColor } }
8234
+ };
8235
+ }
8236
+ function setExcelCellStyle(excelCell, align = "left") {
8237
+ excelCell.protection = {
8238
+ locked: false
8239
+ };
8240
+ excelCell.alignment = {
8241
+ vertical: "middle",
8242
+ horizontal: align
8243
+ };
8244
+ }
8245
+ function downloadXlsxBlob(blob, filename) {
8246
+ const linkElem = document.createElement("a");
8247
+ linkElem.target = "_blank";
8248
+ linkElem.download = `${filename}.xlsx`;
8249
+ linkElem.href = URL.createObjectURL(blob);
8250
+ document.body.appendChild(linkElem);
8251
+ linkElem.click();
8252
+ document.body.removeChild(linkElem);
8253
+ URL.revokeObjectURL(linkElem.href);
8254
+ }
8255
+ async function exportRowsToXlsx(options) {
8256
+ const ExcelObj = await getExcelJS();
8257
+ if (!ExcelObj) return false;
8258
+ const columns = normalizeExportXlsxColumns(options.columns);
8259
+ const workbook = new ExcelObj.Workbook();
8260
+ const worksheet = workbook.addWorksheet(options.sheetName || "Sheet1");
8261
+ workbook.creator = "maxax-ui";
8262
+ worksheet.columns = columns.map((column) => ({
8263
+ header: column.title,
8264
+ key: column.field,
8265
+ width: column.width || 18
8266
+ }));
8267
+ worksheet.addRows(
8268
+ options.data.map((row) => {
8269
+ return columns.reduce((record, column) => {
8270
+ record[column.field] = normalizeExcelCellValue(row[column.field]);
8271
+ return record;
8272
+ }, {});
8273
+ })
8274
+ );
8275
+ const headerRow = worksheet.getRow(1);
8276
+ headerRow.height = 22;
8277
+ headerRow.eachCell((excelCell) => {
8278
+ setExcelCellStyle(excelCell);
8279
+ Object.assign(excelCell, {
8280
+ font: {
8281
+ bold: true,
8282
+ size: 14,
8283
+ color: { argb: defaultCellFontColor }
8284
+ },
8285
+ fill: {
8286
+ type: "pattern",
8287
+ pattern: "solid",
8288
+ fgColor: { argb: defaultHeaderBackgroundColor }
8289
+ },
8290
+ border: getDefaultBorderStyle()
8291
+ });
8292
+ });
8293
+ worksheet.eachRow((excelRow, rowNumber) => {
8294
+ if (rowNumber > 1) {
8295
+ excelRow.height = 22;
8296
+ excelRow.eachCell((excelCell) => {
8297
+ setExcelCellStyle(excelCell);
8298
+ Object.assign(excelCell, {
8299
+ font: {
8300
+ size: 14,
8301
+ color: { argb: defaultCellFontColor }
8302
+ },
8303
+ border: getDefaultBorderStyle()
8304
+ });
8305
+ });
8306
+ }
8307
+ });
8308
+ const buffer = await workbook.xlsx.writeBuffer();
8309
+ const blob = new Blob([buffer], { type: "application/octet-stream" });
8310
+ if (options.download === false) {
8311
+ return { type: "application/octet-stream", content: "", blob };
8312
+ }
8313
+ downloadXlsxBlob(blob, options.filename || "export");
8314
+ return true;
8315
+ }
8201
8316
  function handleFieldColumn(columns) {
8202
8317
  columns.forEach((column) => {
8203
8318
  column.field || (column.field = column.type || "");
@@ -9346,6 +9461,15 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
9346
9461
  function getInstance() {
9347
9462
  return tableElRef.value;
9348
9463
  }
9464
+ async function exportXlsx(options = {}) {
9465
+ return exportRowsToXlsx({
9466
+ filename: "export",
9467
+ sheetName: "Sheet1",
9468
+ columns: getColumns(),
9469
+ data: getDataSource(),
9470
+ ...options
9471
+ });
9472
+ }
9349
9473
  const tableAction = {
9350
9474
  emit,
9351
9475
  reload,
@@ -9370,6 +9494,7 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
9370
9494
  getSearchInfo,
9371
9495
  setColumns,
9372
9496
  getColumns,
9497
+ exportXlsx,
9373
9498
  getCacheColumns,
9374
9499
  setCacheColumns,
9375
9500
  setCacheColumnsByField,
@@ -30720,6 +30845,32 @@ vxeTable.VxeUI.setConfig({
30720
30845
  zIndex: 2e3
30721
30846
  });
30722
30847
  const XBasicTable = utils.withInstall(_sfc_main$F);
30848
+ const IMPORT_PREVIEW_ROW_NO_FIELD = "rowNo";
30849
+ const IMPORT_PREVIEW_ERROR_FIELD = "errorMsg";
30850
+ function isErrorRow(row) {
30851
+ return Boolean(row == null ? void 0 : row[IMPORT_PREVIEW_ERROR_FIELD]);
30852
+ }
30853
+ function getPreviewColumns(columns = [], options) {
30854
+ const { errorTitle, rowNoTitle } = options;
30855
+ const visibleColumns = columns.filter((column) => column.visible !== false);
30856
+ const hasRowNoColumn = visibleColumns.some((column) => column.field === IMPORT_PREVIEW_ROW_NO_FIELD);
30857
+ const hasErrorColumn = visibleColumns.some((column) => column.field === IMPORT_PREVIEW_ERROR_FIELD);
30858
+ return [...hasRowNoColumn ? [] : [{ field: IMPORT_PREVIEW_ROW_NO_FIELD, title: rowNoTitle, width: 90, fixed: "left" }], ...hasErrorColumn ? [] : [{ field: IMPORT_PREVIEW_ERROR_FIELD, title: errorTitle, minWidth: 180, fixed: "left" }], ...columns];
30859
+ }
30860
+ function getExcelColumns(columns = [], options) {
30861
+ return getPreviewColumns(columns, options).filter((column) => column.field && column.visible !== false).map((column) => ({
30862
+ field: String(column.field),
30863
+ title: String(column.title || column.field),
30864
+ width: getExcelColumnWidth(column)
30865
+ }));
30866
+ }
30867
+ function getExcelColumnWidth(column) {
30868
+ const width = Number(column.width || column.minWidth);
30869
+ if (Number.isFinite(width) && width > 0) {
30870
+ return Math.max(10, Math.ceil(width / 7.2));
30871
+ }
30872
+ return 18;
30873
+ }
30723
30874
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30724
30875
  __name: "PreviewModal",
30725
30876
  props: {
@@ -30727,9 +30878,17 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30727
30878
  previewColumns: {},
30728
30879
  previewTableProps: {},
30729
30880
  previewTitle: {},
30730
- showPreviewCount: { type: Boolean, default: true }
30731
- },
30732
- emits: ["confirm", "cancel"],
30881
+ showPreviewCount: { type: Boolean, default: true },
30882
+ showPreviewToolbar: { type: Boolean, default: true },
30883
+ showPreviewFilter: { type: Boolean, default: true },
30884
+ showExportErrorButton: { type: Boolean, default: true },
30885
+ showDeleteErrorButton: { type: Boolean, default: true },
30886
+ rowNoColumnTitle: {},
30887
+ errorColumnTitle: {},
30888
+ exportErrorFileName: { default: "import-error-data" },
30889
+ exportErrorHandler: {}
30890
+ },
30891
+ emits: ["confirm", "cancel", "deleteError"],
30733
30892
  setup(__props, { expose: __expose, emit: __emit }) {
30734
30893
  const props = __props;
30735
30894
  const emit = __emit;
@@ -30738,12 +30897,14 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30738
30897
  const { t: t2 } = useLocale();
30739
30898
  const tableData = vue.ref([]);
30740
30899
  const errorData = vue.ref([]);
30900
+ const previewFilter = vue.ref("all");
30741
30901
  const { visible, show, hide } = useBasicDrawerModal({
30742
30902
  async onShow(context) {
30743
30903
  var _a, _b;
30744
30904
  await vue.nextTick();
30745
30905
  const list = ((_a = context.data) == null ? void 0 : _a.list) || [];
30746
- const errorList = list.filter((item) => item.errorMsg);
30906
+ const errorList = list.filter((item) => isErrorRow(item));
30907
+ previewFilter.value = "all";
30747
30908
  tableData.value = list;
30748
30909
  errorData.value = errorList;
30749
30910
  (_b = basicTableRef.value) == null ? void 0 : _b.setTableData(list);
@@ -30752,6 +30913,25 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30752
30913
  const previewModalStyle = vue.computed(() => {
30753
30914
  return { width: props.previewWidth || "900px" };
30754
30915
  });
30916
+ const rowNoColumnTitle = vue.computed(() => props.rowNoColumnTitle || t2("max.import.rowNo"));
30917
+ const errorColumnTitle = vue.computed(() => props.errorColumnTitle || t2("max.import.errorMessage"));
30918
+ const normalDataCount = vue.computed(() => Math.max(tableData.value.length - errorData.value.length, 0));
30919
+ const previewFilterOptions = vue.computed(() => [
30920
+ { label: t2("max.import.showAllData"), value: "all" },
30921
+ { label: t2("max.import.showErrorRows"), value: "error" },
30922
+ { label: t2("max.import.showNormalRows"), value: "normal" }
30923
+ ]);
30924
+ const filteredTableData = vue.computed(() => {
30925
+ if (previewFilter.value === "error") return errorData.value;
30926
+ if (previewFilter.value === "normal") return tableData.value.filter((item) => !isErrorRow(item));
30927
+ return tableData.value;
30928
+ });
30929
+ const tableColumns = vue.computed(
30930
+ () => getPreviewColumns(props.previewColumns, {
30931
+ errorTitle: errorColumnTitle.value,
30932
+ rowNoTitle: rowNoColumnTitle.value
30933
+ })
30934
+ );
30755
30935
  const previewTableBindValues = vue.computed(() => {
30756
30936
  return {
30757
30937
  border: "inner",
@@ -30761,11 +30941,62 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30761
30941
  toolbarConfig: {
30762
30942
  enabled: false
30763
30943
  },
30944
+ virtualYConfig: {
30945
+ enabled: true,
30946
+ gt: 0
30947
+ },
30948
+ showIndexColumn: false,
30764
30949
  showCheckboxColumn: false,
30765
30950
  ...props.previewTableProps,
30766
- columns: props.previewColumns || []
30951
+ columns: tableColumns.value
30767
30952
  };
30768
30953
  });
30954
+ function syncPreviewTableData() {
30955
+ var _a;
30956
+ (_a = basicTableRef.value) == null ? void 0 : _a.setTableData(filteredTableData.value);
30957
+ }
30958
+ function onPreviewFilterChange() {
30959
+ syncPreviewTableData();
30960
+ }
30961
+ async function onExportErrorData() {
30962
+ var _a;
30963
+ if (errorData.value.length === 0) return;
30964
+ if (props.exportErrorHandler) {
30965
+ await props.exportErrorHandler({
30966
+ columns: tableColumns.value,
30967
+ rows: errorData.value
30968
+ });
30969
+ return;
30970
+ }
30971
+ const columns = getExcelColumns(props.previewColumns, {
30972
+ errorTitle: errorColumnTitle.value,
30973
+ rowNoTitle: rowNoColumnTitle.value
30974
+ });
30975
+ await ((_a = basicTableRef.value) == null ? void 0 : _a.exportXlsx({
30976
+ columns,
30977
+ filename: props.exportErrorFileName,
30978
+ data: errorData.value,
30979
+ sheetName: t2("max.import.errorDataSheetName")
30980
+ }));
30981
+ }
30982
+ function deleteErrorData() {
30983
+ const deletedErrors = [...errorData.value];
30984
+ tableData.value = tableData.value.filter((item) => !isErrorRow(item));
30985
+ errorData.value = [];
30986
+ previewFilter.value = "all";
30987
+ syncPreviewTableData();
30988
+ emit("deleteError", { data: tableData.value, errors: deletedErrors });
30989
+ }
30990
+ function onDeleteErrorData() {
30991
+ if (errorData.value.length === 0) return;
30992
+ XBasicMessageBox.confirm(t2("max.import.confirmDeleteErrorData"), t2("max.basic.warning"), {
30993
+ confirmButtonText: t2("max.import.confirm"),
30994
+ cancelButtonText: t2("max.import.cancel")
30995
+ }).then(() => {
30996
+ deleteErrorData();
30997
+ }).catch(() => {
30998
+ });
30999
+ }
30769
31000
  function onConfirm() {
30770
31001
  var _a;
30771
31002
  const records = ((_a = basicTableRef.value) == null ? void 0 : _a.getSelectRows()) || [];
@@ -30778,7 +31009,7 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30778
31009
  return (_ctx, _cache) => {
30779
31010
  return vue.openBlock(), vue.createBlock(vue.unref(naiveUi.NModal), {
30780
31011
  show: vue.unref(visible),
30781
- "onUpdate:show": _cache[0] || (_cache[0] = ($event) => vue.isRef(visible) ? visible.value = $event : null),
31012
+ "onUpdate:show": _cache[1] || (_cache[1] = ($event) => vue.isRef(visible) ? visible.value = $event : null),
30782
31013
  segmented: { footer: "soft" },
30783
31014
  closable: false,
30784
31015
  preset: "card",
@@ -30820,10 +31051,10 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30820
31051
  ], 2)
30821
31052
  ]),
30822
31053
  default: vue.withCtx(() => [
30823
- vue.renderSlot(_ctx.$slots, "preview-table-before", {
30824
- tableData: tableData.value,
30825
- errorData: errorData.value
30826
- }, () => [
31054
+ props.showPreviewToolbar ? (vue.openBlock(), vue.createElementBlock("div", {
31055
+ key: 0,
31056
+ class: vue.normalizeClass(vue.unref(em)("preview-toolbar"))
31057
+ }, [
30827
31058
  props.showPreviewCount ? (vue.openBlock(), vue.createElementBlock("span", {
30828
31059
  key: 0,
30829
31060
  class: vue.normalizeClass(vue.unref(em)("preview-count"))
@@ -30833,9 +31064,64 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30833
31064
  }, vue.toDisplayString(vue.unref(t2)("max.import.totalCount")) + ": " + vue.toDisplayString(tableData.value.length), 3),
30834
31065
  vue.createElementVNode("span", {
30835
31066
  class: vue.normalizeClass(vue.unref(em)("error-count"))
30836
- }, vue.toDisplayString(vue.unref(t2)("max.import.errorCount")) + ": " + vue.toDisplayString(errorData.value.length), 3)
30837
- ], 2)) : vue.createCommentVNode("", true)
30838
- ]),
31067
+ }, vue.toDisplayString(vue.unref(t2)("max.import.errorCount")) + ": " + vue.toDisplayString(errorData.value.length), 3),
31068
+ vue.createElementVNode("span", {
31069
+ class: vue.normalizeClass(vue.unref(em)("normal-count"))
31070
+ }, vue.toDisplayString(vue.unref(t2)("max.import.normalCount")) + ": " + vue.toDisplayString(normalDataCount.value), 3)
31071
+ ], 2)) : vue.createCommentVNode("", true),
31072
+ vue.createElementVNode("span", {
31073
+ class: vue.normalizeClass(vue.unref(em)("preview-actions"))
31074
+ }, [
31075
+ props.showPreviewFilter ? (vue.openBlock(), vue.createBlock(vue.unref(naiveUi.NSelect), {
31076
+ key: 0,
31077
+ value: previewFilter.value,
31078
+ "onUpdate:value": [
31079
+ _cache[0] || (_cache[0] = ($event) => previewFilter.value = $event),
31080
+ onPreviewFilterChange
31081
+ ],
31082
+ class: vue.normalizeClass(vue.unref(em)("filter-select")),
31083
+ options: previewFilterOptions.value
31084
+ }, null, 8, ["value", "class", "options"])) : vue.createCommentVNode("", true),
31085
+ props.showExportErrorButton ? (vue.openBlock(), vue.createBlock(vue.unref(XBasicButton), {
31086
+ key: 1,
31087
+ type: "error",
31088
+ secondary: "",
31089
+ icon: "ri:download-2-line",
31090
+ disabled: errorData.value.length === 0,
31091
+ onClick: onExportErrorData
31092
+ }, {
31093
+ default: vue.withCtx(() => [
31094
+ vue.createTextVNode(vue.toDisplayString(vue.unref(t2)("max.import.exportErrorData")), 1)
31095
+ ]),
31096
+ _: 1
31097
+ }, 8, ["disabled"])) : vue.createCommentVNode("", true),
31098
+ props.showDeleteErrorButton ? (vue.openBlock(), vue.createBlock(vue.unref(XBasicButton), {
31099
+ key: 2,
31100
+ secondary: "",
31101
+ icon: "ri:delete-bin-line",
31102
+ disabled: errorData.value.length === 0,
31103
+ onClick: onDeleteErrorData
31104
+ }, {
31105
+ default: vue.withCtx(() => [
31106
+ vue.createTextVNode(vue.toDisplayString(vue.unref(t2)("max.import.deleteErrorData")), 1)
31107
+ ]),
31108
+ _: 1
31109
+ }, 8, ["disabled"])) : vue.createCommentVNode("", true)
31110
+ ], 2)
31111
+ ], 2)) : props.showPreviewCount ? (vue.openBlock(), vue.createElementBlock("span", {
31112
+ key: 1,
31113
+ class: vue.normalizeClass(vue.unref(em)("preview-count"))
31114
+ }, [
31115
+ vue.createElementVNode("span", {
31116
+ class: vue.normalizeClass(vue.unref(em)("total-count"))
31117
+ }, vue.toDisplayString(vue.unref(t2)("max.import.totalCount")) + ": " + vue.toDisplayString(tableData.value.length), 3),
31118
+ vue.createElementVNode("span", {
31119
+ class: vue.normalizeClass(vue.unref(em)("error-count"))
31120
+ }, vue.toDisplayString(vue.unref(t2)("max.import.errorCount")) + ": " + vue.toDisplayString(errorData.value.length), 3),
31121
+ vue.createElementVNode("span", {
31122
+ class: vue.normalizeClass(vue.unref(em)("normal-count"))
31123
+ }, vue.toDisplayString(vue.unref(t2)("max.import.normalCount")) + ": " + vue.toDisplayString(normalDataCount.value), 3)
31124
+ ], 2)) : vue.createCommentVNode("", true),
30839
31125
  vue.createElementVNode("div", {
30840
31126
  class: vue.normalizeClass(vue.unref(em)("preview-table"))
30841
31127
  }, [
@@ -30843,13 +31129,9 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
30843
31129
  ref_key: "basicTableRef",
30844
31130
  ref: basicTableRef
30845
31131
  }), null, 16)
30846
- ], 2),
30847
- vue.renderSlot(_ctx.$slots, "preview-table-after", {
30848
- tableData: tableData.value,
30849
- errorData: errorData.value
30850
- })
31132
+ ], 2)
30851
31133
  ]),
30852
- _: 3
31134
+ _: 1
30853
31135
  }, 8, ["show", "class", "style"]);
30854
31136
  };
30855
31137
  }
@@ -30860,7 +31142,9 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
30860
31142
  props: {
30861
31143
  width: {},
30862
31144
  showTplButton: { type: Boolean },
30863
- showCoverSwitch: { type: Boolean }
31145
+ showCoverSwitch: { type: Boolean },
31146
+ maxSize: { default: 50 },
31147
+ accept: { default: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" }
30864
31148
  },
30865
31149
  emits: ["confirm", "downloadTemplate"],
30866
31150
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -30879,9 +31163,9 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
30879
31163
  return { width: props.width || "630px" };
30880
31164
  });
30881
31165
  const beforeUpload = (file) => {
30882
- const isLt2M = (file.size || 0) / 1024 / 1024 < 50;
30883
- if (!isLt2M) {
30884
- XBasicNotification.error(t2("max.import.fileSizeLimit"));
31166
+ const isInSize = (file.size || 0) / 1024 / 1024 < props.maxSize;
31167
+ if (!isInSize) {
31168
+ XBasicNotification.error(t2("max.import.fileSizeLimit").replace("{max}", String(props.maxSize)));
30885
31169
  return false;
30886
31170
  }
30887
31171
  return false;
@@ -30966,7 +31250,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
30966
31250
  "show-upload-list": "",
30967
31251
  type: "drag",
30968
31252
  "max-count": 1,
30969
- accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
31253
+ accept: props.accept
30970
31254
  }, {
30971
31255
  default: vue.withCtx(() => [
30972
31256
  vue.createElementVNode("p", {
@@ -30982,7 +31266,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
30982
31266
  }, vue.toDisplayString(vue.unref(t2)("max.import.uploadTip")), 3)
30983
31267
  ]),
30984
31268
  _: 1
30985
- }, 8, ["file-list"]),
31269
+ }, 8, ["file-list", "accept"]),
30986
31270
  props.showTplButton ? (vue.openBlock(), vue.createElementBlock("div", {
30987
31271
  key: 0,
30988
31272
  class: vue.normalizeClass(vue.unref(em)("tips"))
@@ -31013,6 +31297,8 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31013
31297
  props: {
31014
31298
  showTplButton: { type: Boolean, default: true },
31015
31299
  showCoverSwitch: { type: Boolean },
31300
+ maxSize: {},
31301
+ accept: {},
31016
31302
  width: {},
31017
31303
  previewWidth: {},
31018
31304
  href: {},
@@ -31021,16 +31307,27 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31021
31307
  beforeFetchImport: {},
31022
31308
  afterFetchImport: {},
31023
31309
  listField: { default: "resultList" },
31310
+ rowNoField: { default: IMPORT_PREVIEW_ROW_NO_FIELD },
31311
+ errorField: { default: IMPORT_PREVIEW_ERROR_FIELD },
31312
+ rowNoColumnTitle: {},
31313
+ errorColumnTitle: {},
31024
31314
  previewColumns: {},
31025
31315
  previewTableProps: {},
31026
31316
  previewTitle: {},
31027
31317
  showPreviewCount: { type: Boolean, default: true },
31318
+ showPreviewToolbar: { type: Boolean, default: true },
31319
+ showPreviewFilter: { type: Boolean, default: true },
31320
+ showExportErrorButton: { type: Boolean, default: true },
31321
+ showDeleteErrorButton: { type: Boolean, default: true },
31322
+ exportErrorFileName: {},
31323
+ exportErrorHandler: {},
31324
+ blockSaveWhenError: { type: Boolean, default: true },
31028
31325
  saveApi: {},
31029
31326
  beforeSaveInterceptor: {},
31030
31327
  beforeFetchSave: {},
31031
31328
  afterFetchSave: {}
31032
31329
  },
31033
- emits: ["import", "preview", "save"],
31330
+ emits: ["import", "preview", "save", "deleteError"],
31034
31331
  setup(__props, { emit: __emit }) {
31035
31332
  const props = __props;
31036
31333
  const emit = __emit;
@@ -31042,8 +31339,8 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31042
31339
  const currentFile = vue.ref(null);
31043
31340
  const currentChecked = vue.ref(false);
31044
31341
  async function runBeforeSaveGuard(payload) {
31045
- if (payload.errors.length > 0) {
31046
- XBasicNotification.error("存在校验失败的数据,请检查");
31342
+ if (props.blockSaveWhenError && payload.errors.length > 0) {
31343
+ XBasicNotification.error(t2("max.import.validationFailed"));
31047
31344
  return false;
31048
31345
  }
31049
31346
  if (!props.beforeSaveInterceptor || !lodashEs.isFunction(props.beforeSaveInterceptor)) return true;
@@ -31060,6 +31357,20 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31060
31357
  return false;
31061
31358
  }
31062
31359
  }
31360
+ function normalizePreviewRows(rows = []) {
31361
+ return rows.map((item) => {
31362
+ const row = { ...item };
31363
+ const rowNo = props.rowNoField ? lodashEs.get(item, props.rowNoField) : void 0;
31364
+ const errorMsg = props.errorField ? lodashEs.get(item, props.errorField) : void 0;
31365
+ if (row[IMPORT_PREVIEW_ROW_NO_FIELD] === void 0 && rowNo !== void 0) {
31366
+ row[IMPORT_PREVIEW_ROW_NO_FIELD] = rowNo;
31367
+ }
31368
+ if (row[IMPORT_PREVIEW_ERROR_FIELD] === void 0 && errorMsg !== void 0) {
31369
+ row[IMPORT_PREVIEW_ERROR_FIELD] = errorMsg;
31370
+ }
31371
+ return row;
31372
+ });
31373
+ }
31063
31374
  async function onImport(file, checked, showPreview = false) {
31064
31375
  var _a, _b, _c, _d;
31065
31376
  const { importApi, beforeFetchImport, afterFetchImport } = props;
@@ -31076,6 +31387,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31076
31387
  if (afterFetchImport && lodashEs.isFunction(afterFetchImport)) {
31077
31388
  resultItems = await afterFetchImport(resultItems) || resultItems;
31078
31389
  }
31390
+ resultItems = normalizePreviewRows(resultItems);
31079
31391
  currentFile.value = file;
31080
31392
  currentChecked.value = checked;
31081
31393
  (_b = previewModalRef.value) == null ? void 0 : _b.show({ type: "other", data: { list: resultItems } });
@@ -31135,7 +31447,10 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31135
31447
  }
31136
31448
  try {
31137
31449
  const params = props.beforeFetchSave ? props.beforeFetchSave({ data, records }) : { dtoList: data };
31138
- const res = await props.saveApi(params);
31450
+ let res = await props.saveApi(params);
31451
+ if (props.afterFetchSave && lodashEs.isFunction(props.afterFetchSave)) {
31452
+ res = await props.afterFetchSave(res) || res;
31453
+ }
31139
31454
  emit("save", { data: res, checked: currentChecked.value, file: currentFile.value, records });
31140
31455
  } catch (error) {
31141
31456
  console.error(error);
@@ -31148,6 +31463,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31148
31463
  var _a;
31149
31464
  (_a = uploadModalRef.value) == null ? void 0 : _a.show({ type: "other" });
31150
31465
  }
31466
+ function onDeleteError(payload) {
31467
+ emit("deleteError", payload);
31468
+ }
31151
31469
  return (_ctx, _cache) => {
31152
31470
  return vue.openBlock(), vue.createElementBlock("span", null, [
31153
31471
  vue.createElementVNode("div", {
@@ -31171,9 +31489,11 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31171
31489
  width: props.width,
31172
31490
  "show-tpl-button": props.showTplButton,
31173
31491
  "show-cover-switch": props.showCoverSwitch,
31492
+ "max-size": props.maxSize,
31493
+ accept: props.accept,
31174
31494
  onConfirm: onUploadConfirm,
31175
31495
  onDownloadTemplate: onExport
31176
- }, null, 8, ["width", "show-tpl-button", "show-cover-switch"]),
31496
+ }, null, 8, ["width", "show-tpl-button", "show-cover-switch", "max-size", "accept"]),
31177
31497
  vue.createVNode(_sfc_main$2, {
31178
31498
  ref_key: "previewModalRef",
31179
31499
  ref: previewModalRef,
@@ -31182,23 +31502,17 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
31182
31502
  "preview-table-props": props.previewTableProps,
31183
31503
  "preview-title": props.previewTitle,
31184
31504
  "show-preview-count": props.showPreviewCount,
31185
- onConfirm: onPreviewConfirm
31186
- }, vue.createSlots({ _: 2 }, [
31187
- _ctx.$slots["preview-table-before"] ? {
31188
- name: "preview-table-before",
31189
- fn: vue.withCtx((slotProps) => [
31190
- vue.renderSlot(_ctx.$slots, "preview-table-before", vue.normalizeProps(vue.guardReactiveProps(slotProps)))
31191
- ]),
31192
- key: "0"
31193
- } : void 0,
31194
- _ctx.$slots["preview-table-after"] ? {
31195
- name: "preview-table-after",
31196
- fn: vue.withCtx((slotProps) => [
31197
- vue.renderSlot(_ctx.$slots, "preview-table-after", vue.normalizeProps(vue.guardReactiveProps(slotProps)))
31198
- ]),
31199
- key: "1"
31200
- } : void 0
31201
- ]), 1032, ["preview-width", "preview-columns", "preview-table-props", "preview-title", "show-preview-count"])
31505
+ "show-preview-toolbar": props.showPreviewToolbar,
31506
+ "show-preview-filter": props.showPreviewFilter,
31507
+ "show-export-error-button": props.showExportErrorButton,
31508
+ "show-delete-error-button": props.showDeleteErrorButton,
31509
+ "row-no-column-title": props.rowNoColumnTitle,
31510
+ "error-column-title": props.errorColumnTitle,
31511
+ "export-error-file-name": props.exportErrorFileName,
31512
+ "export-error-handler": props.exportErrorHandler,
31513
+ onConfirm: onPreviewConfirm,
31514
+ onDeleteError
31515
+ }, null, 8, ["preview-width", "preview-columns", "preview-table-props", "preview-title", "show-preview-count", "show-preview-toolbar", "show-preview-filter", "show-export-error-button", "show-delete-error-button", "row-no-column-title", "error-column-title", "export-error-file-name", "export-error-handler"])
31202
31516
  ]);
31203
31517
  };
31204
31518
  }
@@ -31435,11 +31749,13 @@ exports.basicUploadProps = basicUploadProps;
31435
31749
  exports.configProviderProps = configProviderProps;
31436
31750
  exports.default = installer;
31437
31751
  exports.detectFlexGapSupported = detectFlexGapSupported;
31752
+ exports.exportRowsToXlsx = exportRowsToXlsx;
31438
31753
  exports.formatterFCN = formatterFCN;
31439
31754
  exports.formatterFCR = formatterFCR;
31440
31755
  exports.formatterFYN = formatterFYN;
31441
31756
  exports.install = install;
31442
31757
  exports.makeInstaller = makeInstaller;
31758
+ exports.normalizeExportXlsxColumns = normalizeExportXlsxColumns;
31443
31759
  exports.notificationTypes = notificationTypes;
31444
31760
  exports.provideGlobalConfig = provideGlobalConfig;
31445
31761
  exports.responsiveArray = responsiveArray;