DataTableSlot.vue 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: DataTableSlot.vue
  4. * @Description: 商品列表-单元格插槽
  5. * @Author: Cheney
  6. */
  7. import { useCountryInfoStore } from '/@/stores/countryInfo';
  8. import { getTagType } from '/@/utils/useTagColor';
  9. import { Tickets } from '@element-plus/icons-vue';
  10. import PermissionButton from '/@/components/PermissionButton/index.vue';
  11. import { useResponse } from '/@/utils/useResponse';
  12. import * as api from '../api';
  13. const router = useRouter();
  14. const props = defineProps<{
  15. row: any,
  16. field: any
  17. }>();
  18. const { row, field } = props;
  19. const countryInfoStore = useCountryInfoStore();
  20. const country = countryInfoStore.Countries.find(c => c.code == row.country_code);
  21. const color = country ? country.color : '#3875F6';
  22. const region = countryInfoStore.Region.find(r => r.code == row.shop.region);
  23. async function goto() {
  24. const query = {
  25. asin: row.asin,
  26. country_code: row.country_code
  27. }
  28. const res: any = await useResponse(api.getDetail, query )
  29. const routeUrl = router.resolve({
  30. path: '/product/comment',
  31. query: {
  32. asin: res.data[0].asin,
  33. title: res.data[0].title,
  34. img: res.data[0].img,
  35. url: res.data[0].url
  36. }
  37. });
  38. window.open(routeUrl.href, '_blank');
  39. }
  40. </script>
  41. <template>
  42. <div class="font-medium">
  43. <div v-if="field === 'region'">
  44. <el-tag :disable-transitions="true" :type=getTagType(row.shop.region)>
  45. {{ region ? region.name : '-' }}
  46. </el-tag>
  47. </div>
  48. <div v-else-if="field === 'country_code'">
  49. <el-tag :disable-transitions="true" :style="{ color: color, borderColor: color }" effect="plain" round>
  50. {{ country ? country.name : '-' }}
  51. </el-tag>
  52. </div>
  53. <div v-else-if="field === 'platform_number'">
  54. {{ row.shop.platform_number }}
  55. </div>
  56. <div v-else-if="field === 'shop_name'">
  57. {{ row.shop.name }}
  58. </div>
  59. <div v-else-if="field === 'fulfillment_channel'">
  60. <el-tag :disable-transitions="true" :type="row.fulfillment_channel === 'FBM' ? 'primary' : 'warning'">
  61. {{ row.fulfillment_channel }}
  62. </el-tag>
  63. </div>
  64. <div v-else-if="field === 'status'">
  65. <el-tag :disable-transitions="true"
  66. :type="row.status === 'Active' ? 'success' : row.status === 'Inactive' ? 'danger' : 'info'">
  67. {{ row.status === 'Active' ? '在售' : row.status === 'Inactive' ? '不在售' : '不完整' }}
  68. </el-tag>
  69. </div>
  70. <div v-else-if="field === 'operate'">
  71. <el-tooltip :enterable="false" :show-arrow="false" content="评论详情" hide-after="0"
  72. placement="top" popper-class="custom-btn-tooltip">
  73. <PermissionButton circle plain type="success" @click="goto">
  74. <el-icon>
  75. <Tickets />
  76. </el-icon>
  77. </PermissionButton>
  78. </el-tooltip>
  79. </div>
  80. <!-- 动态获取 -->
  81. <div v-else>
  82. {{ row[field] }}
  83. </div>
  84. </div>
  85. </template>
  86. <style scoped>
  87. </style>