detail.vue 7.42 KB
Newer Older
godwithdh's avatar
godwithdh committed
1 2 3
<style lang="less" scoped>
    #chartCustomDetail{
        font-size:12px;
张锡奇's avatar
张锡奇 committed
4
        height:100%;
张锡奇's avatar
张锡奇 committed
5 6 7 8 9 10 11
        display:flex;
        flex-direction: column;
        .Table{
            flex-grow: 1;
            height:1px;
            overflow: auto;
        }
godwithdh's avatar
godwithdh committed
12 13
        h2{
            text-align: center;
张锡奇's avatar
张锡奇 committed
14 15 16 17 18
            height:40px;
            line-height: 40px;
            background: #19be6b;
            color:white;
            width:100%;
godwithdh's avatar
godwithdh committed
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
        }
        .center{
            text-align: center;
        }
        /deep/ .weui-cells{
            margin-top:0;
        }
        /deep/ .vux-datetime{
            div>p{
                margin-bottom: 0;
            }
        }
        /deep/ .weui-cell_access{
            padding-right: 10px;
        }
        /deep/ .weui-cell_access .weui-cell__ft:after{
            height: 10px;
            width: 10px;
            margin-top: -4px;
            right: 0;
        }
        /deep/ .weui-dialog{
            max-width:60px;
        }
        img{
            width:100%;
        }
张锡奇's avatar
张锡奇 committed
46 47 48 49 50 51
        .vux_table{
            margin-top:40px;
        }
        .noData{
            margin-top:120px;
        }
godwithdh's avatar
godwithdh committed
52 53 54 55
    }
</style>

<template>
张锡奇's avatar
张锡奇 committed
56
  <div id="chartCustomDetail" :style="value.length <= 0 ? 'background:white;' : ''">
godwithdh's avatar
godwithdh committed
57
    <h2>{{title}}</h2>
张锡奇's avatar
张锡奇 committed
58
    <!-- <div class="vux_table" v-if="value.length > 0">
张锡奇's avatar
张锡奇 committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        <x-table :cell-bordered="true" style="background-color:#fff;">
            <thead>
                <tr style="background-color: #F7F7F7">
                    <th>日期</th>
                    <th>金额</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="(item,index) in value" :key="index">
                    <td>{{item.sYearMonth}}</td>
                    <td>{{item.nAmount || 0}}</td>
                </tr>
            </tbody>
        </x-table>
    </div>
    <div class="noData" v-else>
        <img src="@/assets/noData.jpg" class="_img" alt="">
张锡奇's avatar
张锡奇 committed
76
    </div> -->
张锡奇's avatar
张锡奇 committed
77 78
    <!-- <div ref='chart' :style="{width: '100vw', height: '100vh',display:value.length> 0 ? 'block' : 'none'}"></div>
    <img v-if="value.length<= 0" src="@/assets/noData.jpg" class="_img" alt=""> -->
张锡奇's avatar
张锡奇 committed
79 80 81
    <div class="Table">
        <customerTable :columns="columns" :list="value" :tableStyle="tableStyle"></customerTable>  
    </div>
godwithdh's avatar
godwithdh committed
82 83 84 85 86 87
  </div>
</template>

<script>
import Util from '@/libs/util.js'
import { mapState } from 'vuex';
张锡奇's avatar
张锡奇 committed
88
import customerTable from '@/components/Table'
godwithdh's avatar
godwithdh committed
89 90 91 92 93 94

export default {
    name: 'chartCustomDetail',
    data () {
        return {
            value:[],
张锡奇's avatar
张锡奇 committed
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
            title:'',
            columns:[
                {
                    width:'50%',
                    name:'日期',
                    align:'center',
                    field:'sYearMonth'
                },
                {
                    width:'50%',
                    name:'金额',
                    align:'center',
                    field:'nAmount',
                }
            ],
            tableStyle:{
                theadBgColor:'rgba(223,238,253,1)',
                complexTrBgColor:'white',
                singleTrBgColor:'#eef4fe',
                theadTdBorder:false,
                tbodyTdBorder:false,
                tbodyHeight:'calc(100vh)',
                tbodyTrBorderBottom:'1px solid #dbe9f8',
                width:'100%'
            },
godwithdh's avatar
godwithdh committed
120 121 122 123 124 125 126 127 128 129
        }
    },
    async activated(){
        if(this.chartHearData.type == 'pbcustomer'){
            this.title = '客户';
            await this.getPbcustomerDtl();
        }else{
            this.title = '销售员';
            await this.getPbsalesDtl();
        }
张锡奇's avatar
张锡奇 committed
130
        // this.setChart()
godwithdh's avatar
godwithdh committed
131 132 133 134
    },
    computed:{
        ...mapState({
            chartHearData:state => state.app.chartHearData,
张锡奇's avatar
张锡奇 committed
135
            iProjectId:state => state.app.iProjectId
godwithdh's avatar
godwithdh committed
136 137 138
        })
    },
    mounted(){
张锡奇's avatar
张锡奇 committed
139 140 141 142 143 144 145
        // this.myChart=this.$echarts.init(this.$refs.chart)
        // window.addEventListener("resize",()=>{
        //     this.myChart.resize()
        //     var options=this.myChart.getOption()
        //     options.dataZoom[0].end = document.documentElement.clientWidth > document.documentElement.clientHeight ? 40 : 20
        //     this.myChart.setOption(options);
        // });
godwithdh's avatar
godwithdh committed
146 147 148 149 150
    },
    methods:{
        async getPbcustomerDtl(){
            let result = await this.request('getPbcustomerDtl',{
                params:this.chartHearData
张锡奇's avatar
张锡奇 committed
151
            },true,{iProjectId:this.iProjectId})
godwithdh's avatar
godwithdh committed
152
            this.value=typeof result=='object'&&result.length>0&&result||[]
张锡奇's avatar
张锡奇 committed
153
            this.value = this.value.filter(x=>x.nAmount > 0)
godwithdh's avatar
godwithdh committed
154 155 156 157
        },
        async getPbsalesDtl(){
            let result= await this.request('getPbsalesDtl',{
                params:this.chartHearData
张锡奇's avatar
张锡奇 committed
158
            },true,{iProjectId:this.iProjectId})
godwithdh's avatar
godwithdh committed
159
            this.value=typeof result=='object'&&result.length>0&&result||[]
张锡奇's avatar
张锡奇 committed
160 161

            this.value = this.value.filter(x=>x.nAmount > 0)
godwithdh's avatar
godwithdh committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
        },
        setChart(){
            let options = {
                color:['#5CADFF'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: '#999'
                        }
                    }
                },
                toolbox: {
                    feature: {
                        // dataView: {show: true, readOnly: false},
                        magicType: {show: true, type: ['line', 'bar']},
                        restore: {show: true},
                        // saveAsImage: {show: true}
                    },

                },
                grid: {
                    left: '3%',   // 与容器左侧的距离
                    right: '3%', // 与容器右侧的距离
                    containLabel: true
                },
                legend: {
                    data:['金额'],
                    x: 'left'
                },
                xAxis: [
                    {
                        type: 'category',
                        data: this.value.map(x => `${x.sYearMonth}`) ,
                        axisPointer: {
                            type: 'shadow'
                        },
                        axisTick: {
                            alignWithLabel: true
                        },
                        axisLabel: {
                            interval:0 
                        }
                    },
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '金额',
                        axisLabel: {
                            formatter: '¥{value}'
                        },
                        scale:true
                    }
                ],
                series: [
                    {
                        name:'金额',
                        type:'bar',
                        data: this.value.map(x => `${x.nAmount||0}`) ,
                    }
                ],
                dataZoom: [{
                    type: 'inside',
                    show: true, //flase直接隐藏图形
                    xAxisIndex: [0],
                    left: '9%', //滚动条靠左侧的百分比
                    start: 0,//滚动条的起始位置
                    end: 20 //滚动条的截止位置(按比例分割你的柱状图x轴长度)
                }] 
            };
            this.myChart.setOption(options);
            this.myChart.resize()
        }
张锡奇's avatar
张锡奇 committed
237 238
    },
    components: {
张锡奇's avatar
张锡奇 committed
239
        customerTable
godwithdh's avatar
godwithdh committed
240 241 242 243 244
    }
}
</script>