99 lines
2.6 KiB
Vue
99 lines
2.6 KiB
Vue
<template>
|
|
<div class="pie-container self">
|
|
<public-title title="步数" />
|
|
<div class="inner" ref="healthChart"></div>
|
|
<div class="count">
|
|
<div class="t">总人数</div>
|
|
<div class="v">{{ total }}</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { ref, unref, onMounted, watch } from 'vue';
|
|
import * as echarts from 'echarts';
|
|
import PublicTitle from '/@/components/publicTitle.vue';
|
|
import { useSpin } from '/@/components/body-d-left/bodyLeftHooks.ts';
|
|
import { useStep } from '/@/components/secondaryScreen/screen-right/screenRightHooks.ts';
|
|
import { screenPie } from '/@/components/item-d/pieCharts.ts';
|
|
import { getStep } from '/@/components/secondaryScreen/commonApi.ts';
|
|
|
|
const props = defineProps({
|
|
orgCode: String,
|
|
type: String,
|
|
});
|
|
watch(
|
|
props,
|
|
() => {
|
|
init();
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
const { setSpin, spinning } = useSpin();
|
|
const healthChart = ref<HTMLElement>();
|
|
const color = ref(['#B750BE', '#6C63F0', '#3AACFF', '#ED589D', '#FB466C']);
|
|
const { stepData, total, setStep } = useStep();
|
|
|
|
async function init() {
|
|
try {
|
|
const params = {
|
|
orgCode: props.orgCode,
|
|
type: props.type,
|
|
};
|
|
const { code, result } = await getStep(params);
|
|
setSpin(true);
|
|
if (code != 200) {
|
|
return;
|
|
}
|
|
setStep(result);
|
|
initChart(unref(stepData), '15000');
|
|
} catch {
|
|
initChart(unref(stepData), 0);
|
|
}
|
|
}
|
|
|
|
function initChart(chartData, total) {
|
|
let myChart = echarts.init(healthChart.value);
|
|
let options = screenPie(chartData, total, color.value, '{c}');
|
|
myChart.setOption(options);
|
|
window.addEventListener('resize', () => {
|
|
myChart.resize();
|
|
});
|
|
}
|
|
</script>
|
|
<style scoped lang="less">
|
|
.inner {
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
height: calc(100% - 40px);
|
|
}
|
|
|
|
.pie-container.self {
|
|
position: relative;
|
|
padding-bottom: 0 !important;
|
|
}
|
|
|
|
.count {
|
|
position: absolute;
|
|
width: 80%;
|
|
top: 51%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
color: #fff;
|
|
font-size: 22px;
|
|
font-weight: bold;
|
|
z-index: 1;
|
|
pointer-events: none;
|
|
|
|
> div {
|
|
width: 80px;
|
|
z-index: 0;
|
|
}
|
|
|
|
.t {
|
|
font-size: 14px;
|
|
font-weight: normal;
|
|
}
|
|
}
|
|
</style> |