| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <template>
- <div class="div-new-box-new" >
- <div class="content-new-content">
- <div class="div-line"></div>
- <div class="title"> 开票金额趋势分析</div>
- <div style="float: right">
- <departmentSalesperson ref="departmentSalesperson" class="inline-16" @depSelect="depSelect" @personSelect="personSelect"></departmentSalesperson>
- <span class="search__label inline-16">年度:</span>
- <el-date-picker
- v-model="yearNow"
- @change="changeDate"
- :picker-options="pickerOptions"
- :clearable="false"
- type="year"
- size="small"
- placeholder="选择年">
- </el-date-picker>
- </div>
- </div>
- <div class="chart">
- <div id="invoiceAmountAnalysisChart" style="height: 300px;"></div>
- </div>
- </div>
- </template>
- <script>
- import departmentSalesperson from "@/views/salesData/components/departmentSalesperson";
- import { DualAxes } from '@antv/g2plot';
- export default {
- name: "invoiceAmountAnalysis",
- props:['dataid'],
- components:{departmentSalesperson},
- data(){
- return {
- pickerOptions: {
- disabledDate(time){
- // 获取当前时间
- const today = new Date();
- // 比较日期,将未来的年份禁用
- return time.getFullYear() > today.getFullYear();
- }
- },
- chartDualAxes:null,
- param:{
- "id": 20231016095304,
- "content": {
- "type": 0,
- "dataid": 54,
- "year": "2023"
- }
- },
- yearNow:new Date(),
- list:[],
- list1:[],
- }
- },
- methods:{
- async listData(val){
- this.renderPie(val)
- },
- async queryModel(val){
- this.param.content.dataid = val || this.dataid
- this.param.content.year = new Date(this.yearNow).getFullYear()
- const res = await this.$api.requested(this.param)
- let amount = res.data.map(item=>{
- return {
- "value":Math.round(((item.amount)*100)/100),
- "date":item.date,
- "type":'本期金额'
- }
- })
- let oldamount = res.data.map(item=>{
- return {
- "date":item.date,
- "value":Math.round(((item.oldamount)*100)/100),
- "type":'去年同期金额'
- }
- })
- this.list = amount.concat(oldamount)
- this.list1 = res.data.map(item=>{
- return {
- "date":item.date,
- "tbzzl":Math.round(((item.tbzzl * 100)*100)/100)
- }
- })
- this.chartDualAxes.changeData([this.list,this.list1])
- },
- renderPie(val){
- this.chartDualAxes = new DualAxes('invoiceAmountAnalysisChart', {
- data: [this.list,this.list1],
- xField: 'date',
- yField: ['value','tbzzl'],
- meta:{
- tbzzl:{
- alias:'同比增长率(%)'
- }
- },
- geometryOptions: [
- {
- geometry: 'column',
- isGroup: true,
- seriesField: 'type',
- },
- {
- geometry: 'line',
- lineStyle: {
- lineWidth: 2,
- },
- },
- ],
- tooltip: {
- fields: ['type','tbzzl', 'value'],
- formatter: (datum) => {
- return {
- name:datum.type === undefined?'同比增长率(%)':datum.type,
- value:datum.value === undefined?datum.tbzzl:'¥' + this.tool.formatAmount(datum.value,2)
- }
- }
- }
- });
- this.chartDualAxes.render();
- this.queryModel(val)
- },
- changeDate(){
- this.queryModel(this.param.content.dataid)
- },
- /*选择部门*/
- depSelect(val){
- this.param.content.type = 1
- this.param.content.dataid = val
- this.queryModel(val)
- },
- /*选择业务员*/
- personSelect(val){
- this.param.content.type = 0
- this.param.content.dataid = val
- this.queryModel(val)
- }
- }
- }
- </script>
- <style scoped>
- </style>
|