140 lines
2.9 KiB
Vue
140 lines
2.9 KiB
Vue
|
<!--
|
||
|
filename: ChipRateItem.vue
|
||
|
author: liubin
|
||
|
date: 2024-04-29 14:25:18
|
||
|
description:
|
||
|
-->
|
||
|
|
||
|
<template>
|
||
|
<div class="chip-rate-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">
|
||
|
<span class="legend-item__value">20%</span>
|
||
|
<span class="legend-item__label">2023年累计</span>
|
||
|
</div>
|
||
|
<div class="legend-item">
|
||
|
<span class="legend-item__value">20%</span>
|
||
|
<span class="legend-item__label">2024年累计</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/chipOptions.js";
|
||
|
|
||
|
export default {
|
||
|
name: "ChipRateItem",
|
||
|
components: { CopilotButtons },
|
||
|
mixins: [chartMixin, fullscreenMixin],
|
||
|
props: {
|
||
|
cities: {
|
||
|
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">
|
||
|
.chip-rate-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
|