three-trees-ui 1.0.71 → 1.0.72
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 +17716 -16437
- package/lib/three-trees-ui.css +1 -1
- package/lib/three-trees-ui.umd.js +17716 -16437
- package/lib/three-trees-ui.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/CustomDialog/src/customDialog.vue +74 -12
- package/packages/DataLists/src/main.vue +2 -3
- package/packages/QuerySqlPreview/src/QuerySqlPreview.vue +43 -1
- package/packages/Subtable/src/SubExportDialog.vue +92 -1
- package/packages/Subtable/src/SubImportDialog.vue +171 -8
- package/packages/TableSearchField/src/main.vue +5 -0
- package/packages/TemplatePreview/src/TemplatePreview.vue +43 -0
- package/src/directive/formulas.js +1 -1
- package/src/mixins/onlineSubtable.js +301 -0
- package/src/mixins/querySqlPreview.js +354 -32
- package/src/mixins/templatePreview.js +525 -42
- package/src/services/SubPagination.js +40 -1
- package/src/utils.js +32 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import SubPagination from '../services/SubPagination.js'
|
|
2
|
+
import utils from '../utils.js'
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
data() {
|
|
5
6
|
return {
|
|
7
|
+
searchVal: '', //搜索关键字
|
|
6
8
|
fillOrg: {},
|
|
7
9
|
fillOrgConfMap: {},
|
|
8
10
|
transitionIndex: -1,
|
|
@@ -52,6 +54,305 @@ export default {
|
|
|
52
54
|
}
|
|
53
55
|
},
|
|
54
56
|
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
|
+
},
|
|
55
356
|
getExpandArr(data, type) {
|
|
56
357
|
if (type === 'expand' && data) {
|
|
57
358
|
let arr = []
|