three-trees-ui 1.0.66 → 1.0.68
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 +861 -1363
- package/lib/three-trees-ui.css +1 -1
- package/lib/three-trees-ui.umd.js +861 -1363
- 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 +9 -168
- package/src/directive/formulas.js +1 -1
- package/src/mixins/onlineSubtable.js +0 -301
- package/src/services/SubPagination.js +3 -43
- package/src/utils.js +1 -32
|
@@ -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 = []
|
|
@@ -12,8 +12,8 @@ const SubPagination = {
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
// 销毁path对象的数据
|
|
15
|
-
clear: (path) => {
|
|
16
|
-
const pInst = utils.getOnlineFormInstance(
|
|
15
|
+
clear: (path, _that) => {
|
|
16
|
+
const pInst = utils.getOnlineFormInstance(_that)
|
|
17
17
|
let formUid = pInst && pInst._uid ? pInst._uid : ''
|
|
18
18
|
SubPagination._map.delete(path + formUid)
|
|
19
19
|
SubPagination._map.delete(SubPagination._vueComponentKey(path))
|
|
@@ -29,9 +29,8 @@ const SubPagination = {
|
|
|
29
29
|
return `${path}:VueComponent`
|
|
30
30
|
},
|
|
31
31
|
// 导入数据
|
|
32
|
-
importData: (path, importRows, mode, mergeMethod,
|
|
32
|
+
importData: (path, importRows, mode, mergeMethod, pInst) => {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
34
|
-
const pInst = utils.getOnlineFormInstance(this)
|
|
35
34
|
let formUid = pInst && pInst._uid ? pInst._uid : ''
|
|
36
35
|
if (SubPagination._map.has(path + formUid)) {
|
|
37
36
|
const instKey = SubPagination._vueComponentKey(path)
|
|
@@ -62,45 +61,6 @@ const SubPagination = {
|
|
|
62
61
|
utils.setValueByPath(inst, path, newRows)
|
|
63
62
|
break
|
|
64
63
|
}
|
|
65
|
-
case 'condition': {
|
|
66
|
-
importRows.forEach((item) => {
|
|
67
|
-
let index = array.findIndex((sub) => {
|
|
68
|
-
let orArr = conditionConfig.conditionArr.filter((condition) => {
|
|
69
|
-
return condition.relation == 'or'
|
|
70
|
-
})
|
|
71
|
-
let andArr = conditionConfig.conditionArr.filter(
|
|
72
|
-
(condition) => {
|
|
73
|
-
return condition.relation == 'and'
|
|
74
|
-
}
|
|
75
|
-
)
|
|
76
|
-
let orFlag = true
|
|
77
|
-
let andFlag = true
|
|
78
|
-
if (orArr.length) {
|
|
79
|
-
orFlag = orArr.some((j) => {
|
|
80
|
-
return sub[j.subField] == item[j.exportField]
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
if (andArr.length) {
|
|
84
|
-
andFlag = andArr.every((j) => {
|
|
85
|
-
return sub[j.subField] == item[j.exportField]
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
return orFlag && andFlag
|
|
89
|
-
})
|
|
90
|
-
if (index != -1) {
|
|
91
|
-
let updateArr = conditionConfig.backField.split(',')
|
|
92
|
-
updateArr.forEach((field) => {
|
|
93
|
-
array[index][field] = item[field]
|
|
94
|
-
})
|
|
95
|
-
} else {
|
|
96
|
-
// 未匹配到时是否新增
|
|
97
|
-
if (conditionConfig.conditionType == 'add') {
|
|
98
|
-
array.push(item)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
utils.setValueByPath(inst, path, array)
|
|
103
|
-
}
|
|
104
64
|
}
|
|
105
65
|
obj.rows = utils.getValueByPath(inst, path)
|
|
106
66
|
SubPagination._digest(obj.rows)
|
package/src/utils.js
CHANGED
|
@@ -955,7 +955,7 @@ var utils = {
|
|
|
955
955
|
}
|
|
956
956
|
const keyPath = config[key]
|
|
957
957
|
// 获取当前组件所在的表单
|
|
958
|
-
const formInst = utils.getOnlineFormInstance(inst)
|
|
958
|
+
const formInst = utils.getOnlineFormInstance(inst.$parent)
|
|
959
959
|
// 获取当前组件是否在子表中的某一行
|
|
960
960
|
const { subScopeEl, index, subname } = utils.getSubScopeElAndIndex(inst.$el)
|
|
961
961
|
if (subScopeEl) {
|
|
@@ -1256,35 +1256,4 @@ Date.prototype.format = function(format) {
|
|
|
1256
1256
|
return format
|
|
1257
1257
|
}
|
|
1258
1258
|
|
|
1259
|
-
//精确四舍五入
|
|
1260
|
-
Number.prototype.toFixedRound = function(d) {
|
|
1261
|
-
d = Number(d)
|
|
1262
|
-
var s = this + ''
|
|
1263
|
-
if (!d) d = 0
|
|
1264
|
-
if (s.indexOf('.') == -1) s += '.'
|
|
1265
|
-
s += new Array(d + 1).join('0')
|
|
1266
|
-
if (new RegExp('^(-|\\+)?(\\d+(\\.\\d{0,' + (d + 1) + '})?)\\d*$').test(s)) {
|
|
1267
|
-
var s = '0' + RegExp.$2,
|
|
1268
|
-
pm = RegExp.$1,
|
|
1269
|
-
a = RegExp.$3.length,
|
|
1270
|
-
b = true
|
|
1271
|
-
if (a == d + 2) {
|
|
1272
|
-
a = s.match(/\d/g)
|
|
1273
|
-
if (parseInt(a[a.length - 1]) > 4) {
|
|
1274
|
-
for (var i = a.length - 2; i >= 0; i--) {
|
|
1275
|
-
a[i] = parseInt(a[i]) + 1
|
|
1276
|
-
if (a[i] == 10) {
|
|
1277
|
-
a[i] = 0
|
|
1278
|
-
b = i != 1
|
|
1279
|
-
} else break
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
s = a.join('').replace(new RegExp('(\\d+)(\\d{' + d + '})\\d$'), '$1.$2')
|
|
1283
|
-
}
|
|
1284
|
-
if (b) s = s.substr(1)
|
|
1285
|
-
return (pm + s).replace(/\.$/, '')
|
|
1286
|
-
}
|
|
1287
|
-
return this + ''
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
1259
|
export default utils
|