DataTableSlot.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: DataTableSlot.vue
  4. * @Description: 产品属性-单元格插槽
  5. * @Author: Cheney
  6. */
  7. import { Delete, InfoFilled, Key, Operation, Tools, View } from '@element-plus/icons-vue';
  8. import PermissionButton from '/@/components/PermissionButton/index.vue';
  9. import { hasPermission } from '/@/utils/hasPermission';
  10. const props = defineProps<{
  11. row: any;
  12. field: any;
  13. }>();
  14. const { row, field } = props;
  15. const emit = defineEmits([ 'edit-row', 'handle-delete', 'handle-manage', 'show-detail' ]);
  16. function handleView() {
  17. emit('show-detail', row);
  18. }
  19. function handleEdit() {
  20. emit('edit-row', row);
  21. }
  22. function onConfirm() {
  23. emit('handle-delete', row);
  24. }
  25. function handleManage() {
  26. emit('handle-manage', row);
  27. }
  28. </script>
  29. <template>
  30. <div class="font-medium">
  31. <div v-if="field === 'operate'">
  32. <div class="flex justify-center gap-2">
  33. <div v-if="hasPermission('SkuAttrUpdate')">
  34. <PermissionButton circle plain type="warning" @click="handleEdit">
  35. <el-icon>
  36. <Operation />
  37. </el-icon>
  38. </PermissionButton>
  39. </div>
  40. <div v-if="hasPermission('SkuAttrDelete')">
  41. <el-popconfirm :icon="InfoFilled" icon-color="#626AEF" title="你确定要删除此项吗?" width="220"
  42. @confirm="onConfirm">
  43. <template #reference>
  44. <PermissionButton circle plain type="danger">
  45. <el-icon>
  46. <Delete />
  47. </el-icon>
  48. </PermissionButton>
  49. </template>
  50. <template #actions="{ confirm, cancel }">
  51. <el-button size="small" @click="cancel">No!</el-button>
  52. <el-button size="small" type="danger" @click="confirm"> Yes?</el-button>
  53. </template>
  54. </el-popconfirm>
  55. </div>
  56. <div>
  57. <el-tooltip :enterable="false" :show-arrow="false" content="管理枚举" placement="top"
  58. popper-class="custom-btn-tooltip-2">
  59. <el-button :icon="Key" circle color="#8d87e8" plain @click="handleManage"></el-button>
  60. </el-tooltip>
  61. </div>
  62. <div>
  63. <el-button :icon="View" circle plain type="success" @click="handleView"></el-button>
  64. </div>
  65. </div>
  66. </div>
  67. <div v-else>
  68. {{ row[field] }}
  69. </div>
  70. </div>
  71. </template>
  72. <style lang="scss">
  73. .custom-btn-tooltip-2 {
  74. background-color: #f0f0fe !important;
  75. color: #606266 !important;
  76. border: 1px solid #8d87e8 !important;
  77. font-size: 14px;
  78. }
  79. </style>