index6.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div>
  3. <!-- :header-cell-style="{background:'#EEEEEE',color:'#333'}" -->
  4. <el-table ref="table" :row-class-name="tableClassName" highlight-current-row :data="data" size="mini" :height="height ==''?data.length <= 4?'260px':data.length <= 20?'':'calc(100vh - 420px)':height" @row-click="rowClick"
  5. style="width:100%;" :header-cell-style="{height:'40px',color:'#606266',fontWeight:'400',fontSize:'14px'}" tooltip-effect="dark"
  6. :cell-style="{height:'40px',color:'#666666',fontWeight:'400'}" border @selection-change="selectionChange" >
  7. <el-table-column
  8. type="selection"
  9. width="35" fixed v-if="checkbox">
  10. </el-table-column>
  11. <el-table-column v-for="col in layout" :key="col.tablecolid" :prop="col.columnname" :label="col.title" :width="col.width" :fixed="fixedName ? fixedName.indexOf(col.columnname)!= -1?'right':false : false">
  12. <template :slot="headerOptions ? headerOptions.includes(col.columnname) ? 'header' : '' : ''" slot-scope="scope">
  13. <slot name="header" :column="{data:scope.row,columnname:col.columnname}"></slot>
  14. </template>
  15. <template slot-scope="scope">
  16. <div class="table-panel">
  17. <!-- 自定义表格显示内容 -->
  18. <slot v-if="custom" name="customcol" :column="{data:scope.row,columnname:col.columnname}"></slot>
  19. <!-- 否则就是默认 -->
  20. <span v-else>{{scope.row[col.columnname]}}</span>
  21. <!-- 操作结构内容 -->
  22. <slot v-if="col.columnname === 'operation'" name="opreation" :data="scope.row"></slot>
  23. </div>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. </div>
  28. </template>
  29. <script>
  30. import {mapGetters} from "vuex"
  31. export default {
  32. /*
  33. layout:表结构数据;
  34. data:表渲染数据;
  35. custom:是否启用自定义结构;
  36. opwidth:操作列宽度
  37. */
  38. props:['layout','data','custom','height','fixedName','width','checkbox','headerOptions'],
  39. data () {
  40. return {
  41. list:[],
  42. allArr:[],
  43. loading:false
  44. }
  45. },
  46. /*computed:{
  47. ...mapGetters({
  48. loading:'loading'
  49. })
  50. },*/
  51. methods:{
  52. rowClick (row) {
  53. this.$emit('rowClick',row)
  54. },
  55. tableClassName ({row,rowIndex}) {
  56. row.index = rowIndex
  57. },
  58. selectionChange(row){
  59. this.allArr = row
  60. this.$emit('selectionChange',row)
  61. }
  62. },
  63. mounted () {
  64. }
  65. }
  66. </script>
  67. <style>
  68. .el-tooltip__popper {
  69. max-width: 90%;
  70. }
  71. </style>
  72. <style scoped>
  73. /deep/ .el-table--border .el-table__cell {
  74. /* border-right: 1px solid #ebeef5; */
  75. }
  76. </style>