projects/mescc/zhp #12

Merged
juzi merged 13 commits from projects/mescc/zhp into projects/mescc/develop 2024-05-08 16:40:47 +08:00
9 changed files with 940 additions and 29 deletions
Showing only changes of commit ea63cb5730 - Show all commits

View File

@ -9,6 +9,7 @@
<div class="copilot-container">
<!-- refresh btn -->
<button
v-if="0"
style="
appearance: none;
outline: none;
@ -109,7 +110,12 @@ export default {
border-radius: 2px;
top: 0%;
left: 0;
background: radial-gradient(circle at center , #024798 2%, #024798 30%, transparent);
background: radial-gradient(
circle at center,
#024798 2%,
#024798 30%,
transparent
);
z-index: 1;
}

View File

@ -0,0 +1,296 @@
<!--
filename: LineChartBase.vue
author: liubin
date: 2024-04-30 08:59:28
description:
-->
<template>
<chart-container class="line-chart-base">
<div class="legend">
<span
v-for="item in legend"
:key="item.label"
class="legend-item"
:style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }"
>{{ item.label }}</span
>
</div>
<div
ref="chart"
style="max-width: 50vw"
:style="{ height: vHeight + 'vh' }"
></div>
</chart-container>
</template>
<script>
import screenfull from "screenfull";
import ChartContainer from "./ChartContainer.vue";
import chartMixin from "@/mixins/chart.js";
export default {
name: "LineChartBase",
components: {
ChartContainer,
},
mixins: [chartMixin],
props: {
vHeight: {
type: Number,
default: 34,
},
legend: {
type: Array,
required: true,
},
xAxis: {
type: Array,
required: true,
},
series: {
type: Array,
required: true,
},
in: {
type: String,
default: "",
},
},
data() {
return {
isFullscreen: false,
actualOptions: null,
options: {
grid: {
left: "5%",
right: "4%",
bottom: "3%",
top: "15%",
containLabel: true,
},
tooltip: {},
xAxis: {
axisTick: {
show: false,
},
axisLine: {
lineStyle: {
color: "#4561AE",
},
},
axisLabel: {
color: "#fff",
fontSize: 12,
},
data: this.xAxis,
},
yAxis: {
name: "单位/片",
nameTextStyle: {
color: "#fff",
fontSize: 12,
},
axisTick: {
show: false,
},
axisLabel: {
color: "#fff",
fontSize: 12,
},
axisLine: {
show: true,
lineStyle: {
color: "#4561AE",
},
},
splitLine: {
lineStyle: {
color: "#4561AE",
},
},
},
series: [
{
name: "", // this.series[0].name,
type: "bar",
barWidth: 12,
itemStyle: {
borderRadius: [10, 10, 0, 0],
color: {
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "#12f7f1", // 0%
},
{
offset: 0.35,
color: "#12f7f177", // 100%
},
{
offset: 0.75,
color: "#12f7f133", // 100%
},
{
offset: 1,
color: "transparent", // 100%
},
],
global: false, // false
},
},
data: [], // this.series[0].data,
},
{
name: "", // this.series[1].name,
type: "bar",
barWidth: 12,
// tooltip: {
// valueFormatter: function (value) {
// return value + " ml";
// },
// },
itemStyle: {
borderRadius: [10, 10, 0, 0],
color: {
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "#57abf8", // 0%
},
{
offset: 1,
color: "#364BFE66", // 100%
},
],
global: false, // false
},
},
data: [], // this.series[1].data,
},
],
},
};
},
watch: {
/** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
isFullscreen(val) {
this.actualOptions.series.map((item) => {
item.barWidth = val ? 18 : 12;
});
this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
this.initOptions(this.actualOptions);
},
series(val) {
if (!val) {
this.initOptions(this.options);
return;
}
const actualOptions = JSON.parse(JSON.stringify(this.options));
actualOptions.series[0].data = val[0].data;
actualOptions.series[0].name = val[0].name;
actualOptions.series[1].data = val?.[1]?.data || [];
actualOptions.series[1].name = val?.[1]?.name || "";
this.actualOptions = actualOptions;
this.initOptions(actualOptions);
},
},
mounted() {
this.actualOptions = this.options;
this.initOptions(this.options);
if (screenfull.isEnabled) {
screenfull.on("change", () => {
this.isFullscreen = screenfull.isFullscreen;
});
}
},
};
</script>
<style scoped lang="scss">
.line-chart-base {
// position: relative;
.legend {
position: absolute;
top: 5.2vh;
right: 1vw;
}
.legend-item {
position: relative;
// font-size: 12px;
margin-right: 0.67vw;
&::before {
content: "";
display: inline-block;
width: 0.432vw;
height: 0.432vw;
border-radius: 100%;
margin-right: 0.4vw;
}
&::after {
content: "";
display: inline-block;
width: 1vw;
height: 0.125vw;
position: absolute;
top: 54%;
left: -15%;
transform: translateY(-50%);
border-radius: 100;
margin-right: 0.22vw;
}
}
.legend-item:nth-child(1):after,
.legend-item:nth-child(1):before {
background-color: #fad162;
}
.legend-item:nth-child(2):after,
.legend-item:nth-child(2):before {
background-color: #2160f3;
}
.legend-item:nth-child(3):after,
.legend-item:nth-child(3):before {
background-color: #13dbf3;
}
.legend-item:nth-child(4):after,
.legend-item:nth-child(4):before {
background-color: #88ca67;
}
.legend-item:nth-child(5):after,
.legend-item:nth-child(5):before {
background-color: #5c97fc;
}
.legend-item:nth-child(6):after,
.legend-item:nth-child(6):before {
background-color: #f48900;
}
.legend-item:nth-child(7):after,
.legend-item:nth-child(7):before {
background-color: #776bf0;
}
}
</style>

View File

@ -6,25 +6,123 @@
-->
<template>
<div class="elec-cost">elec cost</div>
<LineChartBase
v-if="1"
:legend="legend"
:series="series"
:xAxis="xAxis"
in="elecCost"
class="elec-cost"
/>
<BarChartBase
v-else
:legend="legend"
:series="series"
:xAxis="xAxis"
in="elecCost"
class="elec-cost"
/>
</template>
<script>
import BarChartBaseVue from "@/views/copilot/components/BarChartBase.vue";
import LineChartBaseVue from "@/views/copilot/components/LineChartBase.vue";
export default {
name: "ElecCost",
components: {},
props: {},
data() {
return {};
components: {
BarChartBase: BarChartBaseVue,
LineChartBase: LineChartBaseVue,
},
props: {
period: {
type: String,
default: "日",
},
},
data() {
//
const cities = ["瑞昌", "邯郸", "株洲", "佳木斯", "成都", "凯盛", "蚌埠"];
return {
xAxis: cities,
};
},
computed: {
legend() {
switch (this.period) {
case "日":
return [{ label: "昨日", color: "#12f7f1" }];
case "周":
return [{ label: "本周", color: "#12f7f1" }];
case "月": {
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
return [
{ label: `${year - 1}${month}`, color: "#12f7f1" },
{ label: `${year}${month}`, color: "#58adfa" },
];
}
case "年": {
const year = new Date().getFullYear();
return [
{ label: `${year - 1}`, color: "#12f7f1" },
{ label: `${year}`, color: "#58adfa" },
];
}
default:
return [
{ label: `${year - 1}`, color: "#12f7f1" },
{ label: `${year}`, color: "#58adfa" },
];
}
},
series() {
const { ftoInvest } = this.$store.getters.copilot.yield;
let dataList = null;
switch (this.period) {
case "日":
case "周":
dataList = ftoInvest?.current;
break;
default:
dataList = [];
dataList[0] = ftoInvest?.pervious;
dataList[1] = ftoInvest?.current;
}
return getTemplate(this.period, dataList);
},
},
computed: {},
methods: {},
};
function getTemplate(period, dataList) {
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
return period == "日" || period == "周"
? [
{
name: period == "日" ? "昨日" : "本周",
data: dataList ?? [],
},
]
: [
{
name: period == "年" ? `${year - 1}` : `${year - 1}${month}`,
data: dataList ? dataList[0] : [],
},
{
name: period == "年" ? `${year}` : `${year}${month}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
}
</script>
<style scoped lang="scss">
.elec-cost {
background: #cc03;
flex: 1;
}
</style>

View File

@ -6,25 +6,110 @@
-->
<template>
<div class="nat-gas">nat-gas</div>
<BarChartBase
:legend="legend"
:series="series"
:xAxis="xAxis"
in="nat-gas"
class="nat-gas"
/>
</template>
<script>
import BarChartBase from "@/views/copilot/components/BarChartBase.vue";
export default {
name: "NatGas",
components: {},
props: {},
data() {
return {};
name: "NatGasCost",
components: { BarChartBase },
props: {
period: {
type: String,
default: "日",
},
},
data() {
//
const cities = ["瑞昌", "邯郸", "株洲", "佳木斯", "成都", "凯盛", "蚌埠"];
return {
xAxis: cities,
};
},
computed: {
legend() {
switch (this.period) {
case "日":
return [{ label: "昨日", color: "#12f7f1" }];
case "周":
return [{ label: "本周", color: "#12f7f1" }];
case "月": {
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
return [
{ label: `${year - 1}${month}`, color: "#12f7f1" },
{ label: `${year}${month}`, color: "#58adfa" },
];
}
case "年": {
const year = new Date().getFullYear();
return [
{ label: `${year - 1}`, color: "#12f7f1" },
{ label: `${year}`, color: "#58adfa" },
];
}
default:
return [
{ label: `${year - 1}`, color: "#12f7f1" },
{ label: `${year}`, color: "#58adfa" },
];
}
},
series() {
const { ftoInvest } = this.$store.getters.copilot.yield;
let dataList = null;
switch (this.period) {
case "日":
case "周":
dataList = ftoInvest?.current;
break;
default:
dataList = [];
dataList[0] = ftoInvest?.pervious;
dataList[1] = ftoInvest?.current;
}
return getTemplate(this.period, dataList);
},
},
computed: {},
methods: {},
};
function getTemplate(period, dataList) {
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
return period == "日" || period == "周"
? [
{
name: period == "日" ? "昨日" : "本周",
data: dataList ?? [],
},
]
: [
{
name: period == "年" ? `${year - 1}` : `${year - 1}${month}`,
data: dataList ? dataList[0] : [],
},
{
name: period == "年" ? `${year}` : `${year}${month}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
}
</script>
<style scoped lang="scss">
.nat-gas {
background: #31f2;
flex: 1;
}
</style>

View File

@ -6,16 +6,36 @@
-->
<template>
<div class="stock-monitor">仓库监控</div>
<div class="stock-monitor">
<MonitorItem
:cities="['成都', '邯郸', '株洲', '瑞昌', '佳木斯']"
:legendList="dhgList"
/>
<MonitorItem :cities="['凯盛光伏', '蚌埠兴科']" :legendList="otherList" />
</div>
</template>
<script>
import MonitorItemVue from "./sub/monitor/MonitorItem.vue";
export default {
name: "StockMonitor",
components: {},
components: { MonitorItem: MonitorItemVue },
props: {},
data() {
return {};
return {
dhgList: [
{ name: "总库存", value: "1000" },
{ name: "已用库存", value: "500" },
{ name: "剩余库存", value: "500" },
],
otherList: [
{ name: "分类1", value: "1000" },
{ name: "分类2", value: "1000" },
{ name: "分类3", value: "1000" },
{ name: "分类4", value: "1000" },
],
};
},
computed: {},
methods: {},
@ -24,7 +44,20 @@ export default {
<style scoped lang="scss">
.stock-monitor {
background: #fff2;
flex: 1;
display: flex;
gap: 5px;
position: relative;
&:after {
content: "";
position: absolute;
left: 50%;
top: 0;
width: 3px;
height: 100%;
transform: translateX(-50%);
background: linear-gradient(to bottom, transparent, #00f2ff, transparent);
}
}
</style>

View File

@ -6,25 +6,123 @@
-->
<template>
<div class="water-cost">water cost</div>
<LineChartBase
v-if="0"
:legend="legend"
:series="series"
:xAxis="xAxis"
in="waterCost"
class="water-cost"
/>
<BarChartBase
v-else
:legend="legend"
:series="series"
:xAxis="xAxis"
in="waterCost"
class="water-cost"
/>
</template>
<script>
import BarChartBaseVue from "@/views/copilot/components/BarChartBase.vue";
import LineChartBaseVue from "@/views/copilot/components/LineChartBase.vue";
export default {
name: "WaterCost",
components: {},
props: {},
data() {
return {};
components: {
BarChartBase: BarChartBaseVue,
LineChartBase: LineChartBaseVue,
},
props: {
period: {
type: String,
default: "日",
},
},
data() {
//
const cities = ["瑞昌", "邯郸", "株洲", "佳木斯", "成都", "凯盛", "蚌埠"];
return {
xAxis: cities,
};
},
computed: {
legend() {
switch (this.period) {
case "日":
return [{ label: "昨日", color: "#12f7f1" }];
case "周":
return [{ label: "本周", color: "#12f7f1" }];
case "月": {
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
return [
{ label: `${year - 1}${month}`, color: "#12f7f1" },
{ label: `${year}${month}`, color: "#58adfa" },
];
}
case "年": {
const year = new Date().getFullYear();
return [
{ label: `${year - 1}`, color: "#12f7f1" },
{ label: `${year}`, color: "#58adfa" },
];
}
default:
return [
{ label: `${year - 1}`, color: "#12f7f1" },
{ label: `${year}`, color: "#58adfa" },
];
}
},
series() {
const { ftoInvest } = this.$store.getters.copilot.yield;
let dataList = null;
switch (this.period) {
case "日":
case "周":
dataList = ftoInvest?.current;
break;
default:
dataList = [];
dataList[0] = ftoInvest?.pervious;
dataList[1] = ftoInvest?.current;
}
return getTemplate(this.period, dataList);
},
},
computed: {},
methods: {},
};
function getTemplate(period, dataList) {
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
return period == "日" || period == "周"
? [
{
name: period == "日" ? "昨日" : "本周",
data: dataList ?? [],
},
]
: [
{
name: period == "年" ? `${year - 1}` : `${year - 1}${month}`,
data: dataList ? dataList[0] : [],
},
{
name: period == "年" ? `${year}` : `${year}${month}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
}
</script>
<style scoped lang="scss">
.water-cost {
background: #f002;
flex: 1;
}
</style>

View File

@ -0,0 +1,139 @@
<!--
filename: ChipRateItem.vue
author: liubin
date: 2024-04-29 14:25:18
description:
-->
<template>
<div class="monitor-item">
<div class="cities">
<CopilotButtons :options="cities" @update:active="handleCityUpdate" />
</div>
<div class="chart" ref="chart"></div>
<div class="legend" v-if="1">
<div class="legend-item" v-for="lgd in legendList" :key="lgd.name">
<span class="legend-item__label">{{ lgd.name }}</span>
<span class="legend-item__value">{{ lgd.value }}</span>
</div>
</div>
</div>
</template>
<script>
import CopilotButtons from "@/views/copilot/components/select.vue";
import chartMixin from "@/mixins/chart.js";
import fullscreenMixin from "@/mixins/fullscreen.js";
import getOptions from "../../../options/monitorOptions.js";
export default {
name: "ChipRateItem",
components: { CopilotButtons },
mixins: [chartMixin, fullscreenMixin],
props: {
cities: {
type: Array,
default: () => [],
},
legendList: {
type: Array,
default: () => [],
},
color: {
type: Number,
default: 1,
},
},
data() {
return {
period: "月",
valueTuple: [100, 100, 200],
};
},
computed: {
options() {
const year = new Date().getFullYear();
const month = new Date().getMonth() + 1;
const vt = this.valueTuple;
let titleValue =
vt[0] != null && vt[2] != null && vt[2] !== 0
? `${((vt[1] / vt[2]) * 100).toFixed(0)}%`
: "0%",
subtitle =
this.period == "月" ? `${month}月累计产出` : `${year}年累计产出`;
return getOptions({
single: true,
color: this.color == 1 ? "#4CF0E8" : "#1065ff",
titleValue,
subtitle,
previousSum: this.valueTuple[0],
currentSum: this.valueTuple[1],
targetSum: this.valueTuple[2],
});
},
},
mounted() {
this.initOptions(this.options);
},
methods: {
handleCityUpdate() {},
fullscreenCallback(isFullscreen) {
console.log("isFullscreen--->", isFullscreen);
},
},
};
</script>
<style scoped lang="scss">
.monitor-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 3px;
backdrop-filter: blur(24px);
.cities {
height: 40px;
}
.chart {
align-self: stretch;
height: 280px;
}
.legend {
height: 80px;
display: flex;
gap: 40px;
justify-content: space-around;
}
.legend-item {
display: flex;
flex-direction: column;
align-items: center;
gap: 3px;
&:first-child {
.legend-item__value {
color: #0e61f5;
}
}
&:nth-child(2) {
.legend-item__value {
color: #0fd5d1;
}
}
}
.legend-item__value {
font-size: 24px;
font-weight: 600;
}
}
</style>
l

View File

@ -8,10 +8,10 @@
<template>
<div class="energy-copilot">
<Container title="仓库监控·当前" icon="chip2">
<StockMonitorVue />
<StockMonitorVue :period="period" />
</Container>
<Container title="天然气能耗" icon="std">
<NatGasVue />
<NatGasVue :period="period" />
</Container>
<Container title="电能耗" icon="chip">
<ElecCostVue :period="period" />

View File

@ -0,0 +1,156 @@
export default function ({
single = false,
color,
titleValue,
subtitle,
previousSum,
currentSum,
targetSum,
}) {
return {
grid: {
left: 0,
right: 0,
bottom: 0,
top: 0,
containLabel: true,
},
tooltip: {},
title: {
text: titleValue,
left: "49%",
top: "39%",
textAlign: "center",
textStyle: {
fontWeight: 600,
fontSize: 32,
color: "#fffd",
},
subtext: `\u2002${subtitle}\u2002`,
subtextStyle: {
fontSize: 14,
fontWeight: 100,
color: "#fffd",
align: "right",
},
},
series: [
// 背景 series
{
type: "pie",
name: "当前目标",
radius: ["70%", "85%"],
center: ["50%", "52%"],
emptyCircleStyle: {
color: "#040c5f45",
},
},
// 数据 series
{
type: "pie",
radius: ["70%", "85%"],
center: ["50%", "52%"],
avoidLabelOvervlap: false,
label: {
show: false,
},
labelLine: {
show: false,
},
data: [
{
value: currentSum,
name: "当前累计产出",
selected: false,
itemStyle: {
borderJoin: "round",
borderCap: "round",
borderWidth: 12,
borderRadius: "50%",
// color: {
// type: "linear",
// x: 1,
// y: 0,
// x2: 0,
// y2: 1,
// colorStops: single
// ? [
// { offset: 0, color: `${color}11` },
// { offset: 1, color: `${color}` },
// ]
// : [
// { offset: 0, color: "#4CF0E811" },
// { offset: 1, color: "#4CF0E8" },
// ],
// },
},
},
{
value:
targetSum > currentSum
? targetSum - currentSum
: targetSum == 0
? currentSum == 0
? 1
: 0
: 0,
name: "未达成累计",
itemStyle: { color: "transparent" },
label: { show: false },
},
],
},
// 数据 series2 - 2023累计
single
? null
: {
type: "pie",
radius: ["55%", "70%"],
center: ["50%", "52%"],
avoidLabelOvervlap: false,
label: {
show: false,
},
labelLine: {
show: false,
},
data: [
{
value: previousSum,
name: "上期累计产出",
selected: false,
itemStyle: {
borderJoin: "round",
borderCap: "round",
borderWidth: 12,
borderRadius: "50%",
// color: {
// type: "linear",
// x: 1,
// y: 0,
// x2: 0,
// y2: 1,
// colorStops: [
// { offset: 0, color: "#1065ff66" },
// { offset: 1, color: "#1065ff" },
// ],
// },
},
},
{
value:
targetSum > previousSum
? targetSum - previousSum
: previousSum == 0
? 1
: 0,
name: "-",
itemStyle: { color: "transparent" },
label: { show: false },
},
],
},
],
};
}