Commit 3bced908 by 姜雷

修改储值视图滚动精度

parent 19f2818c
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
import CustomerRecharge from '../CustomerRecharge/CustomerRecharge'; import CustomerRecharge from '../CustomerRecharge/CustomerRecharge';
import CustomerConsumption from '../CustomerConsumption/CustomerConsumption'; import CustomerConsumption from '../CustomerConsumption/CustomerConsumption';
import { mapGetters, mapActions } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import { getFilters } from '@/utils/index';
export default { export default {
name: 'CustomerMoneyData', name: 'CustomerMoneyData',
...@@ -66,7 +67,8 @@ export default { ...@@ -66,7 +67,8 @@ export default {
'updateFilters', 'updateFilters',
]), ]),
...mapActions('Dashboard/customerRecharge', ['getRechargeOrderList']), ...mapActions('Dashboard/customerRecharge', ['getRechargeOrderList']),
fetchAllData(entity) { fetchAllData() {
let entity = getFilters(this.filters);
this.getConsumeOrderList(entity); this.getConsumeOrderList(entity);
this.getRechargeOrderList(entity); this.getRechargeOrderList(entity);
}, },
......
...@@ -103,15 +103,24 @@ export default { ...@@ -103,15 +103,24 @@ export default {
}, },
computed: { computed: {
dataList() { dataList() {
return this.data.map((item, index) => ({ ...item, index: index })); return this.data.map((item, index, array) => ({
...item,
index: index,
scaleValue: array.length - 1 ? index / (array.length - 1) : 0,
}));
}, },
}, },
methods: { methods: {
initData() { initData() {
let start =
this.dataList.length - 4 >= 0
? (this.dataList.length - 4) / this.dataList.length
: 0;
let end = 1;
this.ds = new DataSet({ this.ds = new DataSet({
state: { state: {
start: 0, start: start,
end: 3, end: end,
}, },
}); });
const dv = this.ds.createView().source(this.dataList); const dv = this.ds.createView().source(this.dataList);
...@@ -127,7 +136,7 @@ export default { ...@@ -127,7 +136,7 @@ export default {
dv.transform({ dv.transform({
type: 'filter', type: 'filter',
callback: obj => { callback: obj => {
const currentRadio = obj.index; const currentRadio = obj.scaleValue;
return ( return (
currentRadio >= this.ds.state.start && currentRadio >= this.ds.state.start &&
currentRadio <= this.ds.state.end currentRadio <= this.ds.state.end
...@@ -143,11 +152,6 @@ export default { ...@@ -143,11 +152,6 @@ export default {
}); });
this.chart.source(dv, { this.chart.source(dv, {
index: {
type: 'linear',
min: 0,
max: this.dataList.length - 1,
},
rechargeMoney: { rechargeMoney: {
alias: '充值金额', alias: '充值金额',
}, },
...@@ -213,17 +217,19 @@ export default { ...@@ -213,17 +217,19 @@ export default {
this.sliderDom = document.getElementById('CustomerRechangeSlider'); this.sliderDom = document.getElementById('CustomerRechangeSlider');
this.sliderDom.style = `height:${this.height}px`; this.sliderDom.style = `height:${this.height}px`;
const spanNum = 4 / this.dataList.length;
this.slider = new Slider({ this.slider = new Slider({
container: this.sliderDom, // dom 容器 id 或者 dom 容器对象 container: this.sliderDom, // dom 容器 id 或者 dom 容器对象
width: 26, // slider 的宽度,默认为 'auto',即自适应宽度 width: 26, // slider 的宽度,默认为 'auto',即自适应宽度
height: this.height, // slider 的高度,默认为 '26px' height: this.height, // slider 的高度,默认为 '26px'
padding: [20, 0, 20, 0], padding: [20, 0, 20, 0],
xAxis: 'rechargeMen', // 背景图的横轴对应字段,同时为数据筛选的字段 xAxis: 'rechargeMen', // 背景图的横轴对应字段,同时为数据筛选的字段
yAxis: 'index', // 背景图的纵轴对应字段 yAxis: 'scaleValue', // 背景图的纵轴对应字段
start: 0, start: 0,
end: 3, end: 3 / this.dataList.length,
minSpan: 4, minSpan: spanNum,
maxSpan: 4, maxSpan: spanNum,
data: this.dataList, // slider 的数据源 data: this.dataList, // slider 的数据源
textStyle: { textStyle: {
display: 'none', display: 'none',
...@@ -245,9 +251,13 @@ export default { ...@@ -245,9 +251,13 @@ export default {
this.sliderDom.innerHTML = ''; this.sliderDom.innerHTML = '';
const arrLength = this.dataList.length; const arrLength = this.dataList.length;
let start = this.dataList.length - 4 >= 0 ? this.dataList.length - 4 : 0; let start =
let end = this.dataList.length - 1 >= 1 ? this.dataList.length - 1 : 1; this.dataList.length - 4 >= 0
? (this.dataList.length - 4) / this.dataList.length
: 0;
let end = 1;
// console.log('2222', this.dataList.length - 1, start, end); // console.log('2222', this.dataList.length - 1, start, end);
const spanNum = 4 / this.dataList.length;
if (arrLength) { if (arrLength) {
this.slider = new Slider({ this.slider = new Slider({
...@@ -256,21 +266,20 @@ export default { ...@@ -256,21 +266,20 @@ export default {
height: this.height, height: this.height,
padding: [20, 0, 20, 0], padding: [20, 0, 20, 0],
xAxis: 'rechargeMoney', xAxis: 'rechargeMoney',
yAxis: 'index', yAxis: 'scaleValue',
scales: { scales: {
min: 0, scaleValue: {
max: arrLength - 1,
index: {
type: 'linear',
formatter: val => { formatter: val => {
return parseInt(val, 10); let indexValue = val * (this.dataList.length - 1);
// console.log(val, indexValue);
return parseInt(indexValue, 10);
}, },
}, },
}, },
start: start, start: start,
end: end, end: end,
minSpan: 4, minSpan: spanNum,
maxSpan: 4, maxSpan: spanNum,
data: this.dataList, data: this.dataList,
handleStyle: { handleStyle: {
...@@ -293,14 +302,15 @@ export default { ...@@ -293,14 +302,15 @@ export default {
const arrLength = this.data.length; const arrLength = this.data.length;
let spanNum = 4 / arrLength; let spanNum = 4 / arrLength;
let start = let start =
this.dataList.length - 4 >= 0 ? this.dataList.length - 4 : 0; this.dataList.length - 4 >= 0
let end = this.dataList.length - 1 >= 1 ? this.dataList.length - 1 : 1; ? (this.dataList.length - 4) / this.dataList.length
: 0;
let end = 1;
this.ds.setState('start', start); this.ds.setState('start', start);
this.ds.setState('end', end); this.ds.setState('end', end);
this.dv.source(this.dataList); this.dv.source(this.dataList);
// let height = this.data.length * 50;
// this.chart.changeHeight(height);
this.updateSlider(); this.updateSlider();
this.updateData(); this.updateData();
console.log(this.chart.getYScales()); console.log(this.chart.getYScales());
......
import System from '../lib/main'; import System from '../lib/main';
window.manageShell = { default: System }; window.manageShell = { default: System };
console.log('manageShell');
setTimeout(() => { setTimeout(() => {
let allAasyncRouterMap = [ let allAasyncRouterMap = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment