113 lines
2.4 KiB
Vue
113 lines
2.4 KiB
Vue
![]() |
<template>
|
||
|
<el-card style="width: 49.9%;">
|
||
|
<template #header>
|
||
|
<div class="card-header">
|
||
|
<span>采购合同</span>
|
||
|
</div>
|
||
|
</template>
|
||
|
<div style="display: flex;justify-content: space-around;">
|
||
|
<div v-for=" item in customList" :key="item" style="text-align: center;">
|
||
|
<div>{{ item.value }}</div>
|
||
|
<div>{{ item.name }}</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div id="PurchaseContracts" class="chart"></div>
|
||
|
</el-card>
|
||
|
</template>
|
||
|
<script setup>
|
||
|
import * as echarts from 'echarts';
|
||
|
import { apistatisticsprocurementContract } from '@/api/statistics'
|
||
|
|
||
|
const customList = reactive([
|
||
|
{
|
||
|
name: "客户总数",
|
||
|
value: 3
|
||
|
},
|
||
|
{
|
||
|
name: "今年增加",
|
||
|
value: 3
|
||
|
},
|
||
|
{
|
||
|
name: "今年增加",
|
||
|
value: 3
|
||
|
}
|
||
|
])
|
||
|
|
||
|
const labelOption = {
|
||
|
show: true,
|
||
|
rich: {
|
||
|
name: {}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
const initChart = (id, opt) => {
|
||
|
var chartDom = document.getElementById(id);
|
||
|
var myChart = echarts.init(chartDom);
|
||
|
myChart.setOption(opt);
|
||
|
}
|
||
|
|
||
|
const setHistogramOption = (legend, xAxisData, series) => {
|
||
|
return {
|
||
|
tooltip: {
|
||
|
trigger: 'axis',
|
||
|
axisPointer: {
|
||
|
type: 'shadow'
|
||
|
}
|
||
|
},
|
||
|
|
||
|
legend,
|
||
|
toolbox: {
|
||
|
show: true,
|
||
|
orient: 'vertical',
|
||
|
left: 'right',
|
||
|
top: 'center',
|
||
|
},
|
||
|
xAxis: [
|
||
|
{
|
||
|
type: 'category',
|
||
|
axisTick: { show: false },
|
||
|
data: xAxisData
|
||
|
}
|
||
|
],
|
||
|
yAxis: [
|
||
|
{
|
||
|
type: 'value'
|
||
|
}
|
||
|
],
|
||
|
series
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
const getCustom = async () => {
|
||
|
let res = await apistatisticsprocurementContract()
|
||
|
initChart("PurchaseContracts", setHistogramOption({ data: [res.series.name] }, res.column
|
||
|
, [{
|
||
|
name: res.series.name,
|
||
|
type: 'bar',
|
||
|
barGap: 0,
|
||
|
label: labelOption,
|
||
|
emphasis: {
|
||
|
focus: 'series'
|
||
|
},
|
||
|
data: res.series.data
|
||
|
},]))
|
||
|
customList[0].value = res.custom_total
|
||
|
customList[1].value = res.this_year_add
|
||
|
}
|
||
|
|
||
|
getCustom()
|
||
|
</script>
|
||
|
<style lang="scss" scoped>
|
||
|
#main,
|
||
|
#main2,
|
||
|
#main3 {
|
||
|
width: 100%;
|
||
|
height: 300px;
|
||
|
}
|
||
|
|
||
|
.chart {
|
||
|
width: 100%;
|
||
|
height: 300px;
|
||
|
}
|
||
|
</style>
|