Commit 302c7881 by 王志慧

commit

1 parent 089669a9
......@@ -7,6 +7,10 @@ Component({
opts: {
type: Object,
value: {}
},
chartData:{
type: Object,
value: {}
}
},
......
......@@ -5,6 +5,6 @@
</view>
<view class="container" style="height: 200px;">
<bar-echart class="f2-chart" keys="{{opts.keys}}" chartData="{{opts.chartData}}" color="{{opts.color}}" tickCount="{{opts.tickCount}}" />
<bar-echart class="f2-chart" keys="{{opts.keys}}" chartData="{{chartData}}" color="{{opts.color}}" tickCount="{{opts.tickCount}}" />
</view>
</view>
\ No newline at end of file
......@@ -7,6 +7,10 @@ Component({
opts: {
type: Object,
value: {}
},
chartData:{
type: Object,
value: {}
}
},
......
......@@ -14,7 +14,7 @@
</view>
</view>
<view class="container" style="height: 180px;">
<line-echart class="f2-chart" period="{{timePeriod}}" chartData="{{opts.lineData}}" color="{{opts.lineColr}}" tickCount="{{opts.tickCount}}" keys="{{opts.keys}}"/>
<line-echart class="f2-chart" period="{{timePeriod}}" chartData="{{chartData}}" color="{{opts.lineColr}}" tickCount="{{opts.tickCount}}" keys="{{opts.keys}}"/>
</view>
</view>
\ No newline at end of file
import ActivityApi from '~/api/activityApi/index'
let thisPage;
Component({
/**
* 组件的属性列表
*/
properties: {
entranceType: {
type: Number,
observer: function (val) {
console.log(val, 'index')
this.initLocal(val)
}
}
/**
* 组件的属性列表
*/
properties: {
entranceType: {
type: Number,
observer: function (val) {
console.log(val, 'index')
this.initLocal(val)
}
}
},
/**
* 组件的初始数据
*/
data: {
outputView: {
outputValue: [{
label: '总报价量',
name: 'totalQuotationCount'
}, {
label: '总成交量',
name: 'totalSuccessCount',
unit: ''
}, {
label: '总产值',
name: 'totalOutputValue',
_unit: '¥'
}, {
label: '当月报价量',
name: 'monthQuotationCount',
_unit: '¥'
}, {
label: '当月成交量',
name: 'monthSuccessCount',
unit: ''
}, {
label: '当月产值',
name: 'monthOutputValue',
_unit: '¥'
}, {
label: '单价',
name: 'avgPrice',
_unit: '¥'
}, {
label: '升级率',
name: 'conversionRate',
unit_: '%',
multiple: 100,
}, {
label: '平均车险报价',
name: 'avgQuotationPrice',
_unit: '¥'
}],
boutiqueOutputValue: [{
label: '发券量(总)/张',
name: 'sendCouponCountTotal',
unit: ''
}, {
label: '升级订单/单',
name: 'upgradeCountTotal',
unit: ''
}, {
label: '营业额(总)/元',
name: 'orderMoneyTotal',
_unit: '¥'
}, {
label: '客单价/元',
name: 'averagePrice',
_unit: '¥'
}, {
label: '转化率',
name: 'upgradeRatio',
unit_: '%'
}],
todayOutiqueOutputValue: [{
label: '发券量/张',
name: 'sendCouponCountToday',
unit: ''
}, {
label: '升级订单/单',
name: 'upgradeCountToday',
unit: ''
}, {
label: '营业额(总)/元',
name: 'orderMoneyTotalToday',
unit: ''
}],
todayOutputValue: [{
label: '报价量',
name: 'quotationCount',
unit: ''
}, {
label: '成交量',
name: 'successCount',
unit: ''
}, {
label: '产值',
name: 'outputValue',
unit: ''
}],
},
/**
* 组件的初始数据
*/
data: {
outputView: {
outputValue: [{
label: '总报价量',
name: 'totalQuotationCount'
}, {
label: '总成交量',
name: 'totalSuccessCount',
unit: ''
}, {
label: '总产值',
name: 'totalOutputValue',
_unit: '¥'
}, {
label: '当月报价量',
name: 'monthQuotationCount',
_unit: '¥'
}, {
label: '当月成交量',
name: 'monthSuccessCount',
unit: ''
}, {
label: '当月产值',
name: 'monthOutputValue',
_unit: '¥'
}, {
label: '单价',
name: 'avgPrice',
_unit: '¥'
}, {
label: '升级率',
name: 'conversionRate',
unit_: '%',
multiple: 100,
listData: [],
chartData: [],
activeTrigger: false,
activePageNum: 1,
activeTotal: 0,
pageNum: 1,
total: 0,
pageSize: 10,
noResult: false,
isShow: false,
opts: {
keys: ['abscissaValue', 'ordinateValue'],
color: '#69C9FF',
lineColr: '#6ED0BE',
tickCount: 8,
lineList: [],
barList: [],
},
},
/**
* 组件的方法列表
*/
methods: {
// 初始化
initLocal(val) {
this.setData({
type: val,
activeTrigger: false,
noResult: false,
outputData: {},
sfaffList: [],
tabelTh: []
}, () => {
thisPage = wx.$router.getPageInstance()
this.getActivityInfo()
})
},
getActivityInfo() {
this.initSearch()
this.getOutput()
this.getStaffOutput()
this.merchantsOutputToday()
this.getHistogram()
this.getTrend()
},
initSearch() {
let {
type,
opts
} = this.data
const obj = {
1: {
lineList: [{
title: '营业额',
type: 1
}, {
label: '平均车险报价',
name: 'avgQuotationPrice',
_unit: '¥'
title: '到店量',
type: 2
}],
boutiqueOutputValue: [{
label: '发券量(总)/张',
name: 'sendCouponCountTotal',
unit: ''
barList: [{
title: '发券量',
type: 3
}, {
label: '升级订单/单',
name: 'upgradeCountTotal',
unit: ''
title: '营业额',
type: 1
}]
},
2: {
lineList: [{
title: '报价量',
type: 1
}, {
label: '营业额(总)/元',
name: 'orderMoneyTotal',
_unit: '¥'
title: '成交量',
type: 2
}, {
label: '客单价/元',
name: 'averagePrice',
_unit: '¥'
}, {
label: '转化率',
name: 'upgradeRatio',
unit_: '%'
title: '产值',
type: 3
}],
todayOutiqueOutputValue: [{
label: '发券量/张',
name: 'sendCouponCountToday',
unit: ''
barList: [{
title: '报价量',
type: 1
}, {
label: '升级订单/单',
name: 'upgradeCountToday',
unit: ''
title: '成交量',
type: 2
}, {
label: '营业额(总)/元',
name: 'orderMoneyTotalToday',
unit: ''
}],
todayOutputValue: [{
label: '报价量',
name: 'quotationCount',
unit: ''
}, {
label: '成交量',
name: 'successCount',
unit: ''
}, {
label: '产值',
name: 'outputValue',
unit: ''
}],
title: '产值',
type: 3
}]
}
},
listData: [],
activeTrigger: false,
activePageNum: 1,
activeTotal: 0,
pageNum: 1,
total: 0,
pageSize: 10,
noResult: false,
isShow: false,
lineList = obj[type].lineList,
barList = obj[type].barList
const barObj = this.selectComponent('#bar')
const lineObj = this.selectComponent('#line')
this.setData({
opts: {
keys: ['abscissaValue', 'ordinateValue'],
color: '#69C9FF',
lineColr: '#6ED0BE',
tickCount: 8,
lineList: [],
barList: [],
chartData: [],
lineData: []
},
...opts,
lineList,
barList
}
})
lineObj.setData({
startTime: '',
endTime: '',
dataType: 1,
timePeriod: 1
})
barObj.setData({
dataType: type == 1 ? 3 : 1
})
},
/**
* 组件的方法列表
*/
methods: {
// 初始化
initLocal(val) {
this.setData({
type: val,
activeTrigger: false,
noResult: false,
outputData: {},
sfaffList: [],
tabelTh: []
}, () => {
thisPage = wx.$router.getPageInstance()
this.getActivityInfo()
})
},
getActivityInfo() {
this.initSearch()
this.getOutput()
this.getStaffOutput()
this.merchantsOutputToday()
this.getHistogram()
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() {
const {
type,
} = this.data
let apiName = 'boutiquecouponOutputValue'
let params = {
merchantId: thisPage.data.merchantId
}
if ([2].includes(type)) {
apiName = 'merchantsOutput'
params = {
merchantIds: [thisPage.data.merchantId]
}
}
ActivityApi[apiName](params).then(res => {
this.setData({
outputData: { ...this.data.outputData, ...res }
})
console.log(this.data.outputData)
})
},
merchantsOutputToday() {
const {
type,
} = this.data
if (type != 2) return
ActivityApi.merchantsOutputToday({ merchantIds: [thisPage.data.merchantId] }).then(res => {
this.setData({
outputData: { ...this.data.outputData, ...res }
})
})
},
selectEvent() {
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() {
const barObj = this.selectComponent('#bar')
let {
dataType
} = barObj.data
const methods = {
1: 'boutiquecouponQueryCouponCountAndOrderMoney',
2: 'merchantsHistogram'
}
const params = {
merchantId: thisPage.data.merchantId,
dataType //数据类型:1报价量/ 2成交量 /3产值
// timePeriod: 1, //时间类型 1本周 / 2本月 /3全年
// startTime: '',
// endTime: ''
}
ActivityApi[methods[this.data.type]](params).then(res => {
this.setData({
'opts.chartData': res
})
})
},
/**折线图 */
getTrend() {
const lineObj = this.selectComponent('#line')
// 看产值-产值总览
getOutput() {
const {
type,
} = this.data
let apiName = 'boutiquecouponOutputValue'
let params = {
merchantId: thisPage.data.merchantId
}
if ([2].includes(type)) {
apiName = 'merchantsOutput'
params = {
merchantIds: [thisPage.data.merchantId]
}
}
ActivityApi[apiName](params).then(res => {
this.setData({
outputData: {
...this.data.outputData,
...res
}
})
console.log(this.data.outputData)
})
},
merchantsOutputToday() {
const {
type,
} = this.data
if (type != 2) return
ActivityApi.merchantsOutputToday({
merchantIds: [thisPage.data.merchantId]
}).then(res => {
this.setData({
outputData: {
...this.data.outputData,
...res
}
})
})
},
selectEvent() {
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).toString().padStart(2,0)}-${(date.getDate()).toString().padStart(2,0)}`;
},
/**柱状图 */
getHistogram() {
const barObj = this.selectComponent('#bar')
let {
dataType
} = barObj.data
const methods = {
1: 'boutiquecouponQueryCouponCountAndOrderMoney',
2: 'merchantsHistogram'
}
const params = {
merchantId: thisPage.data.merchantId,
dataType //数据类型:1报价量/ 2成交量 /3产值
// timePeriod: 1, //时间类型 1本周 / 2本月 /3全年
// startTime: '',
// endTime: ''
}
ActivityApi[methods[this.data.type]](params).then(res => {
this.setData({
chartData: res
})
})
},
/**折线图 */
getTrend() {
const lineObj = this.selectComponent('#line')
let {
dataType,
timePeriod,
startTime,
endTime
} = lineObj.data
const methods = {
1: 'boutiquecouponQueryOrderMoneyTotalAndToShopCount',
2: 'merchantsTrend'
}
const params = {
merchantId: thisPage.data.merchantId,
dataType, //数据类型:1报价量/ 2成交量 /3产值
dateDimension: timePeriod, //时间类型 1本周 / 2本月 /3全年
startDate: startTime,
endDate: endTime
}
this.data.type == 1 ? params.dateDimension = timePeriod : params.timePeriod = timePeriod
ActivityApi[methods[this.data.type]](params).then(res => {
this.setData({
'opts.lineData': res
})
})
},
getOutputReport() {
ActivityApi.merchantsOutputReport
},
/**员工排行 */
getStaffOutput() {
const {
type
} = this.data
let apiName, params, tabelTh;
const dataT = {
1: () => {
apiName = 'boutiquecouponQueryEmployeeRankList',
params = {
merchantId: thisPage.data.merchantId
},
tabelTh = {
employeeName: '员工',
orderMoneyTotal: '产值(营业额)',
upgradeCountTotal: '单量',
averagePrice: '客单价',
upgradeRatio: '转化率'
}
},
2: () => {
apiName = 'merchantsStaffOutput',
params = {
merchantIds: [thisPage.data.merchantId]
}
tabelTh = {
transferName: "员工姓名",
outputValue: "产值",
successCount: "成交量",
quotationCount: "报价量",
conversionRate: "转化率",
}
}
let {
dataType,
timePeriod,
startTime,
endTime
} = lineObj.data
const methods = {
1: 'boutiquecouponQueryOrderMoneyTotalAndToShopCount',
2: 'merchantsTrend'
}
const params = {
merchantId: thisPage.data.merchantId,
dataType, //数据类型:1报价量/ 2成交量 /3产值
}
this.data.type == 1 ? params.dateDimension = timePeriod : params.timePeriod = timePeriod
if (startTime) this.data.type == 1 ? params.startDate = startTime : params.startTime = startTime + ' 00:00:00 '
if (endTime) this.data.type == 1 ? params.endDate = endTime : params.endTime = endTime + ' 23:59:59'
ActivityApi[methods[this.data.type]](params).then(res => {
this.setData({
lineData: res
})
})
},
getOutputReport() {
ActivityApi.merchantsOutputReport
},
/**员工排行 */
getStaffOutput() {
const {
type
} = this.data
let apiName, params, tabelTh;
const dataT = {
1: () => {
apiName = 'boutiquecouponQueryEmployeeRankList',
params = {
merchantId: thisPage.data.merchantId
},
tabelTh = {
employeeName: '员工',
orderMoneyTotal: '产值(营业额)',
upgradeCountTotal: '单量',
averagePrice: '客单价',
upgradeRatio: '转化率'
}
dataT[type]()
ActivityApi[apiName](params).then(res => {
const sfaffList = res.list || res || []
this.setData({
sfaffList,
tabelTh
})
})
},
formatArr(arr, fn) {
let res = {}
for (let v of arr) {
const val = Object.keys(v)
for (let i of val) {
if (res[i]) {
res[i].push(v[i])
continue
}
res[i] = [v[i]]
}
2: () => {
apiName = 'merchantsStaffOutput',
params = {
merchantIds: [thisPage.data.merchantId]
}
return fn(res)
},
// 下拉刷新
activityRefresh(e) {
this.getActivityInfo()
},
jumpReport(e) {
const {
time
} = e.target.dataset
const {
entranceType
} = this.data
wx.navigateTo({
url: `/packagesList/packageOutput/pages/monthReport/monthReport?time=${time}&type=${entranceType}&merchantId=${thisPage.data.merchantId}&merchantName=${thisPage.data.merchantName}`,
})
tabelTh = {
transferName: "员工姓名",
outputValue: "产值",
successCount: "成交量",
quotationCount: "报价量",
conversionRate: "转化率",
}
}
}
dataT[type]()
ActivityApi[apiName](params).then(res => {
const sfaffList = res.list || res || []
this.setData({
sfaffList,
tabelTh
})
})
},
formatArr(arr, fn) {
let res = {}
for (let v of arr) {
const val = Object.keys(v)
for (let i of val) {
if (res[i]) {
res[i].push(v[i])
continue
}
res[i] = [v[i]]
}
}
return fn(res)
},
// 下拉刷新
activityRefresh(e) {
this.getActivityInfo()
},
// lifetimes: {
// attached() {
// if(this.control)return
// this.control = true
// this.initLocal(this.data.entranceType)
// }
// },
jumpReport(e) {
const {
time
} = e.target.dataset
const {
entranceType
} = this.data
wx.navigateTo({
url: `/packagesList/packageOutput/pages/monthReport/monthReport?time=${time}&type=${entranceType}&merchantId=${thisPage.data.merchantId}&merchantName=${thisPage.data.merchantName}`,
})
}
},
// lifetimes: {
// attached() {
// if(this.control)return
// this.control = true
// this.initLocal(this.data.entranceType)
// }
// },
})
\ No newline at end of file
......@@ -16,10 +16,10 @@
</view>
</view>
<view class="line-box">
<output-line id="line" opts="{{opts}}" bind:selectTime="selectTime" bind:selectEvent="selectEvent"></output-line>
<output-line id="line" opts="{{opts}}" chartData="{{lineData}}" bind:selectTime="selectTime" bind:selectEvent="selectEvent"></output-line>
</view>
<view class="bar-box">
<output-bar opts="{{opts}}" id="bar" bind:selectEvent="selectBarEvent"></output-bar>
<output-bar opts="{{opts}}" chartData="{{chartData}}" id="bar" bind:selectEvent="selectBarEvent"></output-bar>
</view>
<staff sfaffList="{{sfaffList}}" tabelTh="{{tabelTh}}" downType="{{type ==2?'equity':'boutique'}}"/>
<view class="table-box">
......@@ -28,4 +28,4 @@
</view>
</scroll-view >
<van-calendar show="{{ isShow }}" type="range" color="#4466F0" bind:confirm="onConfirm" bind:close="onClose"/>
\ No newline at end of file
<van-calendar max-range="{{ 30 }}" show="{{ isShow }}" type="range" color="#4466F0" bind:confirm="onConfirm" bind:close="onClose"/>
\ No newline at end of file
......@@ -24,7 +24,7 @@ Component({
},
observers: {
'chartData': function (data) {
console.log(data, '9999999999')
console.log(data, '----------------')
this.initData(data)
......@@ -72,7 +72,7 @@ Component({
type: 'solid'
}
},
padding: [2, 10],
padding: [0, 12],
borderWidth: 2,
borderColor: this.data.color,
borderRadius: 10,
......@@ -86,7 +86,7 @@ Component({
// },
formatter: function (item) {
console.log(item)
return `${item[0].value}` + '人'
return `${item[0].value}`
}
},
xAxis: {
......
......@@ -52,6 +52,7 @@ Component({
})
},
setOption(chart,xData,yData) {
console.log(xData)
var option = {
grid: {
left: 8,
......@@ -68,7 +69,7 @@ Component({
type: 'solid'
}
},
padding: [2, 10],
padding: [0, 12],
borderWidth: 2,
borderColor: '#6ED0BE',
borderRadius: 10,
......@@ -82,7 +83,7 @@ Component({
// },
formatter: function (item) {
console.log(item)
return `${item[0].value}` + '人'
return `${item[0].value}`
}
},
xAxis: {
......@@ -124,7 +125,7 @@ Component({
},
dataZoom: {
type: "inside",
maxSpan: 10
maxSpan: xData.length<5?50:10
},
series: [{
data: yData,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!