index7.vue 2.2 KB

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