Table.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <el-table
  3. :data="tableData"
  4. border
  5. class="table"
  6. @selection-change="handleSelectionChange"
  7. height="auto"
  8. style="width: 100%">
  9. <el-table-column
  10. type="selection"
  11. fixed
  12. width="55">
  13. </el-table-column>
  14. <el-table-column
  15. prop="sort"
  16. label="序号"
  17. width="360">
  18. </el-table-column>
  19. <el-table-column
  20. prop="codeName"
  21. label="菜单"
  22. width="360">
  23. </el-table-column>
  24. <el-table-column
  25. prop="url"
  26. label="链接"
  27. :show-overflow-tooltip="true"
  28. width="360">
  29. <template slot-scope="scope">
  30. <a :href="scope.row.url" class="table-link" target="_blank">{{scope.row.url}}</a>
  31. </template>
  32. </el-table-column>
  33. <el-table-column
  34. prop="pic"
  35. label="图片"
  36. width="300">
  37. <template slot-scope="scope">
  38. <el-image
  39. style="width: 200px;height: 200px"
  40. :src="scope.row.pic"
  41. :lazy="true"
  42. :preview-src-list="scope.row.pic ? [scope.row.pic]: []"
  43. fit="contain"></el-image>
  44. </template>
  45. </el-table-column>
  46. <el-table-column
  47. prop="createTime"
  48. label="创建时间"
  49. :show-overflow-tooltip="true"
  50. width="200">
  51. </el-table-column>
  52. <el-table-column
  53. prop="createUserName"
  54. label="创建者"
  55. :show-overflow-tooltip="true"
  56. width="200">
  57. </el-table-column>
  58. <el-table-column
  59. prop="updateTime"
  60. label="更新时间"
  61. :show-overflow-tooltip="true"
  62. width="200">
  63. </el-table-column>
  64. <el-table-column
  65. prop="updateUserName"
  66. label="更新者"
  67. :show-overflow-tooltip="true"
  68. width="200">
  69. </el-table-column>
  70. <el-table-column
  71. label="操作"
  72. fixed="right"
  73. >
  74. <template slot-scope="scope">
  75. <el-button type="text" @click="handleEditor(scope.row)">编辑</el-button>
  76. <el-button type="text" v-if="false" @click="handleDelete(scope.row)">删除</el-button>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. </template>
  81. <script>
  82. export default {
  83. name: 'Table',
  84. inject: {
  85. tableServiceData: {
  86. type: Object,
  87. default: () => {
  88. },
  89. },
  90. paginationServiceData: {
  91. type: Object,
  92. default: () => {
  93. },
  94. },
  95. },
  96. computed: {
  97. tableData() {
  98. return this.tableServiceData.myData;
  99. },
  100. },
  101. methods: {
  102. handleSelectionChange(data) {
  103. const arr = [];
  104. data.forEach(item => {
  105. arr.push(item.bnId)
  106. })
  107. this.$emit('select-change', arr);
  108. },
  109. handleEditor(data) {
  110. this.$emit('editor', data);
  111. },
  112. handleDelete(data) {
  113. this.$emit('delete', data);
  114. },
  115. },
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .table {
  120. ::v-deep .is-leaf {
  121. .cell {
  122. text-align: center;
  123. }
  124. }
  125. ::v-deep .el-table-column--selection {
  126. .cell {
  127. text-align: center;
  128. }
  129. }
  130. }
  131. </style>