three-trees-ui 1.0.66 → 1.0.67
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/lib/three-trees-ui.common.js +860 -1362
- package/lib/three-trees-ui.css +1 -1
- package/lib/three-trees-ui.umd.js +860 -1362
- package/lib/three-trees-ui.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/Subtable/src/SubExportDialog.vue +1 -90
- package/packages/Subtable/src/SubImportDialog.vue +8 -169
- package/src/directive/formulas.js +1 -1
- package/src/mixins/onlineSubtable.js +0 -301
- package/src/services/SubPagination.js +1 -40
- package/src/utils.js +1 -32
package/package.json
CHANGED
|
@@ -35,16 +35,6 @@
|
|
|
35
35
|
type: String,
|
|
36
36
|
default: '子表数据',
|
|
37
37
|
},
|
|
38
|
-
exportMaxRow: {
|
|
39
|
-
type: [String, Number],
|
|
40
|
-
},
|
|
41
|
-
exportField: {
|
|
42
|
-
// 禁止导出的字段集合
|
|
43
|
-
type: String,
|
|
44
|
-
},
|
|
45
|
-
exportFieldTransformData: {
|
|
46
|
-
type: String,
|
|
47
|
-
},
|
|
48
38
|
},
|
|
49
39
|
computed: {
|
|
50
40
|
columns: function() {
|
|
@@ -57,44 +47,6 @@
|
|
|
57
47
|
}
|
|
58
48
|
},
|
|
59
49
|
methods: {
|
|
60
|
-
async sqlChange(config, value = '') {
|
|
61
|
-
return new Promise((resolve) => {
|
|
62
|
-
let params = {
|
|
63
|
-
dsName: config.dataSource,
|
|
64
|
-
sql: config.relevancyValue
|
|
65
|
-
? config.relevancyValue.replace(/{val}/g, value)
|
|
66
|
-
: '',
|
|
67
|
-
}
|
|
68
|
-
this.$requestConfig.getValueBySql(params).then((res) => {
|
|
69
|
-
resolve(res)
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
},
|
|
73
|
-
transformFieldData(data) {
|
|
74
|
-
return new Promise(async (resolve) => {
|
|
75
|
-
let fieldTransformData = JSON.parse(
|
|
76
|
-
decode(this.exportFieldTransformData)
|
|
77
|
-
)
|
|
78
|
-
for (let i = 0; i < data.length; i++) {
|
|
79
|
-
for (let j = 0; j < fieldTransformData.length; j++) {
|
|
80
|
-
if (fieldTransformData[j].relevancyType == 'value') {
|
|
81
|
-
data[i][fieldTransformData[j].field] =
|
|
82
|
-
fieldTransformData[j].relevancyValue
|
|
83
|
-
} else {
|
|
84
|
-
// 动态时 请求接口修改数据
|
|
85
|
-
let result = await this.sqlChange(
|
|
86
|
-
fieldTransformData[j],
|
|
87
|
-
data[i][fieldTransformData[j].field]
|
|
88
|
-
)
|
|
89
|
-
if (result) {
|
|
90
|
-
data[i][fieldTransformData[j].field] = result
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
resolve(data)
|
|
96
|
-
})
|
|
97
|
-
},
|
|
98
50
|
// 配置的数据字典 导出时翻译为汉字
|
|
99
51
|
changeDictionary(data) {
|
|
100
52
|
return new Promise(async (resolve, reject) => {
|
|
@@ -124,18 +76,10 @@
|
|
|
124
76
|
},
|
|
125
77
|
changeRowKey(rows) {
|
|
126
78
|
var exportData = []
|
|
127
|
-
let exportFieldArr = null
|
|
128
|
-
if (this.exportField) {
|
|
129
|
-
exportFieldArr = this.exportField.split(',')
|
|
130
|
-
}
|
|
131
79
|
rows.forEach((row) => {
|
|
132
80
|
var exportRow = {}
|
|
133
81
|
this.columns.forEach((col) => {
|
|
134
|
-
if (
|
|
135
|
-
col.ctrlType != 'suntable' &&
|
|
136
|
-
(!exportFieldArr ||
|
|
137
|
-
(exportFieldArr && !exportFieldArr.includes(col.name)))
|
|
138
|
-
) {
|
|
82
|
+
if (col.ctrlType != 'suntable') {
|
|
139
83
|
exportRow[col.desc] = row[col.name]
|
|
140
84
|
}
|
|
141
85
|
})
|
|
@@ -143,25 +87,6 @@
|
|
|
143
87
|
})
|
|
144
88
|
return exportData
|
|
145
89
|
},
|
|
146
|
-
getConfirmValue(rows, count) {
|
|
147
|
-
return new Promise((resolve) => {
|
|
148
|
-
this.$confirm(
|
|
149
|
-
`导出数据量超出导出限制【${count}】,将导出${count}条,是否继续?`,
|
|
150
|
-
'提示',
|
|
151
|
-
{
|
|
152
|
-
confirmButtonText: '确定',
|
|
153
|
-
cancelButtonText: '取消',
|
|
154
|
-
type: 'warning',
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
.then(() => {
|
|
158
|
-
resolve(rows.slice(0, count))
|
|
159
|
-
})
|
|
160
|
-
.catch(() => {
|
|
161
|
-
resolve(false)
|
|
162
|
-
})
|
|
163
|
-
})
|
|
164
|
-
},
|
|
165
90
|
handleCommand(type) {
|
|
166
91
|
const pInst = utils.getOnlineFormInstance(this)
|
|
167
92
|
SubPagination.exportData(
|
|
@@ -172,20 +97,6 @@
|
|
|
172
97
|
)
|
|
173
98
|
.then(async (data) => {
|
|
174
99
|
data = JSON.parse(JSON.stringify(data))
|
|
175
|
-
if (this.exportMaxRow && Number(this.exportMaxRow) < data.length) {
|
|
176
|
-
let result = await this.getConfirmValue(
|
|
177
|
-
data,
|
|
178
|
-
Number(this.exportMaxRow)
|
|
179
|
-
)
|
|
180
|
-
if (result === false) {
|
|
181
|
-
return
|
|
182
|
-
}
|
|
183
|
-
data = result
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (this.exportFieldTransformData) {
|
|
187
|
-
data = await this.transformFieldData(data)
|
|
188
|
-
}
|
|
189
100
|
// 导出时 字典转换
|
|
190
101
|
await this.changeDictionary(data)
|
|
191
102
|
let exportData = this.changeRowKey(data)
|
|
@@ -102,45 +102,6 @@
|
|
|
102
102
|
type: String,
|
|
103
103
|
required: true,
|
|
104
104
|
},
|
|
105
|
-
importMaxRow: {
|
|
106
|
-
type: [String, Number],
|
|
107
|
-
default: null,
|
|
108
|
-
},
|
|
109
|
-
templateType: {
|
|
110
|
-
// 导入模板类型 default 系统默认 custom 自定义
|
|
111
|
-
type: String,
|
|
112
|
-
default: 'default',
|
|
113
|
-
},
|
|
114
|
-
customTemplate: {
|
|
115
|
-
// 自定义的导入模板文件
|
|
116
|
-
type: String,
|
|
117
|
-
default: '',
|
|
118
|
-
},
|
|
119
|
-
importTransform: {
|
|
120
|
-
// 是否有转换字段
|
|
121
|
-
type: String,
|
|
122
|
-
default: '0',
|
|
123
|
-
},
|
|
124
|
-
importModes: {
|
|
125
|
-
// 导入模式选项显示
|
|
126
|
-
type: String,
|
|
127
|
-
default: 'append,override,merge',
|
|
128
|
-
},
|
|
129
|
-
fieldTransformData: {
|
|
130
|
-
// 转换字段配置
|
|
131
|
-
type: String,
|
|
132
|
-
default: '',
|
|
133
|
-
},
|
|
134
|
-
conditionRule: {
|
|
135
|
-
// 条件模式配置
|
|
136
|
-
type: String,
|
|
137
|
-
default: '',
|
|
138
|
-
},
|
|
139
|
-
conditionType: {
|
|
140
|
-
// 条件模式配置
|
|
141
|
-
type: String,
|
|
142
|
-
default: 'cover',
|
|
143
|
-
},
|
|
144
105
|
},
|
|
145
106
|
data() {
|
|
146
107
|
return {
|
|
@@ -149,6 +110,11 @@
|
|
|
149
110
|
showRowData: false,
|
|
150
111
|
mergeFunc: null,
|
|
151
112
|
mode: 'append',
|
|
113
|
+
modeOptions: [
|
|
114
|
+
{ mode: 'append', desc: '追加导入' },
|
|
115
|
+
{ mode: 'override', desc: '覆盖导入' },
|
|
116
|
+
{ mode: 'merge', desc: '合并导入', disabled: true },
|
|
117
|
+
],
|
|
152
118
|
cacheDicData: {}, // 缓存字典数据
|
|
153
119
|
}
|
|
154
120
|
},
|
|
@@ -156,30 +122,6 @@
|
|
|
156
122
|
columns: function() {
|
|
157
123
|
return eval(decode(this.dataColumns))
|
|
158
124
|
},
|
|
159
|
-
modeOptions() {
|
|
160
|
-
let options = [
|
|
161
|
-
{ mode: 'append', desc: '追加导入' },
|
|
162
|
-
{ mode: 'override', desc: '覆盖导入' },
|
|
163
|
-
{ mode: 'merge', desc: '合并导入' },
|
|
164
|
-
{ mode: 'condition', desc: '条件导入' },
|
|
165
|
-
]
|
|
166
|
-
return options.filter((k) => {
|
|
167
|
-
return this.importModes.includes(k.mode)
|
|
168
|
-
})
|
|
169
|
-
},
|
|
170
|
-
conditionConfig() {
|
|
171
|
-
let config = {}
|
|
172
|
-
if (this.conditionRule) {
|
|
173
|
-
config = JSON.parse(decode(this.conditionRule))
|
|
174
|
-
config.conditionArr.forEach((k) => {
|
|
175
|
-
k.exportField = this.getNameByDesc(k.exportField)
|
|
176
|
-
})
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
conditionType: this.conditionType,
|
|
180
|
-
...config,
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
125
|
},
|
|
184
126
|
watch: {
|
|
185
127
|
dialogVisible: {
|
|
@@ -197,7 +139,7 @@
|
|
|
197
139
|
handler: function(newVal) {
|
|
198
140
|
if (newVal) {
|
|
199
141
|
// 如果有导入合并的代码,则允许选择合并导入模式
|
|
200
|
-
|
|
142
|
+
this.$set(this.modeOptions[2], 'disabled', false)
|
|
201
143
|
// 并设置默认为 合并导入
|
|
202
144
|
this.mode = 'merge'
|
|
203
145
|
// 解码合并的代码
|
|
@@ -214,9 +156,6 @@
|
|
|
214
156
|
}
|
|
215
157
|
},
|
|
216
158
|
mounted() {
|
|
217
|
-
if (this.importModes) {
|
|
218
|
-
this.mode = this.importModes.split(',')[0]
|
|
219
|
-
}
|
|
220
159
|
// 初始化导入时需要的参数
|
|
221
160
|
const pInst = utils.getOnlineFormInstance(this)
|
|
222
161
|
let formUid = pInst && pInst._uid ? pInst._uid : ''
|
|
@@ -235,46 +174,6 @@
|
|
|
235
174
|
SubPagination.clear(this.dataSubname, this)
|
|
236
175
|
},
|
|
237
176
|
methods: {
|
|
238
|
-
transformFieldData(data) {
|
|
239
|
-
return new Promise(async (resolve) => {
|
|
240
|
-
if (this.importTransform === '0') {
|
|
241
|
-
resolve(data)
|
|
242
|
-
return
|
|
243
|
-
}
|
|
244
|
-
let fieldTransformData = JSON.parse(decode(this.fieldTransformData))
|
|
245
|
-
for (let i = 0; i < data.length; i++) {
|
|
246
|
-
for (let j = 0; j < fieldTransformData.length; j++) {
|
|
247
|
-
if (fieldTransformData[j].relevancyType == 'value') {
|
|
248
|
-
data[i][fieldTransformData[j].field] =
|
|
249
|
-
fieldTransformData[j].relevancyValue
|
|
250
|
-
} else {
|
|
251
|
-
// 动态时 请求接口修改数据
|
|
252
|
-
let result = await this.sqlChange(
|
|
253
|
-
fieldTransformData[j],
|
|
254
|
-
data[i][fieldTransformData[j].field]
|
|
255
|
-
)
|
|
256
|
-
if (result) {
|
|
257
|
-
data[i][fieldTransformData[j].field] = result
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
resolve(data)
|
|
263
|
-
})
|
|
264
|
-
},
|
|
265
|
-
async sqlChange(config, value = '') {
|
|
266
|
-
return new Promise((resolve) => {
|
|
267
|
-
let params = {
|
|
268
|
-
dsName: config.dataSource,
|
|
269
|
-
sql: config.relevancyValue
|
|
270
|
-
? config.relevancyValue.replace(/{val}/g, value)
|
|
271
|
-
: '',
|
|
272
|
-
}
|
|
273
|
-
this.$requestConfig.getValueBySql(params).then((res) => {
|
|
274
|
-
resolve(res)
|
|
275
|
-
})
|
|
276
|
-
})
|
|
277
|
-
},
|
|
278
177
|
changeDictionary(data) {
|
|
279
178
|
return new Promise(async (resolve) => {
|
|
280
179
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -315,28 +214,6 @@
|
|
|
315
214
|
},
|
|
316
215
|
//子表模板导出
|
|
317
216
|
exportFormSub() {
|
|
318
|
-
// 如果是自定义模板
|
|
319
|
-
if (this.templateType == 'custom' && this.customTemplate) {
|
|
320
|
-
let file = JSON.parse(decode(this.customTemplate))[0]
|
|
321
|
-
this.$requestConfig
|
|
322
|
-
.download(file.response.fileId)
|
|
323
|
-
.then(({ data, headers }) => {
|
|
324
|
-
if (data && headers) {
|
|
325
|
-
// 附件下载
|
|
326
|
-
const fileName = decodeURIComponent(
|
|
327
|
-
headers['content-disposition']
|
|
328
|
-
.split(';')[1]
|
|
329
|
-
.split('filename=')[1]
|
|
330
|
-
)
|
|
331
|
-
const blob = new Blob([data])
|
|
332
|
-
saveAs(blob, fileName)
|
|
333
|
-
}
|
|
334
|
-
})
|
|
335
|
-
.catch((err) => {
|
|
336
|
-
this.$message.error(`附件下载失败:${err}`)
|
|
337
|
-
})
|
|
338
|
-
return
|
|
339
|
-
}
|
|
340
217
|
let columns = this.columns.filter((item) => {
|
|
341
218
|
return !(
|
|
342
219
|
item.ctrlType &&
|
|
@@ -386,7 +263,6 @@
|
|
|
386
263
|
let count = this.importRows.length
|
|
387
264
|
if (count > maxRowInt && maxRowInt != 0) {
|
|
388
265
|
this.$message.error('子表数据已超过最大行数【' + maxRowInt + '】')
|
|
389
|
-
this.$refs.selectFile.value = ''
|
|
390
266
|
return
|
|
391
267
|
}
|
|
392
268
|
} else if (this.mode == 'append') {
|
|
@@ -415,21 +291,17 @@
|
|
|
415
291
|
}
|
|
416
292
|
}
|
|
417
293
|
let importRows = await this.changeDictionary(this.importRows)
|
|
418
|
-
// 导入如果有数据转换的此处做转换
|
|
419
|
-
importRows = await this.transformFieldData(importRows)
|
|
420
294
|
SubPagination.importData(
|
|
421
295
|
this.dataSubname,
|
|
422
296
|
importRows,
|
|
423
297
|
this.mode,
|
|
424
|
-
this.mergeFunc
|
|
425
|
-
this.conditionConfig
|
|
298
|
+
this.mergeFunc
|
|
426
299
|
)
|
|
427
300
|
.then(() => {
|
|
428
301
|
this.$message.success('导入成功!')
|
|
429
302
|
this.dialogVisible = false
|
|
430
303
|
})
|
|
431
304
|
.catch((err) => {
|
|
432
|
-
this.$refs.selectFile.value = ''
|
|
433
305
|
this.$message.error(`数据导入失败:${err}`)
|
|
434
306
|
})
|
|
435
307
|
},
|
|
@@ -438,43 +310,10 @@
|
|
|
438
310
|
return
|
|
439
311
|
}
|
|
440
312
|
this.importRows = []
|
|
441
|
-
this.readWorkbookFromLocalFile(m.target.files[0],
|
|
442
|
-
if (this.importMaxRow) {
|
|
443
|
-
let count = rows.length
|
|
444
|
-
if (count > parseInt(this.importMaxRow)) {
|
|
445
|
-
let result = await this.getConfirmValue(
|
|
446
|
-
rows,
|
|
447
|
-
parseInt(this.importMaxRow)
|
|
448
|
-
)
|
|
449
|
-
if (result === false) {
|
|
450
|
-
this.$refs.selectFile.value = ''
|
|
451
|
-
return
|
|
452
|
-
}
|
|
453
|
-
rows = result
|
|
454
|
-
}
|
|
455
|
-
}
|
|
313
|
+
this.readWorkbookFromLocalFile(m.target.files[0], (rows) => {
|
|
456
314
|
this.importRows = this.changeRowKey(rows)
|
|
457
315
|
})
|
|
458
316
|
},
|
|
459
|
-
getConfirmValue(rows, count) {
|
|
460
|
-
return new Promise((resolve) => {
|
|
461
|
-
this.$confirm(
|
|
462
|
-
`导入数据量已超过最大限制,将默认导入前【${count}】条,是否继续?`,
|
|
463
|
-
'提示',
|
|
464
|
-
{
|
|
465
|
-
confirmButtonText: '确定',
|
|
466
|
-
cancelButtonText: '取消',
|
|
467
|
-
type: 'warning',
|
|
468
|
-
}
|
|
469
|
-
)
|
|
470
|
-
.then(() => {
|
|
471
|
-
resolve(rows.slice(0, count))
|
|
472
|
-
})
|
|
473
|
-
.catch(() => {
|
|
474
|
-
resolve(false)
|
|
475
|
-
})
|
|
476
|
-
})
|
|
477
|
-
},
|
|
478
317
|
// 读取本地excel文件
|
|
479
318
|
readWorkbookFromLocalFile(file, callback) {
|
|
480
319
|
const reader = new FileReader()
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import SubPagination from '../services/SubPagination.js'
|
|
2
|
-
import utils from '../utils.js'
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
data() {
|
|
6
5
|
return {
|
|
7
|
-
searchVal: '', //搜索关键字
|
|
8
6
|
fillOrg: {},
|
|
9
7
|
fillOrgConfMap: {},
|
|
10
8
|
transitionIndex: -1,
|
|
@@ -54,305 +52,6 @@ export default {
|
|
|
54
52
|
}
|
|
55
53
|
},
|
|
56
54
|
methods: {
|
|
57
|
-
//合计计算
|
|
58
|
-
getSummaries(param, list) {
|
|
59
|
-
let CancelTheCalculation = sessionStorage.getItem(
|
|
60
|
-
'Cancel_The_Calculation'
|
|
61
|
-
)
|
|
62
|
-
? JSON.parse(sessionStorage.getItem('Cancel_The_Calculation'))
|
|
63
|
-
: {}
|
|
64
|
-
//
|
|
65
|
-
let listChange = JSON.parse(Base64.decode(list, 'utf-8'))
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
if (listChange.length < 1) {
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
const { columns, data } = param
|
|
73
|
-
this.tableData = data
|
|
74
|
-
const sums = []
|
|
75
|
-
let calcProp = []
|
|
76
|
-
let columnsDep = _.cloneDeep(columns)
|
|
77
|
-
listChange.forEach((item, idex) => {
|
|
78
|
-
if (item.addFunc == 'calcFunc') {
|
|
79
|
-
columnsDep.forEach((column, index) => {
|
|
80
|
-
if (
|
|
81
|
-
item.mathExp &&
|
|
82
|
-
item.mathExp.indexOf('.' + column.property) > -1
|
|
83
|
-
) {
|
|
84
|
-
calcProp.push(column.property)
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
columnsDep.forEach((column, index) => {
|
|
90
|
-
if (item.columnField == column.property) {
|
|
91
|
-
column.combinedOption = item
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
columnsDep.forEach((column, index) => {
|
|
97
|
-
if (index === 0 && columnsDep[0].type == 'index') {
|
|
98
|
-
sums[index] = ''
|
|
99
|
-
return
|
|
100
|
-
}
|
|
101
|
-
//当有需要才合计
|
|
102
|
-
if (column.combinedOption) {
|
|
103
|
-
let {
|
|
104
|
-
addFunc,
|
|
105
|
-
columnField,
|
|
106
|
-
name,
|
|
107
|
-
unit,
|
|
108
|
-
showType,
|
|
109
|
-
num,
|
|
110
|
-
tag,
|
|
111
|
-
mainTarget,
|
|
112
|
-
} = column.combinedOption
|
|
113
|
-
|
|
114
|
-
let Bol =
|
|
115
|
-
tag &&
|
|
116
|
-
CancelTheCalculation &&
|
|
117
|
-
CancelTheCalculation[tag] &&
|
|
118
|
-
CancelTheCalculation[tag].length > 0
|
|
119
|
-
const values = data.map((item) => Number(item[column.property]))
|
|
120
|
-
let depValues = _.cloneDeep(values)
|
|
121
|
-
if (Bol) {
|
|
122
|
-
let delMin = []
|
|
123
|
-
depValues.forEach((item, i) => {
|
|
124
|
-
if (!CancelTheCalculation[tag].includes(i)) {
|
|
125
|
-
delMin.push(item)
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
depValues = delMin
|
|
130
|
-
}
|
|
131
|
-
let units = unit ? unit : ''
|
|
132
|
-
//求和
|
|
133
|
-
if (addFunc === 'add') {
|
|
134
|
-
if (!depValues.every((value) => isNaN(value))) {
|
|
135
|
-
sums[index] = depValues.reduce((prev, curr) => {
|
|
136
|
-
const value = Number(curr)
|
|
137
|
-
if (!isNaN(value)) {
|
|
138
|
-
return prev + curr
|
|
139
|
-
} else {
|
|
140
|
-
return prev
|
|
141
|
-
}
|
|
142
|
-
}, 0)
|
|
143
|
-
|
|
144
|
-
sums[index] = this.dealWithDataHtml(
|
|
145
|
-
name,
|
|
146
|
-
sums[index],
|
|
147
|
-
showType,
|
|
148
|
-
num,
|
|
149
|
-
units,
|
|
150
|
-
mainTarget
|
|
151
|
-
)
|
|
152
|
-
} else {
|
|
153
|
-
sums[index] = this.dealWithDataHtml(
|
|
154
|
-
name,
|
|
155
|
-
0,
|
|
156
|
-
showType,
|
|
157
|
-
num,
|
|
158
|
-
units,
|
|
159
|
-
mainTarget
|
|
160
|
-
)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
//计数
|
|
164
|
-
if (addFunc === 'count') {
|
|
165
|
-
let numCount = values.length
|
|
166
|
-
|
|
167
|
-
if (Bol) {
|
|
168
|
-
numCount = values.length - CancelTheCalculation[tag].length
|
|
169
|
-
}
|
|
170
|
-
sums[index] = this.dealWithDataHtml(
|
|
171
|
-
name,
|
|
172
|
-
numCount,
|
|
173
|
-
showType,
|
|
174
|
-
num,
|
|
175
|
-
units,
|
|
176
|
-
mainTarget
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
//平均值
|
|
180
|
-
if (addFunc === 'average') {
|
|
181
|
-
let sum = 0
|
|
182
|
-
var average = 0
|
|
183
|
-
|
|
184
|
-
for (var i = 0; i < depValues.length; i++) {
|
|
185
|
-
sum += depValues[i]
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
depValues.length > 0
|
|
189
|
-
? (average = sum / depValues.length)
|
|
190
|
-
: (average = 0)
|
|
191
|
-
|
|
192
|
-
sums[index] = this.dealWithDataHtml(
|
|
193
|
-
name,
|
|
194
|
-
average,
|
|
195
|
-
showType,
|
|
196
|
-
num,
|
|
197
|
-
units,
|
|
198
|
-
mainTarget
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
//最大值
|
|
202
|
-
if (addFunc === 'max') {
|
|
203
|
-
let maxNum = Math.max.apply(
|
|
204
|
-
null,
|
|
205
|
-
depValues.length > 0 ? depValues : [0]
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
sums[index] = this.dealWithDataHtml(
|
|
209
|
-
name,
|
|
210
|
-
maxNum,
|
|
211
|
-
showType,
|
|
212
|
-
num,
|
|
213
|
-
units,
|
|
214
|
-
mainTarget
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
//最小值
|
|
218
|
-
if (addFunc === 'min') {
|
|
219
|
-
let minNum = Math.min.apply(
|
|
220
|
-
null,
|
|
221
|
-
depValues.length > 0 ? depValues : [0]
|
|
222
|
-
)
|
|
223
|
-
sums[index] = this.dealWithDataHtml(
|
|
224
|
-
name,
|
|
225
|
-
minNum,
|
|
226
|
-
showType,
|
|
227
|
-
num,
|
|
228
|
-
units,
|
|
229
|
-
mainTarget
|
|
230
|
-
)
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
//公式计算
|
|
234
|
-
if (addFunc === 'calcFunc') {
|
|
235
|
-
const calcVal = this.dealCustomCalc(data, column.combinedOption)
|
|
236
|
-
sums[index] = this.dealWithDataHtml(
|
|
237
|
-
name,
|
|
238
|
-
calcVal,
|
|
239
|
-
showType,
|
|
240
|
-
num,
|
|
241
|
-
units,
|
|
242
|
-
mainTarget
|
|
243
|
-
)
|
|
244
|
-
}
|
|
245
|
-
} else if (calcProp.indexOf(column.property) > -1) {
|
|
246
|
-
const values = data.map((item) => Number(item[column.property]))
|
|
247
|
-
}
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
return sums
|
|
251
|
-
},
|
|
252
|
-
//合计行
|
|
253
|
-
handleSummary(summary) {
|
|
254
|
-
return summary && !this.searchVal ? true : false
|
|
255
|
-
},
|
|
256
|
-
dealCustomCalc(data, calc) {
|
|
257
|
-
let exp = calc.mathExp
|
|
258
|
-
if (!exp) return null
|
|
259
|
-
var reg = /([\[|\{]).*?\((.*?)\)[\}|\]]/g
|
|
260
|
-
exp = exp.replace(reg, function() {
|
|
261
|
-
var symbol = arguments[1],
|
|
262
|
-
name = arguments[2]
|
|
263
|
-
const prop = name.split('.')[1]
|
|
264
|
-
const values = data.map((item) => Number(item[prop]))
|
|
265
|
-
return values.join(',')
|
|
266
|
-
})
|
|
267
|
-
exp = exp.replace(/[|\[|\]]/g, '')
|
|
268
|
-
exp = eval(`(${exp})`)
|
|
269
|
-
if (exp === Infinity || isNaN(exp)) {
|
|
270
|
-
exp = null
|
|
271
|
-
}
|
|
272
|
-
return exp
|
|
273
|
-
},
|
|
274
|
-
dealWithDataHtml(name, type, showType, num, units, mainTarget) {
|
|
275
|
-
let { data, monCap } = this.dealWithData(type, showType, num, mainTarget)
|
|
276
|
-
if (monCap) {
|
|
277
|
-
return name + ':' + data + units + '\n' + monCap
|
|
278
|
-
}
|
|
279
|
-
return name + ':' + data + units
|
|
280
|
-
},
|
|
281
|
-
//处理数据
|
|
282
|
-
dealWithData(data, showType, numfix = 0, mainTarget) {
|
|
283
|
-
data = Number(data)
|
|
284
|
-
|
|
285
|
-
let list = showType
|
|
286
|
-
let num = {
|
|
287
|
-
data: 0,
|
|
288
|
-
monCap: '',
|
|
289
|
-
}
|
|
290
|
-
// 保留小数位
|
|
291
|
-
if (list.includes('keepSmall')) {
|
|
292
|
-
const fixData = data.toFixedRound(numfix)
|
|
293
|
-
num.data = fixData
|
|
294
|
-
if (mainTarget) {
|
|
295
|
-
mainTarget = !mainTarget.startsWith('data.')
|
|
296
|
-
? 'data.' + mainTarget
|
|
297
|
-
: mainTarget
|
|
298
|
-
utils.setValueByConfigKey(this, { trget: mainTarget }, 'trget', data)
|
|
299
|
-
}
|
|
300
|
-
} else {
|
|
301
|
-
if (mainTarget && data != null) {
|
|
302
|
-
mainTarget = !mainTarget.startsWith('data.')
|
|
303
|
-
? 'data.' + mainTarget
|
|
304
|
-
: mainTarget
|
|
305
|
-
utils.setValueByConfigKey(
|
|
306
|
-
this,
|
|
307
|
-
{ trget: mainTarget },
|
|
308
|
-
'trget',
|
|
309
|
-
data.toFixedRound(4)
|
|
310
|
-
)
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
//百分比
|
|
315
|
-
if (list.includes('percentage')) {
|
|
316
|
-
num.data = Number(data * 100) + '%'
|
|
317
|
-
}
|
|
318
|
-
// 千分位
|
|
319
|
-
if (list.includes('Micrometer')) {
|
|
320
|
-
num.data = utils.thousandBit(data)
|
|
321
|
-
}
|
|
322
|
-
if (
|
|
323
|
-
list.includes('keepSmall') &&
|
|
324
|
-
list.includes('percentage') &&
|
|
325
|
-
list.includes('Micrometer')
|
|
326
|
-
) {
|
|
327
|
-
num.data =
|
|
328
|
-
utils.thousandBit(Number(data * 100).toFixedRound(numfix)) + '%'
|
|
329
|
-
|
|
330
|
-
return num
|
|
331
|
-
}
|
|
332
|
-
if (list.includes('keepSmall') && list.includes('percentage')) {
|
|
333
|
-
num.data = Number(data * 100).toFixedRound(numfix) + '%'
|
|
334
|
-
|
|
335
|
-
return num
|
|
336
|
-
}
|
|
337
|
-
if (list.includes('Micrometer') && list.includes('percentage')) {
|
|
338
|
-
num.data = utils.thousandBit(Number(data * 100)) + '%'
|
|
339
|
-
return num
|
|
340
|
-
}
|
|
341
|
-
if (list.includes('keepSmall') && list.includes('Micrometer')) {
|
|
342
|
-
num.data = utils.thousandBit(data.toFixedRound(numfix))
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// 货币大写
|
|
346
|
-
if (list.includes('monCap')) {
|
|
347
|
-
num = {
|
|
348
|
-
data: data,
|
|
349
|
-
monCap: utils.convertCurrency(data),
|
|
350
|
-
}
|
|
351
|
-
return num
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return num
|
|
355
|
-
},
|
|
356
55
|
getExpandArr(data, type) {
|
|
357
56
|
if (type === 'expand' && data) {
|
|
358
57
|
let arr = []
|