mergeTable.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div>
  3. <el-table :data="commonData" header-row-class-name="custom-table-header" @expand-change="expandChange" @sort-change="sortChange">
  4. <el-table-column type="expand">
  5. <template slot-scope="props">
  6. <div style="padding: 10px;height: 340px;">
  7. <Table :column="column" :tableData="props.row.data" @option="handleOption" :row="{row:props.row,groupBy:groupBy,searchOption:searchOption,}" v-bind="$attrs" v-on="$listeners"/>
  8. </div>
  9. </template>
  10. </el-table-column>
  11. <el-table-column v-for="column in groupingOption.filter(item=> {return item.value == groupBy})" :key="column.value" :label="column.name" :prop="column.value" sortable="custom"
  12. show-overflow-tooltip>
  13. <template slot-scope="scope">
  14. <div>
  15. {{ scope.row.name?scope.row.name:'--' }}
  16. </div>
  17. </template>
  18. </el-table-column>
  19. </el-table>
  20. </div>
  21. </template>
  22. <script>
  23. import Table from "./table";
  24. export default {
  25. props: {
  26. // 检索条件
  27. searchOption: {
  28. type: Object,
  29. default: () => {
  30. return {}
  31. }
  32. },
  33. // 分组的栏位
  34. groupingOption: {
  35. type: Array,
  36. default: () => {
  37. return []
  38. }
  39. },
  40. // 分组的值
  41. groupBy:String,
  42. commonData: Array,
  43. column: {//显示栏位管理数组
  44. type: Array,
  45. default: () => {
  46. return [
  47. {
  48. ifGroup: false,
  49. ifSearch: true,
  50. name: "事件名称",
  51. type: "String",
  52. value: "name",
  53. },
  54. {
  55. name: "创建人",
  56. type: "String",
  57. value: "createName",
  58. ifSearch: true,
  59. ifGroup: false
  60. },
  61. {
  62. name: "创建时间",
  63. type: "DateTime",
  64. value: "createTime",
  65. ifSearch: true,
  66. ifGroup: true
  67. },
  68. {
  69. name: "发生时间",
  70. type: "DateTime",
  71. value: "eventDate",
  72. ifSearch: true,
  73. ifGroup: true
  74. },
  75. {
  76. name: "描述",
  77. type: "String",
  78. value: "description",
  79. ifSearch: true,
  80. ifGroup: false
  81. },
  82. {
  83. name: "应用场景",
  84. type: "Integer",
  85. value: "scenarioId",
  86. ifSearch: true,
  87. ifGroup: true
  88. }
  89. ]
  90. }
  91. }
  92. },
  93. mixins: [],
  94. components: {
  95. Table
  96. },
  97. data() {
  98. return {
  99. // columnList: [],
  100. tableData: [],
  101. showData: [],
  102. expandList: [],
  103. sort:[],
  104. }
  105. },
  106. watch: {
  107. },
  108. mounted() {
  109. },
  110. methods: {
  111. // 排序
  112. sortChange({ column, prop, order }) {
  113. let str='1'
  114. this.$emit('on-sort',{ column, prop, order ,str})
  115. },
  116. //操作列事件
  117. handleOption(data) {
  118. this.$emit('option', data)
  119. },
  120. //打开展开行获取数据并保存起来
  121. expandChange(row, expandedRows) {
  122. row.data = []
  123. }
  124. }
  125. }
  126. </script>