dealMixin.js
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
export default {
methods: {
createHeadColumn (headColumnData = []) {
let headColumn = []
if (headColumnData.length) {
let i = 0, temp = {}
headColumnData.forEach((item, index) => {
let matched = item.split('_')
if (matched.length > 1) {
if (temp[matched[1]]) {
temp[matched[1]].push({
prop: `defaultOrg${index++}`,
label: matched[0]
})
} else {
temp[matched[1]] = [{
prop: `defaultOrg${index++}`,
label: matched[0]
}]
}
}
})
headColumn = Object.keys(temp).map((key) => {
return {
label: key + '/' + this.$t('format.seconds'),
children: temp[key]
}
})
headColumn.unshift({
prop: `defaultOrg${i++}`,
label: headColumnData[0]
})
}
return headColumn
},
buildTableContent(headData, data) {
let result = [], temp = {}
if (headData.length) {
data.forEach((item, index) => {
temp = {}
item.data.forEach((dataItem, dataIndex) => {
temp[`defaultOrg${dataIndex}`] = (
(typeof(dataItem) === 'number'
|| typeof(dataItem) === 'string')
&& dataItem !== 'null'
) ? dataItem : '--'
})
result.push(temp)
})
}
return result
},
// add total column
addTotalColumn(data) {
data.reduce((arr, item) => {
//
})
}
}
}