DataTableSlot.vue 4.2 KB

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