detail.vue 8.37 KB
Newer Older
godwithdh's avatar
godwithdh committed
1 2 3
<style lang="less" scoped>
    #chartMmcolorsale{
        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="chartMmcolorsale"  :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 76 77
        <x-table :cell-bordered="true" style="background-color:#fff;">
            <thead>
                <tr style="background-color: #F7F7F7">
                    <th>日期</th>
                    <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>
                    <td>{{item.nQty || 0}}</td>
                </tr>
            </tbody>
        </x-table>
    </div>
    <div class="noData" v-else>
        <img src="@/assets/noData.jpg" class="_img" alt="">
张锡奇's avatar
张锡奇 committed
78 79 80
    </div> -->
     <div class="Table">
        <customerTable :columns="columns" :list="value" :tableStyle="tableStyle"></customerTable>  
张锡奇's avatar
张锡奇 committed
81
    </div>
张锡奇's avatar
张锡奇 committed
82

张锡奇's avatar
张锡奇 committed
83 84
    <!-- <div ref='chart' :style="{width: '100vw', height: '100vh',display:value.length > 0 ? 'block' : 'none'}"></div>
    <img v-if="value.lenght<= 0" src="@/assets/noData.jpg" class="_img" alt=""> -->
godwithdh's avatar
godwithdh committed
85 86 87 88 89 90
  </div>
</template>

<script>
import Util from '@/libs/util.js';
import { mapState } from 'vuex';
张锡奇's avatar
张锡奇 committed
91
import customerTable from '@/components/Table'
godwithdh's avatar
godwithdh committed
92 93 94 95 96 97 98 99 100 101

export default {
    name: 'chartMmcolorsaleDetail',
    data () {
        return {
            mmcolorsaledeltop:[],
            mmsaledtltop:[],

            value:[],
            title:'',
张锡奇's avatar
张锡奇 committed
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
            columns:[
                {
                    width:'40%',
                    name:'日期',
                    align:'center',
                    field:'sYearMonth'
                },
                {
                    width:'30%',
                    name:'金额',
                    align:'center',
                    field:'nAmount',
                },
                {
                    width:'30%',
                    name:'数量',
                    align:'center',
                    field:'nQty',
                }
            ],
            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
132 133 134
            myChart:null
        }
    },
张锡奇's avatar
张锡奇 committed
135
    components: {
张锡奇's avatar
张锡奇 committed
136
        customerTable
张锡奇's avatar
张锡奇 committed
137
    },
godwithdh's avatar
godwithdh committed
138 139 140 141 142 143 144 145
    async activated(){
        if(this.chartHearData.type == 'mmsaletop'){
            this.title = '产品销售排行';
            await this.getMmsaledtltop();
        }else{
            this.title = '产品颜色销售排行';
            await this.getMmcolorsaledtltop();
        }
张锡奇's avatar
张锡奇 committed
146
        // this.setChart()
godwithdh's avatar
godwithdh committed
147 148 149 150
    },
    computed:{
        ...mapState({
            chartHearData:state => state.app.chartHearData,
张锡奇's avatar
张锡奇 committed
151
            iProjectId:state => state.app.iProjectId
godwithdh's avatar
godwithdh committed
152 153 154
        })
    },
    mounted(){
张锡奇's avatar
张锡奇 committed
155 156 157 158 159 160 161 162
        // this.myChart=this.$echarts.init(this.$refs.chart)
        // window.addEventListener("resize",()=>{
        //     var options=this.myChart.getOption()
        //     options.dataZoom[0].end = document.documentElement.clientWidth > document.documentElement.clientHeight ? 40 : 20
        //     this.myChart.setOption(options);
        //     this.myChart.resize()
        // });
        // console.log(this.iProjectId)
godwithdh's avatar
godwithdh committed
163 164 165 166 167
    },
    methods:{
        async getMmcolorsaledtltop(){
            let result = await this.request('getMmcolorsaledtltop',{
                params:this.chartHearData
张锡奇's avatar
张锡奇 committed
168
            },true,{iProjectId:this.iProjectId})
godwithdh's avatar
godwithdh committed
169
            this.value=typeof result=='object'&&result.length>0&&result||[]
张锡奇's avatar
张锡奇 committed
170
            this.value = this.value.filter(x=>x.nAmount > 0 || x.nQty > 0)
godwithdh's avatar
godwithdh committed
171 172 173 174
        },
        async getMmsaledtltop(){
            let result= await this.request('getMmsaledtltop',{
                params:this.chartHearData
张锡奇's avatar
张锡奇 committed
175
            },true,{iProjectId:this.iProjectId})
godwithdh's avatar
godwithdh committed
176
            this.value=typeof result=='object'&&result.length>0&&result||[]
张锡奇's avatar
张锡奇 committed
177
            this.value = this.value.filter(x=>x.nAmount > 0 || x.nQty > 0)
godwithdh's avatar
godwithdh committed
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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
        },
        setChart(){
            let options = {
                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%',
                    bottom: '10%',

                    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
                    },
                    {
                        type: 'value',
                        name: '数量',
                        scale:true,
                        axisLabel: {
                            formatter: '¥{value}'
                        }
                    }
                ],
                series: [
                    {
                        name:'金额',
                        type:'bar',
                        data:this.value.map(x => `${x.nAmount}`)
                    },
                    {
                        name:'数量',
                        type:'line',
                        yAxisIndex: 1,
                        data:this.value.map(x => `${x.nQty}`)
                    }
                ],
                dataZoom: [{
                    type: 'inside',
                    show: true, //flase直接隐藏图形
                    xAxisIndex: [0],
                    left: '9%', //滚动条靠左侧的百分比
                    start: 0,//滚动条的起始位置
                    end: 20 //滚动条的截止位置(按比例分割你的柱状图x轴长度)
                }] 
            };
            this.myChart.setOption(options);
            this.myChart.resize()
        }
    }
}
</script>