@indfnd/utils 0.0.40 → 0.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.
- package/CHANGELOG.md +20 -0
- package/dist/ind-utils.es.js +72 -10
- package/dist/ind-utils.umd.cjs +14 -14
- package/package.json +1 -1
- package/src/api/item.ts +2 -2
- package/src/utils/table.ts +87 -11
- package/src/utils/validate.ts +2 -2
- package/types/utils/table.d.ts +8 -1
- package/types/utils/table.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
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
|
+
### [0.1.1](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.1.0...v0.1.1) (2024-04-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* package.json脚本修改 ([1e545a2](http://git.inspur.com/imp-ec/ind-front/ind-utils/commit/1e545a2488fc8b914ca19bc00248c07d78b02346))
|
|
11
|
+
* **table:** 支持合计列 ([47505c7](http://git.inspur.com/imp-ec/ind-front/ind-utils/commit/47505c702c743bb89fa4cfb71e2f7545216e2690))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* 车牌号校验修改,支持鲁AD1234 ([9e8fc5b](http://git.inspur.com/imp-ec/ind-front/ind-utils/commit/9e8fc5bb1ca10244b65ebcee4b21a1d157e38adf))
|
|
17
|
+
|
|
18
|
+
## [0.1.0](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.0.40...v0.1.0) (2024-03-18)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **table:** 修改headerTooltip ([949db39](http://git.inspur.com/imp-ec/ind-front/ind-utils/commit/949db3940c4dd297a2b93cb5109428768ed417c2))
|
|
24
|
+
|
|
5
25
|
### [0.0.40](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.0.39...v0.0.40) (2024-03-13)
|
|
6
26
|
|
|
7
27
|
|
package/dist/ind-utils.es.js
CHANGED
|
@@ -10633,6 +10633,7 @@ function renderHeaderTooltip({
|
|
|
10633
10633
|
return text;
|
|
10634
10634
|
}
|
|
10635
10635
|
function renderColumnTree(data, columnGroup, option = {}) {
|
|
10636
|
+
var _b;
|
|
10636
10637
|
const _a = columnGroup, {
|
|
10637
10638
|
key,
|
|
10638
10639
|
keyProp,
|
|
@@ -10660,7 +10661,7 @@ function renderColumnTree(data, columnGroup, option = {}) {
|
|
|
10660
10661
|
]);
|
|
10661
10662
|
const { keyPropName = "key", titlePropName = "title", keyPrefix = "", parents = [] } = option;
|
|
10662
10663
|
if (keyProp) {
|
|
10663
|
-
let columnUniqData = _.uniqBy(data, columnGroup.keyProp) || [];
|
|
10664
|
+
let columnUniqData = ((_b = _.uniqBy(data, columnGroup.keyProp)) == null ? void 0 : _b.filter((item) => !isNil(item[columnGroup.keyProp]))) || [];
|
|
10664
10665
|
if (sortProp) {
|
|
10665
10666
|
const unSortData = columnUniqData.filter((item) => isNil(item[sortProp]));
|
|
10666
10667
|
const sortData = columnUniqData.filter((item) => !isNil(item[sortProp]));
|
|
@@ -10691,7 +10692,13 @@ function renderColumnTree(data, columnGroup, option = {}) {
|
|
|
10691
10692
|
const suffix = keyLastSuffix ? `${GROUP_SEP}${keyLastSuffix}` : "";
|
|
10692
10693
|
return __spreadProps(__spreadValues({}, args), {
|
|
10693
10694
|
[keyPropName]: `${keyPrefix}${keyProp}${VALUE_SEP}${item[keyProp]}${suffix}`,
|
|
10694
|
-
[titlePropName]: columnTitle
|
|
10695
|
+
[titlePropName]: columnTitle,
|
|
10696
|
+
headerTooltip: renderHeaderTooltip({
|
|
10697
|
+
tooltip: headerTooltip,
|
|
10698
|
+
item,
|
|
10699
|
+
parents,
|
|
10700
|
+
title: columnTitle
|
|
10701
|
+
})
|
|
10695
10702
|
});
|
|
10696
10703
|
});
|
|
10697
10704
|
}
|
|
@@ -10746,16 +10753,71 @@ function renderRowData(data, keys) {
|
|
|
10746
10753
|
const value = (_a = data == null ? void 0 : data[0]) == null ? void 0 : _a[key];
|
|
10747
10754
|
return value;
|
|
10748
10755
|
}
|
|
10756
|
+
function getRowKeyValue(item, rowKey) {
|
|
10757
|
+
if (!item)
|
|
10758
|
+
return "";
|
|
10759
|
+
if (isString(rowKey))
|
|
10760
|
+
return item[rowKey] || "";
|
|
10761
|
+
for (const key of rowKey) {
|
|
10762
|
+
if (item[key]) {
|
|
10763
|
+
return item[key];
|
|
10764
|
+
}
|
|
10765
|
+
}
|
|
10766
|
+
return "";
|
|
10767
|
+
}
|
|
10768
|
+
function renderSumColumn(keys, titles, idx, columns, def) {
|
|
10769
|
+
if (idx >= keys.length)
|
|
10770
|
+
return;
|
|
10771
|
+
const key = keys[idx];
|
|
10772
|
+
let header = _.find(columns, { key });
|
|
10773
|
+
if (!header) {
|
|
10774
|
+
header = { key, title: titles[idx], children: [] };
|
|
10775
|
+
columns.push(header);
|
|
10776
|
+
if (idx === keys.length - 1) {
|
|
10777
|
+
Object.assign(header, def, { title: titles[idx] });
|
|
10778
|
+
return;
|
|
10779
|
+
}
|
|
10780
|
+
}
|
|
10781
|
+
renderSumColumn(keys, titles, idx + 1, header.children, def);
|
|
10782
|
+
}
|
|
10783
|
+
function renderSumColumns({ sumColumnDefs }) {
|
|
10784
|
+
const columns = [];
|
|
10785
|
+
for (const def of sumColumnDefs) {
|
|
10786
|
+
const { key, title } = def;
|
|
10787
|
+
const keys = key.split(GROUP_SEP);
|
|
10788
|
+
const titles = title.split(GROUP_SEP);
|
|
10789
|
+
renderSumColumn(keys, titles, 0, columns, def);
|
|
10790
|
+
}
|
|
10791
|
+
return columns;
|
|
10792
|
+
}
|
|
10749
10793
|
function row2column(data = [], columnGroups = [], rowKey, option = {}) {
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
)
|
|
10794
|
+
var _a;
|
|
10795
|
+
const columns = [];
|
|
10796
|
+
if (option.sumColumnDefs && option.sumColumnDefs.length) {
|
|
10797
|
+
columns.push(...renderSumColumns(option));
|
|
10798
|
+
}
|
|
10799
|
+
const groupColumns = _.flatten(columnGroups.map((group) => renderColumnTree(data, group, option))) || [];
|
|
10800
|
+
columns.push(...groupColumns);
|
|
10753
10801
|
const leafColumns = getLeafColumns(columns);
|
|
10754
|
-
const rowKeyUniqData = _.uniqBy(data, rowKey)
|
|
10755
|
-
|
|
10802
|
+
const rowKeyUniqData = ((_a = _.uniqBy(data, (item) => getRowKeyValue(item, rowKey))) == null ? void 0 : _a.filter(
|
|
10803
|
+
(item) => !isNil(getRowKeyValue(item, rowKey))
|
|
10804
|
+
)) || [];
|
|
10805
|
+
const groupData = _.groupBy(data, (item) => getRowKeyValue(item, rowKey));
|
|
10756
10806
|
const rltData = rowKeyUniqData.map((item) => {
|
|
10757
|
-
const
|
|
10807
|
+
const rowKeyValue = getRowKeyValue(item, rowKey);
|
|
10808
|
+
const rowGroupData = groupData[rowKeyValue] || [];
|
|
10758
10809
|
const newItem = __spreadValues({}, item);
|
|
10810
|
+
if (option.sumColumnDefs && option.sumColumnDefs.length) {
|
|
10811
|
+
option.sumColumnDefs.forEach((def) => {
|
|
10812
|
+
const { key } = def;
|
|
10813
|
+
const keys = key.split(GROUP_SEP) || [];
|
|
10814
|
+
const code = (keys == null ? void 0 : keys[0]) || "";
|
|
10815
|
+
const indexCol = (keys == null ? void 0 : keys[keys.length - 1]) || "";
|
|
10816
|
+
const { sumColKeyProp = "sumColCode" } = option;
|
|
10817
|
+
const itemData = _.find(rowGroupData, { [sumColKeyProp]: code }) || {};
|
|
10818
|
+
newItem[key] = itemData[indexCol];
|
|
10819
|
+
});
|
|
10820
|
+
}
|
|
10759
10821
|
leafColumns.forEach((column) => {
|
|
10760
10822
|
const columnKey = column[option.keyPropName || "key"] || "";
|
|
10761
10823
|
const keys = columnKey.split(GROUP_SEP) || [];
|
|
@@ -10935,11 +10997,11 @@ function checkTel(val) {
|
|
|
10935
10997
|
}
|
|
10936
10998
|
}
|
|
10937
10999
|
function checkVehicleNo(str) {
|
|
10938
|
-
const newReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z]-(([DF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))$/;
|
|
11000
|
+
const newReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](-)?(([DF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))$/;
|
|
10939
11001
|
if (newReg.test(str)) {
|
|
10940
11002
|
return true;
|
|
10941
11003
|
}
|
|
10942
|
-
const reg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z]-[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]$/;
|
|
11004
|
+
const reg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](-)?[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]$/;
|
|
10943
11005
|
return reg.test(str);
|
|
10944
11006
|
}
|
|
10945
11007
|
const DICT_KEY = "ind-dict_";
|