index.vue 7.16 KB
Newer Older
张锡奇's avatar
张锡奇 committed
1 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
<style lang="less">
    @import url('../../../../styles/common.less');
    #shopVersionFormEmpAna{
        min-height:100%;
        display:flex;
        flex-direction: column;
        background: #DCE9FE;
        .HEADER{

        }
        .CONTENT{
            height:100%;
            // height:1px;
            // flex-grow: 1;
            // overflow-y: scroll;
            // -webkit-overflow-scrolling: touch;
            .iCard{
                height:260px;
                >p{
                    margin:0;
                    height:30px;
                    line-height: 30px;
                    background: linear-gradient(90deg,#708bf6, #2d8cf0, #00B2EE);
                    color: #fff;
                    text-align: center;
                }
            }
            .iCard:last-child{
                margin-bottom:8px;
            }
        }
        .noData{
            height: calc(100% - 30px);
            width:100%;
            img{
                width: 100%;
                height: 100%;
            }
        }
    }
</style>

<template>
    <div id="shopVersionFormEmpAna">
        <div class="HEADER">
            <searchComponent placeholder="请输入单号/客户进行搜索" :search="search" :typeList="typeList"/>
        </div>
        <div class="CONTENT">
            <div class="iCard" ref="chart1">
                <p>前十名员工(联动)</p>
张锡奇's avatar
张锡奇 committed
51
                <canvas id="chart1" v-if="chartData1.length > 0" width="400" height="260" style="width:100%;height:240px;"></canvas>
张锡奇's avatar
张锡奇 committed
52 53 54 55 56 57
                <div class="noData" v-if="chartData1.length <= 0">
                    <img src="../../../../assets/noData.jpg" class="_img" alt="">
                </div>
            </div>
            <div class="iCard" ref="chart2">
                <p>{{title}}每月回款率</p>
张锡奇's avatar
张锡奇 committed
58
                <canvas id="chart2" v-if="chartData2.length > 0" width="400" height="260" style="width:100%;height:240px;"></canvas>
张锡奇's avatar
张锡奇 committed
59 60 61 62 63 64
                <div class="noData" v-if="chartData2.length <= 0">
                    <img src="../../../../assets/noData.jpg" class="_img" alt="">
                </div>
            </div>
            <div class="iCard" ref="chart3">
                <p>{{title}}按月统计订单金额</p>
张锡奇's avatar
张锡奇 committed
65
                <canvas id="chart3" v-if="chartData3.length > 0" width="400" height="260" style="width:100%;height:240px;"></canvas>
张锡奇's avatar
张锡奇 committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
                <div class="noData" v-if="chartData3.length <= 0">
                    <img src="../../../../assets/noData.jpg" class="_img" alt="">
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import Util from '@/libs/util.js'
import { mapState } from 'vuex'
import searchComponent from '@/components/search'
import { employees } from './mixins/employees'
import { receivable } from './mixins/receivable'
import { orderAmount } from './mixins/orderAmount'

export default {
    name: 'shopVersionFormEmpAna',
    mixins: [employees,receivable,orderAmount],
    data () {
        return {
            search:{
张锡奇's avatar
张锡奇 committed
88
                dBeginDate:Util.dateFormat(new Date(),'yyyy-MM-01'),
张锡奇's avatar
张锡奇 committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 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 133 134 135 136 137 138 139 140 141 142 143 144 145
                dEndDate:Util.dateFormat(new Date(),'yyyy-MM-dd')
            },
            typeList:{time:true},
            direction:'vertical',
            tempChartData2:[],
            tempChartData3:[],
            title:''
        }
    },
    computed:{
        ...mapState({
            iProjectId:state => state.app.iProjectId,
        })
    },
    async mounted(){
        this.$store.dispatch('saveUserId',this.$route.params.userId);
        window.addEventListener("resize",()=>{
            setTimeout(async ()=>{
                this.renderResize();
                if(this.chartData1.length > 0){
                    this.chart1.changeSize(this.$refs['chart1'].offsetWidth); // 清除
                    this.chart1.destroy();
                }
                if(this.chartData2.length > 0){
                    this.chart2.changeSize(this.$refs['chart2'].offsetWidth); // 清除
                    this.chart2.destroy();
                }
                if(this.chartData3.length > 0){
                    this.chart3.changeSize(this.$refs['chart3'].offsetWidth); // 清除
                    this.chart3.destroy();
                }

                if(this.chartData1.length > 0){
                    await this.renderChart1();
                }
                if(this.chartData2.length > 0){
                    await this.renderChart2();
                }
                if(this.chartData3.length > 0){
                    await this.renderChart3();
                }
            })
        });
        
        this.$nextTick(async ()=>{
            this.renderResize();
            await this.getData();
            if(this.chartData1.length > 0){
                await this.renderChart1();
            }
            if(this.chartData2.length > 0){
                await this.renderChart2();
            }
            if(this.chartData3.length > 0){
                await this.renderChart3();
            }
        })
张锡奇's avatar
张锡奇 committed
146

张锡奇's avatar
张锡奇 committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
        window.d = this;
        this.global.$off('searchData');
        //查询条件触发加载
        this.global.$on('searchData',async ()=>{
            this.chartData1 = [];
            this.chartData2 = [];
            this.chartData3 = [];
            if(this.chartData1.length > 0){
                await this.chart1.destroy();
            }
            if(this.chartData2.length > 0){
                await this.chart2.destroy();
            }
            if(this.chartData3.length > 0){
                await this.chart3.destroy();
            }

            await this.getData();
            // this.chart1.changeData(this.chartData1)

            if(this.chartData1.length > 0){
                await this.renderChart1();
            }
            if(this.chartData2.length > 0){
                await this.renderChart2();
            }
            if(this.chartData3.length > 0){
                await this.renderChart3();
            }
        });
张锡奇's avatar
张锡奇 committed
177 178 179
    },
    async activated(){
        
张锡奇's avatar
张锡奇 committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
    },
    methods:{
        renderResize() {
            // 判断横竖屏
            let width = document.documentElement.clientWidth;
            let height = document.documentElement.clientHeight;
            if(width > height) {
                this.direction = 'cross';
            }else{
                this.direction = 'vertical';
            }
        },
        async getData(){
            let data = Util.deepClone(this.search);
            let res = await this.request('getCipSalesinfo',{
                data:{
                    dStartDate:data.dBeginDate,
                    dEndDate:data.dEndDate
                },
                params:{},
            },'加载中',{iProjectId:this.iProjectId})
            this.chartData1 = res.set1;
            if(this.chartData1.length > 0){
                this.title = res.set1[0].sSalesName;

                this.tempChartData2 = Util.deepClone(res.set2);
                this.tempChartData3 = Util.deepClone(res.set3);

                this.chartData2 = res.set2.filter(x=>x.iSalesId == this.chartData1[0].iSalesId);
                this.chartData3 = res.set3.filter(x=>x.iSalesId == this.chartData1[0].iSalesId);
            }
        },
    },
    components:{
        searchComponent
    },
}
</script>