税务预检使用情况

This commit is contained in:
ZZM 2025-06-27 16:54:57 +08:00
parent 7685ea7f60
commit 1104ee84c3
1 changed files with 297 additions and 0 deletions

View File

@ -0,0 +1,297 @@
<template>
<div v-loading="loading" class="sale-statistics card">
<flexbox class="card-title">
<span class="icon wk wk-target" />
<div class="card-title-center text-one-ellipsis">税务预检使用情况</div>
<div class="card-title-right">
<!--<span class="box">{{ filterText }}</span>
<span class="box">{{ timeLine }}</span>-->
<el-dropdown trigger="click" @command="handleCommand">
<span class="box">
{{ optionName }}<i class="el-icon-arrow-down el-icon--right" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(item, index) in options" :key="index" :command="index">
{{ item.name }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</flexbox>
<div id="tax-statistics" />
</div>
</template>
<script>
import { crmTaxPreCheckUsageAPI } from '@/api/crm/workbench'
import echarts from 'echarts'
import ChartMixin from './ChartMixin'
import { mapGetters } from 'vuex'
export default {
name: 'TaxPreCheckUsage',
mixins: [ChartMixin],
data() {
return {
options: [
{ name: '显示全部', value: 0 },
{ name: '使用人数', value: 1 },
{ name: '活跃人数', value: 2 },
{ name: '新增用户', value: 3 },
{ name: '新增企业', value: 4 }
],
optionName: '显示全部',
optionValue: 0,
chartOption: {
color: ['#5470c6', '#91cc75', '#fac858'], //
tooltip: {
trigger: 'axis',
axisPointer: {
//
type: 'shadow' // 线'line' | 'shadow'
}
},
grid: {
top: '46px',
left: '20px',
right: '20px',
bottom: '10px',
containLabel: true,
borderColor: '#fff'
},
xAxis: [
{
type: 'category',
data: [],
axisTick: {
alignWithLabel: true,
lineStyle: { width: 0 }
},
axisLabel: {
color: '#333'
},
/** 坐标轴轴线相关设置 */
axisLine: {
lineStyle: { color: '#BDBDBD' }
},
splitLine: {
show: false
}
}
],
yAxis: [
{
type: 'value',
minInterval: 1, // 1
axisTick: {
alignWithLabel: true,
lineStyle: { width: 0 }
},
/** 坐标轴轴线相关设置 */
axisLine: {
lineStyle: { width: 0 }
},
splitLine: {
lineStyle: {
color: '#eee',
type: 'dotted'
}
}
}
],
series: []
},
chartObj: null,
loading: false
}
},
computed: {
...mapGetters(['manage']),
//
hasSetAuth() {
return this.manage && this.manage.crm && this.manage.crm.achievement
}
},
mounted() {
this.initChart()
// optionValue
this.getData()
},
methods: {
initChart() {
this.chartObj = echarts.init(document.getElementById('tax-statistics'))
this.chartObj.setOption(this.chartOption, true)
},
/**
* 下拉菜单选项选择
* @param index 选项序号
*/
handleCommand(index) {
if (this.optionValue === this.options[index].value) return
this.optionName = this.options[index].name
this.optionValue = this.options[index].value
this.getData()
},
getData() {
this.loading = true
crmTaxPreCheckUsageAPI({
label: this.optionValue,
...this.getBaseParams()
}).then(res => {
// API
this.processChartData(res.data)
this.loading = false
}).catch(() => {
this.loading = false
})
},
//
processChartData(data) {
// "" (optionValue = 0)
if (this.optionValue === 0) {
// - 线
this.renderAllData(data)
} else {
// -
this.renderSingleData(data)
}
},
//
renderSingleData(data) {
const list = data.list || []
const showNum = []
const xAxisData = []
list.forEach(element => {
showNum.push(element.value)
xAxisData.push(element.type)
})
//
this.chartOption.xAxis[0].data = xAxisData
this.chartOption.series = [{
name: this.optionName,
type: 'bar',
barWidth: '60%',
data: showNum
}]
//
this.chartObj.setOption(this.chartOption, true)
},
// 线
renderAllData(data) {
//
const metrics = [
{ name: '使用人数', field: 'syyhs' },
{ name: '活跃人数', field: 'hyyhs' },
{ name: '新增用户', field: 'addUser' },
{ name: '新增企业', field: 'addQys' }
]
//
const categories = []
const seriesData = []
//
data.list.forEach(item => {
categories.push(item.type)
})
//
metrics.forEach(metric => {
const values = []
//
data.list.forEach(item => {
const value = item.value ? item.value[metric.field] : 0
values.push(value)
})
//
seriesData.push({
name: metric.name,
data: values
})
})
// - 线
const colors = ['#5470c6', '#91cc75', '#fac858', '#ee6666']
// ()
const series = seriesData.map((item, index) => ({
name: item.name,
type: 'line', // 线
data: item.data,
symbol: 'circle',
symbolSize: 6,
lineStyle: { width: 2 },
itemStyle: { color: colors[index] } // 线
}))
//
const option = {
color: colors,
tooltip: {
trigger: 'axis',
axisPointer: { type: 'line' } // 线使线
},
grid: {
top: '70px', //
left: '20px',
right: '20px',
bottom: '10px',
containLabel: true
},
legend: {
data: seriesData.map(item => item.name), //
top: 10 //
},
xAxis: [{
type: 'category',
data: categories,
axisTick: {
alignWithLabel: true,
lineStyle: { width: 0 }
},
axisLabel: {
color: '#333',
rotate: 45, // 45
interval: 0 //
},
axisLine: {
lineStyle: { color: '#BDBDBD' }
}
}],
yAxis: [{
type: 'value',
minInterval: 1, // Y
axisLabel: {
formatter: value => Math.floor(value) === value ? value : Math.round(value)
},
axisTick: {
lineStyle: { width: 0 }
},
axisLine: {
lineStyle: { width: 0 }
},
splitLine: {
lineStyle: {
color: '#eee',
type: 'dotted'
}
}
}],
series
}
//
this.chartObj.setOption(option, true)
}
}
}
</script>
<style scoped lang="scss">
@import "style";
#tax-statistics {
width: 100%;
height: 300px;
}
</style>