|
@@ -0,0 +1,387 @@
|
|
|
+<template>
|
|
|
+ <div class="w-full h-full" v-loading="loading">
|
|
|
+ <div class="c-title flex justify-between">
|
|
|
+ <span>目标完成情况(月)</span>
|
|
|
+ <div>
|
|
|
+ <!-- <el-select
|
|
|
+ size="mini"
|
|
|
+ style="width: 100px; margin-right: 10px"
|
|
|
+ v-model="queryParams.type"
|
|
|
+ @change="dateTypeChange"
|
|
|
+ placeholder="请选择时间纬度"
|
|
|
+ >
|
|
|
+ <el-option label="按年展示" value="reportYear"></el-option>
|
|
|
+ <el-option label="按月展示" value="reportDate"></el-option>
|
|
|
+ </el-select> -->
|
|
|
+
|
|
|
+ <el-date-picker
|
|
|
+ style="width: 90px"
|
|
|
+ size="mini"
|
|
|
+ v-model="queryParams.reportYear"
|
|
|
+ type="year"
|
|
|
+ format="yyyy"
|
|
|
+ value-format="yyyy"
|
|
|
+ placeholder="选择年"
|
|
|
+ :clearable="false"
|
|
|
+ @change="getList"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ <el-select
|
|
|
+ size="mini"
|
|
|
+ style="width: 100px; margin-left: 10px"
|
|
|
+ v-model="zdlx"
|
|
|
+ @change="dateLxChange"
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(ite, i) in yearTypeList"
|
|
|
+ :key="i"
|
|
|
+ :label="ite.label"
|
|
|
+ :value="ite.key"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-select
|
|
|
+ v-if="queryParams.type == 'reportDate'"
|
|
|
+ size="mini"
|
|
|
+ style="width: 120px; margin-left: 10px"
|
|
|
+ v-model="currentCompany"
|
|
|
+ @change="dateCpChange"
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(ite, i) in cpList"
|
|
|
+ :key="i"
|
|
|
+ :label="ite"
|
|
|
+ :value="ite"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- <div
|
|
|
+ v-if="queryParams.type == 'reportYear'"
|
|
|
+ ref="barChart"
|
|
|
+ id="barChart"
|
|
|
+ :style="{ height: height, width: width }"
|
|
|
+ ></div> -->
|
|
|
+ <div
|
|
|
+ ref="stopTargetLineRef"
|
|
|
+ id="stopTimeMonth2"
|
|
|
+ :style="{ height: height, width: width }"
|
|
|
+ ></div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import moment from "moment/moment";
|
|
|
+import * as echarts from "echarts";
|
|
|
+import TargetLine from "../monthLine.vue";
|
|
|
+import { stopActualList } from "@/api/powerdistribution/power-outage-control";
|
|
|
+export default {
|
|
|
+ components: { TargetLine },
|
|
|
+ props: {
|
|
|
+ width: {
|
|
|
+ type: String,
|
|
|
+ default: "100%",
|
|
|
+ },
|
|
|
+ height: {
|
|
|
+ type: String,
|
|
|
+ default: "200px",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 查询参数
|
|
|
+ queryParams: {
|
|
|
+ type: "reportDate",
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ reportDate: null,
|
|
|
+ reportYear: moment(new Date()).format("yyyy"),
|
|
|
+ },
|
|
|
+ zdlx: 1,
|
|
|
+ dataList: [],
|
|
|
+ loading: false,
|
|
|
+ yearTypeList: [
|
|
|
+ {
|
|
|
+ label: "总目标",
|
|
|
+ key: 1,
|
|
|
+ value: {
|
|
|
+ 0: "stopTimeTotal",
|
|
|
+ 1: "stopTotalActual",
|
|
|
+ 2: "stopTotalRatio",
|
|
|
+ },
|
|
|
+ value2: { 0: "stopTimeMonth", 1: "stopMonth" },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "计划停电目标",
|
|
|
+ key: 2,
|
|
|
+ value: {
|
|
|
+ 0: "planStopTimeTotal",
|
|
|
+ 1: "planStopTotalActual",
|
|
|
+ 2: "planStopTotalRatio",
|
|
|
+ },
|
|
|
+ value2: { 0: "planStopTimeMonth", 1: "planStopMonth" },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "故障停电目标",
|
|
|
+ key: 3,
|
|
|
+ value: {
|
|
|
+ 0: "errorStopTimeTotal",
|
|
|
+ 1: "errorStopTotalActual",
|
|
|
+ 2: "errorStopTotalRatio",
|
|
|
+ },
|
|
|
+ value2: { 0: "errorStopTimeMonth", 1: "errorStopMonth" },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ currentCompany: "",
|
|
|
+ cpList: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ dateCpChange(e) {
|
|
|
+ this.currentCompany = e;
|
|
|
+ if (this.queryParams.type == "reportYear") {
|
|
|
+ // this.initEcharts();
|
|
|
+ } else {
|
|
|
+ this.initEcharts2();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ dateTypeChange(e) {
|
|
|
+ this.queryParams.type = e;
|
|
|
+ this.dataList = [];
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ dateLxChange(e) {
|
|
|
+ this.zdlx = e;
|
|
|
+ if (this.queryParams.type == "reportYear") {
|
|
|
+ // this.initEcharts();
|
|
|
+ } else {
|
|
|
+ this.initEcharts2();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 查询列表 */
|
|
|
+ getList() {
|
|
|
+ this.loading = true;
|
|
|
+ stopActualList(this.queryParams).then((response) => {
|
|
|
+ this.dataList = response.rows.filter(
|
|
|
+ (ite) => ite.companyName != "总计"
|
|
|
+ );
|
|
|
+ this.cpList = this.dataList.map((ite) => ite.companyName);
|
|
|
+ this.currentCompany = this.cpList ? this.cpList[0] : "";
|
|
|
+ this.loading = false;
|
|
|
+ if (this.queryParams.type == "reportYear") {
|
|
|
+ // this.initEcharts();
|
|
|
+ } else {
|
|
|
+ this.currentCompany = this.dataList
|
|
|
+ ? this.dataList[0].companyName
|
|
|
+ : "";
|
|
|
+ this.initEcharts2();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ initEcharts() {
|
|
|
+ let myChart = echarts.getInstanceByDom(
|
|
|
+ document.getElementById("barChart")
|
|
|
+ );
|
|
|
+ if (myChart == null) {
|
|
|
+ myChart = echarts.init(document.getElementById("barChart"));
|
|
|
+ }
|
|
|
+ const zdlx = this.yearTypeList.find((ite) => ite.key == this.zdlx).value;
|
|
|
+ const yAxisData = this.dataList.map((ite) => ite.companyName);
|
|
|
+ const targetData = this.dataList.map((ite) => ite[zdlx[0]] || 0);
|
|
|
+ const actualData = this.dataList.map((ite) => ite[zdlx[1]] || 0);
|
|
|
+ const ratioData = this.dataList.map((ite) => ite[zdlx[2]] || "0%");
|
|
|
+ // 指定图表的配置项和数据
|
|
|
+ var option = {
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ axisPointer: {
|
|
|
+ type: "shadow",
|
|
|
+ },
|
|
|
+ formatter: function (params) {
|
|
|
+ // params 是一个数组,数组中包含每个系列的数据信息
|
|
|
+ let result = "";
|
|
|
+ params.forEach(function (item) {
|
|
|
+ // item 是每一个系列的数据
|
|
|
+ const seriesName = item.seriesName; // 系列名称
|
|
|
+ const value = item.value; // 数据值
|
|
|
+ const marker = item.marker; // 标志图形
|
|
|
+ result += `${marker}${seriesName}: ${value}<br/>`;
|
|
|
+ });
|
|
|
+ result += `${params[0].marker}执行率: ${
|
|
|
+ ratioData[params[0].dataIndex]
|
|
|
+ }`;
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ textStyle: {
|
|
|
+ color: "#fff",
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ top: "10",
|
|
|
+ textStyle: {
|
|
|
+ color: "#fff",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ left: "2%", //图表距离容器左侧多少距离
|
|
|
+ right: "2%", //图表距离容器右侧侧多少距离
|
|
|
+ bottom: "5%", //图表距离容器上面多少距离
|
|
|
+ top: "10%", //图表距离容器下面多少距离
|
|
|
+ containLabel: true,
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: "value",
|
|
|
+ boundaryGap: [0, 0.01],
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "category",
|
|
|
+ data: yAxisData,
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: "目标值",
|
|
|
+ type: "bar",
|
|
|
+ data: targetData,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "实际值",
|
|
|
+ type: "bar",
|
|
|
+ data: actualData,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ // 使用刚指定的配置项和数据显示图表。
|
|
|
+ myChart.clear();
|
|
|
+ myChart.setOption(option, true);
|
|
|
+ window.addEventListener("resize", () => {
|
|
|
+ myChart.resize();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ initEcharts2() {
|
|
|
+ let data = [];
|
|
|
+ let legend = [];
|
|
|
+ let series = [];
|
|
|
+ data = this.dataList.filter(
|
|
|
+ (ite) => ite.companyName == this.currentCompany
|
|
|
+ );
|
|
|
+ console.log(data, "data");
|
|
|
+
|
|
|
+ const zdlx = this.yearTypeList.find((ite) => ite.key == this.zdlx).value2;
|
|
|
+ data.forEach((e, i) => {
|
|
|
+ legend.push(e.companyName);
|
|
|
+ series.push(
|
|
|
+ {
|
|
|
+ name: `${e.companyName}目标值`,
|
|
|
+ type: "line",
|
|
|
+ stack: "Total",
|
|
|
+ data: Array(12)
|
|
|
+ .fill(0)
|
|
|
+ .map((ite, i) => {
|
|
|
+ return (
|
|
|
+ e[`${zdlx[0]}${i + 1 < 10 ? "0" + (i + 1) : i + 1}`] || 0
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: `${e.companyName}实际值`,
|
|
|
+ type: "line",
|
|
|
+ stack: "Total",
|
|
|
+ data: Array(12)
|
|
|
+ .fill(0)
|
|
|
+ .map((ite, i) => {
|
|
|
+ return (
|
|
|
+ e[`${zdlx[1]}${i + 1 < 10 ? "0" + (i + 1) : i + 1}Actual`] ||
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
+ let myChart = echarts.getInstanceByDom(
|
|
|
+ document.getElementById("stopTimeMonth2")
|
|
|
+ );
|
|
|
+ if (myChart == null) {
|
|
|
+ myChart = echarts.init(document.getElementById("stopTimeMonth2"));
|
|
|
+ }
|
|
|
+ // 指定图表的配置项和数据
|
|
|
+ var option = {
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ formatter: function (params) {
|
|
|
+ // params 是一个数组,数组中包含每个系列的数据信息
|
|
|
+ let result = "";
|
|
|
+ params.forEach(function (item, i) {
|
|
|
+ // item 是每一个系列的数据
|
|
|
+ const seriesName = item.seriesName; // 系列名称
|
|
|
+ const value = item.value; // 数据值
|
|
|
+ const marker = item.marker; // 标志图形
|
|
|
+ result += `${marker}${seriesName}: ${value}<br/>`;
|
|
|
+ });
|
|
|
+ const ii = params[0].dataIndex;
|
|
|
+ result += `${params[0].marker}执行率: ${
|
|
|
+ data[0][`${zdlx[1]}${ii + 1 < 10 ? "0" + (ii + 1) : ii + 1}Ratio`]
|
|
|
+ }<br/>`;
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ textStyle: {
|
|
|
+ color: "#fff",
|
|
|
+ },
|
|
|
+ color: ["#0052F1", "#00a4ff"],
|
|
|
+ legend: {
|
|
|
+ data: legend,
|
|
|
+ type: "scroll",
|
|
|
+ top: "8%",
|
|
|
+ textStyle: {
|
|
|
+ color: "#fff",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ left: "1%",
|
|
|
+ right: "3%",
|
|
|
+ bottom: "2%",
|
|
|
+ containLabel: true,
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ data: Array(12)
|
|
|
+ .fill(0)
|
|
|
+ .map((it, i) => `${i + 1}月`),
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "value",
|
|
|
+ splitLine: {
|
|
|
+ show: true,
|
|
|
+ lineStyle: {
|
|
|
+ color: ["#02367c"], // 设置 Y 轴分割线颜色为深灰色
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ series: series,
|
|
|
+ };
|
|
|
+ // 使用刚指定的配置项和数据显示图表。
|
|
|
+ myChart.clear();
|
|
|
+ myChart.setOption(option, true);
|
|
|
+ setTimeout(() => {
|
|
|
+ myChart.resize();
|
|
|
+ }, 100);
|
|
|
+ window.addEventListener("resize", () => {
|
|
|
+ myChart.resize();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.c-title {
|
|
|
+ border-left: 4px solid #00a4ff;
|
|
|
+ padding-left: 10px;
|
|
|
+ color: #00a4ff;
|
|
|
+}
|
|
|
+</style>
|