vue动手写一个类似淘宝的订单表格

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

 

 


 

一、vue表格

二、使用步骤

1.正文

代码如下(示例):

<template>
  <div class="content">
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column type="selection" width="55"/>
      <el-table-column width="1" class="box">
        <template slot-scope="scope">
          <div class="item">
            <span style="margin-left:-80%">订单编号:{{ scope.row.id }} <span>共<span style="color:#409EFF">10</span>件</span></span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="商品" width="300" class="box">
        <template slot-scope="scope">
          <div v-for="(item, index) in scope.row.children" :key="index" class="mesSty">
            <img class="imgSty" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1607508642445&di=0e36873f5842d9a862bf9f8f2da19510&imgtype=0&src=http%3A%2F%2Fc.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Ff3d3572c11dfa9ecc052be8060d0f703918fc12d.jpg" alt="">
            <div class="mesFont">
              <!-- <p class="pb_sty"><span>{{ item.name }}</span></p> -->
              <p>fasdfasfsfs 啊</p>
              <p>蓝色:10*5cm</p>
            </div>
          </div>
        </template>
      </el-table-column>
      <el-table-column min-width="100" label="单价/数量">
        <template slot-scope="scope">
          <div v-for="(item, index) in scope.row.children" :key="index" class="mesSty2">
            <p>{{ item.name }}</p>
            <p>X2</p>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="address" min-width="140" label="商品状态">
        <template slot-scope="scope">
          <div v-for="(item, index) in scope.row.children" :key="index" class="mesSty2">
            <p>已导出</p>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="address" min-width="140" label="收货人">
        <template slot-scope="scope">
          {{ scope.row.address }}
        </template>
      </el-table-column>
      <el-table-column min-width="140" label="订单状态">
        <template slot-scope="">
          <span>微信</span><span>(100积分)</span>
        </template>
      </el-table-column>
      <el-table-column prop="address" valign="top" min-width="140" label="实收款"/>
      <el-table-column
        label="操作"
        align="center"
        min-width="140">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="btnClick(scope.row.id)">退款</el-button>
          <div>
            <el-button type="text" size="small" @click="btnClick(scope.row.id)">订单详情</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

 

2.data数据及样式

代码如下(示例):

<script>
export default {
  data() {
    return {
      popSty: false,
      textarea: '',
      tableData: [{
        id: 1,
        date: '2016-05-02',
        name: '王小虎',
        address: '12',
        children: [
          {
            name: '撒旦法1'
          },
          {
            name: '撒旦法2'
          }
        ]
      }, {
        id: 3,
        date: '2016-05-01',
        name: '王小虎',
        address: '12',
        children: [
          {
            name: '撒旦法11'
          },
          {
            name: '撒旦法22'
          }
        ]
      }, {
        id: 4,
        date: '2016-05-03',
        name: '王小虎',
        address: '12',
        children: [
          {
            name: '撒旦法111'
          },
          {
            name: '撒旦法222'
          }
        ]
      }]
    }
  },
  methods: {
    btnClick(id) {
      console.log(id)
    }
  }
}
</script>

<style scoped>
.content {
  padding: 20px;
}
.el-table--enable-row-transition /deep/ .cell {
  padding: 20px 0;
}
.item {
  width: 100vw;
  background: #f1f1f1;
  position: absolute;
  top: 0;
  left: -55px;
  z-index: 1;
  height: 50px;
  line-height: 50px;
}
</style>
<style scoped>
.imgSty {
  width: 100px;
  display: block;
  padding-left: 10px;
}
.mesSty {
  display: flex;
  align-items: center;
  padding: 40px 0;
  border-bottom: 1px solid #ebeef5;
}
.mesSty:last-child {
  padding-top: 20px;
  border-bottom: none;
  padding-bottom: 0px;
}
.mesSty2 {
  padding: 40px 0;
  border-bottom: 1px solid #ebeef5;
}
.mesSty2:last-child {
  padding-top: 20px;
  border-bottom: none;
  padding-bottom: 0px;
}
.content >>> .el-table--border td:nth-child(-n+4) {
 border-right: none!important;
}
.content >>> .el-table--border td:nth-child(2) {
 border-left: 1px solid #ebeef5;
}
.content /deep/ .el-table__row td:nth-child(n+6) .cell {
  position: absolute!important;
  top: 100px!important;
  left: 50%;
  transform: translateX(-50%);
}
.content /deep/ .el-table__row td:nth-child(1) .cell {
  position: absolute!important;
  top: -5px!important;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
}
.pb_sty span {
  background: #1dc8de;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
}

.mesFont p {
  margin-block-start: 0;
  margin-block-end: 0;
  padding: 0 10px;
}
.mesFont p:nth-child(2) {
  text-overflow: -o-ellipsis-lastline;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
/* .el-table__row:hover .item {
  background-color: #eaf8ff;
} */
</style>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shuleijia

您的鼓励是我最大的创作动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值