web-africa-h5/pages/market/performance/monthlyPerformanceComparison/Repurchase.vue

293 lines
6.7 KiB
Vue

<template>
<view class="content-box">
<view class="d-c-c charts-box"><canvas canvas-id="RxLfvHATljsyuMzkObqjWYVZPqXlLibz" id="RxLfvHATljsyuMzkObqjWYVZPqXlLibz" class="charts" @touchend="tap" /></view>
<view class="tabulation-box">
<view class="tabulation-top d-c-c">
<view class="flex-1 tc fb f28">{{ $t('w_0146') }}</view>
<view class="flex-1 tc">
<text class="fb f28">{{ $t('S_C_18') }}</text>
<text class="f22 gray9">({{ $t('ENU_TOTAL_V_1') }}{{ $t('S_C_58') }})</text>
</view>
<view class="flex-1 tc">
<text class="fb f28">{{ $t('S_C_19') }}</text>
<text class="f22 gray9">({{ $t('ENU_TOTAL_V_1') }}{{ $t('S_C_58') }})</text>
</view>
</view>
<view class="d-b-c tabulation-item" v-for="(item, index) in listData" :key="index">
<view class="flex-1 f22 gray6 tc">{{ item.time }}</view>
<view class="flex-1 f22 gray6 tc">{{ item.data1 }}</view>
<view class="flex-1 f22 gray6 tc">{{ item.data2 }}</view>
</view>
</view>
</view>
</template>
<script>
import uCharts from '@/uni_modules/qiun-data-charts/js_sdk/u-charts/u-charts.js';
var uChartsInstance = {};
export default {
data() {
return {
cWidth: 661,
cHeight: 638,
chartsDataColumn: {},
listData: []
};
},
onReady() {
//这里的 661 对应 css .charts 的 width
this.cWidth = uni.upx2px(661);
//这里的 638 对应 css .charts 的 height
this.cHeight = uni.upx2px(638);
this.getServerData();
},
methods: {
getServerData() {
let self = this;
self._get('report/api/achieve/new-add-achieve-day', {}, res => {
let list = res.data;
let obj = {
categories: [],
series: [
{
data: [],
name: self.$t('S_C_18')
},
{
data: [],
name: self.$t('S_C_19')
}
]
};
if (list && list.length > 0) {
list.forEach((item, index) => {
obj.categories.push(item.settleDate);
obj.series[0].data.push(self.formatNum(item.repANewPv) || null);
obj.series[1].data.push(self.formatNum(item.repBNewPv) || null);
self.listData.push({
time: item.settleDate,
data1: self.formatNum(item.repANewPv) || null,
data2: self.formatNum(item.repBNewPv) || null
});
});
}
self.chartsDataColumn = JSON.parse(JSON.stringify(obj));
self.listData.reverse();
self.drawCharts('RxLfvHATljsyuMzkObqjWYVZPqXlLibz', self.chartsDataColumn);
});
},
drawCharts(id, data) {
const ctx = uni.createCanvasContext(id, this);
uChartsInstance[id] = new uCharts({
type: 'line',
context: ctx,
width: this.cWidth,
height: this.cHeight,
categories: data.categories,
series: data.series,
animation: true,
timing: 'easeOut',
duration: 1000,
rotate: false,
rotateLock: false,
background: '#FFFFFF',
color: ['#ff5a5a', '#ffae36'],
padding: [15, 10, 0, 15],
fontSize: 13,
fontColor: '#666666',
dataLabel: false,
dataPointShape: false,
dataPointShapeType: 'solid',
touchMoveLimit: 60,
enableScroll: false,
enableMarkLine: false,
legend: {
show: true,
position: 'bottom',
float: 'center',
padding: 5,
margin: 5,
backgroundColor: 'rgba(0,0,0,0)',
borderColor: 'rgba(0,0,0,0)',
borderWidth: 0,
fontSize: 13,
fontColor: '#666666',
lineHeight: 11,
hiddenColor: '#CECECE',
itemGap: 10
},
xAxis: {
disableGrid: true,
disabled: false,
axisLine: true,
axisLineColor: '#CCCCCC',
calibration: false,
fontColor: '#666666',
fontSize: 8,
lineHeight: 20,
marginTop: 20,
rotateLabel: true,
rotateAngle: 45,
itemCount: 5,
boundaryGap: 'center',
splitNumber: 5,
gridColor: '#CCCCCC',
gridType: 'solid',
dashLength: 4,
gridEval: 1,
scrollShow: false,
scrollAlign: 'left',
scrollColor: '#A6A6A6',
scrollBackgroundColor: '#EFEBEF',
title: '',
titleFontSize: 8,
titleOffsetY: 0,
titleOffsetX: 0,
titleFontColor: '#666666',
formatter: ''
},
yAxis: {
gridType: 'dash',
dashLength: 2,
disabled: false,
disableGrid: false,
splitNumber: 5,
gridColor: '#CCCCCC',
padding: 10,
showTitle: true,
data: [
{
type: 'value',
position: 'left',
disabled: false,
axisLine: false,
axisLineColor: '#CCCCCC',
calibration: false,
fontColor: '#666666',
fontSize: 11,
textAlign: 'right',
title: this.$t('w_0339'),
titleFontSize: 11,
titleOffsetY: 0,
titleOffsetX: 0,
titleFontColor: '#666666',
min: null,
max: null,
tofix: null,
unit: '',
formatter: ''
}
]
},
extra: {
line: {
type: 'straight',
width: 2,
activeType: 'hollow',
linearType: 'none',
onShadow: false,
animation: 'vertical'
},
tooltip: {
showBox: true,
showArrow: true,
showCategory: false,
borderWidth: 0,
borderRadius: 0,
borderColor: '#000000',
borderOpacity: 0.7,
bgColor: '#000000',
bgOpacity: 0.7,
gridType: 'solid',
dashLength: 4,
gridColor: '#CCCCCC',
boxPadding: 3,
fontSize: 13,
lineHeight: 20,
fontColor: '#FFFFFF',
legendShow: true,
legendShape: 'auto',
splitLine: true,
horizentalLine: false,
xAxisLabel: false,
yAxisLabel: false,
labelBgColor: '#FFFFFF',
labelBgOpacity: 0.7,
labelFontColor: '#666666'
},
markLine: {
type: 'solid',
dashLength: 4,
data: []
}
}
});
},
tap(e) {
uChartsInstance[e.target.id].touchLegend(e);
uChartsInstance[e.target.id].showToolTip(e);
}
}
};
</script>
<style scoped>
page {
/* background-color: #fff; */
}
.content {
padding: 26rpx 22rpx 26rpx 23rpx;
}
.content-box {
padding: 30rpx 0;
min-height: 100vh;
}
.picker-small {
width: 232rpx;
height: 72rpx;
border: 1rpx solid #eeeeee;
border-radius: 15rpx;
font-size: 28rpx;
padding: 0 28rpx 0 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
}
.charts-box {
padding: 22rpx 26rpx 23rpx 28rpx;
width: 706rpx;
height: 692rpx;
box-sizing: border-box;
background: #ffffff;
border-radius: 20rpx;
margin: 0 auto;
margin-bottom: 30rpx;
}
.charts {
width: 661rpx;
height: 638rpx;
}
.tabulation-box {
width: 704rpx;
padding: 0 26rpx 20rpx 26rpx;
box-sizing: border-box;
background: #ffffff;
border-radius: 20rpx;
margin: 0 auto;
}
.tabulation-top {
padding: 20rpx 0;
border-bottom: 1prx solid #eee;
}
.tabulation-item {
height: 40rpx;
}
.tabulation-item:nth-child(2n) {
background: #f8f8f8;
}
</style>