TableTool.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div style="float: right">
  3. <!-- <div v-show="stripe" class="stripe-panel">-->
  4. <!-- <el-checkbox v-model="stripe">斑马纹</el-checkbox>-->
  5. <!-- </div>-->
  6. <!-- <div class="border-panel">-->
  7. <!-- <el-checkbox v-model="border">边框(可拉伸列)</el-checkbox>-->
  8. <!-- </div>-->
  9. <!-- <el-button-->
  10. <!-- style="margin: 0 10px 10px 0 !important"-->
  11. <!-- type="primary"-->
  12. <!-- @click="clickFullScreen">-->
  13. <!-- <vab-icon-->
  14. <!-- :icon="isFullscreen ? 'fullscreen-exit-fill' : 'fullscreen-fill'" />-->
  15. <!-- 表格全屏-->
  16. <!-- </el-button>-->
  17. <!-- <el-popover-->
  18. <!-- ref="popover"-->
  19. <!-- popper-class="custom-table-checkbox"-->
  20. <!-- trigger="hover">-->
  21. <!-- <el-radio-group v-model="lineHeight">-->
  22. <!-- <el-radio label="medium">大</el-radio>-->
  23. <!-- <el-radio label="small">中</el-radio>-->
  24. <!-- <el-radio label="mini">小</el-radio>-->
  25. <!-- </el-radio-group>-->
  26. <!-- <template #reference>-->
  27. <!-- <el-button style="margin: 0 10px 10px 0 !important" type="primary">-->
  28. <!-- <vab-icon icon="line-height" />-->
  29. <!-- 表格尺寸-->
  30. <!-- </el-button>-->
  31. <!-- </template>-->
  32. <!-- </el-popover>-->
  33. <el-popover popper-class="custom-table-checkbox" trigger="hover">
  34. <el-checkbox-group v-model="checkColumns">
  35. <vab-draggable v-bind="dragOptions" :list="columns">
  36. <div v-for="(item, index) in columns" :key="item + index">
  37. <vab-icon icon="drag-drop-line" />
  38. <el-checkbox :disabled="item.disableCheck === true" :label="item.label">
  39. {{ item.label }}
  40. </el-checkbox>
  41. </div>
  42. </vab-draggable>
  43. </el-checkbox-group>
  44. <template #reference>
  45. <el-button icon="el-icon-setting" style="margin: 0 10px 10px 0 !important" />
  46. </template>
  47. </el-popover>
  48. </div>
  49. </template>
  50. <script>
  51. import VabDraggable from 'vuedraggable'
  52. export default {
  53. name: 'TableTool',
  54. components: {
  55. VabDraggable,
  56. },
  57. props: {
  58. columns: {
  59. type: Array,
  60. default() {
  61. return []
  62. },
  63. },
  64. checkList: {
  65. type: Array,
  66. default() {
  67. return []
  68. },
  69. },
  70. },
  71. data() {
  72. return {
  73. isFullscreen: false,
  74. border: true,
  75. height: this.$baseTableHeight(1),
  76. stripe: false,
  77. lineHeight: 'medium',
  78. // checkList: ['标题', '作者', '评级', '点击量', '时间'],
  79. // columns: [
  80. // {
  81. // label: '标题',
  82. // width: 'auto',
  83. // prop: 'title',
  84. // sortable: true,
  85. // disableCheck: true,
  86. // },
  87. // ],
  88. flag: true,
  89. }
  90. },
  91. computed: {
  92. dragOptions() {
  93. return {
  94. animation: 600,
  95. group: 'description',
  96. }
  97. },
  98. checkColumns: {
  99. get() {
  100. return this.checkList
  101. },
  102. set(val) {
  103. this.$emit('update:checkList', val)
  104. },
  105. },
  106. },
  107. created() {
  108. let list = []
  109. for (let item of this.columns) {
  110. list.push(item['label'])
  111. }
  112. this.$emit('update:checkList', list)
  113. },
  114. methods: {},
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .custom-table-container {
  119. :deep() {
  120. i {
  121. cursor: pointer;
  122. }
  123. }
  124. .stripe-panel,
  125. .border-panel {
  126. margin: 0 10px #{$base-margin/2} 10px !important;
  127. }
  128. }
  129. </style>
  130. <style lang="scss">
  131. .custom-table-checkbox {
  132. [class*='ri'] {
  133. vertical-align: -2.5px;
  134. cursor: pointer;
  135. }
  136. .el-checkbox {
  137. margin: 5px 0 5px 8px;
  138. }
  139. }
  140. </style>