ColumnsTsx.tsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import { useCountryInfoStore } from '/@/stores/countryInfo';
  2. import { getTagType } from '/@/utils/useTagColor';
  3. const countryInfoStore = useCountryInfoStore();
  4. export const productColumns = (handleMonitor: Function) => [
  5. { type: 'checkbox', width: 50, align: 'center', fixed: 'left' },
  6. { type: 'seq', title: 'No.', width: 60, align: 'center' },
  7. {
  8. field: 'is_monitor', title: '监控管理', width: 90, align: 'center',
  9. slots: {
  10. default({ row }: any) {
  11. return <el-switch v-model={ row.is_monitor }
  12. onChange={ (newVal: any) => handleMonitor({ id: row.id, isMonitor: newVal }) } />;
  13. }
  14. }
  15. },
  16. {
  17. field: 'product_info', title: '商品信息', minWidth: 'auto', align: 'center',
  18. slots: { default: 'product_info' }
  19. },
  20. {
  21. field: 'sku', title: 'SKU', minWidth: 'auto', align: 'center',
  22. slots: {
  23. default({ row }: any) {
  24. return <span class={ 'font-medium' }>{ row.sku ? row.sku : '--' }</span>;
  25. }
  26. }
  27. },
  28. {
  29. field: 'country_code', title: '国 家', minWidth: 'auto', align: 'center',
  30. slots: {
  31. default({ row }: any) {
  32. const country = countryInfoStore.countries.find(c => c.code === row.country_code);
  33. const color = country ? country.color : '#3875F6';
  34. return (
  35. <el-tag effect="plain" round
  36. style={ { color: color, borderColor: color } }>{ country ? country.name : '--' }
  37. </el-tag>
  38. );
  39. }
  40. }
  41. },
  42. {
  43. field: 'platform_number', title: '平台编号', minWidth: 'auto', align: 'center',
  44. slots: {
  45. default({ row }: any) {
  46. return <span class={ 'font-medium' }>{ row.platform_number ? row.platform_number : '--' }</span>;
  47. }
  48. }
  49. },
  50. {
  51. field: 'shop_name', title: '店 铺', minWidth: 'auto', align: 'center',
  52. slots: {
  53. default({ row }: any) {
  54. return (
  55. <el-tag type={ getTagType.value(row.shop_name) }>
  56. { row.shop_name ? row.shop_name : '--' }
  57. </el-tag>
  58. );
  59. }
  60. }
  61. },
  62. {
  63. field: 'tag', title: '分 组', minWidth: 'auto', align: 'center',
  64. slots: {
  65. default({ row }: any) {
  66. return (
  67. <el-tag type={ getTagType.value(row.tag) }>
  68. { row.tag ? row.tag : '--' }
  69. </el-tag>
  70. );
  71. }
  72. }
  73. },
  74. {
  75. field: 'brand', title: '品 牌', minWidth: 'auto', align: 'center',
  76. slots: {
  77. default({ row }: any) {
  78. return (
  79. <el-tag type={ getTagType.value(row.brand) } effect="plain" round>
  80. { row.brand ? row.brand : '--' }
  81. </el-tag>
  82. );
  83. }
  84. }
  85. },
  86. {
  87. field: 'price_info', title: '价 格', minWidth: 'auto', align: 'center',
  88. slots: {
  89. default({ row }: any) {
  90. return (
  91. <div v-if={ row.price > 0 } class={ `font-medium text-left` }>
  92. <p>现 价:{ row.currency_code + '‎' + row.price }</p>
  93. <p>折 扣:{ row.discount > 0 ? row.discount + '%' : '-' }</p>
  94. <p>优惠劵:{ !row || row.coupon <= 0 ? '-' : row.currency_code + '‎' + row.coupon }</p>
  95. </div>
  96. );
  97. }
  98. }
  99. },
  100. {
  101. field: 'show_price', title: '展示价格', minWidth: 'auto', align: 'center',
  102. slots: {
  103. default({ row }: any) {
  104. return <div class={ 'font-medium' }>{ row.show_price ? row.currency_code + row.show_price : '--' }</div>;
  105. }
  106. }
  107. },
  108. {
  109. field: 'activity_price', title: '平时活动售价', minWidth: 'auto', align: 'center',
  110. slots: {
  111. default({ row }: any) {
  112. return <div
  113. class={ 'font-medium' }>{ row.activity_price ? row.currency_code + row.activity_price : '--' }</div>;
  114. }
  115. }
  116. },
  117. {
  118. field: 'minimum_price', title: '最低活动售价', minWidth: 'auto', align: 'center',
  119. slots: {
  120. default({ row }: any) {
  121. return <div class={ 'font-medium' }>{ row.minimum_price ? row.currency_code + row.minimum_price : '--' }</div>;
  122. }
  123. }
  124. },
  125. {
  126. field: 'launch_date', title: '上架日期', minWidth: 'auto', align: 'center', sortable: true,
  127. slots: {
  128. default({ row }: any) {
  129. return <div class={ 'font-medium' }>{ row.launch_date ? row.launch_date : '--' }</div>;
  130. }
  131. }
  132. },
  133. {
  134. field: 'category', title: '类 目', minWidth: 'auto', align: 'center',
  135. slots: {
  136. default({ row }: any) {
  137. return <div class={ 'font-medium' }>{ row.category ? row.category : '--' }</div>;
  138. }
  139. }
  140. },
  141. {
  142. field: 'status', title: '状 态', minWidth: 'auto', align: 'center',
  143. slots: {
  144. default({ row }: any) {
  145. const statusText = row.status === 1 ? '在售' : '停售';
  146. const statusType = row.status === 1 ? 'success' : 'info';
  147. return (
  148. <el-tag type={ statusType }>
  149. { statusText }
  150. </el-tag>
  151. );
  152. }
  153. }
  154. },
  155. {
  156. field: 'update_datetime', title: '更新时间', minWidth: 'auto', align: 'center',
  157. slots: {
  158. default({ row }: any) {
  159. return <div class={ 'font-medium' }>{ row.update_datetime ? row.update_datetime : '--' }</div>;
  160. }
  161. }
  162. },
  163. {
  164. field: 'create_datetime', title: '创建时间', minWidth: 'auto', align: 'center',
  165. slots: {
  166. default({ row }: any) {
  167. return <div class={ 'font-medium' }>{ row.create_datetime ? row.create_datetime : '--' }</div>;
  168. }
  169. }
  170. },
  171. {
  172. field: 'operate', title: '操 作', width: 100, align: 'center', fixed: 'right',
  173. slots: { default: 'operate' }
  174. }
  175. ];