seckillActivity.data.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
  2. import { dateFormatter2 } from '@/utils/formatTime'
  3. import { SeckillConfigApi } from '@/api/mall/promotion/seckill/seckillConfig'
  4. // 表单校验
  5. export const rules = reactive({
  6. spuId: [required],
  7. name: [required],
  8. startTime: [required],
  9. endTime: [required],
  10. sort: [required],
  11. configIds: [required],
  12. totalLimitCount: [required],
  13. singleLimitCount: [required],
  14. totalStock: [required]
  15. })
  16. // CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
  17. const crudSchemas = reactive<CrudSchema[]>([
  18. {
  19. label: '秒杀活动名称',
  20. field: 'name',
  21. isSearch: true,
  22. form: {
  23. colProps: {
  24. span: 24
  25. }
  26. },
  27. table: {
  28. width: 120
  29. }
  30. },
  31. {
  32. label: '活动开始时间',
  33. field: 'startTime',
  34. formatter: dateFormatter2,
  35. isSearch: true,
  36. search: {
  37. component: 'DatePicker',
  38. componentProps: {
  39. valueFormat: 'YYYY-MM-DD',
  40. type: 'daterange'
  41. }
  42. },
  43. form: {
  44. component: 'DatePicker',
  45. componentProps: {
  46. type: 'date',
  47. valueFormat: 'x'
  48. }
  49. },
  50. table: {
  51. width: 120
  52. }
  53. },
  54. {
  55. label: '活动结束时间',
  56. field: 'endTime',
  57. formatter: dateFormatter2,
  58. isSearch: true,
  59. search: {
  60. component: 'DatePicker',
  61. componentProps: {
  62. valueFormat: 'YYYY-MM-DD',
  63. type: 'daterange'
  64. }
  65. },
  66. form: {
  67. component: 'DatePicker',
  68. componentProps: {
  69. type: 'date',
  70. valueFormat: 'x'
  71. }
  72. },
  73. table: {
  74. width: 120
  75. }
  76. },
  77. {
  78. label: '秒杀时段',
  79. field: 'configIds',
  80. form: {
  81. component: 'Select',
  82. componentProps: {
  83. multiple: true,
  84. optionsAlias: {
  85. labelField: 'name',
  86. valueField: 'id'
  87. }
  88. },
  89. api: SeckillConfigApi.getSimpleSeckillConfigList
  90. },
  91. table: {
  92. width: 300
  93. }
  94. },
  95. {
  96. label: '总限购数量',
  97. field: 'totalLimitCount',
  98. form: {
  99. component: 'InputNumber',
  100. value: 0
  101. },
  102. table: {
  103. width: 120
  104. }
  105. },
  106. {
  107. label: '单次限够数量',
  108. field: 'singleLimitCount',
  109. form: {
  110. component: 'InputNumber',
  111. value: 0
  112. },
  113. table: {
  114. width: 120
  115. }
  116. },
  117. {
  118. label: '排序',
  119. field: 'sort',
  120. form: {
  121. component: 'InputNumber',
  122. value: 0
  123. },
  124. table: {
  125. width: 80
  126. }
  127. },
  128. {
  129. label: '秒杀活动商品',
  130. field: 'spuId',
  131. isTable: true,
  132. isSearch: false,
  133. form: {
  134. colProps: {
  135. span: 24
  136. }
  137. },
  138. table: {
  139. width: 300
  140. }
  141. },
  142. {
  143. label: '备注',
  144. field: 'remark',
  145. isSearch: false,
  146. form: {
  147. component: 'Input',
  148. componentProps: {
  149. type: 'textarea',
  150. rows: 4
  151. },
  152. colProps: {
  153. span: 24
  154. }
  155. },
  156. table: {
  157. width: 300
  158. }
  159. }
  160. ])
  161. export const { allSchemas } = useCrudSchemas(crudSchemas)