美文网首页
elment表格嵌套表格 点击展开 手风琴展开 type="ex

elment表格嵌套表格 点击展开 手风琴展开 type="ex

作者: 十一他叫路易斯 | 来源:发表于2019-12-04 15:05 被阅读0次
    image.png
    image.png

    直接上代码

    <template>
      <div class="Databox">
        <div class="table">
          <el-table
            ref="table"
            highlight-current-row
            :data="tableData"
            @selection-change="handleSelectionChange"
            border
            style="width: 100%"
            :header-cell-style="{background:'#b8dbf7',padding:'0px',color:'#000000',fontWeight:'normal'}"
          >
            <el-table-column prop="cangku_name" align="center" width="50" label=" ">
              <template slot-scope="scope">
                <span
                  id="linkspan"
                  @click="toogleExpand(scope.row)"
                >{{scope.row.expansion ? '收起' : '展开'}}</span>
              </template>
            </el-table-column>
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column type="index" width="55" align="center" label="#"></el-table-column>
    
            <el-table-column prop="name.value" align="center" label="站点"></el-table-column>
            <el-table-column prop="id.value" align="center" label="运营人数"></el-table-column>
            <el-table-column prop="id.value" align="center" label="店铺数"></el-table-column>
            <el-table-column prop="id.value" align="center" label="近30天销量"></el-table-column>
            <el-table-column prop="id.value" align="center" label="近30天销售额"></el-table-column>
            <el-table-column prop="id.value" align="center" label="FBA货值¥"></el-table-column>
    
            <el-table-column type="expand" width="1">
              <template slot-scope="props">
                <div class="table2box">
                  <el-table
                    ref="tabletow"
                    highlight-current-row
                    :data="tableData2"
                    @selection-change="handleSelectionChange"
                    border
                    style="width: 100%"
                    :header-cell-style="{background:'#5eb7ff',padding:'0px',color:'#000000',fontWeight:'normal'}"
                  >
                    <el-table-column prop="cangku_name" align="center" width="50" label=" ">
                      <template slot-scope="scope">
                        <span
                          id="linkspan"
                          @click="toogleExpand2(scope.row)"
                        >{{scope.row.expansion ? '收起' : '展开'}}</span>
                      </template>
                    </el-table-column>
                    <el-table-column type="selection" width="55"></el-table-column>
                    <el-table-column type="index" width="55" align="center" label="#"></el-table-column>
                    <el-table-column prop="address.value" align="center" label="组别"></el-table-column>
                    <el-table-column prop="sku" align="center" label="运营人数"></el-table-column>
                    <el-table-column prop="model" align="center" label="店铺数"></el-table-column>
                    <el-table-column prop="color_two" align="center" label="近30天销量"></el-table-column>
                    <el-table-column prop="size" align="center" label="近30天销售额"></el-table-column>
    
                    <el-table-column width="1" type="expand">
                      <template slot-scope="props">
                        <div class="table3box">
                          <el-table
                            highlight-current-row
                            :data="tableData3"
                            @selection-change="handleSelectionChange"
                            border
                            style="width: 100%"
                            :header-cell-style="{background:'#1f9bff',padding:'0px',color:'#000000',fontWeight:'normal'}"
                          >
                            <el-table-column type="selection" width="55"></el-table-column>
                            <el-table-column type="index" width="55" align="center" label="#"></el-table-column>
                            <el-table-column prop="shop.value" align="center" label="运营"></el-table-column>
                            <el-table-column prop="sku" align="center" label="身份"></el-table-column>
                            <el-table-column prop="model" align="center" label="店铺名"></el-table-column>
                            <el-table-column prop="color_two" align="center" label="年销量"></el-table-column>
                            <el-table-column prop="size" align="center" label="年销售额"></el-table-column>
                            <el-table-column prop="size" align="center" label="月销量"></el-table-column>
                            <el-table-column prop="size" align="center" label="月销售额"></el-table-column>
                            <el-table-column label="操作"></el-table-column>
                          </el-table>
                        </div>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </template>
    
    <script>
    export default {
      props: {},
      data() {
        return {
          tableData2: [
            {
              id: {
                key: "商品 ID",
                value: "12987122",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987123",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987124",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987125",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            }
          ],
          tableData3: [
            {
              id: {
                key: "商品 ID",
                value: "12987122",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987123",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987124",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987125",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            }
          ],
          tableData: [
            {
              id: {
                key: "商品 ID",
                value: "12987122",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987123",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987124",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            },
            {
              id: {
                key: "商品 ID",
                value: "12987125",
                visible: false
              },
              name: {
                key: "商品名称",
                value: "好滋好味鸡蛋仔",
                visible: false
              },
              shop: {
                key: "所属店铺",
                value: "王小虎夫妻店",
                visible: false
              },
              shopId: {
                key: "店铺 ID",
                value: "10333",
                visible: false
              },
              category: {
                key: "商品分类",
                value: "江浙小吃、小吃零食",
                visible: false
              },
              address: {
                key: "店铺地址",
                value: "上海市普陀区真北路",
                visible: false
              },
              desc: {
                key: "商品描述",
                value: "荷兰优质淡奶,奶香浓而不腻",
                visible: false
              }
            }
          ],
          moreshow: false,
          radio1: "7天内"
        };
      },
      computed: {},
      created() {
        let tableData = this.tableData;
        tableData.map(item => {
          item.expansion = false;
        });
    
        let tableData2 = this.tableData2;
        tableData2.map(item => {
          item.expansion = false;
        });
      },
      mounted() {
    
      },
      watch: {},
      methods: {
        toogleExpand(row) {
          let $table = this.$refs.table;
          this.tableData.map(item => {
            if (row.id != item.id) {
              $table.toggleRowExpansion(item, false);
              item.expansion = false;
            } else {
              item.expansion = !item.expansion;
            }
          });
          $table.toggleRowExpansion(row);
        },
        toogleExpand2(row) {
          let $tabletow = this.$refs.tabletow;
          this.tableData2.map(item => {
            if (row.id != item.id) {
              $tabletow.toggleRowExpansion(item, false);
              item.expansion = false;
            } else {
              item.expansion = !item.expansion;
            }
          });
          $tabletow.toggleRowExpansion(row);
        },
    
        handleSelectionChange(val) {
          console.log(val);
        }
      },
      components: {}
    };
    </script>
    
    <style scoped lang="less">
    .Databox {
      // 头部数据样式
      .table {
        margin-top: 10px;
        /deep/ .el-table__expanded-cell[class*="cell"] {
          padding: 0px 50px;
          // padding-top: 10px;
           padding-right: 0px;
        }
        /deep/ .el-table td,
        .el-table th {
          padding: 0px;
    
          color: black;
        }
        /deeo/ .el-table--small td,
        .el-table--small th {
          padding: 0px;
        }
        .table2box {
          /deep/ .el-table__expanded-cell[class*="cell"] {
            padding: 0px 50px;
            // padding-top: 10px;
            padding-right: 0px;
          }
          /deep/ .el-table td,
          .el-table th {
            padding: 0px;
            background-color: #ecf5ff;
            color: black;
          }
          .table3box {
            /deep/ .el-table td,
            .el-table th {
              padding: 0px;
              background-color: #ffffff;
              color: black;
            }
          }
        }
        #linkspan {
          cursor: pointer;
          font-size: 12px;
          color: rgb(95, 153, 240);
        }
      }
    }
    </style>
    
    

    相关文章

      网友评论

          本文标题:elment表格嵌套表格 点击展开 手风琴展开 type="ex

          本文链接:https://www.haomeiwen.com/subject/wiklgctx.html