Merge branch 'master' of git.picaiba.com:g7hoo/chenzhou

This commit is contained in:
gtz 2024-03-20 11:45:43 +08:00
commit 1b0746cc2d
3 changed files with 16 additions and 15 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, onMounted, ref, watch } from "vue"; import { computed, nextTick, onMounted, ref, watch } from "vue";
import * as echarts from "echarts"; import * as echarts from "echarts";
import getOptions from "./rateOption"; import getOptions from "./rateOption";
@ -33,14 +33,14 @@ watch(
); );
const rate = computed(() => { const rate = computed(() => {
if (!props.rawData.nowYield || props.rawData.nowYield == 0) return [0, 0]; if (!props.rawData?.nowYield || props.rawData.nowYield == 0) return [0, 0];
// const _rate = ((props.rawData.nowYield / props.rawData.targetYield) * 100) // const _rate = ((props.rawData.nowYield / props.rawData.targetYield) * 100)
// .toFixed(2) // .toFixed(2)
// .toString(); // .toString();
// return [parseInt(_rate), _rate.split(".")[1]]; // return [parseInt(_rate), _rate.split(".")[1]];
return [ return [
parseInt(props.rawData.nowYield), parseInt(props.rawData.nowYield),
(props.rawData.nowYield + "").split(".")[1], ((props.rawData.nowYield + "").split(".")[1] ?? "").padStart(2, "0"),
]; ];
}); });
@ -55,18 +55,17 @@ function reInitChart() {
} }
onMounted(() => { onMounted(() => {
nextTick(() => {
reInitChart(); reInitChart();
}); });
});
</script> </script>
<template> <template>
<div class="chart rate-chart"> <div class="chart rate-chart">
<div ref="rateChartRef" class="chart-container"></div> <div ref="rateChartRef" class="chart-container"></div>
<div <div :class="['fake-chart-title', isOnlyChild ? 'is-only-child' : '']">
v-if="!displayPlaceholder"
:class="['fake-chart-title', isOnlyChild ? 'is-only-child' : '']"
>
<span class="integer-part">{{ rate[0] }}.</span> <span class="integer-part">{{ rate[0] }}.</span>
<span class="decimal-part">{{ rate[1] }}%</span> <span class="decimal-part">{{ rate[1] }}%</span>
</div> </div>
@ -104,11 +103,11 @@ onMounted(() => {
user-select: none; user-select: none;
position: absolute; position: absolute;
top: 30%; top: 30%;
left: 32%; left: 36%;
} }
.fake-chart-title.is-only-child { .fake-chart-title.is-only-child {
left: 42%; left: 36%;
} }
.fake-chart-title > .integer-part { .fake-chart-title > .integer-part {

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onMounted, ref } from "vue"; import { nextTick, onMounted, ref } from "vue";
import * as echarts from "echarts"; import * as echarts from "echarts";
import getOptions from "./yieldOption"; import getOptions from "./yieldOption";
@ -33,8 +33,10 @@ function reInitChart() {
} }
onMounted(() => { onMounted(() => {
nextTick(() => {
reInitChart(); reInitChart();
}); });
});
</script> </script>
<template> <template>

View File

@ -15,9 +15,9 @@ onMounted(() => {
// websocketData.value = loadData([ // websocketData.value = loadData([
// { // {
// targetProduction: 120, // targetProduction: 120,
// nowProduction: 10, // nowProduction: 0,
// targetYield: 10.34, // targetYield: 0,
// nowYield: 3.11, // nowYield: 10,
// }, // },
// ]); // ]);
websocketData.value = loadData(store.data2.dailyTarget); websocketData.value = loadData(store.data2.dailyTarget);