index1.vue 2.4 KB

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