DataTableSlot.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script setup lang="ts">
  2. /**
  3. * @Name: DataTableSlot.vue
  4. * @Description:
  5. * @Author: xinyan
  6. */
  7. import { hasPermission } from '/@/utils/hasPermission';
  8. import { Delete, InfoFilled, Key, Operation, View } from '@element-plus/icons-vue';
  9. import PermissionButton from '/@/components/PermissionButton/index.vue';
  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 handleEdit() {
  17. emit('edit-row', row);
  18. }
  19. function onConfirm() {
  20. emit('handle-delete', row);
  21. }
  22. </script>
  23. <template>
  24. <div class="font-medium">
  25. <div v-if="field === 'operate'">
  26. <div class="flex justify-center gap-2">
  27. <div v-if="hasPermission('SkuAttrUpdate')">
  28. <PermissionButton circle plain type="warning" @click="handleEdit">
  29. <el-icon>
  30. <Operation />
  31. </el-icon>
  32. </PermissionButton>
  33. </div>
  34. <div v-if="hasPermission('SkuAttrDelete')">
  35. <el-popconfirm :icon="InfoFilled" icon-color="#626AEF" title="你确定要删除此项吗?" width="220"
  36. @confirm="onConfirm">
  37. <template #reference>
  38. <PermissionButton circle plain type="danger">
  39. <el-icon>
  40. <Delete />
  41. </el-icon>
  42. </PermissionButton>
  43. </template>
  44. <template #actions="{ confirm, cancel }">
  45. <el-button size="small" @click="cancel">No!</el-button>
  46. <el-button size="small" type="danger" @click="confirm"> Yes?</el-button>
  47. </template>
  48. </el-popconfirm>
  49. </div>
  50. </div>
  51. </div>
  52. <div v-else>
  53. {{ row[field] || '-' }}
  54. </div>
  55. </div>
  56. </template>
  57. <style scoped>
  58. </style>