浏览代码

group-table添加header点击事件

杨宽 3 年之前
父节点
当前提交
25fc871af8
共有 2 个文件被更改,包括 38 次插入5 次删除
  1. 5 2
      src/components/coms/table/group-table.vue
  2. 33 3
      src/views/NewPages/power-benchmarking.vue

+ 5 - 2
src/components/coms/table/group-table.vue

@@ -1,7 +1,7 @@
 <template>
 <template>
-  <el-table :class="customClass" stripe :data="data.data" :height="height" style="width: 100%" @cell-click="onClick">
+  <el-table :class="customClass" stripe :data="data.data" :height="height" style="width: 100%" @cell-click="onClick" @header-click="onHeaderClick">
     <template v-for="col in data.column" :key="col">
     <template v-for="col in data.column" :key="col">
-      <el-table-column v-if="col.child && col.child.length > 0" :label="col.name">
+      <el-table-column v-if="col.child && col.child.length > 0" :label="col.name" :key="col">
         <el-table-column
         <el-table-column
           v-for="sub in col.child"
           v-for="sub in col.child"
           :key="sub"
           :key="sub"
@@ -142,6 +142,9 @@ export default {
     onClick(row, column, cell, event) {
     onClick(row, column, cell, event) {
       if (column.rawColumnKey.click) column.rawColumnKey.click(event, row);
       if (column.rawColumnKey.click) column.rawColumnKey.click(event, row);
     },
     },
+    onHeaderClick(column, event) {
+      if (column.rawColumnKey.headerClick) column.rawColumnKey.headerClick(event, column, this.data.data);
+    },
     handleCurrentChange(val) {
     handleCurrentChange(val) {
       this.currentPage = val;
       this.currentPage = val;
       this.$emit("onPagging", {
       this.$emit("onPagging", {

+ 33 - 3
src/views/NewPages/power-benchmarking.vue

@@ -90,22 +90,42 @@ export default {
             ],
             ],
           },
           },
           {
           {
-            name: "配送信息",
+            name: "基础指标",
+            headerClick: function(event, col, data) {
+              console.log(event);
+              console.log(col);
+              console.log(data);
+            },
             child: [
             child: [
               {
               {
                 name: "装机容量(MW)",
                 name: "装机容量(MW)",
                 field: "v1",
                 field: "v1",
                 width: 55,
                 width: 55,
+                headerClick: function(event, col, data) {
+                  console.log(event);
+                  console.log(col);
+                  console.log(data);
+                },
               },
               },
               {
               {
                 name: "在运台数 (台)",
                 name: "在运台数 (台)",
                 field: "v1",
                 field: "v1",
                 width: 55,
                 width: 55,
+                headerClick: function(event, col, data) {
+                  console.log(event);
+                  console.log(col);
+                  console.log(data);
+                },
               },
               },
               {
               {
                 name: "理论电量 (万kwh)",
                 name: "理论电量 (万kwh)",
                 field: "v1",
                 field: "v1",
                 width: 55,
                 width: 55,
+                headerClick: function(event, col, data) {
+                  console.log(event);
+                  console.log(col);
+                  console.log(data);
+                },
               },
               },
               {
               {
                 name: "发电量 (万kwh)",
                 name: "发电量 (万kwh)",
@@ -141,6 +161,11 @@ export default {
           },
           },
           {
           {
             name: "安全指标",
             name: "安全指标",
+            headerClick: function(event, col, data) {
+              console.log(event);
+              console.log(col);
+              console.log(data);
+            },
             child: [
             child: [
               {
               {
                 name: "人身设备事故 (次)",
                 name: "人身设备事故 (次)",
@@ -156,6 +181,11 @@ export default {
           },
           },
           {
           {
             name: "经济指标",
             name: "经济指标",
+            headerClick: function(event, col, data) {
+              console.log(event);
+              console.log(col);
+              console.log(data);
+            },
             child: [
             child: [
               {
               {
                 name: "人身设备事故 (次)",
                 name: "人身设备事故 (次)",
@@ -558,9 +588,9 @@ export default {
           display: flex;
           display: flex;
           .selecttion {
           .selecttion {
             flex: 1 0 250px;
             flex: 1 0 250px;
-            width:250px;
+            width: 250px;
             display: flex;
             display: flex;
-            
+
             .item {
             .item {
               flex: 0 0 44px;
               flex: 0 0 44px;
               height: 28px;
               height: 28px;