list.data.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { BasicColumn, FormProps } from '/@/components/Table';
  2. import { UnSaleApi, EnSaleApi } from '/@/api/product/list';
  3. import { h } from 'vue';
  4. import { Switch } from 'ant-design-vue';
  5. import { useMessage } from '/@/hooks/web/useMessage';
  6. import { useI18n } from '/@/hooks/web/useI18n';
  7. import { useUserStore } from '/@/store/modules/user';
  8. const userStore = useUserStore();
  9. const { getCheckRole } = userStore;
  10. export const searchForm: Partial<FormProps> = {
  11. labelWidth: 100,
  12. schemas: [
  13. {
  14. field: 'name',
  15. label: '商品名称',
  16. component: 'Input',
  17. componentProps: {
  18. placeholder: '请输入商品名称',
  19. maxLength: 100,
  20. },
  21. colProps: {
  22. xl: 6,
  23. xxl: 6,
  24. },
  25. },
  26. {
  27. field: 'brandName',
  28. label: '直播间名称',
  29. component: 'Input',
  30. componentProps: {
  31. placeholder: '请输入直播间名称',
  32. maxLength: 100,
  33. },
  34. colProps: {
  35. xl: 6,
  36. xxl: 6,
  37. },
  38. },
  39. ],
  40. };
  41. export const columns: BasicColumn[] = [
  42. // {
  43. // title: 'ID',
  44. // dataIndex: 'id',
  45. // fixed: 'left',
  46. // width: 60,
  47. // },
  48. {
  49. title: '商品名称',
  50. dataIndex: 'name',
  51. width: 160,
  52. },
  53. // {
  54. // title: '商品描述',
  55. // dataIndex: 'goodsSimpleDesc',
  56. // width: 150,
  57. // },
  58. {
  59. title: '购买链接',
  60. dataIndex: 'realShopUrl',
  61. slots: { customRender: 'realShopUrl' },
  62. width: 150,
  63. },
  64. {
  65. title: '商品分类',
  66. dataIndex: 'categoryName',
  67. // slots: { customRender: 'productType' },
  68. sorter: true,
  69. width: 120,
  70. },
  71. {
  72. title: '直播间名称',
  73. dataIndex: 'brandName',
  74. // customRender: ({ record }) => {
  75. // return record.steamRoom.name as unknown as {};
  76. // },
  77. sorter: true,
  78. width: 120,
  79. },
  80. {
  81. title: '零售价格',
  82. dataIndex: 'retailPrice',
  83. sorter: true,
  84. width: 80,
  85. },
  86. {
  87. title: '销售量',
  88. dataIndex: 'sellVolume',
  89. sorter: true,
  90. width: 80,
  91. },
  92. {
  93. title: '市场价',
  94. dataIndex: 'marketPrice',
  95. sorter: true,
  96. width: 80,
  97. },
  98. {
  99. title: '创建时间',
  100. dataIndex: 'addTime',
  101. slots: { customRender: 'addTime' },
  102. sorter: true,
  103. width: 140,
  104. },
  105. {
  106. title: '上架状态',
  107. dataIndex: 'isOnSale',
  108. width: 180,
  109. customRender: ({ record }) => {
  110. if (!Reflect.has(record, 'pendingStatus')) {
  111. record.pendingStatus = false;
  112. }
  113. return h(Switch, {
  114. checked: record.isOnSale === 1,
  115. checkedChildren: '上架',
  116. unCheckedChildren: '下架',
  117. loading: false,
  118. onChange: async (checked: boolean) => {
  119. record.pendingStatus = true;
  120. const id: string = record.id || '';
  121. const newStatus = checked ? 1 : 0;
  122. const { createMessage } = useMessage();
  123. const { t } = useI18n();
  124. if (checked) {
  125. Reflect.set(record, 'isOnSale', newStatus);
  126. await EnSaleApi([id]);
  127. } else {
  128. Reflect.set(record, 'isOnSale', newStatus);
  129. await UnSaleApi([id]);
  130. }
  131. createMessage.success(t('common.optSuccess'));
  132. // createMessage.info(`暂未接入` + newStatus);
  133. },
  134. });
  135. },
  136. },
  137. {
  138. title: '操作',
  139. dataIndex: '',
  140. slots: { customRender: 'action' },
  141. ifShow: !getCheckRole('tourist'),
  142. fixed: 'right',
  143. width: 120,
  144. },
  145. ];