no message

Former-commit-id: 648de15b0be18286cf40e4527285dd41c53a4a83
Former-commit-id: 712e392b2ff0285e2229985a0283322182020841
Former-commit-id: 4ce1c9f6ed83541655eb941ab64c8b58e608b4d2
This commit is contained in:
李杨
2018-02-18 18:04:45 +08:00
parent 94658db1bf
commit 03c37e4e9c
4 changed files with 22 additions and 44 deletions

View File

@@ -1,16 +1,5 @@
import Mock from 'mockjs' import Mock from 'mockjs'
import * as fn from './_publicFunction'
const r = (add = 0) => {
return Math.round(Math.random() * 100) + add
}
const returnMaker = (data = []) => {
return {
code: 0,
msg: '请求成功',
data
}
}
Mock.mock('/api/chart/G2Bar', 'post', ({body, type, url}) => { Mock.mock('/api/chart/G2Bar', 'post', ({body, type, url}) => {
const _body = JSON.parse(body) const _body = JSON.parse(body)
@@ -20,14 +9,14 @@ Mock.mock('/api/chart/G2Bar', 'post', ({body, type, url}) => {
const year = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月'] const year = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月']
const data = year.map(e => ({ const data = year.map(e => ({
year: e, year: e,
value: r() value: fn.r()
})).map(e => ({ })).map(e => ({
x: e.year, x: e.year,
y: e.value y: e.value
})).sort((a, b) => { })).sort((a, b) => {
return a.y - b.y return a.y - b.y
}) })
return returnMaker(data) return fn.returnMaker(data)
} }
default: default:
return {} return {}

View File

@@ -1,16 +1,5 @@
import Mock from 'mockjs' import Mock from 'mockjs'
import * as fn from './_publicFunction'
const r = (add = 0) => {
return Math.round(Math.random() * 100) + add
}
const returnMaker = (data = []) => {
return {
code: 0,
msg: '请求成功',
data
}
}
Mock.mock('/api/chart/G2Column', 'post', ({body, type, url}) => { Mock.mock('/api/chart/G2Column', 'post', ({body, type, url}) => {
const _body = JSON.parse(body) const _body = JSON.parse(body)
@@ -20,12 +9,12 @@ Mock.mock('/api/chart/G2Column', 'post', ({body, type, url}) => {
const year = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月'] const year = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月']
const data = year.map(e => ({ const data = year.map(e => ({
year: e, year: e,
value: r() value: fn.r()
})).map(e => ({ })).map(e => ({
x: e.year, x: e.year,
y: e.value y: e.value
})) }))
return returnMaker(data) return fn.returnMaker(data)
} }
default: default:
return {} return {}

View File

@@ -1,16 +1,5 @@
import Mock from 'mockjs' import Mock from 'mockjs'
import * as fn from './_publicFunction'
const r = (add = 0) => {
return Math.round(Math.random() * 100) + add
}
const returnMaker = (data = []) => {
return {
code: 0,
msg: '请求成功',
data
}
}
Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => { Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
const _body = JSON.parse(body) const _body = JSON.parse(body)
@@ -23,7 +12,7 @@ Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
year: e, year: e,
value: 0 value: 0
})).map(e => { })).map(e => {
e.value = last + r() e.value = last + fn.r()
last = e.value last = e.value
return e return e
}).map(e => ({ }).map(e => ({
@@ -31,19 +20,19 @@ Mock.mock('/api/chart/G2Line', 'post', ({body, type, url}) => {
y: e.value y: e.value
})) }))
last = 0 last = 0
return returnMaker(data) return fn.returnMaker(data)
} }
// 阶梯折线图 // 阶梯折线图
case 'step': { case 'step': {
const month = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月'] const month = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月']
const data = month.map(e => ({ const data = month.map(e => ({
month: e, month: e,
value: r() value: fn.r()
})).map(e => ({ })).map(e => ({
x: e.month, x: e.month,
y: e.value y: e.value
})) }))
return returnMaker(data) return fn.returnMaker(data)
} }
default: default:
return {} return {}

View File

@@ -0,0 +1,11 @@
export const r = (add = 0) => {
return Math.round(Math.random() * 100) + add
}
export const returnMaker = (data = []) => {
return {
code: 0,
msg: '请求成功',
data
}
}