index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div>
  3. <el-table ref="table" :row-class-name="tableClassName" highlight-current-row :data="data" :header-cell-style="{background:'#EEEEEE',color:'#333'}" size="mini" :height="height" @row-click="rowClick" style="width:100%;min-height:300px" border>
  4. <el-table-column v-for="col in layout" :key="col.tablecolid" :prop="col.columnname" :label="col.title" :width="col.width === 0 ? 150 : col.width" :fixed="fixedName ? fixedName.indexOf(col.columnname)!= -1?'right':false : ''">
  5. <template slot-scope="scope">
  6. <!-- 自定义表格显示内容 -->
  7. <slot v-if="custom" name="customcol" :column="{data:scope.row,columnname:col.columnname}"></slot>
  8. <!-- 否则就是默认 -->
  9. <span v-else>{{scope.row[col.columnname]}}</span>
  10. <!-- 操作结构内容 -->
  11. <slot v-if="col.columnname === 'operation'" name="opreation" :data="scope.row"></slot>
  12. </template>
  13. </el-table-column>
  14. </el-table>
  15. </div>
  16. </template>
  17. <script>
  18. import {mapGetters} from "vuex"
  19. export default {
  20. /*
  21. layout:表结构数据;
  22. data:表渲染数据;
  23. custom:是否启用自定义结构;
  24. opwidth:操作列宽度
  25. */
  26. props:['layout','data','custom','height','fixedName'],
  27. data () {
  28. return {
  29. list:[],
  30. }
  31. },
  32. computed:{
  33. ...mapGetters({
  34. loading:'loading'
  35. })
  36. },
  37. methods:{
  38. rowClick (row) {
  39. this.$emit('rowClick',row)
  40. },
  41. tableClassName ({row,rowIndex}) {
  42. row.index = rowIndex
  43. }
  44. },
  45. mounted () {
  46. }
  47. }
  48. </script>
  49. <style>
  50. </style>