Commit 16a04866 by 胡悦

Merge branch 'dev_v1.0.0' of http://192.168.3.233:8090/gh/data-view into dev_v1.0.0

2 parents aa6e8fa7 ae0b391d
......@@ -3,7 +3,7 @@
<div id="line-chart" class="line-chart"></div>
<div class="rank-box">
<div class="rank-title-block">
<p :class="[ 'rank-title', rankFlag == 'first' ? 'rank-title-active' : '' ]" @click="handleRankChange('first')">前5{{ storeOrBrandTxt }}</p>
<p :class="[ 'rank-title', rankFlag == 'top' ? 'rank-title-active' : '' ]" @click="handleRankChange('top')">前5{{ storeOrBrandTxt }}</p>
<p :class="[ 'rank-title', rankFlag == 'last' ? 'rank-title-active' : '' ]" @click="handleRankChange('last')">后5{{ storeOrBrandTxt }}</p>
</div>
<div class="rank-block">
......@@ -23,15 +23,11 @@ import getLineOptions from './lineOptions'
export default {
name: 'LineChart',
props: {
apiName: {
type: String,
default: ''
},
storeOrBrandTxt: {
type: String,
default: '门店'
},
rankList: {
dataList: {
type: Array,
default: () => []
}
......@@ -41,13 +37,10 @@ export default {
return {
directionTimer: datas.DefaultData.directionTimer,
delayTimer: datas.DefaultData.delayTimer,
rankFlag: 'first',
rankFlag: 'top',
lineOptions: [],
xAxisLabel: {
monthList: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
},
rankList: [],
echartsLine: '',
dataList: [1, 2, 3, 10, 5, 2, 7, 8, 9, 10, 11, 12],
moveAttr: {
speed: 900,
seriesIndex: 0,
......@@ -65,18 +58,18 @@ export default {
this.lineDom = document.getElementById('line-chart')
this.echartsLine = echarts.init(this.lineDom)
this.chartBindEvent()
},
this.drawLine()
watch: {
dataList() {
this.drawLine()
}
},
methods: {
dealxAxisLabel() {
this.lineOptions.xAxis.data = this.xAxisLabel.monthList
},
tooltipFormatter(obj) {
var currentItem = this.dataList[obj[0].dataIndex]
return `数量:${currentItem}<br>环比:${currentItem}<br>同比:${currentItem}`
return `数量:${currentItem.num}<br>环比:${currentItem.hrate}%<br>同比:${currentItem.trate}%`
},
autoMove() {
......@@ -86,8 +79,10 @@ export default {
if (this.moveAttr.dataIndex === this.dataList.length) {
this.moveAttr.dataIndex = 0
}
this.chartAction()
this.autoMove()
this.getRankList(this.moveAttr.dataIndex, this.rankFlag + 'List')
}, this.moveAttr.speed)
},
......@@ -118,19 +113,25 @@ export default {
})
},
getRankList(idx, attrName = 'topList') {
this.rankList = this.dataList[idx][attrName]
},
drawLine() {
this.dealxAxisLabel()
this.lineOptions.series[0].data = this.dataList
this.lineOptions.xAxis.data = this.dataList.map(item => item.statDate)
this.lineOptions.series[0].data = this.dataList.map(item => item.num)
this.echartsLine.setOption(this.lineOptions)
console.log(this.echartsLine)
this.getRankList(0)
this.autoMove()
},
handleRankChange(value) {
this.rankFlag = value
this.$emit('handleRankChange', value)
this.getRankList(this.moveAttr.seriesIndex, this.rankFlag + 'List')
}
}
}
......@@ -192,7 +193,7 @@ p {
padding-bottom: 0.6vh;
}
}
.rank-line:first-child {
.rank-line:top-child {
border-width: 0;
}
}
......
function getLineOptions(obj) {
const { tooltipFormatter } = obj
console.log(obj)
var lineOptions = {
tooltip: {
trigger: 'axis',
......
import Vue from 'vue'
import {
Toast,
Dialog
} from 'vant'
import { Toast, Dialog } from 'vant'
/**
* 日期格式化
......@@ -17,14 +14,14 @@ Date.prototype.format = function (fmt) {
's+': this.getSeconds(), //秒
//季度
'q+': Math.floor((this.getMonth() + 3) / 3),
'S': this.getMilliseconds() //毫秒
};
S: this.getMilliseconds() //毫秒
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return fmt
......@@ -99,7 +96,6 @@ const setLocalStorage = (key, item) => {
const getLocalStorage = key => {
return JSON.parse(window.localStorage.getItem(key))
// return JSON.parse(sessionStorage.getItem(key))
}
const removeLocalStorage = key => {
window.localStorage.removeItem(key)
......@@ -116,7 +112,7 @@ const makePhoneCall = phoneNumber => {
/**是否全面屏 */
const isFullSucreen = () => {
let result = false;
let result = false
const rate = window.screen.height / window.screen.width
let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65 // 临界判断值
result = rate > limit
......@@ -164,7 +160,7 @@ const toTop = () => {
const getParams = () => {
return window.vm.$route.params
}
const getQuery = (name) => {
const getQuery = name => {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
......@@ -189,6 +185,22 @@ const getCurrentDate = (fmt = 'yyyy-MM-dd') => {
return new Date().format(fmt)
}
/** 获取前/后n天
* 负数:今天前n天
* 正数:今天后n天
*/
const getNDate = (n, fmt = 'yyyy-MM-dd') => {
return new Date(new Date().setDate(new Date().getDate() + n)).format(fmt)
}
/** 获取前/后n月
* 负数:今天前n月
* 正数:今天后n月
*/
const getNMonth = (n, fmt = 'yyyy-MM-dd') => {
return new Date(new Date().setMonth(new Date().getMonth() + n)).format(fmt)
}
const utils = {
removeLocalStorage,
setClipboardData,
......@@ -214,7 +226,9 @@ const utils = {
dialog,
toTop,
numAddSymbol,
getCurrentDate
getCurrentDate,
getNDate,
getNMonth
}
Object.keys(utils).map(key => {
......
......@@ -8,7 +8,7 @@
<template>
<div>
<div class="title">售后档案客户</div>
<LineChart @handleRankChange="handleRankChange" :rankList="rankList"></LineChart>
<LineChart :dataList="dataList"></LineChart>
</div>
</template>
......@@ -25,28 +25,7 @@ export default {
},
data() {
return {
rankList: [
{
name: '奥迪',
num: 599604
},
{
name: '宝马',
num: 599604
},
{
name: '现代起亚',
num: 599604
},
{
name: '奔驰',
num: 599604
},
{
name: '沃尔沃',
num: 599604
}
]
dataList: []
}
},
mounted() {
......@@ -54,30 +33,57 @@ export default {
},
methods: {
init(val) {
console.log(val)
// console.log(val)
var params = {
req: {
corporateGroupName: '广汇',
queryItem: 'file',
queryTime: '2022-06-25',
queryType: 0
querystartTime: +val.reportType === 1 ? this.getNDate(-30) : this.getNMonth(-12),
queryendTime: +val.reportType === 1 ? this.getNDate(-1) : this.getNMonth(-1),
queryType: val.reportType || 0
}
}
this.api.afterSales.getAfterSale(params).then(res => {
console.log(res)
var { code, data, message } = res
switch (+code) {
case 0:
this.dataList = []
this.dealList(data.dataList)
break
default:
alert(message)
}
})
},
// 折线图数据
getList() { },
// 排名数据
getRankList() { },
dealList() {
this.rankList.forEach(item => {
item.num = this.numAddSymbol(item.num)
dealList(list) {
var topList = []
var lastList = []
list.forEach(item => {
const topTempList = JSON.parse(item.topList)
const lastTempList = JSON.parse(item.lastList)
topList = []
lastList = []
Object.keys(topTempList).forEach(item => {
topList.push({
label: item,
value: this.numAddSymbol(topTempList[item])
})
})
Object.keys(lastTempList).forEach(item => {
lastList.push({
label: item,
value: this.numAddSymbol(lastTempList[item])
})
})
this.dataList.push({
num: item.num || 0,
hrate: item.hrate || 0,
trate: item.trate || 0,
statDate: item.statDate,
topList: topList,
lastList: lastList
})
})
},
handleRankChange(value) {
// console.log(value)
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!