@indfnd/common 1.0.13 → 1.0.15

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.15](http://git.inspur.com/imp-ec/ind-front/ind-common-front/compare/v1.0.14...v1.0.15) (2024-07-08)
6
+
7
+
8
+ ### Features
9
+
10
+ * 表格计算逻辑修改`` ([21a6a95](http://git.inspur.com/imp-ec/ind-front/ind-common-front/commit/21a6a958528a6cb3c678bfa1b898aa8b1b8d6485))
11
+
12
+ ### [1.0.14](http://git.inspur.com/imp-ec/ind-front/ind-common-front/compare/v1.0.13...v1.0.14) (2024-06-29)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * 导出excel支持百分比格式 ([2e3fc6c](http://git.inspur.com/imp-ec/ind-front/ind-common-front/commit/2e3fc6cb0d32c94a2382d37f2a96e32f1f9700c5))
18
+
5
19
  ### [1.0.13](http://git.inspur.com/imp-ec/ind-front/ind-common-front/compare/v1.0.12...v1.0.13) (2024-06-28)
6
20
 
7
21
 
@@ -2,7 +2,7 @@ import { Button as Button$1, ButtonGroup as ButtonGroup$1, Input, Drawer as Draw
2
2
  import { isNil, formatDate as formatDate$1, useConfig, getQuarterNum, formatQuarter, str2Date, isDate, isArray, checkIdCard, checkVehicleNo, checkPhone, getDictMapApi, axios, isFunction, isString, uuid, exportJsonToExcel as exportJsonToExcel$1, importJsonFromExcel, on, off, deleteMenuHistoryApi, deleteMenuCollectApi, getMenuHistoryApi, getMenuCollectApi, getPermissionCache, listItemTreeApi, getPriceInfo, MIME_TYPE, base64ToBlob, putOssFileApi, isEqual, getCaptchaURL, getLocalStorage, guid, setLocalStorage, removeLocalStorage, clearSessionStorage, cryptor, getToken, putOssFileUrl, getOssFileUrl, responseInterceptors, config as config$1, setToken, loginApi, clearUserInfoCache, clearPermissionCache, logoutApi, getUserInfoCache, getUserInfoApi, setUserInfoCache, getSessionStorage, setSessionStorage, getAppListApi, getPermissionApi, setPermissionCache, menuHistoryApi, addMenuCollectApi, removeMenuCollectApi, getIndexDescCache, listIndexDescApi, setIndexDescCache } from "@indfnd/utils";
3
3
  import Vue$1 from "vue";
4
4
  const name$1 = "@indfnd/common";
5
- const version = "1.0.12";
5
+ const version = "1.0.14";
6
6
  const author = "huxuetong";
7
7
  const publishConfig = {
8
8
  registry: "https://registry.npmjs.org/"
@@ -43160,14 +43160,16 @@ function getAgColumnTitleAndData({ columns, datas }) {
43160
43160
  }
43161
43161
  calcColumns(columnsClo, columnsCalc);
43162
43162
  var columnAlign = columnsCalc.map((d) => d.align || "left");
43163
- var columnType = columnsCalc.map((d) => d.align == "right" || d.align == "rightNum" ? "n" : "s");
43163
+ var columnType = columnsCalc.map((d) => d.dataType == "percent" ? "p" : d.align == "right" || d.align == "rightNum" ? "n" : "s");
43164
43164
  var columnWidth = columnsCalc.map(
43165
43165
  (d) => d.excelWidth ? d.excelWidth : d.width ? Math.floor(d.width / 10) : 10
43166
43166
  );
43167
43167
  var numberFormat = columnsCalc.map((d) => {
43168
43168
  var _a;
43169
43169
  let scale = (_a = d == null ? void 0 : d.cellRendererParams) == null ? void 0 : _a.scale;
43170
- if (scale !== void 0) {
43170
+ if (d.dataType == "percent") {
43171
+ return "0.00%";
43172
+ } else if (scale !== void 0) {
43171
43173
  return "#,##0." + _.range(scale).fill(0).join("");
43172
43174
  } else {
43173
43175
  return d.align == "rightNum" ? "#,##0.0000" : d.align == "right" ? "#,##0.00" : "";
@@ -43394,14 +43396,17 @@ function exportJsonToExcel(excelData) {
43394
43396
  for (var i = 0; i < jsonData.length; i++) {
43395
43397
  var lineData = jsonData[i];
43396
43398
  for (var j = 0; j < lineData.length; j++) {
43397
- if (columnType[j] === "s" && lineData[j]) {
43398
- sheet.cell(rowsNow + i, j + 1).value(lineData[j]);
43399
- dataCellStyle.numberFormat = "";
43399
+ if (columnType[j] === "p" && lineData[j]) {
43400
+ sheet.cell(rowsNow + i, j + 1).value(parseFloat(lineData[j] / 100));
43401
+ dataCellStyle.numberFormat = numberFormat[j];
43400
43402
  } else if (columnType[j] === "n" && lineData[j]) {
43401
43403
  sheet.cell(rowsNow + i, j + 1).value(parseFloat(lineData[j]));
43402
43404
  dataCellStyle.numberFormat = numberFormat[j];
43405
+ } else if (columnType[j] === "s" && lineData[j]) {
43406
+ sheet.cell(rowsNow + i, j + 1).value(lineData[j]);
43407
+ dataCellStyle.numberFormat = "";
43403
43408
  } else {
43404
- if (columnType[j] === "n") {
43409
+ if (columnType[j] === "p" || columnType[j] === "n") {
43405
43410
  dataCellStyle.numberFormat = numberFormat[j];
43406
43411
  } else {
43407
43412
  sheet.cell(rowsNow + i, j + 1).value("");
@@ -53143,6 +53148,9 @@ const __vue2_script$_ = {
53143
53148
  if (column.align) {
53144
53149
  agColumn.align = column.align;
53145
53150
  }
53151
+ if (column.dataType) {
53152
+ agColumn.dataType = column.dataType;
53153
+ }
53146
53154
  if (column.headerTooltip) {
53147
53155
  agColumn.headerTooltip = agColumn.headerTooltip || column.headerTooltip;
53148
53156
  }
@@ -53543,70 +53551,57 @@ const __vue2_script$_ = {
53543
53551
  },
53544
53552
  renderSumRow: _.debounce(async function() {
53545
53553
  var _a;
53546
- let hasSumRow = _.some(this.flatColumns, (item2) => item2.isSum);
53554
+ let hasSumRow = this.flatColumns.some((item2) => item2.isSum);
53547
53555
  if (hasSumRow) {
53548
53556
  console.time("calcSum");
53549
- let sumCols = _.filter(this.flatColumns, (item2) => item2.isSum);
53550
- let sumCalcCols = _.remove(sumCols, (item2) => isString(item2.isSum));
53551
- let sumFuncCols = _.remove(sumCols, (item2) => item2.isSum instanceof Function);
53552
- const sumCalcRuleMap = {};
53553
- _.forEach(sumCalcCols, (col) => {
53554
- addCalcRuleMap(sumCalcRuleMap, col.isSum, col.field || col.key);
53555
- });
53556
53557
  let sumData = {};
53557
- for (let i = 0; i < this.flatColumns.length; i++) {
53558
- if (!["checkbox", "radios", "index"].includes((_a = this.flatColumns[i]) == null ? void 0 : _a.type)) {
53559
- let colTmp = this.flatColumns[i];
53560
- sumData[colTmp.field || colTmp.key] = "\u5408\u8BA1";
53558
+ for (let col of this.flatColumns) {
53559
+ if (!["checkbox", "radios", "index"].includes(col.type)) {
53560
+ sumData[col.field || col.key] = "\u5408\u8BA1";
53561
53561
  break;
53562
53562
  }
53563
53563
  }
53564
- sumCols.forEach((d) => sumData[d.field || d.key] = 0);
53565
- sumData = _.reduce(
53566
- this.rowDataFiltered,
53567
- (s, d, idx) => {
53568
- sumCols.forEach((dd) => {
53569
- if (isString(dd.isSum))
53570
- return;
53571
- let field = dd.field || dd.key;
53572
- let rowMergeInfo = this.tableRowSpanMergeIndexMap[field];
53573
- let mergedRows = [];
53574
- _.forEach(rowMergeInfo, (v, k) => {
53575
- let rows2 = _.range(k, parseInt(k) + v);
53576
- mergedRows.push(...rows2.slice(1));
53577
- });
53578
- if (!mergedRows.includes(idx)) {
53579
- sumData[field] = _.round(
53580
- sumData[field] + (!d[field] || isNaN(d[field]) ? 0 : parseFloat(d[field])),
53581
- 6
53582
- );
53583
- }
53584
- });
53585
- return s;
53586
- },
53587
- sumData
53588
- );
53589
- _.forEach(sumFuncCols, (d) => {
53590
- sumData[d.field || d.key] = d.isSum(this.rowDataFiltered, d);
53564
+ let sumCols = this.flatColumns.filter((item2) => item2.isSum);
53565
+ let sumCalcCols = [], sumFuncCols = [];
53566
+ sumCols.forEach((col) => {
53567
+ if (typeof col.isSum === "string")
53568
+ sumCalcCols.push(col);
53569
+ else if (col.isSum instanceof Function)
53570
+ sumFuncCols.push(col);
53591
53571
  });
53592
- let sumRows = [sumData];
53593
- let calcRules = {};
53594
- _.forEach(sumCalcRuleMap, (v, k) => {
53595
- _.merge(calcRules, v);
53572
+ const sumCalcRuleMap = {};
53573
+ sumCalcCols.forEach((col) => {
53574
+ addCalcRuleMap(sumCalcRuleMap, col.isSum, col.field || col.key);
53596
53575
  });
53597
- let rules = [];
53598
- _.forEach(calcRules, (v, k) => {
53599
- var _a2;
53600
- let column = _.find(sumCalcCols, (d) => {
53601
- return d.field == k || d.key == k;
53576
+ sumCols.forEach((col) => {
53577
+ if (!(col.field || col.key) in sumData)
53578
+ sumData[col.field || col.key] = 0;
53579
+ });
53580
+ this.rowDataFiltered.forEach((d) => {
53581
+ sumCols.forEach((dd) => {
53582
+ if (typeof dd.isSum === "string")
53583
+ return;
53584
+ let field = dd.field || dd.key;
53585
+ let value = d[field];
53586
+ if (typeof value === "number" && !isNaN(value)) {
53587
+ sumData[field] = (sumData[field] || 0) + value;
53588
+ }
53602
53589
  });
53590
+ });
53591
+ sumFuncCols.forEach((col) => {
53592
+ sumData[col.field || col.key] = col.isSum(this.rowDataFiltered, col);
53593
+ });
53594
+ let sumRows = [sumData];
53595
+ let rules = [];
53596
+ for (let key in sumCalcRuleMap) {
53597
+ let column = sumCalcCols.find((col) => col.field === key || col.key === key);
53603
53598
  rules.push({
53604
- rltKey: k,
53605
- ast: v,
53606
- precision: ((_a2 = column == null ? void 0 : column.cellRendererParams) == null ? void 0 : _a2.scale) || 2,
53599
+ rltKey: key,
53600
+ ast: sumCalcRuleMap[key],
53601
+ precision: ((_a = column == null ? void 0 : column.cellRendererParams) == null ? void 0 : _a.scale) || 2,
53607
53602
  errRtn: 0
53608
53603
  });
53609
- });
53604
+ }
53610
53605
  let options = { calcRules: rules };
53611
53606
  calcDatas(sumRows, options);
53612
53607
  this.topRows = this.pinnedTopRowDataWithUnit ? _.concat(this.pinnedTopRowDataWithUnit, sumRows) : sumRows;