@newview/ui 0.0.7 → 1.1.1

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.
@@ -8,11 +8,11 @@ import { BaseInstance } from "@newview/base-vue";
8
8
  import { openBlock, createElementBlock, normalizeStyle, defineComponent, ref, resolveComponent, createVNode, reactive, watch, onMounted, onUnmounted, createBlock, withCtx, createElementVNode, Fragment, renderList, normalizeClass, withDirectives, createTextVNode, toDisplayString, createCommentVNode, createSlots, vShow, h, computed, nextTick, renderSlot, mergeProps, toHandlers, withModifiers, createApp, getCurrentInstance } from "vue";
9
9
  import { VxeColumn, VxeColgroup, VxeGrid, VxeTable } from "vxe-table";
10
10
  import { utilities } from "@newview/tools";
11
+ import { Space, Icon, Drawer, Button } from "view-ui-plus";
11
12
  import dayjs from "dayjs";
12
13
  import JSZip from "jszip";
13
14
  import x2js from "x2js";
14
15
  import linq from "linq";
15
- import { Drawer, Space, Button } from "view-ui-plus";
16
16
  import XLSX from "xlsx";
17
17
  var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
18
18
  (function() {
@@ -32382,6 +32382,11 @@ const propDefine$i = {
32382
32382
  // 列配置项
32383
32383
  type: Array,
32384
32384
  default: () => []
32385
+ },
32386
+ xTable: {
32387
+ type: Object,
32388
+ default: () => {
32389
+ }
32385
32390
  }
32386
32391
  };
32387
32392
  const _sfc_main$8 = defineComponent({
@@ -32630,6 +32635,19 @@ class GridColumnInstance extends BaseInstance {
32630
32635
  }
32631
32636
  return filterValue.toString();
32632
32637
  };
32638
+ } else if (column.treeNode && this.utilities.isNull(column.format)) {
32639
+ column.format = (h2, params) => {
32640
+ const row = params.row;
32641
+ const hasChild = row.children && row.children.length > 0;
32642
+ let icon = "md-bookmarks";
32643
+ if (hasChild) {
32644
+ icon = this.props.xTable.isTreeExpandByRow(row) ? "ios-folder-open" : "ios-folder";
32645
+ }
32646
+ return h2(Space, { size: 4 }, () => [
32647
+ h2(Icon, { size: 16, type: icon, color: hasChild ? "#ff9900" : "#2db7f5" }),
32648
+ h2("span", row[column.field])
32649
+ ]);
32650
+ };
32633
32651
  }
32634
32652
  }
32635
32653
  /**
@@ -32671,7 +32689,7 @@ class GridColumnInstance extends BaseInstance {
32671
32689
  }
32672
32690
  //#endregion 事件 END
32673
32691
  }
32674
- const GridColumn_vue_vue_type_style_index_0_scoped_1efb5432_lang = "";
32692
+ const GridColumn_vue_vue_type_style_index_0_scoped_1d0a8ef1_lang = "";
32675
32693
  const _hoisted_1$6 = { class: "gridColumn" };
32676
32694
  function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
32677
32695
  const _component_GridTitleContent = resolveComponent("GridTitleContent");
@@ -32693,7 +32711,10 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
32693
32711
  return openBlock(), createElementBlock("div", _hoisted_1$6, [
32694
32712
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columns, (column) => {
32695
32713
  return openBlock(), createElementBlock(Fragment, null, [
32696
- _ctx.getHasColgroup(column) ? (openBlock(), createBlock(_component_vxe_colgroup, { key: 0 }, {
32714
+ _ctx.getHasColgroup(column) ? (openBlock(), createBlock(_component_vxe_colgroup, {
32715
+ key: 0,
32716
+ align: column.align ? column.align : "center"
32717
+ }, {
32697
32718
  header: withCtx(() => [
32698
32719
  createVNode(_component_GridTitleContent, { column }, null, 8, ["column"])
32699
32720
  ]),
@@ -32703,7 +32724,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
32703
32724
  }, null, 8, ["columns"])
32704
32725
  ]),
32705
32726
  _: 2
32706
- }, 1024)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
32727
+ }, 1032, ["align"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
32707
32728
  column.colType == "seq" ? (openBlock(), createBlock(_component_vxe_column, {
32708
32729
  key: 0,
32709
32730
  type: "seq",
@@ -32945,7 +32966,7 @@ function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
32945
32966
  }), 256))
32946
32967
  ]);
32947
32968
  }
32948
- const GridColumn = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8], ["__scopeId", "data-v-1efb5432"]]);
32969
+ const GridColumn = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8], ["__scopeId", "data-v-1d0a8ef1"]]);
32949
32970
  const propDefine$h = {
32950
32971
  option: {
32951
32972
  // Gird 配置项
@@ -33081,10 +33102,12 @@ let GridInstance$1 = class GridInstance2 extends BaseInstance {
33081
33102
  * @param row
33082
33103
  */
33083
33104
  __publicField(this, "setCurrentRow", (row) => {
33084
- this.xTable.value.setCurrentRow(row);
33085
- if (this.props.option.event && this.props.option.event.currentChange) {
33086
- const data2 = { "$table": this.xTable.value, row, newValue: row, oldValue: void 0, rowIndex: 1, columnIndex: 0 };
33087
- this.props.option.event.currentChange(data2);
33105
+ if (this.xTable.value) {
33106
+ this.xTable.value.setCurrentRow(row);
33107
+ if (this.props.option.event && this.props.option.event.currentChange) {
33108
+ const data2 = { "$table": this.xTable.value, row, newValue: row, oldValue: void 0, rowIndex: 1, columnIndex: 0 };
33109
+ this.props.option.event.currentChange(data2);
33110
+ }
33088
33111
  }
33089
33112
  });
33090
33113
  //#region 全局值
@@ -33381,6 +33404,13 @@ let GridInstance$1 = class GridInstance2 extends BaseInstance {
33381
33404
  __publicField(this, "getRowConfig", () => {
33382
33405
  return this.utilities.isNull(this.props.option.setting) ? {} : this.props.option.setting.rowConfig;
33383
33406
  });
33407
+ /**
33408
+ * 校验规则配置项
33409
+ * @returns
33410
+ */
33411
+ __publicField(this, "getEditRules", () => {
33412
+ return this.utilities.isNull(this.props.option.setting) ? {} : this.props.option.setting.editRules;
33413
+ });
33384
33414
  /**
33385
33415
  * 获取树配置
33386
33416
  * @returns
@@ -33452,6 +33482,9 @@ let GridInstance$1 = class GridInstance2 extends BaseInstance {
33452
33482
  }
33453
33483
  this.datas.value = _datas;
33454
33484
  nextTick(() => {
33485
+ if (!this.xTable.value) {
33486
+ return;
33487
+ }
33455
33488
  if (this.props.option.setting && this.props.option.setting.isTree && this.props.option.setting.treeConfig && this.props.option.setting.treeConfig.expandAll) {
33456
33489
  this.xTable.value.setAllTreeExpand(true);
33457
33490
  }
@@ -33710,6 +33743,10 @@ let GridInstance$1 = class GridInstance2 extends BaseInstance {
33710
33743
  if (this.props.option.event && this.props.option.event.event_saveBefore && !this.props.option.event.event_saveBefore(saveDatas)) {
33711
33744
  return;
33712
33745
  }
33746
+ if (!await this.validate()) {
33747
+ this.message.warning("校验失败!");
33748
+ return;
33749
+ }
33713
33750
  this.loadDataing.value = true;
33714
33751
  const apiResult = this.getIsTree() ? await this.props.option.api.saveTree(saveDatas) : await this.props.option.api.saves(saveDatas);
33715
33752
  const result = this.utilities.parseApiResult(apiResult);
@@ -33885,6 +33922,16 @@ let GridInstance$1 = class GridInstance2 extends BaseInstance {
33885
33922
  await $table.setEditRow(row);
33886
33923
  $table.clearEdit();
33887
33924
  });
33925
+ /**
33926
+ * 编辑校验
33927
+ * @returns
33928
+ */
33929
+ __publicField(this, "validate", async () => {
33930
+ const $table = this.xTable.value;
33931
+ if ($table) {
33932
+ return await $table.validate(true);
33933
+ }
33934
+ });
33888
33935
  this.props = props;
33889
33936
  this.ctx = ctx;
33890
33937
  this.useSearchPanel();
@@ -34006,7 +34053,7 @@ let GridInstance$1 = class GridInstance2 extends BaseInstance {
34006
34053
  }
34007
34054
  //#endregion 公开方法 END
34008
34055
  };
34009
- const Grid_vue_vue_type_style_index_0_scoped_96859f1d_lang = "";
34056
+ const Grid_vue_vue_type_style_index_0_scoped_cb63f716_lang = "";
34010
34057
  const _hoisted_1$5 = { class: "nv-crud" };
34011
34058
  const _hoisted_2$4 = { class: "nv-crud-body" };
34012
34059
  const _hoisted_3$3 = { class: "nv-crud-body-search" };
@@ -34116,6 +34163,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
34116
34163
  "row-config": _ctx.getRowConfig(),
34117
34164
  "edit-config": _ctx.getEditConfig(),
34118
34165
  "tree-config": _ctx.getTreeConfig(),
34166
+ "edit-rules": _ctx.getEditRules(),
34119
34167
  onKeydownStart: _ctx.gridEvents.keydownStart,
34120
34168
  onKeydown: _ctx.gridEvents.keydown,
34121
34169
  onKeydownEnd: _ctx.gridEvents.keydownEnd,
@@ -34156,13 +34204,14 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
34156
34204
  default: withCtx(() => [
34157
34205
  createVNode(_component_grid_column, {
34158
34206
  columns: _ctx.option.columns,
34207
+ xTable: _ctx.xTable,
34159
34208
  onClearRadioRow: _ctx.doClearRadioRow,
34160
34209
  onDelete: _ctx.doDelete,
34161
34210
  onAddchild: _ctx.doAddChild
34162
- }, null, 8, ["columns", "onClearRadioRow", "onDelete", "onAddchild"])
34211
+ }, null, 8, ["columns", "xTable", "onClearRadioRow", "onDelete", "onAddchild"])
34163
34212
  ]),
34164
34213
  _: 1
34165
- }, 16, ["data", "border", "show-header", "row-config", "edit-config", "tree-config", "onKeydownStart", "onKeydown", "onKeydownEnd", "onPaste", "onCopy", "onCut", "onCurrentChange", "onRadioChange", "onCheckboxChange", "onCheckboxAll", "onCheckboxRangeStart", "onCheckboxRangeChange", "onCheckboxRangeEnd", "onCellClick", "onCellDblclick", "onCellMenu", "onCellMouseenter", "onCellMouseleave", "onHeaderCellClick", "onHeaderCellDblclick", "onHeaderCellMenu", "onFooterCellClick", "onFooterCellDblclick", "onFooterCellMenu", "onSortChange", "onFilterChange", "onResizableChange", "onToggleRowExpand", "onToggleTreeExpand", "onMenuClick", "onEditClosed", "onEditActived", "onEditDisabled", "onValidError", "onScroll", "onCustom"]), [
34214
+ }, 16, ["data", "border", "show-header", "row-config", "edit-config", "tree-config", "edit-rules", "onKeydownStart", "onKeydown", "onKeydownEnd", "onPaste", "onCopy", "onCut", "onCurrentChange", "onRadioChange", "onCheckboxChange", "onCheckboxAll", "onCheckboxRangeStart", "onCheckboxRangeChange", "onCheckboxRangeEnd", "onCellClick", "onCellDblclick", "onCellMenu", "onCellMouseenter", "onCellMouseleave", "onHeaderCellClick", "onHeaderCellDblclick", "onHeaderCellMenu", "onFooterCellClick", "onFooterCellDblclick", "onFooterCellMenu", "onSortChange", "onFilterChange", "onResizableChange", "onToggleRowExpand", "onToggleTreeExpand", "onMenuClick", "onEditClosed", "onEditActived", "onEditDisabled", "onValidError", "onScroll", "onCustom"]), [
34166
34215
  [vShow, _ctx.showTable]
34167
34216
  ])
34168
34217
  ], 512)
@@ -34179,7 +34228,7 @@ function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
34179
34228
  ])) : createCommentVNode("", true)
34180
34229
  ]);
34181
34230
  }
34182
- const Grid = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7], ["__scopeId", "data-v-96859f1d"]]);
34231
+ const Grid = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7], ["__scopeId", "data-v-cb63f716"]]);
34183
34232
  const propDefine$g = {
34184
34233
  width: {
34185
34234
  // Box 宽度
@@ -186904,6 +186953,9 @@ class PrintApi extends BaseInstance {
186904
186953
  const order = Number(sheetHandle);
186905
186954
  const sheet = this.luckysheet.getSheet({ order });
186906
186955
  if (!this.utilities.isNull(sheet)) {
186956
+ if (sheet.config.printPage == void 0) {
186957
+ sheet.config.printPage = {};
186958
+ }
186907
186959
  sheet.config.printPage.oriantation = isPortrait ? "portrait" : "landscape";
186908
186960
  }
186909
186961
  }
@@ -186919,6 +186971,9 @@ class PrintApi extends BaseInstance {
186919
186971
  const order = Number(sheetHandle);
186920
186972
  const sheet = this.luckysheet.getSheet({ order });
186921
186973
  if (!this.utilities.isNull(sheet)) {
186974
+ if (sheet.config.printPage == void 0) {
186975
+ sheet.config.printPage = {};
186976
+ }
186922
186977
  sheet.config.printPage.marginBottom = bottom;
186923
186978
  sheet.config.printPage.marginLeft = left;
186924
186979
  sheet.config.printPage.marginRight = right;
@@ -186933,8 +186988,12 @@ class PrintApi extends BaseInstance {
186933
186988
  getOriantation(sheetHandle = "") {
186934
186989
  const order = this.utilities.isNull(sheetHandle) ? this.reportApi.sheetApi.getSheetIndex() : Number(sheetHandle);
186935
186990
  const sheet = this.reportApi.sheetApi.getSheet(order);
186936
- const oriantation = sheet.config.printPage.oriantation;
186937
- return oriantation;
186991
+ if (sheet.config.printPage == void 0) {
186992
+ const oriantation = sheet.config.printPage.oriantation;
186993
+ return oriantation;
186994
+ } else {
186995
+ return "";
186996
+ }
186938
186997
  }
186939
186998
  /**
186940
186999
  * 获取打印页设置
@@ -186944,7 +187003,8 @@ class PrintApi extends BaseInstance {
186944
187003
  getPrintPage(sheetHandle = "") {
186945
187004
  const order = this.utilities.isNull(sheetHandle) ? this.reportApi.sheetApi.getSheetIndex() : Number(sheetHandle);
186946
187005
  const sheet = this.reportApi.sheetApi.getSheet(order);
186947
- return sheet.config.printPage;
187006
+ const printPage = sheet.config.printPage;
187007
+ return printPage ?? {};
186948
187008
  }
186949
187009
  /**
186950
187010
  * 自适应选定页A4
@@ -186967,7 +187027,7 @@ class PrintApi extends BaseInstance {
186967
187027
  sheetIndexs.split(",").forEach((el) => {
186968
187028
  let sheetHandle = el;
186969
187029
  const sheet = this.luckysheet.getSheet({ order: sheetHandle });
186970
- const oriantation = sheet.config.printPage.oriantation;
187030
+ const oriantation = sheet.config.printPage == void 0 ? "" : sheet.config.printPage.oriantation;
186971
187031
  this.setSheetA4Size(sheetHandle, oriantation == "portrait", leftPx, rightPx, topPx, bottomPx);
186972
187032
  });
186973
187033
  }
@@ -188516,25 +188576,48 @@ class ReportApi extends BaseInstance {
188516
188576
  }
188517
188577
  /**
188518
188578
  * 加载 模板及数据
188519
- * @param content
188520
- * @param callback
188579
+ * @param content
188580
+ * @param callback
188581
+ * @param isHttp
188521
188582
  */
188522
- build(content, callback) {
188523
- let jsonContent = {};
188524
- if (content != null && content != "") {
188525
- if (content.indexOf("<?xml") != -1) {
188526
- jsonContent = LuckyConvert.transformSuXmlToLucky(content);
188527
- } else {
188528
- if (JSON.parse(content).constructor == Array) {
188529
- jsonContent = JSON.parse(content);
188583
+ build(content, callback, isHttp = false) {
188584
+ if (isHttp) {
188585
+ this.importReportByUrl(content, callback);
188586
+ } else {
188587
+ let jsonContent = {};
188588
+ if (content != null && content != "") {
188589
+ if (content.indexOf("<?xml") != -1) {
188590
+ jsonContent = LuckyConvert.transformSuXmlToLucky(content);
188530
188591
  } else {
188531
- jsonContent = JSON.parse(eval("" + content));
188592
+ if (JSON.parse(content).constructor == Array) {
188593
+ jsonContent = JSON.parse(content);
188594
+ } else {
188595
+ jsonContent = JSON.parse(eval("" + content));
188596
+ }
188532
188597
  }
188598
+ this.instanceopts.data = jsonContent;
188533
188599
  }
188534
- this.instanceopts.data = jsonContent;
188600
+ this.loadCallback = callback;
188601
+ luckysheet$2.create(this.instanceopts);
188535
188602
  }
188536
- this.loadCallback = callback;
188537
- luckysheet$2.create(this.instanceopts);
188603
+ }
188604
+ /**
188605
+ * 通过Url导入报表
188606
+ * @param fileUrl
188607
+ * @param callback
188608
+ */
188609
+ importReportByUrl(fileUrl, callback2) {
188610
+ LuckyConvert.transformExcelToLuckyByUrl(fileUrl, "", (exportJson, luckysheetfile) => {
188611
+ if (exportJson.sheets == null || exportJson.sheets.length == 0) {
188612
+ this.message.warning(
188613
+ "Failed to read the content of the excel file, currently does not support xls files!"
188614
+ );
188615
+ return;
188616
+ }
188617
+ this.instanceopts.data = exportJson.sheets;
188618
+ this.loadCallback = callback2;
188619
+ luckysheet$2.create(this.instanceopts);
188620
+ });
188538
188621
  }
188539
188622
  /**
188540
188623
  * 导入报表
@@ -190776,10 +190859,12 @@ class GridInstance extends BaseInstance {
190776
190859
  * @param row
190777
190860
  */
190778
190861
  __publicField(this, "setCurrentRow", (row) => {
190779
- this.xTable.value.setCurrentRow(row);
190780
- if (this.props.option.event && this.props.option.event.currentChange) {
190781
- const data2 = { "$table": this.xTable.value, row, newValue: row, oldValue: void 0, rowIndex: 1, columnIndex: 0 };
190782
- this.props.option.event.currentChange(data2);
190862
+ if (this.xTable.value) {
190863
+ this.xTable.value.setCurrentRow(row);
190864
+ if (this.props.option.event && this.props.option.event.currentChange) {
190865
+ const data2 = { "$table": this.xTable.value, row, newValue: row, oldValue: void 0, rowIndex: 1, columnIndex: 0 };
190866
+ this.props.option.event.currentChange(data2);
190867
+ }
190783
190868
  }
190784
190869
  });
190785
190870
  //#region 全局值
@@ -191076,6 +191161,13 @@ class GridInstance extends BaseInstance {
191076
191161
  __publicField(this, "getRowConfig", () => {
191077
191162
  return this.utilities.isNull(this.props.option.setting) ? {} : this.props.option.setting.rowConfig;
191078
191163
  });
191164
+ /**
191165
+ * 校验规则配置项
191166
+ * @returns
191167
+ */
191168
+ __publicField(this, "getEditRules", () => {
191169
+ return this.utilities.isNull(this.props.option.setting) ? {} : this.props.option.setting.editRules;
191170
+ });
191079
191171
  /**
191080
191172
  * 获取树配置
191081
191173
  * @returns
@@ -191147,6 +191239,9 @@ class GridInstance extends BaseInstance {
191147
191239
  }
191148
191240
  this.datas.value = _datas;
191149
191241
  nextTick(() => {
191242
+ if (!this.xTable.value) {
191243
+ return;
191244
+ }
191150
191245
  if (this.props.option.setting && this.props.option.setting.isTree && this.props.option.setting.treeConfig && this.props.option.setting.treeConfig.expandAll) {
191151
191246
  this.xTable.value.setAllTreeExpand(true);
191152
191247
  }
@@ -191405,6 +191500,10 @@ class GridInstance extends BaseInstance {
191405
191500
  if (this.props.option.event && this.props.option.event.event_saveBefore && !this.props.option.event.event_saveBefore(saveDatas)) {
191406
191501
  return;
191407
191502
  }
191503
+ if (!await this.validate()) {
191504
+ this.message.warning("校验失败!");
191505
+ return;
191506
+ }
191408
191507
  this.loadDataing.value = true;
191409
191508
  const apiResult = this.getIsTree() ? await this.props.option.api.saveTree(saveDatas) : await this.props.option.api.saves(saveDatas);
191410
191509
  const result = this.utilities.parseApiResult(apiResult);
@@ -191580,6 +191679,16 @@ class GridInstance extends BaseInstance {
191580
191679
  await $table.setEditRow(row);
191581
191680
  $table.clearEdit();
191582
191681
  });
191682
+ /**
191683
+ * 编辑校验
191684
+ * @returns
191685
+ */
191686
+ __publicField(this, "validate", async () => {
191687
+ const $table = this.xTable.value;
191688
+ if ($table) {
191689
+ return await $table.validate(true);
191690
+ }
191691
+ });
191583
191692
  this.props = props;
191584
191693
  this.ctx = ctx;
191585
191694
  this.useSearchPanel();