You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
8.6 KiB

<template>
<div class="p10-outter" v-loading="load">
<v-label-div :title="time+'('+form.sStartTime+'至'+form.sEndTime+')'">
<v-btn @click="onTable">查看图表</v-btn>
</v-label-div>
<div class="d2">
<a-form-model layout="inline">
<a-form-model-item label="开始日期">
<a-month-picker style="width: 160px" v-model="selTime[0]" :allowClear="false" :disabled-date="disabledDate" valueFormat="YYYY-MM" placeholder="请选择开始日期"></a-month-picker>
</a-form-model-item>
<a-form-model-item label="结束日期">
<a-month-picker style="width: 160px" v-model="selTime[1]" :allowClear="false" :disabled-date="disabledDate" valueFormat="YYYY-MM" placeholder="请选择结束日期"></a-month-picker>
</a-form-model-item>
<a-form-model-item>
<a-button @click="onSearch" style="margin-left: 40px" type="primary">查询</a-button>
</a-form-model-item>
</a-form-model>
</div>
<div class="d3">
<v-table ref="rtable" :columns="columns" :data="tbData" :pagination="pagination" @change="handlerPagnation" :loading="tableLoading">
<template slot="about" slot-scope="text, record">
<a-button type="primary" ghost @click="onSale(record)">销量</a-button>
</template>
</v-table>
</div>
<a-modal title="50万以上销量排行榜趋势图(单位:辆)" width="1200px" :footer="null" @cancel="onClose" :visible="visible">
<div class="modal-table">
<a-form-model layout="inline">
<a-form-model-item label="开始日期">
<a-month-picker style="width: 160px" :allowClear="false" v-model="selTime[0]" :disabled-date="disabledDate" valueFormat="YYYY-MM" placeholder="请选择开始日期"></a-month-picker>
</a-form-model-item>
<a-form-model-item label="结束日期">
<a-month-picker style="width: 160px" :allowClear="false" v-model="selTime[1]" :disabled-date="disabledDate" valueFormat="YYYY-MM" placeholder="请选择结束日期"></a-month-picker>
<a-button @click="onSearch" type="primary" style="margin-left: 40px">查询</a-button>
</a-form-model-item>
</a-form-model>
<div class="tb-inner">
<v-echarts :opt="opt"></v-echarts>
</div>
</div>
</a-modal>
</div>
</template>
<script>
import {getCheZhuCarCategory} from "@/api/SaleRank"
import {getCheZhuCountTime} from "@/api/SaleRank"
import {getBrandName} from "@/api/comm"
import createOpt from "./opt"
import moment from "moment";
export default {
name: 'Price50',
data() {
return {
load: false,
time: '50万以上销量排行榜',
selTime: [],
form: {
token: '',
sStartTime: '',
sEndTime: '',
sTimeType: 4,
sPriceType: 6,
iPageIndex: 1,
},
opt: {},
//表格
pagination: {
current: 1,
pageSize: 20,
total: 0,
},
tbData: [],
tableLoading: false,
columns: [
{
title: "排名",
dataIndex: "id",
key: "id",
width: 120
},
{
title: "车型",
dataIndex: "seriesname",
key: "seriesname",
width: 240,
},
{
title: "能源类型",
dataIndex: "energys",
key: "energys",
width: 240,
},
{
title: "销量",
dataIndex: "salescount",
key: "salescount",
width: 240,
},
{
title: "售价(万元)",
dataIndex: "price",
key: "price",
},
{
title: "车型相关",
dataIndex: "about",
key: "about",
scopedSlots: { customRender: "about" },
},
],
//图表
visible: false,
}
},
created() {
this.form.token = this.getToken
this.getData();
},
methods: {
getData() {
this.load = true;
let o = {token: this.getToken};
getCheZhuCountTime(o).then(res => {
let data = res.data;
this.form.sStartTime = data.Data[data.Data.length-1].Time;
this.form.sEndTime = data.Data[data.Data.length-1].Time;
this.selTime[0] = data.Data[data.Data.length-1].Time;
this.selTime[1] = data.Data[data.Data.length-1].Time;
this.dDate = data.Data[data.Data.length-1].Time;
let obj = {
token: this.getToken,
sTimeType: 4,
sStartTime: this.form.sStartTime,
sEndTime: this.form.sEndTime,
sPriceType: 6
}
getCheZhuCarCategory(obj).then(res => {
this.pagination.total = res.totalNum
let data = res.data;
this.tbData = data;
let dx = [];
let ds = [];
data.forEach(ele => {
dx.push(ele.seriesname);
ds.push(ele.salescount);
})
this.opt = createOpt(dx,ds);
});
this.load = false
});
},
//改变页面数据
handlerPagnation(page) {
this.tableLoad = true;
let cur = page.current;
this.pagination.current = cur;
this.form.iPageIndex = cur;
getCheZhuCarCategory(this.form).then(res => {
let data = res.data;
this.pagination.total = res.totalNum
this.tbData = data;
let dx = [];
let ds = [];
data.forEach(ele => {
dx.push(ele.seriesname);
ds.push(ele.salescount);
})
this.opt = createOpt(dx,ds);
this.tableLoad = false
})
},
//查询
onSearch() {
this.form.sStartTime = this.selTime[0];
this.form.sEndTime = this.selTime[1];
let obj = Object.assign({},this.form);
getCheZhuCarCategory(obj).then(res => {
let data = res.data;
this.tbData = data;
let dx = [];
let ds = [];
data.forEach(ele => {
dx.push(ele.seriesname);
ds.push(ele.salescount);
})
this.opt = createOpt(dx,ds);
})
},
//查看图表
onTable() {
this.visible = true;
},
onClose() {
this.visible = false;
},
//返回
goBack() {
this.$router.go(-1);
},
disabledDate(current) {
return (current > moment(this.dDate)) && moment(this.dDate);
},
//点击销量
onSale(value) {
let seriesname = value.seriesname;
getBrandName({token: this.getToken, sSeriesName:seriesname}).then(res => {
let brandName = res.data;
this.$router.push(
{
path: '/saleRank/seriesInfo',
query: {
sBrand: brandName,
sSeriesName: seriesname
}
}
);
})
}
}
}
</script>
<style lang="less">
.p10-outter {
width: 1552px;
border: 2px solid #0f2a4d;
.d2 {
display: flex;
justify-content: flex-start;
padding: 16px;
}
}
.modal-table {
width: 1400px;
height: 460px;
.tb-inner {
width: 100%;
height: calc(100% - 48px);
margin-top: 24px;
}
}
</style>