DataTableSlot.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <script lang="ts" setup>
  2. /**
  3. * @Name: DataTableSlot.vue
  4. * @Description: 公司SKU-单元格插槽
  5. * @Author: Cheney
  6. */
  7. import { Delete, DocumentCopy, InfoFilled, Operation, Position, View } from '@element-plus/icons-vue';
  8. import PermissionButton from '/@/components/PermissionButton/index.vue';
  9. import { getTagType } from '/@/utils/useTagColor';
  10. import { handleCopy } from '/@/utils/useCopyText';
  11. const props = defineProps<{
  12. row: any;
  13. field: any;
  14. }>();
  15. const { row, field } = props;
  16. const emit: any = defineEmits([ 'edit-row', 'handle-delete', 'show-sku', 'release-sku' ]);
  17. function handleEdit() {
  18. emit('edit-row', row);
  19. }
  20. function onConfirm() {
  21. emit('handle-delete', row);
  22. }
  23. function release() {
  24. emit('release-sku', row);
  25. }
  26. function showDetail() {
  27. emit('show-sku', row);
  28. }
  29. </script>
  30. <template>
  31. <div class="font-medium">
  32. <div v-if="field === 'operate'">
  33. <div class="flex justify-center gap-2 mb-2">
  34. <div>
  35. <PermissionButton circle plain type="success" @click="showDetail()">
  36. <el-icon>
  37. <View />
  38. </el-icon>
  39. </PermissionButton>
  40. </div>
  41. <div>
  42. <PermissionButton circle plain type="warning" @click="handleEdit">
  43. <el-icon>
  44. <Operation />
  45. </el-icon>
  46. </PermissionButton>
  47. </div>
  48. <div>
  49. <el-popconfirm :icon="InfoFilled" icon-color="#626AEF" title="发布后此sku将无法更改, 是否继续?" width="220"
  50. @confirm="release">
  51. <template #reference>
  52. <!--div不可以删除,否则会导致popconfirm的弹出框消失-->
  53. <div>
  54. <el-tooltip :enterable="false" :show-arrow="false" content="发布" hide-after="0" placement="top"
  55. popper-class="custom-btn-tooltip-2">
  56. <PermissionButton :color="'#6466F1'" :disabled="row.status === 3" circle plain>
  57. <el-icon>
  58. <Position />
  59. </el-icon>
  60. </PermissionButton>
  61. </el-tooltip>
  62. </div>
  63. </template>
  64. <template #actions="{ confirm, cancel }">
  65. <el-button size="small" @click="cancel">No!</el-button>
  66. <el-button size="small" type="danger" @click="confirm"> Yes?</el-button>
  67. </template>
  68. </el-popconfirm>
  69. </div>
  70. <div>
  71. <el-popconfirm :icon="InfoFilled" icon-color="#626AEF" title="你确定要删除此项吗?" width="220"
  72. @confirm="onConfirm">
  73. <template #reference>
  74. <PermissionButton :disabled="row.status === 3" circle plain type="danger">
  75. <el-icon>
  76. <Delete />
  77. </el-icon>
  78. </PermissionButton>
  79. </template>
  80. <template #actions="{ confirm, cancel }">
  81. <el-button size="small" @click="cancel">No!</el-button>
  82. <el-button size="small" type="danger" @click="confirm"> Yes?</el-button>
  83. </template>
  84. </el-popconfirm>
  85. </div>
  86. </div>
  87. </div>
  88. <div v-else-if="field === 'sku'" class="flex flex-nowrap">
  89. {{ row.sku }}
  90. <el-button :disabled="!row.sku" :icon="DocumentCopy" class="ml-2 cursor-pointer" link
  91. @click="handleCopy(row.sku || '')"></el-button>
  92. </div>
  93. <div v-else-if="field === 'brand'">
  94. <el-tag :disable-transitions="true" :type="getTagType(row.brand.brand_name)" effect="plain" round>
  95. {{ row.brand.brand_name }}
  96. </el-tag>
  97. </div>
  98. <div v-else-if="field === 'kind'">
  99. <el-tag :disable-transitions="true" :type="getTagType(row.kind.name)" effect="plain" round>
  100. {{ row.kind.name }}
  101. </el-tag>
  102. </div>
  103. <div v-else-if="field === 'status'">
  104. <el-tag :disable-transitions="true" :type="row.status === 1 ? 'warning' : 'success'">
  105. {{ row.status === 1 ? '草稿' : '已发布' }}
  106. </el-tag>
  107. </div>
  108. <div v-else>
  109. {{ row[field] }}
  110. </div>
  111. </div>
  112. </template>
  113. <style lang="scss">
  114. .custom-btn-tooltip-2 {
  115. background-color: #f0f0fe !important;
  116. color: #606266 !important;
  117. border: 1px solid #6466f1 !important;
  118. font-size: 14px;
  119. }
  120. </style>