eleven.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import Mock from 'mockjs'
  2. import { MockMethod } from 'vite-plugin-mock'
  3. const mockMethodElevent: MockMethod[] = [
  4. {
  5. url: '/mock/api/eleven',
  6. method: 'get',
  7. timeout: 1000,
  8. response: () => {
  9. return {
  10. code: '0',
  11. ...Mock.mock({
  12. 'data|20': [
  13. {
  14. id: '@id',
  15. name: '@ctitle(4,6)',
  16. reason: '@reason',
  17. email: '@integer(10000000, 99999999)',
  18. taxInvoice: '@string(upper, 8, 8)',
  19. source: '@taxInvoiceSource',
  20. payer: '@cname',
  21. total: '@natural(100, 100000)',
  22. dutiable: '@natural(10, 100)',
  23. date: '@datetime("2024-MM-dd hh:mm:ss")',
  24. printing: '@cname',
  25. printDate: function () {
  26. let date = Mock.Random.datetime('2024-MM-dd hh:mm:ss')
  27. while (date < this.date) {
  28. date = Mock.Random.datetime('2024-MM-dd hh:mm:ss')
  29. }
  30. return date
  31. }
  32. }
  33. ]
  34. })
  35. }
  36. }
  37. },
  38. {
  39. url: '/mock/api/eleven/get/child',
  40. method: 'get',
  41. timeout: 1000,
  42. response: () => {
  43. return {
  44. code: '0',
  45. ...Mock.mock({
  46. 'data|2-5': [
  47. {
  48. id: '@id',
  49. name: '@goods("name")',
  50. date: '@datetime',
  51. total: '@natural(100, 100000)',
  52. code: '@natural(100000, 200000)',
  53. type: '@cword(1, 1)',
  54. price: '@natural(100000, 200000)',
  55. unit: '@unit',
  56. taxRate: '@natural(0, 50)',
  57. tax: '@natural(100000, 200000)',
  58. thingName: function () {
  59. return this.name
  60. },
  61. thingTotal: '@natural(100, 100000)',
  62. thingPrice: '@natural(100000, 200000)',
  63. thingCode: function () {
  64. return this.code
  65. }
  66. }
  67. ]
  68. })
  69. }
  70. }
  71. }
  72. ]
  73. export default mockMethodElevent