DataTableSlot.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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, InfoFilled, Operation, Tickets, Timer } from '@element-plus/icons-vue';
  9. import { getTagType } from '/@/utils/useTagColor';
  10. import PermissionButton from '/@/components/PermissionButton/index.vue';
  11. import ProductInfo from '/@/views/product-manage/component/ProductInfo.vue';
  12. import ProgressBar from '/@/views/product-manage/product-monitor/component/ProgressBar.vue';
  13. import router from '/@/router';
  14. const props = defineProps<{
  15. row: any,
  16. field: any
  17. }>();
  18. const { row, field } = props;
  19. const emit = defineEmits([ 'edit-row', 'handle-delete' ]);
  20. const countryInfoStore = useCountryInfoStore();
  21. const country = countryInfoStore.Countries.find(c => c.code == row.country_code);
  22. const color = country ? country.color : '#3875F6';
  23. const statusText = row.status === 1 ? '在售' : '停售';
  24. const statusType = row.status === 1 ? 'success' : 'info';
  25. function handleEdit() {
  26. emit('edit-row', row);
  27. }
  28. function onConfirm() {
  29. emit('handle-delete', row);
  30. }
  31. function handleNavigate(path: string) {
  32. console.log('row=> ', row);
  33. router.push({
  34. path,
  35. query: {
  36. img: row.goods.img,
  37. title: row.goods.title,
  38. url: row.goods.url,
  39. asin: row.goods.asin
  40. }
  41. });
  42. }
  43. </script>
  44. <template>
  45. <div class="font-medium">
  46. <div v-if="field === 'product_info'">
  47. <ProductInfo :img-width="50" :item="row.goods"/>
  48. </div>
  49. <div v-else-if="field === 'country_code'">
  50. <el-tag :disable-transitions="true" :style="{ color: color, borderColor: color }" effect="plain" round>
  51. {{ country ? country.name : '-' }}
  52. </el-tag>
  53. </div>
  54. <div v-else-if="field === 'shop_name'">
  55. <el-tag v-if="row.goods.shop_name" :disable-transitions="true" :type=getTagType(row.shop_name)>
  56. {{ row.shop_name }}
  57. </el-tag>
  58. <div v-else>-</div>
  59. </div>
  60. <div v-else-if="field === 'tag'">
  61. <el-tag v-if="row.goods.tag" :disable-transitions="true" :type=getTagType(row.goods.tag)>
  62. {{ row.goods.tag }}
  63. </el-tag>
  64. <div v-else>-</div>
  65. </div>
  66. <div v-else-if="field === 'brand'">
  67. <el-tag v-if="row.goods.brand" :disable-transitions="true" :type=getTagType(row.goods.brand) effect="plain" round>
  68. {{ row.goods.brand }}
  69. </el-tag>
  70. <div v-else>-</div>
  71. </div>
  72. <div v-else-if="field === 'price_info'">
  73. <div v-if="row.goods.price >= 0" class="font-medium">
  74. <p>现 价:{{ row.goods.currency_code + '‎' + row.goods.price }}</p>
  75. <p>折 扣:{{ row.goods.discount > 0 ? row.goods.discount + '%' : '-' }}</p>
  76. <p>优惠劵:{{ !row || row.goods.coupon <= 0 ? '-' : row.goods.currency_code + '‎' + row.goods.coupon }}</p>
  77. </div>
  78. </div>
  79. <div v-else-if="field === 'show_price'">
  80. <div class="font-medium">
  81. {{ row.goods.show_price ? row.goods.currency_code + row.goods.show_price : '-' }}
  82. </div>
  83. </div>
  84. <div v-else-if="field === 'activity_price'">
  85. <div class="font-medium">
  86. {{ row.goods.activity_price ? row.goods.currency_code + row.goods.activity_price : '-' }}
  87. </div>
  88. </div>
  89. <div v-else-if="field === 'minimum_price'">
  90. <div class="font-medium">
  91. {{ row.goods.minimum_price ? row.goods.currency_code + row.goods.minimum_price : '-' }}
  92. </div>
  93. </div>
  94. <div v-else-if="field === 'score'">
  95. <template v-if="row.goods.score !== null && row.goods.score !== undefined && row.goods.score !== ''">
  96. <el-rate
  97. v-if="row.goods.score > 0"
  98. v-model="row.goods.score"
  99. :colors="['#FF0000', '#FF9900', '#67C23A']"
  100. disabled
  101. show-score
  102. text-color="#1e293b"
  103. />
  104. <span v-else>{{ row.goods.score }}</span> <!-- 值为0时显示0 -->
  105. </template>
  106. <template v-else>
  107. <span>-</span> <!-- 无值时显示'--' -->
  108. </template>
  109. </div>
  110. <div v-else-if="field === 'all_score'">
  111. <template v-if="row.goods.all_score !== null && row.goods.all_score !== undefined && row.goods.all_score !== ''">
  112. <el-rate
  113. v-if="row.goods.all_score > 0"
  114. v-model="row.goods.all_score"
  115. :colors="['#FF0000', '#FF9900', '#67C23A']"
  116. disabled
  117. show-score
  118. text-color="#1e293b"
  119. />
  120. <span v-else>{{ row.goods.all_score }}</span>
  121. </template>
  122. <template v-else>
  123. <span>-</span>
  124. </template>
  125. </div>
  126. <div v-else-if="field === 'stars'" class="flex flex-col font-normal" style="min-width: 170px">
  127. <ProgressBar :row="row" percentage="ratings"/>
  128. </div>
  129. <div v-else-if="field === 'all_stars'" class="flex flex-col font-normal" style="min-width: 170px">
  130. <ProgressBar :row="row" percentage="all_rate"/>
  131. </div>
  132. <div v-else-if="field === 'status'">
  133. <el-tag :disable-transitions="true" :type=statusType>
  134. {{ statusText }}
  135. </el-tag>
  136. </div>
  137. <div v-else-if="field === 'operate'">
  138. <div class="flex justify-center gap-2 mb-2">
  139. <el-tooltip :enterable="false" :show-arrow="false" content="评论详情" hide-after="0"
  140. placement="top" popper-class="custom-btn-tooltip">
  141. <PermissionButton circle plain type="success" @click="handleNavigate('/product/comment')">
  142. <el-icon>
  143. <Tickets/>
  144. </el-icon>
  145. </PermissionButton>
  146. </el-tooltip>
  147. <el-tooltip :enterable="false" :show-arrow="false" content="历史详情" hide-after="0"
  148. placement="top" popper-class="custom-btn-tooltip-2">
  149. <PermissionButton :color="'#6466F1'" circle plain type="success" @click="handleNavigate('/product/history')">
  150. <el-icon>
  151. <Timer/>
  152. </el-icon>
  153. </PermissionButton>
  154. </el-tooltip>
  155. </div>
  156. <div class="flex justify-center gap-2">
  157. <PermissionButton circle plain type="warning" @click="handleEdit">
  158. <el-icon>
  159. <Operation/>
  160. </el-icon>
  161. </PermissionButton>
  162. <el-popconfirm
  163. :icon="InfoFilled"
  164. icon-color="#626AEF"
  165. title="你确定要删除此项吗?"
  166. width="220"
  167. @confirm="onConfirm"
  168. >
  169. <template #reference>
  170. <PermissionButton circle plain type="danger">
  171. <el-icon>
  172. <Delete/>
  173. </el-icon>
  174. </PermissionButton>
  175. </template>
  176. <template #actions="{ confirm, cancel }">
  177. <el-button size="small" @click="cancel">No!</el-button>
  178. <el-button
  179. size="small"
  180. type="danger"
  181. @click="confirm"
  182. >
  183. Yes?
  184. </el-button>
  185. </template>
  186. </el-popconfirm>
  187. </div>
  188. </div>
  189. <div v-else>
  190. {{ row.goods[field] || '-' }}
  191. </div>
  192. </div>
  193. </template>
  194. <style scoped>
  195. :deep(.flex-1 .el-progress__text) {
  196. font-size: 14px !important;
  197. }
  198. </style>
  199. <style lang="scss">
  200. .custom-btn-tooltip {
  201. background-color: #EFF9EB !important;
  202. color: #606266 !important;
  203. border: 1px solid #67C23A !important;
  204. font-size: 14px;
  205. }
  206. .custom-btn-tooltip-2 {
  207. background-color: #F0F0FE !important;
  208. color: #606266 !important;
  209. border: 1px solid #6466F1 !important;
  210. font-size: 14px;
  211. }
  212. </style>