drawer.data.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { FormSchema, BasicColumn } from '/@/components/Table';
  2. import { h } from 'vue';
  3. import { Switch } from 'ant-design-vue';
  4. import { useMessage } from '/@/hooks/web/useMessage';
  5. import { Tinymce } from '/@/components/Tinymce/index';
  6. export const formSchema: FormSchema[] = [
  7. {
  8. field: 'name',
  9. label: '商品名称',
  10. component: 'Input',
  11. required: true,
  12. },
  13. {
  14. field: 'link',
  15. label: '购买链接',
  16. component: 'Input',
  17. },
  18. {
  19. field: 'isLaunched',
  20. label: '是否上架',
  21. component: 'Switch',
  22. },
  23. {
  24. field: 'steamRoom',
  25. label: '直播间名称',
  26. component: 'Input',
  27. helpMessage: '直播间不能修改',
  28. required: true,
  29. colProps: {
  30. lg: 8,
  31. md: 8,
  32. },
  33. componentProps: {
  34. disabled: false,
  35. },
  36. },
  37. {
  38. field: 'desc',
  39. label: '商品描述',
  40. component: 'Input',
  41. render: ({ model, field }) => {
  42. return h(Tinymce, {
  43. value: model[field],
  44. onChange: (value: string) => {
  45. model[field] = value;
  46. },
  47. showImageUpload: true,
  48. });
  49. },
  50. },
  51. ];
  52. export const columns: BasicColumn[] = [
  53. {
  54. title: 'ID',
  55. dataIndex: 'id',
  56. fixed: 'left',
  57. width: 60,
  58. },
  59. {
  60. title: '商品名称',
  61. dataIndex: 'name',
  62. width: 160,
  63. },
  64. {
  65. title: '商品描述',
  66. dataIndex: 'desc',
  67. width: 150,
  68. },
  69. {
  70. title: '购买链接',
  71. dataIndex: 'link',
  72. slots: { customRender: 'link' },
  73. width: 150,
  74. },
  75. {
  76. title: '商品分类',
  77. dataIndex: 'productType',
  78. slots: { customRender: 'productType' },
  79. sorter: true,
  80. width: 120,
  81. },
  82. {
  83. title: '直播间名称',
  84. dataIndex: 'steamRoom.name',
  85. sorter: true,
  86. width: 120,
  87. },
  88. {
  89. title: '零售价格',
  90. dataIndex: 'unit',
  91. sorter: true,
  92. width: 80,
  93. },
  94. {
  95. title: '销售量',
  96. dataIndex: 'amount',
  97. sorter: true,
  98. width: 80,
  99. },
  100. {
  101. title: '市场价',
  102. dataIndex: 'marketingUnit',
  103. sorter: true,
  104. width: 80,
  105. },
  106. {
  107. title: '下单时间',
  108. dataIndex: 'createTime',
  109. sorter: true,
  110. width: 140,
  111. },
  112. {
  113. title: '上架状态',
  114. dataIndex: 'isLaunched',
  115. width: 180,
  116. customRender: ({ record }) => {
  117. if (!Reflect.has(record, 'pendingStatus')) {
  118. record.pendingStatus = false;
  119. }
  120. return h(Switch, {
  121. checked: record.isLaunched,
  122. checkedChildren: '上架',
  123. unCheckedChildren: '下架',
  124. loading: false,
  125. onChange(checked: boolean) {
  126. record.pendingStatus = true;
  127. const newStatus = checked ? '1' : '0';
  128. const { createMessage } = useMessage();
  129. createMessage.info(`暂未接入` + newStatus);
  130. },
  131. });
  132. },
  133. },
  134. {
  135. title: '操作',
  136. dataIndex: '',
  137. slots: { customRender: 'action' },
  138. fixed: 'right',
  139. width: 140,
  140. },
  141. ];