Files

262 lines
6.6 KiB
Vue
Raw Normal View History

2021-11-22 09:17:41 +08:00
<template>
<div>
2021-12-08 22:19:46 +08:00
<container3 title="装药量概况">
2022-02-16 11:17:07 +08:00
<el-date-picker
slot="datePicker"
v-model="dateRange"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
<div style="height: 100%; width: 100%" ref="chart"></div>
2021-12-08 22:19:46 +08:00
</container3>
2021-11-22 09:17:41 +08:00
</div>
</template>
<script>
2022-02-16 11:17:07 +08:00
import scalseBox from "../components/scaleBox.vue";
2021-11-22 09:17:41 +08:00
import bigScreenHead from "../components/bigScreenHead/index.vue";
import rocketTit from "../components/rocketTit/index.vue";
2021-12-08 22:19:46 +08:00
import container3 from "./components/container3/index.vue";
2021-11-22 09:17:41 +08:00
2022-02-16 11:17:07 +08:00
import echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import resize from "../../dashboard/mixins/resize";
2021-11-22 09:17:41 +08:00
export default {
mixins: [resize],
2022-02-16 11:17:07 +08:00
name: "right2",
2021-11-22 09:17:41 +08:00
components: {
scalseBox,
bigScreenHead,
rocketTit,
2021-12-08 22:19:46 +08:00
container3,
2021-11-22 09:17:41 +08:00
},
2022-02-16 11:17:07 +08:00
data() {
2021-11-22 09:17:41 +08:00
return {
2021-11-23 08:38:22 +08:00
dateRange: [],
2021-11-22 09:17:41 +08:00
chart: null,
2022-02-16 11:17:07 +08:00
};
2021-11-22 09:17:41 +08:00
},
2022-02-16 11:17:07 +08:00
mounted() {
2021-11-22 09:17:41 +08:00
this.$nextTick(() => {
2022-02-16 11:17:07 +08:00
this.initChart();
});
2021-11-22 09:17:41 +08:00
},
2022-02-16 11:17:07 +08:00
beforeDestroy() {
2021-11-22 09:17:41 +08:00
if (!this.chart) {
2022-02-16 11:17:07 +08:00
return;
2021-11-22 09:17:41 +08:00
}
2022-02-16 11:17:07 +08:00
this.chart.dispose();
this.chart = null;
2021-11-22 09:17:41 +08:00
},
methods: {
2022-02-16 11:17:07 +08:00
initChart() {
2021-12-09 10:28:26 +08:00
this.chart = echarts.init(this.$refs.chart);
2021-12-16 15:47:55 +08:00
this.request({
2022-02-16 11:17:07 +08:00
url: "/hx/cockpitOverview/chargeQuantityList",
method: "get",
}).then((res) => {
2021-12-16 15:47:55 +08:00
console.log(res);
let titData = [];
let actualQuantity = [];
let forecastQuantity = [];
let targetCompletionRate = [];
for (let i = 0; i < res.data.length; i++) {
const item = res.data[i];
titData.push(item.month);
actualQuantity.push(item.actualQuantity);
forecastQuantity.push(item.forecastQuantity);
targetCompletionRate.push(item.targetCompletionRate);
}
this.chart.setOption({
legend: {
2022-02-16 11:17:07 +08:00
data: ["实际", "预测", "目标完成率"],
2021-12-16 15:47:55 +08:00
textStyle: {
2022-02-16 11:17:07 +08:00
color: "#fff",
2021-12-16 15:47:55 +08:00
},
},
2022-02-16 11:17:07 +08:00
tooltip: {
trigger: "axis",
},
2021-12-16 15:47:55 +08:00
grid: {
2022-02-16 11:17:07 +08:00
left: "3%",
right: "6%",
bottom: "3%",
containLabel: true,
2021-12-16 15:47:55 +08:00
},
xAxis: [
{
2022-02-16 11:17:07 +08:00
type: "category",
2021-12-16 15:47:55 +08:00
data: titData,
// data: [
// '2021-01',
// '2021-02',
// '2021-03',
// '2021-04',
// '2021-05',
// '2021-06',
// '2021-07',
// '2021-08',
// '2021-09',
// '2021-10',
// '2021-11',
// '2021-12',
// ],
axisPointer: {
2022-02-16 11:17:07 +08:00
type: "shadow",
2021-12-16 15:47:55 +08:00
},
axisLine: {
lineStyle: {
2022-02-16 11:17:07 +08:00
color: "rgb(255, 255, 255)",
2021-12-16 15:47:55 +08:00
},
2022-02-16 11:17:07 +08:00
},
},
2021-12-16 15:47:55 +08:00
],
yAxis: [
{
2022-02-16 11:17:07 +08:00
type: "value",
name: "万元",
2021-12-16 15:47:55 +08:00
min: 0,
axisLabel: {
2022-02-16 11:17:07 +08:00
formatter: "{value}",
2021-12-16 15:47:55 +08:00
},
splitLine: {
2022-02-16 11:17:07 +08:00
show: false, //不显示网格线
2021-12-16 15:47:55 +08:00
},
splitArea: {
2022-02-16 11:17:07 +08:00
show: false, //不显示网格区域
2021-12-16 15:47:55 +08:00
},
axisLine: {
lineStyle: {
2022-02-16 11:17:07 +08:00
color: "rgb(255, 255, 255)",
2021-12-16 15:47:55 +08:00
},
2022-02-16 11:17:07 +08:00
},
2021-12-16 15:47:55 +08:00
},
{
2022-02-16 11:17:07 +08:00
type: "value",
2021-12-16 15:47:55 +08:00
interval: 20,
axisLabel: {
2022-02-16 11:17:07 +08:00
formatter: "{value} %",
2021-12-16 15:47:55 +08:00
},
splitLine: {
2022-02-16 11:17:07 +08:00
show: false, //不显示网格线
2021-12-16 15:47:55 +08:00
},
splitArea: {
2022-02-16 11:17:07 +08:00
show: false, //不显示网格区域
2021-12-16 15:47:55 +08:00
},
axisLine: {
lineStyle: {
2022-02-16 11:17:07 +08:00
color: "rgb(255, 255, 255)",
2021-12-16 15:47:55 +08:00
},
2022-02-16 11:17:07 +08:00
},
},
2021-12-16 15:47:55 +08:00
],
grid: {
containLabel: true,
width: "99%",
left: 0,
top: 50,
bottom: 50,
},
2022-02-16 11:17:07 +08:00
// dataZoom: {
// type: 'slider',
// start: 0,
// end: this.dataZoomEnd(titData.length, 7),
// },
dataZoom: [
{
type: "slider",
textStyle: {
color: "#fff",
},
startValue: this.dataZoomStart(titData.length, 4, "start"),
endValue: this.dataZoomStart(titData.length, 4, "end"),
},
{
type: "inside",
},
],
2021-12-16 15:47:55 +08:00
series: [
{
2022-02-16 11:17:07 +08:00
name: "预测",
type: "bar",
z: "-1",
barGap: "-75%",
2021-12-16 15:47:55 +08:00
barWidth: 30,
itemStyle: {
2022-02-16 11:17:07 +08:00
color: "rgba(145, 213, 254, .3)",
2021-12-16 15:47:55 +08:00
},
data: forecastQuantity,
},
{
2022-02-16 11:17:07 +08:00
name: "实际",
type: "bar",
2021-12-16 15:47:55 +08:00
barWidth: 15,
position: [0, 0],
itemStyle: {
color: {
2022-02-16 11:17:07 +08:00
type: "linear", // 线性渐变
2021-12-16 15:47:55 +08:00
x: 0,
y: 0,
x2: 0,
y2: 1,
2022-02-16 11:17:07 +08:00
colorStops: [
{
offset: 0,
color: "#B5D3FE", // 0%处的颜色为红色
},
{
offset: 1,
color: "#7EA7FC", // 100%处的颜色为蓝
},
],
},
2021-12-16 15:47:55 +08:00
},
data: actualQuantity,
},
{
2022-02-16 11:17:07 +08:00
name: "目标完成率",
type: "line",
2021-12-16 15:47:55 +08:00
yAxisIndex: 1,
smooth: false,
data: targetCompletionRate,
// data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2],
itemStyle: {
normal: {
2022-02-16 11:17:07 +08:00
color: "rgba(246, 217, 126, 1)",
},
2021-12-16 15:47:55 +08:00
},
2022-02-16 11:17:07 +08:00
symbol: "none",
},
2021-12-16 15:47:55 +08:00
],
});
2022-02-16 11:17:07 +08:00
});
},
},
};
2021-11-22 09:17:41 +08:00
</script>
<style lang="scss" scoped>
.num {
font-size: 30px;
font-family: Roboto-Black, Roboto;
font-weight: 900;
color: #f6d97e;
line-height: 35px;
// margin-right: 3px;
}
.num2 {
font-size: 30px;
font-family: Roboto-Black, Roboto;
font-weight: 900;
color: rgba(16, 152, 255, 1);
line-height: 35px;
}
</style>