execCntIndex.vue
9.61 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<route lang="yaml">
name: execCntIndex
</route>
<script lang="ts" setup name="execCntIndex">
import { changeNum } from '@/utils/common'
import {
getContractStatis,
getContractMonthStatis,
getLogTableList
} from "@/api/modules/dataSmartContract";
import * as echarts from 'echarts';
import { commonPageConfig } from '@/utils/enum';
const { proxy } = getCurrentInstance() as any;
const detailInfo: any = ref({});
const logTableInfo: any = ref({
id: "plan-detail-table",
loading: false,
// height: 'auto',
// minPanelHeight: '60px',
// minHeight: '60px',
// maxHeight: '250px',
fields: [
{ label: "序号", type: "index", width: 56, align: "center", fixed: true },
{ label: "合约标识", field: "contractId", width: 355 },
{ label: "合约名称", field: "contractName", width: 140 },
{ label: "执行策略id", field: "strategyId", width: 260 },
{ label: "执行时间", field: "operationTime", width: 170 },
{ label: "执行节点标识", field: "executionEntityId", width: 180 },
{ label: "上报时间", field: "operationTime", width: 170 },
{ label: "异常类型", field: "executionResult", width: 120 },
],
data: [],
page: {
type: "normal",
rows: 0,
...commonPageConfig,
},
actionInfo: {
show: false
}
});
const pageChange = (info) => {
logTableInfo.value.page.curr = Number(info.curr);
logTableInfo.value.page.limit = Number(info.limit);
getLogTableListData(true);
};
const getLogTableListData = (isPage = false) => {
isPage && (logTableInfo.value.loading = true);
return getLogTableList({
pageIndex: logTableInfo.value.page.curr,
pageSize: logTableInfo.value.page.limit,
}).then((res: any) => {
logTableInfo.value.loading = false;
if (res?.code == proxy.$passCode) {
const data = res.data || {};
logTableInfo.value.data = data.records || []
logTableInfo.value.page.limit = data.pageSize
logTableInfo.value.page.curr = data.pageIndex
logTableInfo.value.page.rows = data.totalRows
} else {
res?.msg && proxy.$ElMessage.error(res?.msg)
}
})
}
let barChart: any = null;
const barChartData: any = ref([]);
onMounted(() => {
barChart = echarts.init(document.getElementById('bar'));
setBarChartOption(barChart);
})
watch(() => barChartData.value, (val) => {
setBarChartOption(barChart);
}, {
deep: true
})
/** 设置柱形图option,默认只 展示12次的 */
const setBarChartOption = (barChart) => {
return new Promise((resolve, reject) => {
if (!barChartData.value || !Object.keys(barChartData.value).length) {
let option1 = {
title: [
{
text: "",
left: "30px",
top: "30px",
},
{
text: "暂无数据",
left: "center",
top: "center",
textStyle: {
fontFamily: 'SimSun',
fontStyle: "normal",
fontWeight: "400",
fontSize: 18,
color: '#999'
},
},
],
};
barChart.setOption(option1, true);
window.addEventListener("resize", () => {
barChart.resize();
});
return;
}
let getLast12Months = () => {
const months: any = [];
const currentDate = new Date();
for (let i = 11; i >= 0; i--) {
const targetDate = new Date(currentDate);
targetDate.setMonth(targetDate.getMonth() - i);
const year = targetDate.getFullYear();
const month = String(targetDate.getMonth() + 1).padStart(2, '0');
months.push(`${year}-${month}`);
}
return months;
}
// 使用示例
const last12Months = getLast12Months();
let itemXAxisData: any = last12Months;
let itemYAxisData: any = last12Months.map(v => {
return barChartData.value[v] || 0;
});
let option = {
textStyle: {
fontFamily: 'SimSun'
},
color: ['#5B8FF9', '#FF4E00', '#867EEC', '#FDBC3E', '#F48A64', '#276FF5', '#46D0B5'],
title: {
show: false,
left: '30px',
top: '30px',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
},
textStyle: {
align: 'left'
},
},
legend: {
show: false,
right: 0,
textStyle: {
fontSize: 14
},
},
grid: {
left: 30,
right: 60,
bottom: 5,
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
nameTextStyle: {
color: '#000000'
},
axisLabel: {
interval: 'auto',
textStyle: {
color: '#000000'
},
},
axisTick: {
show: false,
},
axisLine: {
lineStyle: {
color: '#d9d9d9'
}
},
data: itemXAxisData
},
yAxis: {
type: 'value',
name: '',
min: 0,
minInterval: 1,
nameTextStyle: {
color: '#000000'
},
axisLabel: {
textStyle: {
color: '#000000'
}
},
axisLine: {
//y轴
show: false
}
},
series: [{
name: '已签署合约数',
type: 'line',
data: itemYAxisData,
label: {
show: false,
},
tooltip: {
valueFormatter: function (value) {
return changeNum(value, 0);
}
},
yAxisIndex: 0
}]
};
option && barChart.setOption(option, true);
barChart.on('finished', () => {
resolve(true);
});
window.addEventListener('resize', () => {
barChart.resize();
});
});
}
const fullscreenloading = ref(false);
onBeforeMount(() => {
fullscreenloading.value = true;
let ps1 = getContractStatis().then((res: any) => {
if (res?.code == proxy.$passCode) {
detailInfo.value = res.data || {};
} else {
res?.msg && proxy.$ElMessage.error(res?.msg)
}
})
let ps2 = getContractMonthStatis().then((res: any) => {
if (res?.code == proxy.$passCode) {
barChartData.value = res.data || {};
} else {
res?.msg && proxy.$ElMessage.error(res?.msg)
}
})
let ps3 = getLogTableListData();
Promise.all([ps1, ps2, ps3]).then(() => {
fullscreenloading.value = false;
}).catch(() => {
fullscreenloading.value = false;
})
})
</script>
<template>
<div class="content-main" v-loading="fullscreenloading">
<div class="title">合约备案执行统计</div>
<div class="kpi-content">
<div class="border-content">
<span class="text">备案合约数</span>
<span class="number num-color">{{ detailInfo.registerNum != null ? changeNum(detailInfo.registerNum ?? 0) : '--'
}}<span class="unit" v-show="detailInfo.registerNum != null"> 个</span></span>
</div>
<div class="border-content ml16">
<span class="text">备案策略数</span>
<span class="number num-color">{{ detailInfo.registerPolicyNum != null ? changeNum(detailInfo.registerPolicyNum
?? 0) : '--'
}}<span class="unit" v-show="detailInfo.registerPolicyNum != null"> 个</span></span>
</div>
<div class="border-content ml16">
<span class="text">策略执行数</span>
<span class="number num-color">{{ detailInfo.registerPolicyExecutionNum != null ?
(changeNum(detailInfo.registerPolicyExecutionNum ?? 0)) :
'--'
}}<span class="unit" v-show="detailInfo.registerPolicyExecutionNum != null"> 个</span></span>
</div>
<div class="border-content ml16">
<span class="text">签署合约主体数</span>
<span class="number num-color">{{ detailInfo.registerSignatureNum != null ?
changeNum(detailInfo.registerSignatureNum ?? 0) : '--'
}}<span class="unit" v-show="detailInfo.registerSignatureNum != null"> 个</span></span>
</div>
<div class="border-content ml16">
<span class="text">策略执行节点数</span>
<span class="number num-color">{{ detailInfo.registerExecutionNodeNum != null ?
changeNum(detailInfo.registerExecutionNodeNum ?? 0) : '--'
}}<span class="unit" v-show="detailInfo.registerExecutionNodeNum != null"> 个</span></span>
</div>
</div>
<div class="title">合约履行异常预警记录</div>
<Table class="table-h" :tableInfo="logTableInfo" @tablePageChange="pageChange" />
<div class="title">近12个月备案合约趋势</div>
<div class="content-chart-bar" id="bar">
</div>
</div>
</template>
<style lang="scss" scoped>
.content-main {
height: 100%;
overflow-y: auto;
overflow-x: hidden;
padding: 0px 16px 16px;
}
.title {
line-height: 24px;
font-size: 16px;
color: #212121;
font-weight: 600;
margin-top: 12px;
margin-bottom: 8px;
}
.kpi-content {
display: flex;
flex-direction: row;
}
.border-content {
height: 76px;
display: flex;
flex-direction: column;
align-items: flex-start;
padding-left: 16px;
justify-content: center;
border: 1px solid #d9d9d9;
//width: 160px;
flex: 1;
min-width: 150px;
border-radius: 2px;
.number {
line-height: 30px;
font-weight: 700;
font-size: 20px;
.unit {
font-size: 18px;
font-weight: 400;
}
}
.num-color {
color: #212121;
}
.text {
font-size: 14px;
color: #666666;
display: flex;
.el-icon {
color: #b2b2b2;
}
}
}
.ml16 {
margin-left: 16px;
}
.content-chart-bar {
height: 300px;
border: 1px solid #d9d9d9;
padding: 8px;
}
.table-h {
height: 300px !important;
}
</style>