index3.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div>
  3. <el-table ref="tables" :row-class-name="tableClassName" v-loading="loading" highlight-current-row :data="data" :header-cell-style="{background:'#EEEEEE',color:'#333'}" size="mini" :height="height" @row-click="rowClick" style="width:100%" @selection-change="handleSelectionChange" border>
  4. <el-table-column
  5. type="selection"
  6. width="55" @handleSelectionChange="handleSelectionChange" v-if="checkbox">
  7. </el-table-column>
  8. <el-table-column :show-overflow-tooltip="col.title == '来源' || col.title == '地址' || col.title == '备注'" v-for="(col,index) in layout" :key="col.tablecolid" :prop="col.columnname" :label="col.title" :min-width="tool.calcTableColWidth($refs.tables,layout,index)">
  9. <template slot-scope="scope">
  10. <!-- 自定义表格显示内容 -->
  11. <slot v-if="custom" name="customcol" :column="{data:scope.row,columnname:col.columnname}"></slot>
  12. <!-- 否则就是默认 -->
  13. <span v-else>{{scope.row[col.columnname]}}</span>
  14. <!-- 操作结构内容 -->
  15. <slot v-if="col.columnname === 'operation'" name="opreation" :data="scope.row"></slot>
  16. </template>
  17. </el-table-column>
  18. </el-table>
  19. </div>
  20. </template>
  21. <script>
  22. import {mapGetters} from "vuex"
  23. export default {
  24. /*
  25. layout:表结构数据;
  26. data:表渲染数据;
  27. custom:是否启用自定义结构;
  28. opwidth:操作列宽度
  29. */
  30. props:['layout','data','custom','height','checkbox'],
  31. data () {
  32. return {
  33. list:[],
  34. }
  35. },
  36. computed:{
  37. ...mapGetters({
  38. loading:'loading'
  39. })
  40. },
  41. methods:{
  42. rowClick (row) {
  43. this.$emit('rowClick',row)
  44. },
  45. tableClassName ({row,rowIndex}) {
  46. row.index = rowIndex
  47. },
  48. handleSelectionChange(val) {
  49. if (val.length >= 2){
  50. this.$refs.tables.clearSelection();
  51. }
  52. this.$emit('checkboxCallBack',val)
  53. },
  54. isCheck(row,rowIndex) {
  55. }
  56. },
  57. mounted () {
  58. // this.listData()
  59. }
  60. }
  61. </script>
  62. <style>
  63. </style>