DataTableSlot.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: DataTableSlot.vue
  4. * @Description: 商品监控-表格插槽
  5. * @Author: Cheney
  6. */
  7. import { useCountryInfoStore } from '/@/stores/countryInfo';
  8. import { Delete, Operation } from '@element-plus/icons-vue';
  9. import PermissionButton from '/@/components/PermissionButton/index.vue';
  10. import ProductInfo from '/@/views/product-manage/product-list/component/ProductInfo.vue';
  11. import { getTagType } from '/@/utils/useTagColor';
  12. const props = defineProps<{
  13. row: any,
  14. field: any
  15. }>();
  16. const { row, field } = props;
  17. const emit = defineEmits([ 'edit-row', 'handle-delete' ]);
  18. const countryInfoStore = useCountryInfoStore();
  19. const country = countryInfoStore.countries.find(c => c.code == row.country_code);
  20. const color = country ? country.color : '#3875F6';
  21. const statusText = row.status === 1 ? '在售' : '停售';
  22. const statusType = row.status === 1 ? 'success' : 'info';
  23. function handleEdit(row: any) {
  24. emit('edit-row', row);
  25. }
  26. function handleDelete(row: any) {
  27. emit('handle-delete', row);
  28. }
  29. </script>
  30. <template>
  31. <div class="font-medium">
  32. <div v-if="field === 'product_info'">
  33. <ProductInfo :img-width="50" :item="row.goods" style="min-width: 230px" />
  34. </div>
  35. <div v-else-if="field === 'country_code'">
  36. <el-tag :disable-transitions="true" :style="{ color: color, borderColor: color }" effect="plain" round>
  37. {{ country ? country.name : '--' }}
  38. </el-tag>
  39. </div>
  40. <div v-else-if="field === 'shop_name'">
  41. <el-tag :disable-transitions="true" :type=getTagType(row.shop_name)>
  42. {{ row.shop_name ?? '--' }}
  43. </el-tag>
  44. </div>
  45. <div v-else-if="field === 'tag'">
  46. <el-tag :disable-transitions="true" :type=getTagType(row.goods.tag)>
  47. {{ row.goods.tag ?? '--' }}
  48. </el-tag>
  49. </div>
  50. <div v-else-if="field === 'brand'">
  51. <el-tag :disable-transitions="true" :type=getTagType(row.goods.brand) effect="plain" round>
  52. {{ row.goods.brand ?? '--' }}
  53. </el-tag>
  54. </div>
  55. <div v-else-if="field === 'price_info'">
  56. <div v-if="row.goods.price > 0" class="font-medium">
  57. <p>现 价:{{ row.goods.currency_code + '‎' + row.goods.price }}</p>
  58. <p>折 扣:{{ row.goods.discount > 0 ? row.goods.discount + '%' : '-' }}</p>
  59. <p>优惠劵:{{ !row || row.goods.coupon <= 0 ? '-' : row.goods.currency_code + '‎' + row.goods.coupon }}</p>
  60. </div>
  61. </div>
  62. <div v-else-if="field === 'show_price'">
  63. <div class="font-medium">
  64. {{ row.goods.show_price ? row.goods.currency_code + row.goods.show_price : '--' }}
  65. </div>
  66. </div>
  67. <div v-else-if="field === 'activity_price'">
  68. <div class="font-medium">
  69. {{ row.goods.activity_price ? row.goods.currency_code + row.goods.activity_price : '--' }}
  70. </div>
  71. </div>
  72. <div v-else-if="field === 'minimum_price'">
  73. <div class="font-medium">
  74. {{ row.goods.minimum_price ? row.goods.currency_code + row.goods.minimum_price : '--' }}
  75. </div>
  76. </div>
  77. <div v-else-if="field === 'score'">
  78. <template v-if="row.goods.score !== null && row.goods.score !== undefined && row.goods.score !== ''">
  79. <el-rate
  80. v-if="row.goods.score > 0"
  81. v-model="row.goods.score"
  82. :colors="['#FF0000', '#FF9900', '#67C23A']"
  83. disabled
  84. show-score
  85. text-color="#1e293b"
  86. />
  87. <span v-else>{{ row.goods.score }}</span> <!-- 值为0时显示0 -->
  88. </template>
  89. <template v-else>
  90. <span>--</span> <!-- 无值时显示'--' -->
  91. </template>
  92. </div>
  93. <div v-else-if="field === 'all_score'">
  94. <template v-if="row.goods.all_score !== null && row.goods.all_score !== undefined && row.goods.all_score !== ''">
  95. <el-rate
  96. v-if="row.goods.all_score > 0"
  97. v-model="row.goods.all_score"
  98. :colors="['#FF0000', '#FF9900', '#67C23A']"
  99. disabled
  100. show-score
  101. text-color="#1e293b"
  102. />
  103. <span v-else>{{ row.goods.all_score }}</span>
  104. </template>
  105. <template v-else>
  106. <span>--</span>
  107. </template>
  108. </div>
  109. <div v-else-if="field === 'stars'" class="flex flex-col font-normal" style="min-width: 170px">
  110. <div v-for="i in [5,4,3,2,1]" :key="i" class="w-full flex items-center">
  111. <span class="w-10 text-right mr-2">{{ i }}星</span>
  112. <el-progress
  113. striped
  114. striped-flow
  115. :color="'#3A8EE6'"
  116. :percentage="row.goods[`ratings${i}`]"
  117. :stroke-width="10"
  118. class="flex-1"
  119. />
  120. </div>
  121. </div>
  122. <div v-else-if="field === 'all_stars'" class="flex flex-col font-normal" style="min-width: 170px">
  123. <div v-for="i in [5,4,3,2,1]" :key="i" class="w-full flex items-center">
  124. <span class="w-10 text-right mr-2">{{ i }}星</span>
  125. <el-progress
  126. striped
  127. striped-flow
  128. :color="'#3A8EE6'"
  129. :percentage="row.goods[`all_rate${i}`]"
  130. :stroke-width="10"
  131. class="flex-1"
  132. />
  133. </div>
  134. </div>
  135. <div v-else-if="field === 'status'">
  136. <el-tag :disable-transitions="true" :type=statusType>
  137. {{ statusText }}
  138. </el-tag>
  139. </div>
  140. <div v-else-if="field === 'operate'">
  141. <div class="flex justify-center gap-2">
  142. <PermissionButton circle plain type="warning" @click="handleEdit(row)">
  143. <el-icon>
  144. <Operation />
  145. </el-icon>
  146. </PermissionButton>
  147. <PermissionButton circle plain type="danger" @click="handleDelete(row)">
  148. <el-icon>
  149. <Delete />
  150. </el-icon>
  151. </PermissionButton>
  152. </div>
  153. </div>
  154. <div v-else>
  155. {{ row.goods[field] }}
  156. </div>
  157. </div>
  158. </template>
  159. <style scoped>
  160. :deep(.flex-1 .el-progress__text) {
  161. font-size: 14px !important;
  162. }
  163. </style>