add mockjs“

This commit is contained in:
lb
2023-03-22 15:04:00 +08:00
parent b54aa84b1c
commit 7f7192f38a
5 changed files with 41 additions and 0 deletions

View File

@@ -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, {

View 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
View 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
}
}
})