2023-12-15 18:08:45 +08:00
|
|
|
<template>
|
2024-05-17 12:06:29 +08:00
|
|
|
<div class="chart-box">
|
|
|
|
|
<div class="date-btn text-color">
|
|
|
|
|
<div class="btn-box">
|
|
|
|
|
<el-icon @click="getData(upMonth)">
|
|
|
|
|
<ArrowLeft/>
|
|
|
|
|
</el-icon>
|
|
|
|
|
<el-date-picker v-model="currentMonth" format="YYYY年MM月" type="month" :editable="false" :clearable="false"
|
|
|
|
|
@change="getData"/>
|
|
|
|
|
<el-icon @click="getData(downMonth)">
|
|
|
|
|
<ArrowRight/>
|
|
|
|
|
</el-icon>
|
|
|
|
|
</div>
|
2023-12-15 18:08:45 +08:00
|
|
|
</div>
|
2024-05-17 12:06:29 +08:00
|
|
|
<div ref="chartDom" class="chart-dom"></div>
|
|
|
|
|
<div class="total-mini">本月共计{{ total }}台手术</div>
|
|
|
|
|
</div>
|
2023-12-15 18:08:45 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang='ts' setup>
|
2024-05-17 12:06:29 +08:00
|
|
|
import {onMounted, ref} from 'vue'
|
2023-12-26 17:11:15 +08:00
|
|
|
import * as echarts from 'echarts'
|
2024-05-17 12:06:29 +08:00
|
|
|
import {dateFormater, getMonthDays} from '@/utils/date-util'
|
|
|
|
|
import * as medicineApi from "@/api/medicine";
|
2023-12-15 18:08:45 +08:00
|
|
|
|
|
|
|
|
const chartDom = ref()
|
|
|
|
|
|
|
|
|
|
const currentMonth = ref(new Date())
|
|
|
|
|
const upMonth = ref()
|
|
|
|
|
const downMonth = ref()
|
|
|
|
|
const total = ref(0)
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2024-05-17 12:06:29 +08:00
|
|
|
init();
|
2023-12-15 18:08:45 +08:00
|
|
|
})
|
|
|
|
|
|
2024-05-17 12:06:29 +08:00
|
|
|
function init() {
|
|
|
|
|
getData(new Date())
|
2023-12-15 18:08:45 +08:00
|
|
|
}
|
2024-05-17 12:06:29 +08:00
|
|
|
|
2023-12-15 18:08:45 +08:00
|
|
|
function initChart(chartData: any) {
|
2024-05-17 12:06:29 +08:00
|
|
|
const chart = echarts.init(chartDom.value as HTMLElement);
|
|
|
|
|
chart.clear();
|
|
|
|
|
const option = {
|
|
|
|
|
color: [],
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
formatter: (params: any) => {
|
|
|
|
|
return dateFormater('yyyy年MM月', currentMonth.value) + params[0].axisValue + '<br>手术数量 <b>' + params[0].value + '</b> 台'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
|
|
|
|
left: 20,
|
|
|
|
|
right: 50,
|
|
|
|
|
bottom: 5,
|
|
|
|
|
top: 50,
|
|
|
|
|
containLabel: true,
|
|
|
|
|
},
|
|
|
|
|
xAxis: {
|
|
|
|
|
name: '日期',
|
|
|
|
|
show: true,
|
|
|
|
|
type: 'category',
|
|
|
|
|
boundaryGap: false,
|
|
|
|
|
nameTextStyle: {color: '#909399'},
|
|
|
|
|
axisLine: {show: true, lineStyle: {color: '#006080', width: 2}},
|
|
|
|
|
axisTick: {show: false},
|
|
|
|
|
axisLabel: {show: true, interval: chartData.xData.length - 2},
|
|
|
|
|
splitLine: {show: true, lineStyle: {color: 'rgba(0, 96, 128, .05)', width: 1, type: 'solid'}},
|
|
|
|
|
data: chartData.xData,
|
|
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
name: '数量',
|
|
|
|
|
show: true,
|
|
|
|
|
type: 'value',
|
|
|
|
|
min: 0,
|
|
|
|
|
nameTextStyle: {color: '#909399', align: 'center', verticalAlign: 'top', padding: [0, 0]},
|
|
|
|
|
axisLine: {show: true, lineStyle: {color: '#006080', width: 2}},
|
|
|
|
|
axisTick: {show: false},
|
|
|
|
|
axisLabel: {show: false},
|
|
|
|
|
splitLine: {show: false, lineStyle: {color: '#D4E8F0', width: 1, type: 'solid'}},
|
|
|
|
|
},
|
|
|
|
|
series: [{
|
|
|
|
|
type: 'line',
|
|
|
|
|
symbol: 'none',
|
|
|
|
|
smooth: true,
|
|
|
|
|
showSymbol: false,
|
|
|
|
|
lineStyle: {
|
|
|
|
|
color: 'rgb(0, 96, 128)',
|
|
|
|
|
width: 2,
|
|
|
|
|
shadowColor: 'rgba(0, 96, 128, .3)',
|
|
|
|
|
shadowBlur: 10,
|
|
|
|
|
shadowOffsetY: 20
|
|
|
|
|
},
|
|
|
|
|
areaStyle: {
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: 'rgba(0, 96, 128, 1)'
|
|
|
|
|
}, {
|
|
|
|
|
offset: 0.8,
|
|
|
|
|
color: 'rgba(255, 255, 255, 0.1)'
|
|
|
|
|
}], false)
|
|
|
|
|
},
|
|
|
|
|
data: chartData.data
|
|
|
|
|
}],
|
|
|
|
|
};
|
|
|
|
|
chart.setOption(option);
|
|
|
|
|
chart.resize();
|
|
|
|
|
window.addEventListener('resize', () => {
|
2023-12-15 18:08:45 +08:00
|
|
|
chart.resize();
|
2024-05-17 12:06:29 +08:00
|
|
|
});
|
2023-12-15 18:08:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getData = (date: any) => {
|
2024-05-17 12:06:29 +08:00
|
|
|
currentMonth.value = new Date(date)
|
|
|
|
|
upMonth.value = new Date(currentMonth.value.getFullYear(), currentMonth.value.getMonth() - 1, 1)
|
|
|
|
|
downMonth.value = new Date(currentMonth.value.getFullYear(), currentMonth.value.getMonth() + 1, 1)
|
|
|
|
|
const xData: any = []
|
|
|
|
|
const data: any = []
|
|
|
|
|
let num = 0
|
|
|
|
|
const start = new Date(currentMonth.value.getFullYear(), currentMonth.value.getMonth(), 1)
|
|
|
|
|
const end = new Date(currentMonth.value.getFullYear(), currentMonth.value.getMonth() + 1, 0)
|
|
|
|
|
medicineApi.getSurgeryCount(dateFormater("yyyy-MM-dd", start), dateFormater("yyyy-MM-dd", end)).then(res => {
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
res.data.forEach((item: any) => {
|
|
|
|
|
xData.push(item.time)
|
|
|
|
|
data.push(item.count)
|
|
|
|
|
num += item.count
|
|
|
|
|
})
|
|
|
|
|
total.value = num
|
2023-12-15 18:08:45 +08:00
|
|
|
}
|
2024-05-17 12:06:29 +08:00
|
|
|
initChart({xData, data})
|
|
|
|
|
})
|
2023-12-15 18:08:45 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang='scss' scoped>
|
2024-05-17 12:06:29 +08:00
|
|
|
.chart-box {
|
|
|
|
|
position: relative;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.date-btn {
|
|
|
|
|
position: absolute;
|
|
|
|
|
height: 50px;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 20px;
|
|
|
|
|
right: 230px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
|
|
|
|
.btn-box {
|
|
|
|
|
height: 30px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
color: $text2-color;
|
|
|
|
|
|
|
|
|
|
& > :deep(.el-date-editor) {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
|
|
|
|
.el-input__wrapper {
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
|
|
|
|
.el-input__prefix,
|
|
|
|
|
.el-input__suffix {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-input__inner {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
width: 100px;
|
|
|
|
|
color: $text2-color;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
2023-12-15 18:08:45 +08:00
|
|
|
}
|
2024-05-17 12:06:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-icon {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
2023-12-15 18:08:45 +08:00
|
|
|
}
|
2024-05-17 12:06:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.chart-dom {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.total-mini {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
right: 40px;
|
|
|
|
|
color: $main-color;
|
|
|
|
|
border: 1px solid $main-color;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
padding: 3px 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-15 18:08:45 +08:00
|
|
|
</style>
|