@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indfnd/utils",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "author": "huxuetong",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,6 +1,6 @@
1
1
  import { getSessionStorage, setSessionStorage, removeSessionStorage } from '@/utils/storage'
2
2
 
3
- const PERMISSION_KEY = 'ibp-permission'
3
+ const PERMISSION_KEY = 'ibp-sc-permission'
4
4
 
5
5
  export function getPermissionCache() {
6
6
  return getSessionStorage(PERMISSION_KEY)
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
  }
@@ -1,12 +1,15 @@
1
1
  // 获取半年
2
2
  export function getHalfYear(date: string) {
3
- if (!date || date.length < 6) {
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 < 6) {
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 < 6) {
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 < 6) {
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}`
@@ -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-03-27 18:18:47
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,SAyBhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,QAAK,EAAE,YAAY,KAAK,SAgBjE"}
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,UASvC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,aAOpD;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,UAS9C;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,UASrD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UASnD"}
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"}