add mockjs“
This commit is contained in:
@@ -25,6 +25,8 @@ import cloneDeep from 'lodash/cloneDeep'
|
||||
import myComponents from 'code-brick-zj'
|
||||
|
||||
|
||||
import mocks from './mocks'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
Vue.use(Element, {
|
||||
|
||||
16
src/mocks/carManagement/index.js
Normal file
16
src/mocks/carManagement/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import Mock from 'mockjs'
|
||||
const Random = Mock.Random
|
||||
|
||||
const pageViewModel = () => ({
|
||||
code: Random.county(),
|
||||
stateDictValue: Random.integer(1, 7),
|
||||
orderCode: Random.string(10),
|
||||
posCode: Random.string(10),
|
||||
startTime: Random.datetime(),
|
||||
endTime: Random.datetime(),
|
||||
})
|
||||
pageViewModel.url = '/pms/carHandle/pageView'
|
||||
pageViewModel.method = 'post'
|
||||
|
||||
|
||||
export default pageViewModel
|
||||
21
src/mocks/index.js
Normal file
21
src/mocks/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import Mock from 'mockjs'
|
||||
|
||||
import carManagement from './carManagement'
|
||||
|
||||
|
||||
function m(url, type, fn) {
|
||||
return Mock.mock(window.SITE_CONFIG['apiURL'] + url, type, fn)
|
||||
}
|
||||
|
||||
m(carManagement.url, carManagement.type, opt => {
|
||||
let { limit, page } = JSON.parse(opt.body)
|
||||
// console.log('limit, page', limit, page, opt.body)
|
||||
limit = 5
|
||||
return {
|
||||
code: 0,
|
||||
data: {
|
||||
list: Array(limit).fill(null).map(carManagement),
|
||||
total: limit * page + 10
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user