TableTool.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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
  46. icon="el-icon-setting"
  47. style="margin: 0 10px 10px 0 !important; font-size: 18px; color: black"
  48. type="text" />
  49. </template>
  50. </el-popover>
  51. </div>
  52. </template>
  53. <script>
  54. import VabDraggable from 'vuedraggable'
  55. export default {
  56. name: 'TableTool',
  57. components: {
  58. VabDraggable,
  59. },
  60. props: {
  61. columns: {
  62. type: Array,
  63. default() {
  64. return []
  65. },
  66. },
  67. checkList: {
  68. type: Array,
  69. default() {
  70. return []
  71. },
  72. },
  73. },
  74. data() {
  75. return {
  76. isFullscreen: false,
  77. border: true,
  78. height: this.$baseTableHeight(1),
  79. stripe: false,
  80. lineHeight: 'medium',
  81. // checkList: ['标题', '作者', '评级', '点击量', '时间'],
  82. // columns: [
  83. // {
  84. // label: '标题',
  85. // width: 'auto',
  86. // prop: 'title',
  87. // sortable: true,
  88. // disableCheck: true,
  89. // },
  90. // ],
  91. flag: true,
  92. }
  93. },
  94. computed: {
  95. dragOptions() {
  96. return {
  97. animation: 600,
  98. group: 'description',
  99. }
  100. },
  101. checkColumns: {
  102. get() {
  103. return this.checkList
  104. },
  105. set(val) {
  106. this.$emit('update:checkList', val)
  107. },
  108. },
  109. },
  110. created() {
  111. let list = []
  112. for (let item of this.columns) {
  113. list.push(item['label'])
  114. }
  115. this.$emit('update:checkList', list)
  116. },
  117. methods: {},
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .custom-table-container {
  122. :deep() {
  123. i {
  124. cursor: pointer;
  125. }
  126. }
  127. .stripe-panel,
  128. .border-panel {
  129. margin: 0 10px #{$base-margin/2} 10px !important;
  130. }
  131. }
  132. </style>
  133. <style lang="scss">
  134. .custom-table-checkbox {
  135. [class*='ri'] {
  136. vertical-align: -2.5px;
  137. cursor: pointer;
  138. }
  139. .el-checkbox {
  140. margin: 5px 0 5px 8px;
  141. }
  142. }
  143. </style>