DataTableSlot.vue 7.7 KB

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