DataTableSlot.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: DataTableSlot.vue
  4. * @Description: 审批查看(直接销售)数据表格插槽
  5. * @Author: xinyan
  6. */
  7. import { hasPermission } from '/@/utils/hasPermission';
  8. import { Delete, InfoFilled, Operation } from '@element-plus/icons-vue';
  9. import PermissionButton from '/@/components/PermissionButton/index.vue';
  10. import { useCountryInfoStore } from '/@/stores/countryInfo';
  11. const props = defineProps<{
  12. row: any;
  13. field: any;
  14. }>();
  15. const { row, field } = props;
  16. const emit = defineEmits(['edit-row', 'handle-delete', 'handle-manage', 'show-detail']);
  17. const countryInfoStore = useCountryInfoStore();
  18. const country = countryInfoStore.Countries.find((c) => c.code == row.country_code);
  19. const color = country ? country.color : '#626AEF';
  20. const currency = countryInfoStore.CurrencyCodes.find((c) => c.code == row.currency_code);
  21. const currencyColor = currency ? currency.color : '#626AEF';
  22. // 日常活动销售利润 = 日常活动售价(人民币)-出口报关价-头程运费-尾程费用-转发费-广告费-退货成本-VAT-仓储费-佣金
  23. const routine_activity_profit = computed(
  24. () =>
  25. row.price_daily_rmb -
  26. (row.export_tax +
  27. row.first_cost +
  28. row.final_cost +
  29. row.forwarding_fee +
  30. row.ad_budget +
  31. row.return_or_refurbishment +
  32. row.storage_charges +
  33. row.brokerage)
  34. );
  35. // 日常活动毛利率 = 日常活动销售利润/日常活动售价(人民币)
  36. const gross_margin_daily = computed(() => routine_activity_profit.value / row.price_daily_rmb);
  37. // 平均毛利 = 0.8*日常活动毛利率 + 0.2*毛利率
  38. const average_gross_profit = computed(() => 0.8 * gross_margin_daily.value + 0.2 * row.gross_profit_margin);
  39. function handleEdit() {
  40. emit('edit-row', row);
  41. }
  42. function onConfirm() {
  43. emit('handle-delete', row);
  44. }
  45. </script>
  46. <template>
  47. <div class="font-semibold">
  48. <div v-if="field === 'operate'">
  49. <div class="flex justify-center gap-2">
  50. <div v-if="hasPermission('PRICE_DIRECT_UPDATE')">
  51. <PermissionButton circle plain type="warning" @click="handleEdit">
  52. <el-icon>
  53. <Operation />
  54. </el-icon>
  55. </PermissionButton>
  56. </div>
  57. <div v-if="hasPermission('PRICE_DIRECT_DEL')">
  58. <el-popconfirm :icon="InfoFilled" icon-color="#626AEF" title="你确定要删除此项吗?" width="220" @confirm="onConfirm">
  59. <template #reference>
  60. <PermissionButton circle plain type="danger">
  61. <el-icon>
  62. <Delete />
  63. </el-icon>
  64. </PermissionButton>
  65. </template>
  66. <template #actions="{ confirm, cancel }">
  67. <el-button size="small" @click="cancel">No!</el-button>
  68. <el-button size="small" type="danger" @click="confirm"> Yes?</el-button>
  69. </template>
  70. </el-popconfirm>
  71. </div>
  72. </div>
  73. </div>
  74. <div v-else-if="field === 'average_gross_profit'">
  75. {{ average_gross_profit && average_gross_profit !== -Infinity ? average_gross_profit : '-' }}
  76. </div>
  77. <div v-else-if="field === 'routine_activity_profit'">
  78. {{ routine_activity_profit && routine_activity_profit !== -Infinity ? routine_activity_profit : '-' }}
  79. </div>
  80. <div v-else-if="field === 'gross_margin_daily'">
  81. {{ gross_margin_daily && gross_margin_daily !== -Infinity ? gross_margin_daily : '-' }}
  82. </div>
  83. <div v-else-if="field === 'country_code'">
  84. <el-tag :disable-transitions="true" :style="{ color: color, borderColor: color }" effect="plain" round>
  85. {{ country ? country.name : '-' }}
  86. </el-tag>
  87. </div>
  88. <div v-else-if="field === 'currency_code'">
  89. <el-tag :disable-transitions="true" :style="{ color: currencyColor, borderColor: currencyColor }" effect="plain" round>
  90. {{ currency ? currency.code : '-' }}
  91. </el-tag>
  92. </div>
  93. <div v-else>
  94. {{ row[field] || '-' }}
  95. </div>
  96. </div>
  97. </template>
  98. <style scoped></style>