@nstc-business/imes 1.0.26 → 1.0.28
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/README.md +87 -87
- package/package.json +71 -71
- package/src/components/calculateDetail/dialog.vue +38 -38
- package/src/components/calculateDetail/index.vue +1888 -1888
- package/src/components/common.js +109 -109
- package/src/components/measureCalc/EvaOfCreditConditionsRewrite.vue +624 -637
- package/src/components/measureCalc/MeasureEvalFlatTable.vue +438 -432
- package/src/components/measureCalc/MeasureGroupBlocks.vue +208 -208
- package/src/components/measureCalc/MeasureQualAnalysis.vue +415 -415
- package/src/components/measureCalc/MeasureStatCell.vue +181 -183
- package/src/components/measureCalc/MeasureStatFlatTable.vue +258 -254
- package/src/components/measureCalc/MeasureStatModelTable.vue +196 -193
- package/src/components/measureCalc/MeasureStatPanel.vue +45 -45
- package/src/components/measureCalc/MeasureSubModelPanel.vue +83 -83
- package/src/components/measureCalc/MeasureTreeTable.vue +817 -797
- package/src/components/measureCalc/api.js +18 -18
- package/src/components/measureCalc/helpers.js +507 -489
- package/src/components/measureCalc/index.vue +1676 -1671
- package/src/components/measureCalc/statModelHelper.js +585 -533
- package/src/components/measureCalc/ui/index.js +10 -10
- package/src/components/model-calculate/index.vue +153 -153
- package/src/components/model-calculate/input-number.vue +294 -294
- package/src/components/model-calculate/modelCalcTest.vue +1242 -1242
- package/src/components/model-calculate/tree.vue +132 -132
- package/src/index.js +28 -28
package/src/components/common.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import {N} from 'n20-common-lib'
|
|
2
|
-
/**
|
|
3
|
-
* 设置表格合并行的公共方法
|
|
4
|
-
* @param {any[]} list 表格数据
|
|
5
|
-
* @param {any[]} columns 表头
|
|
6
|
-
* @param {String[]} merges 要合并的列字段名组成的数组
|
|
7
|
-
* @param {String[]} condition 判断条件的字段名组成的数组
|
|
8
|
-
* @param {String} field 表头取值的字段名
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export function setMergeCells({
|
|
14
|
-
list = [],
|
|
15
|
-
columns = [],
|
|
16
|
-
merges = [],
|
|
17
|
-
condition = [],
|
|
18
|
-
field = 'field'
|
|
19
|
-
}) {
|
|
20
|
-
const validMap = new Map() // 有效合并配置项
|
|
21
|
-
for (let i = 0; i < list.length; i++) {
|
|
22
|
-
// 根据判断条件取出当前行对应的表格数据,生成唯一标识
|
|
23
|
-
const hashKey = condition
|
|
24
|
-
.map(key => {
|
|
25
|
-
let rowStr = ''
|
|
26
|
-
if (
|
|
27
|
-
Object.prototype.toString.call(list[i][key]) === '[object Object]'
|
|
28
|
-
) {
|
|
29
|
-
rowStr = list[i][key].code
|
|
30
|
-
} else {
|
|
31
|
-
rowStr = list[i][key]
|
|
32
|
-
}
|
|
33
|
-
return rowStr
|
|
34
|
-
})
|
|
35
|
-
.join('&&')
|
|
36
|
-
|
|
37
|
-
let flag = true
|
|
38
|
-
let count = 1
|
|
39
|
-
// 从当前索引i开始,往后找,数据相同的话,count自增,否则跳出while循环
|
|
40
|
-
while (flag && i + count < list.length) {
|
|
41
|
-
// 根据判断条件取出下一行的表格数据,生成唯一标识
|
|
42
|
-
const nextRow = condition
|
|
43
|
-
.map(key => {
|
|
44
|
-
let rowStr = ''
|
|
45
|
-
if (
|
|
46
|
-
Object.prototype.toString.call(list[i + count][key]) ===
|
|
47
|
-
'[object Object]'
|
|
48
|
-
) {
|
|
49
|
-
rowStr = list[i + count][key].code
|
|
50
|
-
} else {
|
|
51
|
-
rowStr = list[i + count][key]
|
|
52
|
-
}
|
|
53
|
-
return rowStr
|
|
54
|
-
})
|
|
55
|
-
.join('&&')
|
|
56
|
-
if (hashKey === nextRow) {
|
|
57
|
-
// 数据相同,count自增
|
|
58
|
-
count++
|
|
59
|
-
} else {
|
|
60
|
-
// 数据不同,跳出while循环
|
|
61
|
-
flag = false
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// 将有效的合并配置项存入validMap
|
|
65
|
-
count > 1 && validMap.set(hashKey + '_' + i, { row: i, rowspan: count })
|
|
66
|
-
// i 跳过已合并的行,减 1 是因为 i++
|
|
67
|
-
i += count - 1
|
|
68
|
-
// 重置 while 循环标识
|
|
69
|
-
flag = true
|
|
70
|
-
}
|
|
71
|
-
// 合并记录转换
|
|
72
|
-
const recordsList = [...validMap.values()]
|
|
73
|
-
if (recordsList.length == 0) {
|
|
74
|
-
return []
|
|
75
|
-
}
|
|
76
|
-
// 预处理列索引
|
|
77
|
-
|
|
78
|
-
const cols = merges.reduce((acc, mergeField) => {
|
|
79
|
-
const idx = columns.findIndex(item => item[field] === mergeField)
|
|
80
|
-
idx !== -1 && acc.push(idx)
|
|
81
|
-
return acc
|
|
82
|
-
}, [])
|
|
83
|
-
|
|
84
|
-
// 遍历列索引,生成合并单元格配置集合
|
|
85
|
-
const mergeCells = recordsList.flatMap(({ row, rowspan }) =>
|
|
86
|
-
cols.map(col => ({ row, col, rowspan, colspan: 1 }))
|
|
87
|
-
)
|
|
88
|
-
return mergeCells
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const formatFloat2 = (num, digit3 = 2) => {
|
|
92
|
-
return parseFloat(N.subFixed(num, digit3))
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function toFixedTrunc(num, decimals) {
|
|
96
|
-
if (isNaN(num) || num === undefined || num === null) return num
|
|
97
|
-
|
|
98
|
-
let numStr =
|
|
99
|
-
typeof num !== 'string'
|
|
100
|
-
? N.toString(num).replace(/,/g, '')
|
|
101
|
-
: num.replace(/,/g, '')
|
|
102
|
-
const [integerPart, decimalPart = ''] = numStr.split('.')
|
|
103
|
-
const trimmedDecimal = decimalPart.slice(0, decimals)
|
|
104
|
-
const paddedDecimal = trimmedDecimal.padEnd(decimals, '0')
|
|
105
|
-
return decimals === 0 ? integerPart : `${integerPart}.${paddedDecimal}`
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function addThousands(data) {
|
|
109
|
-
return N.addThousands(data)
|
|
1
|
+
import {N} from 'n20-common-lib'
|
|
2
|
+
/**
|
|
3
|
+
* 设置表格合并行的公共方法
|
|
4
|
+
* @param {any[]} list 表格数据
|
|
5
|
+
* @param {any[]} columns 表头
|
|
6
|
+
* @param {String[]} merges 要合并的列字段名组成的数组
|
|
7
|
+
* @param {String[]} condition 判断条件的字段名组成的数组
|
|
8
|
+
* @param {String} field 表头取值的字段名
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export function setMergeCells({
|
|
14
|
+
list = [],
|
|
15
|
+
columns = [],
|
|
16
|
+
merges = [],
|
|
17
|
+
condition = [],
|
|
18
|
+
field = 'field'
|
|
19
|
+
}) {
|
|
20
|
+
const validMap = new Map() // 有效合并配置项
|
|
21
|
+
for (let i = 0; i < list.length; i++) {
|
|
22
|
+
// 根据判断条件取出当前行对应的表格数据,生成唯一标识
|
|
23
|
+
const hashKey = condition
|
|
24
|
+
.map(key => {
|
|
25
|
+
let rowStr = ''
|
|
26
|
+
if (
|
|
27
|
+
Object.prototype.toString.call(list[i][key]) === '[object Object]'
|
|
28
|
+
) {
|
|
29
|
+
rowStr = list[i][key].code
|
|
30
|
+
} else {
|
|
31
|
+
rowStr = list[i][key]
|
|
32
|
+
}
|
|
33
|
+
return rowStr
|
|
34
|
+
})
|
|
35
|
+
.join('&&')
|
|
36
|
+
|
|
37
|
+
let flag = true
|
|
38
|
+
let count = 1
|
|
39
|
+
// 从当前索引i开始,往后找,数据相同的话,count自增,否则跳出while循环
|
|
40
|
+
while (flag && i + count < list.length) {
|
|
41
|
+
// 根据判断条件取出下一行的表格数据,生成唯一标识
|
|
42
|
+
const nextRow = condition
|
|
43
|
+
.map(key => {
|
|
44
|
+
let rowStr = ''
|
|
45
|
+
if (
|
|
46
|
+
Object.prototype.toString.call(list[i + count][key]) ===
|
|
47
|
+
'[object Object]'
|
|
48
|
+
) {
|
|
49
|
+
rowStr = list[i + count][key].code
|
|
50
|
+
} else {
|
|
51
|
+
rowStr = list[i + count][key]
|
|
52
|
+
}
|
|
53
|
+
return rowStr
|
|
54
|
+
})
|
|
55
|
+
.join('&&')
|
|
56
|
+
if (hashKey === nextRow) {
|
|
57
|
+
// 数据相同,count自增
|
|
58
|
+
count++
|
|
59
|
+
} else {
|
|
60
|
+
// 数据不同,跳出while循环
|
|
61
|
+
flag = false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// 将有效的合并配置项存入validMap
|
|
65
|
+
count > 1 && validMap.set(hashKey + '_' + i, { row: i, rowspan: count })
|
|
66
|
+
// i 跳过已合并的行,减 1 是因为 i++
|
|
67
|
+
i += count - 1
|
|
68
|
+
// 重置 while 循环标识
|
|
69
|
+
flag = true
|
|
70
|
+
}
|
|
71
|
+
// 合并记录转换
|
|
72
|
+
const recordsList = [...validMap.values()]
|
|
73
|
+
if (recordsList.length == 0) {
|
|
74
|
+
return []
|
|
75
|
+
}
|
|
76
|
+
// 预处理列索引
|
|
77
|
+
|
|
78
|
+
const cols = merges.reduce((acc, mergeField) => {
|
|
79
|
+
const idx = columns.findIndex(item => item[field] === mergeField)
|
|
80
|
+
idx !== -1 && acc.push(idx)
|
|
81
|
+
return acc
|
|
82
|
+
}, [])
|
|
83
|
+
|
|
84
|
+
// 遍历列索引,生成合并单元格配置集合
|
|
85
|
+
const mergeCells = recordsList.flatMap(({ row, rowspan }) =>
|
|
86
|
+
cols.map(col => ({ row, col, rowspan, colspan: 1 }))
|
|
87
|
+
)
|
|
88
|
+
return mergeCells
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const formatFloat2 = (num, digit3 = 2) => {
|
|
92
|
+
return parseFloat(N.subFixed(num, digit3))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function toFixedTrunc(num, decimals) {
|
|
96
|
+
if (isNaN(num) || num === undefined || num === null) return num
|
|
97
|
+
|
|
98
|
+
let numStr =
|
|
99
|
+
typeof num !== 'string'
|
|
100
|
+
? N.toString(num).replace(/,/g, '')
|
|
101
|
+
: num.replace(/,/g, '')
|
|
102
|
+
const [integerPart, decimalPart = ''] = numStr.split('.')
|
|
103
|
+
const trimmedDecimal = decimalPart.slice(0, decimals)
|
|
104
|
+
const paddedDecimal = trimmedDecimal.padEnd(decimals, '0')
|
|
105
|
+
return decimals === 0 ? integerPart : `${integerPart}.${paddedDecimal}`
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function addThousands(data) {
|
|
109
|
+
return N.addThousands(data)
|
|
110
110
|
}
|