@indfnd/utils 0.1.0 → 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 +13 -0
- package/dist/ind-utils.es.js +65 -9
- package/dist/ind-utils.umd.cjs +14 -14
- package/package.json +2 -2
- package/src/utils/table.ts +81 -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,19 @@
|
|
|
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
|
+
|
|
5
18
|
## [0.1.0](http://git.inspur.com/imp-ec/ind-front/ind-utils/compare/v0.0.40...v0.1.0) (2024-03-18)
|
|
6
19
|
|
|
7
20
|
|
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]));
|
|
@@ -10752,16 +10753,71 @@ function renderRowData(data, keys) {
|
|
|
10752
10753
|
const value = (_a = data == null ? void 0 : data[0]) == null ? void 0 : _a[key];
|
|
10753
10754
|
return value;
|
|
10754
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
|
+
}
|
|
10755
10793
|
function row2column(data = [], columnGroups = [], rowKey, option = {}) {
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
)
|
|
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);
|
|
10759
10801
|
const leafColumns = getLeafColumns(columns);
|
|
10760
|
-
const rowKeyUniqData = _.uniqBy(data, rowKey)
|
|
10761
|
-
|
|
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));
|
|
10762
10806
|
const rltData = rowKeyUniqData.map((item) => {
|
|
10763
|
-
const
|
|
10807
|
+
const rowKeyValue = getRowKeyValue(item, rowKey);
|
|
10808
|
+
const rowGroupData = groupData[rowKeyValue] || [];
|
|
10764
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
|
+
}
|
|
10765
10821
|
leafColumns.forEach((column) => {
|
|
10766
10822
|
const columnKey = column[option.keyPropName || "key"] || "";
|
|
10767
10823
|
const keys = columnKey.split(GROUP_SEP) || [];
|
|
@@ -10941,11 +10997,11 @@ function checkTel(val) {
|
|
|
10941
10997
|
}
|
|
10942
10998
|
}
|
|
10943
10999
|
function checkVehicleNo(str) {
|
|
10944
|
-
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]))$/;
|
|
10945
11001
|
if (newReg.test(str)) {
|
|
10946
11002
|
return true;
|
|
10947
11003
|
}
|
|
10948
|
-
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挂学警港澳]$/;
|
|
10949
11005
|
return reg.test(str);
|
|
10950
11006
|
}
|
|
10951
11007
|
const DICT_KEY = "ind-dict_";
|