Ver código fonte

add mockjs“

docs_0727
lb 1 ano atrás
pai
commit
7f7192f38a
5 arquivos alterados com 41 adições e 0 exclusões
  1. +1
    -0
      package.json
  2. +1
    -0
      public/index.html
  3. +2
    -0
      src/main.js
  4. +16
    -0
      src/mocks/carManagement/index.js
  5. +21
    -0
      src/mocks/index.js

+ 1
- 0
package.json Ver arquivo

@@ -40,6 +40,7 @@
"@vue/cli-plugin-babel": "^4.4.6",
"@vue/cli-service": "^4.4.6",
"element-theme-chalk": "^2.15.12",
"mockjs": "^1.1.0",
"natives": "^1.1.6",
"vue-template-compiler": "^2.6.11"
},


+ 1
- 0
public/index.html Ver arquivo

@@ -41,6 +41,7 @@
// window.SITE_CONFIG['apiURL'] = 'http://192.168.1.49:8080/pms-am'; // tengyun
// window.SITE_CONFIG['apiURL'] = 'http://192.168.1.62:8080/pms-am'; // tao
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.21:8080/pms-am'; // xv
// window.SITE_CONFIG['apiURL'] = 'http://localhost:3000/pms-am'; // xv
</script>
<% } %>
<!-- 集成测试环境 -->


+ 2
- 0
src/main.js Ver arquivo

@@ -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
- 0
src/mocks/carManagement/index.js Ver arquivo

@@ -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
- 0
src/mocks/index.js Ver arquivo

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

Carregando…
Cancelar
Salvar