three.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import Mock from 'mockjs'
  2. import { MockMethod } from 'vite-plugin-mock'
  3. const list = Mock.mock({
  4. 'list|4-10': [
  5. {
  6. id: '@id',
  7. num: function () {
  8. const date = new Date()
  9. const year = date.getFullYear().toString().slice(-2)
  10. const month = (date.getMonth() + 1).toString().padStart(2, '0')
  11. const day = date.getDate().toString().padStart(2, '0')
  12. const random = Math.random().toString().slice(-10)
  13. return `BA${year}${month}${day}${random}`
  14. },
  15. name: '@ctitle',
  16. num2: '@integer(1, 100)',
  17. num3: '@integer(1, 100)',
  18. num4: '@integer(1, 100)',
  19. productName: '@goods("name")',
  20. specifications: function () {
  21. return this.unit
  22. },
  23. price: '@integer(1, 100)',
  24. unit: '@unit',
  25. statistics: '@ctitle',
  26. money: '@ctitle',
  27. total: '@integer(1, 100)',
  28. country: '@country',
  29. mcountry: '@country',
  30. way: '@ctitle',
  31. sprice: '@ctitle',
  32. msprice: '@ctitle'
  33. }
  34. ]
  35. }).list
  36. const mockMethodTen: MockMethod[] = [
  37. {
  38. url: '/mock/api/three',
  39. method: 'get',
  40. timeout: 1000,
  41. response: () => ({
  42. code: '0',
  43. data: {
  44. info: {
  45. filed1: '010120201000005031',
  46. filed2: '010120201000005031',
  47. filed3: '无纸/通关一体化',
  48. filed4: '进口',
  49. filed5: '',
  50. filed6: '',
  51. filed7: '@date',
  52. filed8: '@date',
  53. filed9: '@date',
  54. filed10: '',
  55. filed11: '',
  56. filed12: '',
  57. filed13: '中国大恒(集团)有限公司/1108919038/86652412100006491000000916',
  58. filed14: '中国大恒(集团)有限公司/110891903866524121000064931108919038',
  59. filed15: '中国大恒(团)有限公司/1108919038/866524121000064931/110891903',
  60. filed16: 'no',
  61. filed17: '北京关区',
  62. filed18: '北仑海关',
  63. filed19: '',
  64. filed20: '阿富汗',
  65. filed21: '天津保税区',
  66. filed22: '天津保税区',
  67. filed23: '海关总署/000000',
  68. filed24: '阿富汗',
  69. filed25: '北京天竺综合保税区',
  70. filed26: '',
  71. filed27: '包/袋',
  72. filed28: '',
  73. filed29: '海关总署/000000',
  74. filed30: '水路运输',
  75. filed31: 'UN281924',
  76. filed32: 'T281924',
  77. filed33: 'W20200917048',
  78. filed34: '进口',
  79. filed35: '海关总署/000000',
  80. filed36: '一般贸易',
  81. filed37: '一般征税',
  82. filed38: '',
  83. filed39: '',
  84. filed40: '1.0%',
  85. filed41: '海关总署/000000',
  86. filed42: 'CIF',
  87. filed43: '1',
  88. filed44: '1',
  89. filed45: '1',
  90. filed46: '',
  91. filed47: 'A',
  92. filed48: '',
  93. filed49: '',
  94. filed50: '',
  95. filed51: 'NM',
  96. filed52: '',
  97. filed53: '使用人',
  98. filed54: '两段准入申请',
  99. filed55: ''
  100. },
  101. list
  102. }
  103. })
  104. },
  105. {
  106. url: '/mock/api/three/detail',
  107. method: 'get',
  108. timeout: 1000,
  109. response: ({ query }: { query: any }) => {
  110. const id = query.id || list[0].id
  111. const data = list.find((v: any) => v.id === id)
  112. return {
  113. code: '0',
  114. data
  115. }
  116. }
  117. }
  118. ]
  119. export default mockMethodTen