api-list.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * @Description:
  3. * @Author: zcf
  4. * @Date: 2022-06-15 14:56:24
  5. * @LastEditTime: 2022-06-23 22:09:33
  6. * @LastEditors: zcf
  7. */
  8. import { Random } from 'mockjs'
  9. import { resultSuccess, doCustomTimes } from '../_util.js'
  10. const tableList = (pageSize) => {
  11. const result = []
  12. doCustomTimes(pageSize, () => {
  13. result.push({
  14. id: '@integer(10,999999)',
  15. 'type|1': ['error', 'default', 'warn'],
  16. 'no|100000-10000000': 100000,
  17. name: Random.word(),
  18. 'method|1': ['GET', 'POST', 'PUT', 'DELETE'],
  19. 'describe|1': Random.csentence(10, 25)
  20. })
  21. })
  22. return result
  23. }
  24. export default [
  25. // api表格数据列表
  26. {
  27. url: '/mock/api/list',
  28. timeout: 1000,
  29. method: 'post',
  30. response: ({ body }) => {
  31. const { page = 1, pageSize = 10, search } = body
  32. const list = tableList(Number(pageSize))
  33. // 并非真实,只是为了模拟搜索结果
  34. const count = search ? 20 : 60
  35. return resultSuccess({
  36. page: Number(page),
  37. pageSize: Number(pageSize),
  38. pageCount: count,
  39. itemCount: count * Number(pageSize),
  40. list
  41. })
  42. }
  43. }
  44. ]