TableAction.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="vbe-table-actions">
  3. <div class="table-action action-edit" @click="handleView" v-if="showView">
  4. <i v-if="showIcon" class="el-icon-view"></i>
  5. <span>{{viewText}}</span>
  6. </div>
  7. <div class="table-action action-edit" @click="handleEdit" v-if="showEdit">
  8. <i v-if="showIcon" class="el-icon-edit-outline"/>
  9. <span>{{editText}}</span>
  10. </div>
  11. <div class="table-action action-delete" @click="handleDelete" v-if="showDel">
  12. <i v-if="showIcon" class="el-icon-delete"/>
  13. <span>{{deleteText}}</span>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'TableAction',
  20. props: {
  21. viewText: {
  22. type: String,
  23. default: "View"
  24. },
  25. editText: {
  26. type: String,
  27. default: "Edit"
  28. },
  29. deleteText: {
  30. type: String,
  31. default: "Delete"
  32. },
  33. showDel: {
  34. type: Boolean,
  35. default: true
  36. },
  37. showEdit: {
  38. type: Boolean,
  39. default: true
  40. },
  41. showView: {
  42. type: Boolean,
  43. default: false
  44. },
  45. showIcon: {
  46. type: Boolean,
  47. default: true
  48. }
  49. },
  50. methods: {
  51. handleEdit() {
  52. this.$emit('edit');
  53. },
  54. handleDelete() {
  55. this.$emit('delete');
  56. },
  57. handleView() {
  58. this.$emit('view');
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .vbe-table-actions {
  65. display: flex;
  66. align-items: center;
  67. justify-content: center;
  68. .table-action {
  69. padding: 0 8px;
  70. font-size: 14px;
  71. cursor: pointer;
  72. display: flex;
  73. align-items: center;
  74. position: relative;
  75. i {
  76. font-size: 15px;
  77. margin-right: 3px;
  78. }
  79. span {
  80. white-space: nowrap;
  81. }
  82. & + .table-action::after {
  83. left: 0;
  84. height: 14px;
  85. content: " ";
  86. position: absolute;
  87. border-left: 1px solid #999;
  88. }
  89. &::before {
  90. top: auto;
  91. left: 6px;
  92. right: 5px;
  93. bottom: 1px;
  94. height: 1px;
  95. content: " ";
  96. position: absolute;
  97. transform: scaleX(0);
  98. transition: all .2s;
  99. background-color: #3179E4;
  100. backface-visibility: hidden;
  101. }
  102. &:hover::before {
  103. transform: scaleX(1);
  104. }
  105. }
  106. .action-edit {
  107. color: #3179E4;
  108. }
  109. .action-delete {
  110. color: #ED3F3F;
  111. &::before {
  112. background-color: #ED3F3F;
  113. }
  114. }
  115. }
  116. </style>