基于移动端写的表格之我的笨办法

移动端使用vue,自己写了一个笨笨的表格展示,固定左侧数据

<template>
  <view style="height: 100%">
    <view class="table">
      <view class="thead">
        <view class="th">
          <view class="td" v-for="(item,index) in columns" :key="index">
            <view class="td_wrap">{{item.title}}</view>
            <view class="td_wrap">{{item.day}}</view>
          </view>
        </view>
      </view>
      <view class="t-body">
        <view class="tr"  v-for="(rItem,rIndex) in rowsList">
          <view class="td" v-for="(tdItem,tdItemIndex) in columns">
            <view class="td_wrap">{{rItem[tdItem.key]}}</view>
          </view>
        </view>
      </view>
      <view class="t-footer">
        <view class="th tr-fixed">
          <view class="td">
            <view style="height: 122rpx;text-align: center;line-height: 122rpx;width:110px; border-bottom: 1px solid #ccc;
    border-left: 1px solid #ccc;">项目</view>
          </view>
        </view>
        <view class="tr tr-fixed"  v-for="(rItem,rIndex) in rowsList">
          <view class="td">
            <view class="td_wrap">{{rItem.quotaNme}}</view>
          </view>
        </view>
      </view>

    </view>
  </view>
</template>

<script>
  import common from '../../lib/common.js'
  export default {
    name: "table",
    data(){
      return{
        columns:[
          {title:'项目'},
          {title:'星期一',day:'2020-02-11'},
          {title:'星期二',day:'2020-02-12'},
          {title:'星期三',day:'2020-02-13'},
          {title:'星期四',day:'2020-02-14'},
          {title:'星期五',day:'2020-02-15'},
          {title:'本周合计'},
        ],
        tdHeight:'60',
        rowsList:[]
      }
    },
    methods:{
      getDayData(){
        let params={
          day:'2020-02-23'
        }
        common.$ajax({
          url:'/reportDayInfo/queryWeeek',
          method:'post',
          data:params
        }).then((res)=>{
          if(res.code==200){
            this.columns=res.data.columns
            this.rowsList=res.data.rows
          }else{
            this.rowsList=[]
          }
        }).catch((err)=>{})
      },
    },
    onShow(){
      this.getDayData()
    }
  }
</script>

<style scoped>
  .table{
    overflow-x: scroll;
    font-size: 24rpx;
    height: 100%;
  }
  .th{
    display: flex;
    position: relative;
  }
  .th .td .td_wrap{
    width:220rpx;
    height: 60rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #ccc;
    border-left: 1px solid #ccc;
  }
  .th .td:first-child .td_wrap,.th .td:last-child .td_wrap{
    height: 122rpx;
    line-height: 122rpx;
  }
  .th .td:first-child .td_wrap:last-child,.th .td:last-child .td_wrap:last-child{
     height: 0rpx;
     border:none;
  }
  .tr{
    display: flex;
    position: relative;
  }
  .tr .td .td_wrap{
    width:200rpx;
    height: 60rpx;
    padding:10rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #ccc;
    border-left: 1px solid #ccc;
    font-size: 24rpx;
  }
  .t-body{
    height:calc(100% - 90rpx);
  }
  .t-footer{
    position: absolute;
    left: 0;
    top: 0;
    z-index: 99;
    background: #fff;
    border-right: 1rpx solid #ccc;
  }
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值