207 lines
4.8 KiB
Vue

<template>
<el-card style="width: 49.9%;">
<template #header>
<div class="card-header">
<span>项目合同</span>
</div>
</template>
<div style="height:40px">
<el-date-picker v-model="year" @change='getCustom' value-format="YYYY" type="year" style="float:right"
:placeholder="year" />
</div>
<div style="display: flex;justify-content: space-around;">
<router-link :to="{
path: item.url,
query: item.query ? { year } : null
}" v-for=" item in customList" :key="item" class="header-btn">
<div>
<div>{{ item.value() }}</div>
<div>{{ item.name }}</div>
</div>
</router-link>
</div>
<div id="ProjectContract" class="chart" v-if="showChart"></div>
</el-card>
</template>
<script setup>
import * as echarts from 'echarts';
import { apistatisticoststatisticsinvoice } from '@/api/statistics'
const year = ref(new Date().getFullYear())
const showChart = ref(true)
const customList = reactive([
{
name: "总开票金额",
value: () => {
return baseData.value.total_invoice_amount
},
url: ""
},
{
name: "年度开票金额",
value: () => {
return baseData.value.year_invoice_amount
},
url: ""
},
{
name: "总回款金额",
value: () => {
return baseData.value.total_refund_amount
},
url: ""
},
{
name: "年度回款金额",
value: () => {
return baseData.value.year_refund_amount
},
url: ""
},
{
name: "总结算金额",
value: () => {
return baseData.value.total_settlement_amount
},
url: ""
},
{
name: "年度结算金额",
value: () => {
return baseData.value.year_settlement_amount
},
url: ""
},
])
const labelOption = {
show: true,
rich: {
name: {}
}
};
const initChart = (id, opt) => {
var chartDom = document.getElementById(id);
var myChart = echarts.init(chartDom);
myChart.setOption(opt);
}
const baseData = ref({})
const getCustom = async () => {
showChart.value = false
let res = await apistatisticoststatisticsinvoice({ year: year.value })
baseData.value = res
showChart.value = true
await nextTick()
var option4 = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: [res.settlement_series.name, res.refund_series.name, res.settlement_series.name]
},
toolbox: {
show: true,
orient: 'vertical',
left: 'right',
top: 'center',
},
xAxis: [
{
type: 'category',
axisTick: { show: false },
data: res.column
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: res.invoice_series.name,
type: 'bar',
barGap: 0,
label: labelOption,
emphasis: {
focus: 'series'
},
data: res.invoice_series.data,
itemStyle: {
normal: {
label: {
}
}
}
},
{
name: res.refund_series.name,
type: 'bar',
label: labelOption,
emphasis: {
focus: 'series'
},
data: res.refund_series.data,
itemStyle: {
normal: {
label: {
}
}
}
},
{
name: res.settlement_series.name,
type: 'bar',
label: labelOption,
emphasis: {
focus: 'series'
},
data: res.settlement_series.data,
itemStyle: {
normal: {
label: {
}
}
}
},
]
};
initChart("ProjectContract", option4)
}
getCustom()
</script>
<style lang="scss" scoped>
.chart {
width: 100%;
height: 300px;
}
.header-btn {
text-align: center;
cursor: pointer;
padding: 0px 10px;
}
.header-btn:active {
background-color: #EDEFFF;
}
</style>