customly.vue
3.91 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
<div class="customly">
<div class="asis-table-wrapper heatmap-wrapper single-report-wrapper">
<div class="heatmap-content download-parent">
<!-- 时间热力图 -->
<mix-charts chartId="customHeatmap" class="custom-heatmap-chart" :chartData="customHeatmap_ops" chartType="Heatmap" />
<span class="download-text" @click="exportDataHandle(
$t('asisTab.' + asisLevel) + '-' +
$t('asis.TimeHeat') + '-' + Time(),
'TimeThermodynamic'
)">{{$t('allPages.load')}}</span>
</div>
</div>
<export-data-dialog ref="exportDialog"></export-data-dialog>
</div>
</template>
<script>
import exportData from '../../public/exportData'
import publicChart from '../common/publicChart'
export default {
props: {
propparam: Object
},
data() {
return {
customHeatmap_ops: {},
chartKeyToId: {},
chartIds: '',
emitData: [],
startTime: '',
endTime: '',
asisLevel: 'mall'
}
},
components: {
'heatmap-chart': publicChart,
'export-data-dialog': exportData,
},
watch: {
propparam: {
handler: 'refreshHandle',
immediate: true
}
},
mounted() {
},
methods: {
refreshHandle(param) {
if (param.dateType !== '/timeheat/customly') return;
this.emitData = param.data;
if (this.chartIds && JSON.stringify(this.chartKeyToId) !== '{}') {
this.getChartData(this.chartIds);
} else {
this.getChartId();
}
},
getChartId() {
this.chartKeyToId = {};
this.chartIds = '';
this.$api.baseReport.reportChart({
report: 'TimeThermodynamic',
// _t: Date.parse(new Date()) / 1000
})
.then(res => {
let chartItem = res.data.data;
chartItem.forEach((item, index) => {
this.chartKeyToId[item.key] = item.id;
if (item.key === 'TimeThermodynamic') {
if (index == chartItem.length - 1) {
this.chartIds += item.id;
} else {
this.chartIds += item.id + ','
}
}
});
this.getChartData(this.chartIds);
})
},
getChartData(chartIds) {
if (!this.chartIds) return;
this.customHeatmap_ops = {};
let apiUrl = '', param = {};
if (this.emitData.asis_time == '' || this.emitData.asis_time == undefined) {
this.startTime = this.dayReduce(new Date(), 30)
this.endTime = dateUnit.dateFormat(new Date(), 'yyyy-MM-dd');
} else {
this.startTime = this.emitData.asis_time[0];
this.endTime = this.emitData.asis_time[1];
}
param = {
orgIds: this.emitData.asis_org,
chartIds: chartIds,
startDate: this.startTime,
endDate: this.endTime,
};
let {params,asisLevel} = this.dealFormat(param,this.emitData);
this.asisLevel = asisLevel
this.$api.analysisReport.thermodynamicAnalysis(asisLevel, params)
.then(res => {
this.customHeatmap_ops = res.data.data.body.TimeThermodynamic;
})
.catch(err => {
this.catchErrorHandle(err)
})
},
exportDataHandle(title, chartKey) {
let chartId = this.chartIds;
let exportNeed = {
domId: 'customHeatmap',
title: title,
data: {
url: `/report/thermodynamic/${this.emitData.asis_level}/${chartId}/excel`,
params: `orgIds=${this.emitData.asis_org}&chartIds=${chartId}&startDate=${this.startTime}&endDate=${this.endTime}`
}
}
this.$refs.exportDialog.dialogInit(exportNeed);
},
}
}
</script>
<style scoped>
/* #weekHeatmap, */
.custom-heatmap-chart {
height: 722px;
}
.download-text {
right: 0;
top: 5px;
}
@media only screen and (max-width: 1366px) {
.custom-heatmap-chart {
height: 500px;
}
}
@media only screen and (max-width: 1280px) {
.custom-heatmap-chart {
height: 500px;
}
}
</style>