DataTableSlot.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 : '#3875F6';
  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 + row.first_cost + row.final_cost +row.forwarding_fee+ row.ad_budget + row.return_or_refurbishment + row.storage_charges + row.brokerage)
  27. );
  28. // 日常活动毛利率 = 日常活动销售利润/日常活动售价(人民币)
  29. const gross_margin_daily = computed(() => routine_activity_profit.value / row.price_daily_rmb);
  30. // 平均毛利 = 0.8*日常活动毛利率 + 0.2*毛利率
  31. const average_gross_profit = computed(() => 0.8*gross_margin_daily.value +0.2*row.gross_profit_margin);
  32. function handleEdit() {
  33. emit('edit-row', row);
  34. }
  35. function onConfirm() {
  36. emit('handle-delete', row);
  37. }
  38. </script>
  39. <template>
  40. <div class="font-semibold">
  41. <div v-if="field === 'operate'">
  42. <div class="flex justify-center gap-2">
  43. <div v-if="hasPermission('PRICE_SUPPLY_UPDATE')">
  44. <PermissionButton circle plain type="warning" @click="handleEdit">
  45. <el-icon>
  46. <Operation />
  47. </el-icon>
  48. </PermissionButton>
  49. </div>
  50. <div v-if="hasPermission('PRICE_SUPPLY_DEL')">
  51. <el-popconfirm :icon="InfoFilled" icon-color="#626AEF" title="你确定要删除此项吗?" width="220" @confirm="onConfirm">
  52. <template #reference>
  53. <PermissionButton circle plain type="danger">
  54. <el-icon>
  55. <Delete />
  56. </el-icon>
  57. </PermissionButton>
  58. </template>
  59. <template #actions="{ confirm, cancel }">
  60. <el-button size="small" @click="cancel">No!</el-button>
  61. <el-button size="small" type="danger" @click="confirm"> Yes?</el-button>
  62. </template>
  63. </el-popconfirm>
  64. </div>
  65. </div>
  66. </div>
  67. <div v-else-if="field === 'average_gross_profit'">
  68. {{ average_gross_profit || '-'}}
  69. </div>
  70. <div v-else-if="field === 'routine_activity_profit'">
  71. {{ routine_activity_profit || '-'}}
  72. </div>
  73. <div v-else-if="field === 'gross_margin_daily'">
  74. {{ gross_margin_daily || '-'}}
  75. </div>
  76. <div v-else-if="field === 'country_code'">
  77. <el-tag :disable-transitions="true" :style="{ color: color, borderColor: color }" effect="plain" round>
  78. {{ country ? country.name : '-' }}
  79. </el-tag>
  80. </div>
  81. <div v-else-if="field === 'currency_code'">
  82. <el-tag :disable-transitions="true" :style="{ color: currencyColor, borderColor: currencyColor }" effect="plain" round>
  83. {{ currency ? currency.code : '-' }}
  84. </el-tag>
  85. </div>
  86. <div v-else>
  87. {{ row[field] || '-' }}
  88. </div>
  89. </div>
  90. </template>
  91. <style scoped></style>