Repayment.vue 6.94 KB
Newer Older
godwithdh's avatar
godwithdh committed
1
<style lang="less">
godwithdh's avatar
godwithdh committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    @import url("../../../styles/common.less");
    #repayment{
        .head{
            display:flex;
            >div{
                flex-grow:1;
                display: flex;
                flex-direction: column;
                align-items:center;
                color:#fff;
                >span{
                    margin-top:6px;
                }
            }
        }
        .noData{
            position:absolute;
            top:0;
            height: calc(100% - 30px);
            width:100%;
            img{
                width: 100%;
                height: 100%;
            }
        }
        .DATA{
            width:100%;
            >tr:first-child{
                font-weight: bold;
                text-align: center;
                background:#f2f2f2;
            }
            >tr{
                >td{
godwithdh's avatar
godwithdh committed
36
                    padding:5px 3px;
godwithdh's avatar
godwithdh committed
37 38 39 40 41 42 43 44
                }
                >td:not(:first-child){
                    border-left:1px solid #ddd;
                }
                &:not(:last-child)>td{
                    border-bottom:1px solid #ddd;
                }
            }
godwithdh's avatar
godwithdh committed
45
            // >tr:nth-child(2n)>td{ background:#00C4FF;color:#fff; }
godwithdh's avatar
godwithdh committed
46 47
        }
    }
godwithdh's avatar
godwithdh committed
48 49 50
</style>
<template>
    <div id="repayment">
godwithdh's avatar
godwithdh committed
51
        <dateMonth @month="searchData"/>
godwithdh's avatar
godwithdh committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
        <div class="iCard">
            <div class="head">
                <div style="background:#3BA5EF">
                    <span>年度回款目标</span>
                    <span>{{number(value1["年度回款目标"])}}</span>
                </div>
                <div style="background:#6480ED">
                    <span>年度回款金额</span>
                    <span>{{number(value1["年度回款金额"])}}</span>
                </div>
                <div style="background:#3BA5EF">
                    <span>年度完成比</span>
                    <span>{{parent}}%</span>
                </div>
            </div>
            <div class="content" style="position:relative;">
                <div ref="chart" :style='{width:"100%",height:"240px",overflow:"hidden"}' />
                <div class="noData" v-if="value2.length <= 0">
                    <img src="@/assets/noData.jpg" alt="">
                </div>
            </div>
        </div>
        <div class="iCard" style="margin-bottom:8px;">
            <div style="color: #fff;background: #009BDE;padding: 10px;display: flex;justify-content: space-between;">
                <span>{{new Date().getFullYear()}}年各客户回款达成率</span>
                <span>单位:(万元)</span>
            </div>
            <table class="DATA">
                <tr>
godwithdh's avatar
godwithdh committed
81
                    <td>序号</td>
godwithdh's avatar
godwithdh committed
82 83 84 85 86 87 88 89 90 91 92 93
                    <td>回款目标</td>
                    <td>回款金额</td>
                    <td>客户</td>
                </tr>
                <tr v-for="(v,k) in value3" :key="k">
                   <td>{{v.iIden}}</td>
                   <td>{{v['回款目标']}}</td>
                   <td>{{v["回款金额"]}}</td>
                   <td>{{v["客户"]}}</td> 
                </tr>
            </table>
        </div>
godwithdh's avatar
godwithdh committed
94 95 96
    </div>
</template>
<script>
godwithdh's avatar
godwithdh committed
97 98
import Util from '@/libs/util.js'
import { Confirm } from 'vux'
godwithdh's avatar
godwithdh committed
99
import dateMonth from '@/components/dateMonth'
godwithdh's avatar
godwithdh committed
100 101
import { setTimeout } from 'timers';

godwithdh's avatar
godwithdh committed
102 103
export default {
    name:"repayment",
godwithdh's avatar
godwithdh committed
104
    components:{dateMonth},
godwithdh's avatar
godwithdh committed
105 106
    data(){
        return{
godwithdh's avatar
godwithdh committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
            value1:{},
            value2:[],
            option:{
                dataZoom: {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'empty'
                },
                tooltip:{
                    trigger: 'axis'
                },
                legend: {
                    data:['回款金额','回款目标'],
                    right:0,
                },
                grid:{
                    top:"13%",
                    left:"10",
                    bottom:"10",
                    right:10,
                    containLabel: true,
                },
                calculable : true,
            },
            chart:null,
            value3:[],
godwithdh's avatar
godwithdh committed
133 134
        }
    },
godwithdh's avatar
godwithdh committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    mounted(){
        window.req=this

        window.addEventListener("resize",()=>{
            setTimeout(async ()=>{
                if(this.value2.length>0){
                    this.chart.resize()
                }
            })
        })
        this.$nextTick(async ()=>{
            this.chart=this.$echarts.init(this.$refs.chart)
        })
    },
    methods:{
        number(val){
            return (Math.round((val||0)*100)/100).toLocaleString()
        },
godwithdh's avatar
godwithdh committed
153 154 155 156
        async searchData(start,end){
            this.value2=[]
            this.value3=[]

godwithdh's avatar
godwithdh committed
157 158
            var value=await this.request("getTiipReceive",{
                data:{
godwithdh's avatar
godwithdh committed
159 160
                    dStartDate:start,
                    dEndDate:end
godwithdh's avatar
godwithdh committed
161 162 163 164 165
                }
            },"加载中",{})
            value.set1[0]&&(this.value1=value.set1[0])
            this.value2=value.set2||[]
            this.value3=value.set3||[]
godwithdh's avatar
godwithdh committed
166
            var isOver=0
godwithdh's avatar
godwithdh committed
167
            this.value2.forEach(v=>{
godwithdh's avatar
godwithdh committed
168 169 170 171 172 173 174 175
                if(Math.abs(v["回款金额"])>10000||Math.abs(v["回款目标"])>10000){
                    isOver=isOver<=1?1:isOver
                }
                if(Math.abs(v["回款金额"])>100000||Math.abs(v["回款目标"])>100000){
                    isOver=isOver<=2?2:isOver
                }
                if(Math.abs(v["回款金额"])>1000000||Math.abs(v["回款目标"])>1000000){
                    isOver=3
godwithdh's avatar
godwithdh committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
                }
            })

            this.chart.setOption(Object.assign({
                xAxis:{
                    type:'category',
                    data:this.value2.map((v,i)=>v["销售员"]),
                    axisLabel:{
                        interval:0,
                        rotate:-15,
                    },
                },
                yAxis :{
                    type : 'value',
                    boundaryGap: [0, 0.01],
godwithdh's avatar
godwithdh committed
191
                    name:isOver?`(${String(isOver).replace('2','十').replace('3','百')}万元)`:'',
godwithdh's avatar
godwithdh committed
192 193
                    axisLabel:{
                        formatter(v){
godwithdh's avatar
godwithdh committed
194
                            return isOver?Math.round(v/(isOver==1?100:(isOver==2?1000:10000)))/100:v;
godwithdh's avatar
godwithdh committed
195 196 197 198 199 200 201
                        }
                    },
                },
                series:[ {
                    name:'回款金额',
                    type:'bar',
                    data:this.value2.map(v=>v["回款金额"]),
godwithdh's avatar
godwithdh committed
202 203 204
                    itemStyle:{
                        color:"#1F12F7"
                    }
godwithdh's avatar
godwithdh committed
205 206 207 208 209
                },
                {
                    name:'回款目标',
                    type:'bar',
                    data:this.value2.map(v=>v["回款目标"]),
godwithdh's avatar
godwithdh committed
210 211 212
                    itemStyle:{
                        color:"#3BA5EF"
                    }
godwithdh's avatar
godwithdh committed
213 214 215 216 217 218 219 220 221
                } ]
            },this.option))
        },
    },
    computed:{
        parent(){
            return Math.round(this.value1["年度完成比"]*100)/100
        },
    },
godwithdh's avatar
godwithdh committed
222 223
}
</script>