Commit d7814cad by 王志慧

jiejuechongtu

2 parents 3a5ae479 25065fe5
...@@ -163,8 +163,9 @@ export default { ...@@ -163,8 +163,9 @@ export default {
}) })
var seriesDate = this.dataList.map(item => +item.num) var seriesDate = this.dataList.map(item => +item.num)
this.lineOptions.series[0].data = seriesDate this.lineOptions.series[0].data = seriesDate
this.lineOptions.yAxis.min = Math.min(...seriesDate) this.lineOptions.yAxis.scale = true
this.lineOptions.yAxis.max = Math.max(...seriesDate) // this.lineOptions.yAxis.min = Math.min(...seriesDate)
// this.lineOptions.yAxis.max = Math.max(...seriesDate)
this[this.domId].setOption(this.lineOptions) this[this.domId].setOption(this.lineOptions)
// 默认展示tooltip // 默认展示tooltip
this.chartAction() this.chartAction()
......
...@@ -102,11 +102,11 @@ import * as echarts from 'echarts' ...@@ -102,11 +102,11 @@ import * as echarts from 'echarts'
export default { export default {
name: 'ViewTabs', name: 'ViewTabs',
mixins: [changeMixin], mixins: [changeMixin],
data () { data() {
return { return {
tabs, tabs,
tabHead: [], tabHead: [],
tabTitle:'客户总数', tabTitle: '客户总数',
tabType: 'total', tabType: 'total',
tabIndex: 0, tabIndex: 0,
delayTimer: 3000, delayTimer: 3000,
...@@ -126,10 +126,9 @@ export default { ...@@ -126,10 +126,9 @@ export default {
updata: Date.now() updata: Date.now()
} }
}, },
mounted () { mounted() {},
},
methods: { methods: {
init (params) { init(params) {
this.isGroup = true this.isGroup = true
let req = { let req = {
queryType: params.reportType || 0 queryType: params.reportType || 0
...@@ -144,20 +143,22 @@ export default { ...@@ -144,20 +143,22 @@ export default {
this.getOverallbase('publiccus') this.getOverallbase('publiccus')
this.getOveralltrend('total') this.getOveralltrend('total')
}, },
changeType (type) { changeType(type) {
let title = { let title = {
'total': '客户总数', total: '客户总数',
'wechat': '企微客户数', wechat: '企微客户数',
'wechatGroup': '企微群数', wechatGroup: '企微群数',
'applet': '小程序客户数', applet: '小程序客户数',
'publiccus': '公众号客户数' publiccus: '公众号客户数'
} }
this.tabTitle = title[type] this.tabTitle = title[type]
this.tabType = type this.tabType = type
this.getOveralltrend(type) this.getOveralltrend(type)
}, },
getOverallbase (queryItem) { getOverallbase(queryItem) {
let { req: { queryType } } = this let {
req: { queryType }
} = this
const params = { const params = {
queryItem, queryItem,
queryType, queryType,
...@@ -192,45 +193,46 @@ export default { ...@@ -192,45 +193,46 @@ export default {
} }
} }
this.pageData[queryItem] = dataList this.pageData[queryItem] = dataList
} }
}) })
}, },
ObjectToArray (obj) { ObjectToArray(obj) {
let arr = [] let arr = []
if (obj && obj !== 'null') { if (obj && obj !== 'null') {
obj = obj.replace('null', '"未知"') obj = obj.replace('null', '"未知"')
let item = JSON.parse(obj) let item = JSON.parse(obj)
if (Array.isArray(item)) item.map(e => { if (Array.isArray(item))
item.map(e => {
Object.keys(e).map(name => arr.push({ name, num: e[name] })) Object.keys(e).map(name => arr.push({ name, num: e[name] }))
}) })
else Object.keys(item).map(name => arr.push({ name, num: item[name] })) else Object.keys(item).map(name => arr.push({ name, num: item[name] }))
} }
return arr return arr
}, },
getOveralltrend (queryItem) { getOveralltrend(queryItem) {
let { req: { queryType } } = this let {
req: { queryType }
} = this
const params = { const params = {
queryItem, queryItem,
queryType, queryType,
querystartTime: queryType == 1 ? this.getNDate(-30) : this.getNMonth(-12), querystartTime: queryType == 1 ? this.getNDate(-30) : this.getNMonth(-12),
queryendTime: queryType == 1 ? this.getNDate(-1) : this.getNMonth(-1), queryendTime: queryType == 1 ? this.getNDate(-1) : this.getNMonth(-1)
} }
this.api.overview[this.isGroup ? 'getBrandOveralltrend' : 'getMerchantOveralltrend'](params).then(({ data, code }) => { this.api.overview[this.isGroup ? 'getBrandOveralltrend' : 'getMerchantOveralltrend'](params)
.then(({ data, code }) => {
this.flag = true this.flag = true
if (code == 0) { if (code == 0) {
if (!data.dataList.map(item => item.totalNum).every(item => item === 0)) { if (!data.dataList.map(item => item.totalNum).every(item => item === 0)) {
this.isEmpty = false this.isEmpty = false
this.$nextTick(() => { this.$nextTick(() => {
this.canvas = echarts.init(this.$refs.canvas) this.canvas = echarts.init(this.$refs.canvas)
this.lineData = data.dataList
this.draw(data.dataList, queryType) this.draw(data.dataList, queryType)
}) })
} }
} }
}).catch(() => { })
.catch(() => {
this.flag = true this.flag = true
}) })
}, },
...@@ -241,16 +243,16 @@ export default { ...@@ -241,16 +243,16 @@ export default {
dataIndex: this.lineData.length - 1 dataIndex: this.lineData.length - 1
}) })
}, },
draw (lineData, queryType) { draw(lineData, queryType) {
let data = [], let data = [],
Min=0, Min = 0,
xData = [], xData = [],
title = { title = {
'total': '客户总数', total: '客户总数',
'wechat': '企微客户数', wechat: '企微客户数',
'wechatGroup': '企微群数', wechatGroup: '企微群数',
'applet': '小程序客户数', applet: '小程序客户数',
'publiccus': '公众号客户数' publiccus: '公众号客户数'
}, },
{ tabType } = this { tabType } = this
lineData.map(e => { lineData.map(e => {
...@@ -297,7 +299,8 @@ export default { ...@@ -297,7 +299,8 @@ export default {
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
min: Min, // min: Min,
scale: true,
splitLine: { splitLine: {
lineStyle: { lineStyle: {
color: 'rgba(96,98,102,0.2)' color: 'rgba(96,98,102,0.2)'
......
...@@ -48,7 +48,8 @@ export default { ...@@ -48,7 +48,8 @@ export default {
barData: [], barData: [],
key: '重要价值', key: '重要价值',
isBrand: false, isBrand: false,
brandName: '' brandName: '',
currentData: {}
} }
}, },
mounted() {}, mounted() {},
...@@ -60,6 +61,22 @@ export default { ...@@ -60,6 +61,22 @@ export default {
this.barChart.resize() this.barChart.resize()
}) })
this.option = { this.option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
shadowStyle: {
color: 'rgba(235,96,1,0.30'
}
},
borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)',
confine: true,
textStyle: {
color: '#FFFFFF',
fontSize: 8
}
},
grid: { grid: {
left: '3%', left: '3%',
right: '4%', right: '4%',
...@@ -94,7 +111,7 @@ export default { ...@@ -94,7 +111,7 @@ export default {
// data: [120, 200, 150, 80, 70, 110, 130, 300], // data: [120, 200, 150, 80, 70, 110, 130, 300],
data: this.barData.reverse(), data: this.barData.reverse(),
type: 'bar', type: 'bar',
barWidth: 12, barWidth: 18,
itemStyle: { itemStyle: {
normal: { normal: {
label: { label: {
...@@ -103,7 +120,7 @@ export default { ...@@ -103,7 +120,7 @@ export default {
textStyle: { textStyle: {
fontSize: '12', fontSize: '12',
color: '#fff', color: '#fff',
height: '12', height: '18',
padding: [1, 0, 0, 0] padding: [1, 0, 0, 0]
} }
}, },
...@@ -124,9 +141,16 @@ export default { ...@@ -124,9 +141,16 @@ export default {
} }
this.barChart.clear() this.barChart.clear()
this.barChart.setOption(this.option) this.barChart.setOption(this.option)
this.chartAction()
// 鼠标划入 // 鼠标划入
this.barChart.on('mouseover', data => { this.barChart.on('mouseover', data => {
this.initPieData(data.name) this.initPieData(data.name)
console.log(data)
this.currentData = data
})
this.barChart.on('globalout', () => {
this.chartAction(this.currentData.dataIndex)
this.initPieData(this.currentData.name)
}) })
}, },
getValueType() { getValueType() {
...@@ -178,6 +202,13 @@ export default { ...@@ -178,6 +202,13 @@ export default {
this.brandName = newVal.brand.name this.brandName = newVal.brand.name
} }
this.getValueType() this.getValueType()
},
chartAction(index = 7) {
this.barChart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: index
})
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!