@indfnd/utils 0.1.8 → 0.1.10
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 +17 -0
- package/dist/ind-utils.es.js +25 -7
- package/dist/ind-utils.umd.cjs +8 -8
- package/package.json +1 -1
- package/src/utils/cache/permission-cache.ts +1 -1
- package/src/utils/enum.ts +4 -0
- package/src/utils/half-year.ts +19 -4
- package/src/utils/table.ts +3 -3
- package/types/utils/enum.d.ts.map +1 -1
- package/types/utils/half-year.d.ts.map +1 -1
package/package.json
CHANGED
package/src/utils/enum.ts
CHANGED
|
@@ -101,6 +101,10 @@ export function renderColumnEnums(columns = [], enumRelation = {}) {
|
|
|
101
101
|
column.cellRendererParams.datas = enums
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
if (column.children && column.children.length) {
|
|
106
|
+
column.children = renderColumnEnums(column.children, enumRelation)
|
|
107
|
+
}
|
|
104
108
|
})
|
|
105
109
|
return rlt
|
|
106
110
|
}
|
package/src/utils/half-year.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// 获取半年
|
|
2
2
|
export function getHalfYear(date: string) {
|
|
3
|
-
if (!date || date.length <
|
|
3
|
+
if (!date || date.length < 4) {
|
|
4
4
|
return ''
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
const year = date.substring(0, 4)
|
|
8
8
|
const month = date.substring(4, 6)
|
|
9
9
|
const halfYear = getHalfYearNum(parseInt(month))
|
|
10
|
+
if (!month) {
|
|
11
|
+
return `${year}`
|
|
12
|
+
}
|
|
10
13
|
return `${year}H${halfYear}`
|
|
11
14
|
}
|
|
12
15
|
|
|
@@ -20,21 +23,29 @@ export function getHalfYearNum(month: number | string) {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export function formatHalfYear(halfYear: string) {
|
|
23
|
-
if (!halfYear || halfYear.length <
|
|
26
|
+
if (!halfYear || halfYear.length < 4) {
|
|
24
27
|
return halfYear
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
const year = halfYear.substring(0, 4)
|
|
31
|
+
const month = halfYear.substring(4, 6)
|
|
32
|
+
if (!month) {
|
|
33
|
+
return `${year}全年`
|
|
34
|
+
}
|
|
28
35
|
const halfYearNum = parseInt(halfYear.substring(5))
|
|
29
36
|
const halfStr = halfYearNum === 1 ? '上半年' : '下半年'
|
|
30
37
|
return `${year}${halfStr}`
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
export function getHalfYearBeginMonth(halfYear: string) {
|
|
34
|
-
if (!halfYear || halfYear.length <
|
|
41
|
+
if (!halfYear || halfYear.length < 4) {
|
|
35
42
|
return halfYear
|
|
36
43
|
}
|
|
37
44
|
const year = halfYear.substring(0, 4)
|
|
45
|
+
const month = halfYear.substring(4, 6)
|
|
46
|
+
if (!month) {
|
|
47
|
+
return `${year}01`
|
|
48
|
+
}
|
|
38
49
|
const halfYearNum = parseInt(halfYear.substring(5))
|
|
39
50
|
const beginMonth = halfYearNum * 6 - 5
|
|
40
51
|
const monthStr = beginMonth < 10 ? `0${beginMonth}` : `${beginMonth}`
|
|
@@ -42,10 +53,14 @@ export function getHalfYearBeginMonth(halfYear: string) {
|
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
export function getHalfYearEndMonth(halfYear: string) {
|
|
45
|
-
if (!halfYear || halfYear.length <
|
|
56
|
+
if (!halfYear || halfYear.length < 4) {
|
|
46
57
|
return halfYear
|
|
47
58
|
}
|
|
48
59
|
const year = halfYear.substring(0, 4)
|
|
60
|
+
const month = halfYear.substring(4, 6)
|
|
61
|
+
if (!month) {
|
|
62
|
+
return `${year}12`
|
|
63
|
+
}
|
|
49
64
|
const halfYearNum = parseInt(halfYear.substring(5))
|
|
50
65
|
const endMonth = halfYearNum * 2
|
|
51
66
|
const monthStr = endMonth < 10 ? `0${endMonth}` : `${endMonth}`
|
package/src/utils/table.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: huxuetong
|
|
3
3
|
* @Date: 2023-10-27 15:05:25
|
|
4
4
|
* @Last Modified by: huxuetong
|
|
5
|
-
* @Last Modified time: 2024-
|
|
5
|
+
* @Last Modified time: 2024-05-06 10:23:47
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import _, { head } from 'lodash'
|
|
@@ -183,7 +183,7 @@ function renderColumnTree(
|
|
|
183
183
|
// 非动态列 不是最后一层
|
|
184
184
|
if (children && children.length) {
|
|
185
185
|
// 非动态列的下一层一般都是在一行数据上的,所以拼接key时不加__做不同层级的分割,而是和下一层一起作为属性名
|
|
186
|
-
const prefix = `${keyPrefix}${key}`
|
|
186
|
+
const prefix = `${keyPrefix}${key || ''}`
|
|
187
187
|
const columnChildren = children.map((child) => {
|
|
188
188
|
return renderColumnTree(data, child, { ...option, keyPrefix: prefix })
|
|
189
189
|
})
|
|
@@ -197,7 +197,7 @@ function renderColumnTree(
|
|
|
197
197
|
}
|
|
198
198
|
return {
|
|
199
199
|
...args,
|
|
200
|
-
[keyPropName]: `${keyPrefix}${key}`,
|
|
200
|
+
[keyPropName]: `${keyPrefix}${key || ''}`,
|
|
201
201
|
[titlePropName]: title,
|
|
202
202
|
headerTooltip: headerTooltipText,
|
|
203
203
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/utils/enum.ts"],"names":[],"mappings":"AAGA,eAAe;AACf,eAAO,MAAM,kBAAkB,YAAY,CAAA;AAC3C,iBAAiB;AACjB,eAAO,MAAM,cAAc;;;CAAyB,CAAA;AACpD,kBAAkB;AAClB,eAAO,MAAM,mBAAmB;;;GAG/B,CAAA;AAGD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;CAwBnB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,QAAK,EAAE,KAAK,SAAM,EAAE,KAAK,SAAM;;;IAEjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,QAAK,EAAE,KAAK,SAAM,EAAE,KAAK,SAAM,OAEjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,QAAK,EAAE,YAAY,KAAK,
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../../src/utils/enum.ts"],"names":[],"mappings":"AAGA,eAAe;AACf,eAAO,MAAM,kBAAkB,YAAY,CAAA;AAC3C,iBAAiB;AACjB,eAAO,MAAM,cAAc;;;CAAyB,CAAA;AACpD,kBAAkB;AAClB,eAAO,MAAM,mBAAmB;;;GAG/B,CAAA;AAGD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;CAwBnB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,QAAK,EAAE,KAAK,SAAM,EAAE,KAAK,SAAM;;;IAEjE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,QAAK,EAAE,KAAK,SAAM,EAAE,KAAK,SAAM,OAEjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,QAAK,EAAE,YAAY,KAAK,SA6BhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,QAAK,EAAE,YAAY,KAAK,SAgBjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"half-year.d.ts","sourceRoot":"","sources":["../../src/utils/half-year.ts"],"names":[],"mappings":"AACA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"half-year.d.ts","sourceRoot":"","sources":["../../src/utils/half-year.ts"],"names":[],"mappings":"AACA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAYvC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,aAOpD;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,UAa9C;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,UAarD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAanD"}
|