You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
reagent_manage/vue/src/view/index/component/DailyProfitStat.vue

97 lines
2.8 KiB

7 years ago
<template>
<div :style="{height,width}"/>
</template>
<script>
import {logic, resize} from "@/mixin/chart"
6 years ago
import {getDailyProfitStat} from '@/api/statistic'
import {timeFormat} from "@/util"
7 years ago
6 years ago
export default {
name: "DailyProfitStat",
6 years ago
mixins: [resize, logic],
6 years ago
methods: {
init() {
if (this.loading) return
this.loading = true
getDailyProfitStat()
.then(data => {
const time = []
const purchase = []
const sell = []
const profit = []
data.forEach(i => {
time.push(timeFormat('MM 月 dd日', new Date(i.time)))
purchase.push(i.purchase)
sell.push(i.sell)
profit.push(i.profit)
7 years ago
})
6 years ago
this.setOptions({time, purchase, sell, profit})
})
.finally(() => this.loading = false)
},
6 years ago
setOptions({time, purchase, sell, profit}) {
this.chart.setOption({
title: {
text: '历史七天利润情况统计',
left: 'center',
align: 'right'
},
xAxis: {
data: time,
axisTick: {
show: false
}
},
grid: {
left: 10,
right: 10,
bottom: 20,
top: 30,
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
7 years ago
},
6 years ago
padding: [5, 10]
},
yAxis: {
axisTick: {
show: false
}
},
legend: {
data: ['采购额', '销售额', '毛利润'],
right: 10
},
series: [
{
name: '采购额',
smooth: true,
type: 'line',
data: purchase
7 years ago
},
6 years ago
{
name: '销售额',
smooth: true,
type: 'line',
data: sell
7 years ago
},
6 years ago
{
name: '毛利润',
smooth: true,
type: 'line',
data: profit
}
]
})
7 years ago
}
}
6 years ago
}
7 years ago
</script>