remote-search.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const Mock = require('mockjs')
  2. const NameList = []
  3. const count = 100
  4. for (let i = 0; i < count; i++) {
  5. NameList.push(Mock.mock({
  6. name: '@first'
  7. }))
  8. }
  9. NameList.push({ name: 'mock-Pan' })
  10. module.exports = [
  11. // username search
  12. {
  13. url: '/vue-element-admin/search/user',
  14. type: 'get',
  15. response: config => {
  16. const { name } = config.query
  17. const mockNameList = NameList.filter(item => {
  18. const lowerCaseName = item.name.toLowerCase()
  19. return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
  20. })
  21. return {
  22. code: 20000,
  23. data: { items: mockNameList }
  24. }
  25. }
  26. },
  27. // transaction list
  28. /* {
  29. url: '/vue-element-admin/transaction/list',
  30. type: 'get',
  31. response: _ => {
  32. return {
  33. code: 20000,
  34. data: {
  35. total: 20,
  36. 'items|20': [{
  37. order_no: '@guid()',
  38. timestamp: +Mock.Random.date('T'),
  39. username: '@name()',
  40. price: '@float(1000, 15000, 0, 2)',
  41. 'status|1': ['success', 'pending']
  42. }]
  43. }
  44. }
  45. }
  46. } */
  47. ]