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