index.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="PublicPageTable">
  3. <el-table ref="table" :data="tableData" row-key="id" border default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}" @selection-change="handleSelectionChange" @select="selectBox">
  4. <el-table-column type="selection" width="55">
  5. </el-table-column>
  6. <el-table-column prop="name" label="名称" width="450">
  7. </el-table-column>
  8. <el-table-column prop="date" label="类型" width="180">
  9. </el-table-column>
  10. <el-table-column prop="address" label="所属应用">
  11. </el-table-column>
  12. <el-table-column prop="address" label="编码">
  13. </el-table-column>
  14. <el-table-column prop="address" label="描述">
  15. </el-table-column>
  16. <el-table-column label="操作">
  17. <template slot-scope="scope">
  18. <el-button @click="handleDetails(scope.row)" type="text">详情</el-button>
  19. <el-button @click="handleEdit(scope.row)" type="text">编辑</el-button>
  20. <el-button @click="handleRemove(scope.row)" type="text">删除</el-button>
  21. </template>
  22. </el-table-column>
  23. </el-table>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. name: 'PublicPageTable',
  29. props: {
  30. tableData: {
  31. type: Array,
  32. default: () => []
  33. }
  34. },
  35. data () {
  36. return {
  37. ids: [],
  38. multipleSelection: []
  39. }
  40. },
  41. methods: {
  42. handleDetails (row) {
  43. this.$emit('handleDetails', row)
  44. },
  45. handleEdit (row) {
  46. this.$emit('handleEdit', row)
  47. },
  48. handleRemove (row) {
  49. this.$emit('handleRemove', row)
  50. },
  51. handleSelectionChange (rows) {
  52. },
  53. selectBoxAllChild (row) {
  54. const { isCheck, children } = row
  55. if (children?.length) {
  56. if (isCheck) {
  57. children.map(item => {
  58. item.isCheck = true
  59. this.$refs.table.toggleRowSelection(item, isCheck)
  60. this.selectBoxAllChild(item)
  61. })
  62. } else {
  63. children.map(item => {
  64. item.isCheck = false
  65. this.$refs.table.toggleRowSelection(item, isCheck)
  66. this.selectBoxAllChild(item)
  67. })
  68. }
  69. }
  70. },
  71. selectBox (selection, row) {
  72. row.isCheck = !row.isCheck
  73. const { children } = row
  74. if (children) {
  75. this.selectBoxAllChild(row)
  76. }
  77. },
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .PublicPageTable {
  83. width: 100%;
  84. height: 100%;
  85. }
  86. </style>