Commit 55920f4b by 王志慧

commit

1 parent c032ea47
...@@ -28,7 +28,7 @@ Component({ ...@@ -28,7 +28,7 @@ Component({
text: '年', text: '年',
type: 3 type: 3
}, ], }, ],
timePeriod: 2 timePeriod: 1
}, },
...@@ -50,7 +50,6 @@ Component({ ...@@ -50,7 +50,6 @@ Component({
this.triggerEvent('selectEvent') this.triggerEvent('selectEvent')
}, },
selectTime() { selectTime() {
console.log(122)
this.triggerEvent('selectTime') this.triggerEvent('selectTime')
}, },
......
...@@ -8,6 +8,7 @@ Component({ ...@@ -8,6 +8,7 @@ Component({
entranceType: { entranceType: {
type: Number, type: Number,
observer: function (val) { observer: function (val) {
console.log(val, 'index')
this.initLocal(val) this.initLocal(val)
} }
} }
...@@ -110,51 +111,15 @@ Component({ ...@@ -110,51 +111,15 @@ Component({
total: 0, total: 0,
pageSize: 10, pageSize: 10,
noResult: false, noResult: false,
isShow: false,
opts: { opts: {
keys: ['abscissaValue', 'ordinateValue'], keys: ['abscissaValue', 'ordinateValue'],
color: '#69C9FF', color: '#69C9FF',
lineColr: '#6ED0BE', lineColr: '#6ED0BE',
tickCount: 8, tickCount: 8,
lineList: [{ lineList: [],
title: '营业额', barList: [],
type: 1 chartData: [],
}, {
title: '到店量',
type: 2
}],
chartData: [{
year: '1951 年',
sales: 10000
},
{
year: '1952 年',
sales: 2000
},
{
year: '1956 年',
sales: 61
},
{
year: '1957 年',
sales: 145
},
{
year: '1958 年',
sales: 48
},
{
year: '1959 年',
sales: 38
},
{
year: '1960 年',
sales: 38
},
{
year: '1962 年',
sales: 38
},
],
lineData: [] lineData: []
}, },
}, },
...@@ -180,11 +145,78 @@ Component({ ...@@ -180,11 +145,78 @@ Component({
}) })
}, },
getActivityInfo() { getActivityInfo() {
this.initSearch()
this.getOutput() this.getOutput()
this.getStaffOutput() this.getStaffOutput()
this.getHistogram() this.getHistogram()
this.getTrend() this.getTrend()
}, },
initSearch() {
let {
type,
opts
} = this.data
const obj = {
1: {
lineList: [{
title: '营业额',
type: 1
}, {
title: '到店量',
type: 2
}],
barList: [{
title: '发券量',
type: 3
}, {
title: '营业额',
type: 1
}]
},
2: {
lineList: [{
title: '报价量',
type: 1
}, {
title: '成交量',
type: 2
}, {
title: '产值',
type: 3
}],
barList: [{
title: '报价量',
type: 1
}, {
title: '成交量',
type: 2
}, {
title: '产值',
type: 3
}]
}
},
lineList = obj[type].lineList,
barList = obj[type].barList
const barObj = this.selectComponent('#bar')
const lineObj = this.selectComponent('#line')
this.setData({
opts: {
...opts,
lineList,
barList
}
})
lineObj.setData({
startTime: '',
endTime: '',
dataType: 1,
timePeriod: 1
})
barObj.setData({
dataType: type == 1 ? 3 : 1
})
},
// 看产值-产值总览 // 看产值-产值总览
getOutput() { getOutput() {
const { const {
...@@ -209,23 +241,73 @@ Component({ ...@@ -209,23 +241,73 @@ Component({
selectEvent() { selectEvent() {
this.getTrend() this.getTrend()
}, },
selectBarEvent() {
this.getHistogram()
},
selectTime() {
this.setData({
isShow: true
})
},
onClose() {
this.setData({
isShow: false
});
},
onConfirm(event) {
const [start, end] = event.detail;
const lineObj = this.selectComponent('#line')
this.setData({
isShow: false
});
lineObj.setData({
startTime: this.formatDate(start),
endTime: this.formatDate(end),
timePeriod: ''
})
this.getTrend()
},
formatDate(date) {
date = new Date(date);
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
},
/**柱状图 */ /**柱状图 */
getHistogram() { getHistogram() {
const barObj = this.selectComponent('#bar')
let {
dataType
} = barObj.data
const methods = {
1: 'boutiquecouponQueryCouponCountAndOrderMoney',
2: 'merchantsHistogram'
}
const params = { const params = {
merchantId: thisPage.data.merchantId, merchantId: thisPage.data.merchantId,
dataType: 1, //数据类型:1报价量/ 2成交量 /3产值 dataType //数据类型:1报价量/ 2成交量 /3产值
timePeriod: 1, //时间类型 1本周 / 2本月 /3全年 // timePeriod: 1, //时间类型 1本周 / 2本月 /3全年
startTime: '', // startTime: '',
endTime: '' // endTime: ''
} }
ActivityApi.merchantsHistogram(params).then(res => { ActivityApi[methods[this.data.type]](params).then(res => {
console.log(res) this.setData({
'opts.chartData': res
})
}) })
}, },
/**折线图 */ /**折线图 */
getTrend() { getTrend() {
const lineObj = this.selectComponent('#line') const lineObj = this.selectComponent('#line')
let { dataType, timePeriod, startTime, endTime } = lineObj.data
let {
dataType,
timePeriod,
startTime,
endTime
} = lineObj.data
const methods = {
1: 'boutiquecouponQueryOrderMoneyTotalAndToShopCount',
2: 'merchantsTrend'
}
const params = { const params = {
merchantId: thisPage.data.merchantId, merchantId: thisPage.data.merchantId,
dataType, //数据类型:1报价量/ 2成交量 /3产值 dataType, //数据类型:1报价量/ 2成交量 /3产值
...@@ -233,11 +315,11 @@ Component({ ...@@ -233,11 +315,11 @@ Component({
startDate: startTime, startDate: startTime,
endDate: endTime endDate: endTime
} }
ActivityApi.boutiquecouponQueryOrderMoneyTotalAndToShopCount(params).then(res => { this.data.type == 1 ? params.dateDimension = timePeriod : params.timePeriod = timePeriod
ActivityApi[methods[this.data.type]](params).then(res => {
this.setData({ this.setData({
'opts.lineData': res 'opts.lineData': res
}) })
console.log(this.data.opts.lineData)
}) })
}, },
getOutputReport() { getOutputReport() {
...@@ -252,7 +334,9 @@ Component({ ...@@ -252,7 +334,9 @@ Component({
const dataT = { const dataT = {
1: () => { 1: () => {
apiName = 'boutiquecouponQueryEmployeeRankList', apiName = 'boutiquecouponQueryEmployeeRankList',
params = { merchantId: thisPage.data.merchantId }, params = {
merchantId: thisPage.data.merchantId
},
tabelTh = { tabelTh = {
employeeName: '员工姓名', employeeName: '员工姓名',
orderMoneyTotal: '产值(营业额)', orderMoneyTotal: '产值(营业额)',
...@@ -263,7 +347,9 @@ Component({ ...@@ -263,7 +347,9 @@ Component({
}, },
2: () => { 2: () => {
apiName = 'merchantsStaffOutput', apiName = 'merchantsStaffOutput',
params = { merchantIds: [thisPage.data.merchantId] } params = {
merchantIds: [thisPage.data.merchantId]
}
tabelTh = { tabelTh = {
transferName: "员工姓名", transferName: "员工姓名",
outputValue: "产值", outputValue: "产值",
...@@ -276,7 +362,10 @@ Component({ ...@@ -276,7 +362,10 @@ Component({
dataT[type]() dataT[type]()
ActivityApi[apiName](params).then(res => { ActivityApi[apiName](params).then(res => {
const sfaffList = res.list || res || [] const sfaffList = res.list || res || []
this.setData({ sfaffList ,tabelTh}) this.setData({
sfaffList,
tabelTh
})
}) })
}, },
formatArr(arr, fn) { formatArr(arr, fn) {
......
import * as echarts from '../../../../ec-canvas/echarts'; import * as echarts from '../../../outDetail/ec-canvas/echarts';
Component({ Component({
/** /**
...@@ -24,16 +24,8 @@ Component({ ...@@ -24,16 +24,8 @@ Component({
}, },
observers: { observers: {
'chartData': function (data) { 'chartData': function (data) {
if (data.length == 0) { console.log(data, '9999999999')
this.setData({ this.initData(data)
chartShow: true,
ec: {
onInit: this.onInitChart() //这里就是在js中用到的方法名
}
})
} else {
// this.data.chart.changeData(data)
}
}, },
...@@ -43,7 +35,7 @@ Component({ ...@@ -43,7 +35,7 @@ Component({
*/ */
data: { data: {
ec: { ec: {
onInit: null lazyLoad: true
} }
}, },
...@@ -51,16 +43,19 @@ Component({ ...@@ -51,16 +43,19 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
onInitChart() { onInitChart(xData, yData) {
return (canvas, width, height, dpr) => { this.ecComponent && this.ecComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: dpr, // new devicePixelRatio: dpr,
padding:[10, 20,10,20]
}); });
canvas.setChart(chart); this.setOption(chart, xData, yData);
return chart;
})
},
setOption(chart, xData, yData) {
var option = { var option = {
grid: { grid: {
left: 8, left: 8,
...@@ -106,7 +101,7 @@ Component({ ...@@ -106,7 +101,7 @@ Component({
axisTick: { axisTick: {
show: false //坐标轴刻度 show: false //坐标轴刻度
}, },
data: ['Mon', 'Tue', 'Wed', 'Thu'] data: xData
}, },
yAxis: { yAxis: {
x: 'center', x: 'center',
...@@ -128,35 +123,36 @@ Component({ ...@@ -128,35 +123,36 @@ Component({
} }
}, },
series: [{ series: [{
data: [820, 932, 901, 934], data: yData,
type: 'bar', type: 'bar',
color: this.data.color, color: this.data.color,
itemStyle: { itemStyle: {
borderRadius: [50, 50, 0, 0], borderRadius: [50, 50, 0, 0],
padding:[50, 50, 0, 0] padding: [50, 50, 0, 0]
}, },
barWidth: 24 barWidth: 24
}] }]
}; };
chart.setOption(option)
chart.setOption(option);
return chart;
}
}, },
//初始化数据 //初始化数据
initData() { initData(data) {
let { const xData = [],
chartData, yData = [];
keys, const [x, y] = this.data.keys
viewData data.forEach(item => {
} = this xData.push(item[x])
chartData.forEach(item => { yData.push(item[y])
viewData.push({
name: item[keys[0]],
value: item[keys[1]]
}) })
this.setData({
xData,
yData
}) })
this.onInitChart(xData, yData)
},
}, },
ready() {
// 获取组件
this.ecComponent = this.selectComponent('#mychart-dom-bar');
} }
}) })
\ No newline at end of file \ No newline at end of file
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"ec-canvas": "../../../../ec-canvas/ec-canvas" "ec-canvas": "../../../outDetail/ec-canvas/ec-canvas"
} }
} }
import * as echarts from '../../../../ec-canvas/echarts'; import * as echarts from '../../../outDetail/ec-canvas/echarts';
Component({ Component({
/** /**
* 组件的属性列表 * 组件的属性列表
...@@ -24,18 +24,6 @@ Component({ ...@@ -24,18 +24,6 @@ Component({
observers: { observers: {
'chartData': function (data) { 'chartData': function (data) {
this.initData(data) this.initData(data)
if (data.length == 0) {
this.setData({
chartShow: true,
ec: {
onInit: this.onInitChart()
}
})
} else {
// this.data.chart.changeData(data)
}
}, },
}, },
/** /**
...@@ -43,10 +31,8 @@ Component({ ...@@ -43,10 +31,8 @@ Component({
*/ */
data: { data: {
ec: { ec: {
onInit: null lazyLoad: true
}, }
xData:[],
yData:[]
}, },
...@@ -54,20 +40,22 @@ Component({ ...@@ -54,20 +40,22 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
onInitChart() { onInitChart(xData,yData) {
return (canvas, width, height, dpr) => { this.ecComponent&&this.ecComponent.init((canvas, width, height, dpr) => {
console.log(width, height, )
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: dpr // new devicePixelRatio: dpr // new
}); });
canvas.setChart(chart); this.setOption(chart,xData,yData);
return chart;
})
},
setOption(chart,xData,yData) {
var option = { var option = {
grid: { grid: {
left: 8, left: 8,
right: 10, right: 30,
top: 50, top: 50,
bottom: 0, bottom: 0,
containLabel: true containLabel: true
...@@ -100,6 +88,9 @@ Component({ ...@@ -100,6 +88,9 @@ Component({
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
// min:1,
// max: 5,
axisLabel: { axisLabel: {
fontSize: 11, fontSize: 11,
color: '#A6A6A6' color: '#A6A6A6'
...@@ -110,7 +101,7 @@ Component({ ...@@ -110,7 +101,7 @@ Component({
axisTick: { axisTick: {
show: false //坐标轴刻度 show: false //坐标轴刻度
}, },
data:this.data.xData data: xData
}, },
yAxis: { yAxis: {
x: 'center', x: 'center',
...@@ -132,36 +123,36 @@ Component({ ...@@ -132,36 +123,36 @@ Component({
} }
}, },
dataZoom: { dataZoom: {
start: 10, type: "inside",
type: "inside" maxSpan: 10
}, },
series: [{ series: [{
data: this.data.yData, data: yData,
type: 'line', type: 'line',
smooth: true, smooth: true,
color: this.data.color color: this.data.color
}] }]
};
chart.setOption(option);
return chart;
} }
chart.setOption(option)
}, },
//初始化数据 //初始化数据
initData(data) { initData(data) {
let { const xData = [],
xData, yData = [];
yData const [x, y] = this.data.keys
} = this.data
data.forEach(item => { data.forEach(item => {
xData.push(item.abscissaValue) xData.push(item[x])
yData.push(item.ordinateValue) yData.push(item[y])
}) })
this.setData({ this.setData({
xData, xData,
yData yData
}) })
this.onInitChart(xData, yData)
},
}, },
ready() {
// 获取组件
this.ecComponent = this.selectComponent('#mychart-dom-line');
} }
}) })
\ No newline at end of file \ No newline at end of file
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"ec-canvas": "../../../../ec-canvas/ec-canvas" "ec-canvas": "../../../outDetail/ec-canvas/ec-canvas"
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!