element ui table 表格slot插槽整理

1、scope.row.字段名获取指定行中指定字段名的数据

以oid为例  编辑删除操作时需要向后端传oid这个字段

<el-table :data="studyListAll">
          <el-table-column align="center" label="序号" prop="oid"></el-table-column>
          <el-table-column align="center" label="名称" prop="stName"></el-table-column>
          <el-table-column align="center" label="描述" prop="stPlan"></el-table-column>
          <el-table-column align="center" label="推送用户" :formatter="formatterUser">
          </el-table-column>
          <el-table-column align="center" label="打卡频次" prop='stSignFrequency' :formatter="formatterFrequency"></el-table-column>
          <el-table-column align="center" label="开始时间" prop="stStartTime"></el-table-column>
          <el-table-column align="center" label="结束时间" prop="stEndTime"></el-table-column>
          <el-table-column align="center" label="完成情况">
            <template slot-scope="scope">
              <el-button type="text" @click="lookDetail(scope.row.oid)">查看详情</el-button>
            </template>
          </el-table-column>
          <el-table-column align="center" label="是否隐藏" prop="tstatus">
            <template slot-scope="scope">
              <el-switch
                v-model="scope.row.tstatus"
                :active-value="1"
                :inactive-value="0"
                @change="val=>{changeTstatus(val,scope.row.oid)}">
              </el-switch>
            </template>
          </el-table-column>
          <el-table-column align="center" label="创建时间" prop="createdTime"></el-table-column>
          <el-table-column align="center" label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="edit(scope.row.oid)">编辑</el-button>
              <el-button type="text" class="btn-red" @click="del(scope.row.oid)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>

2、scope.column.字段名

获取列数据

3、scope.$index 获取当前行的下标

以之前打卡后台管理的项目为例子  后台返回的数据中包含detail这个字段  字段为json字符串

需要根据当前行下标去外层数据取它的detail数据

<el-table :data="detailTable">
          <!-- <el-table-column align="center" label="学校" prop="schoolName"></el-table-column> -->
          <el-table-column align="left" label="年级" prop="gradName" width="100"></el-table-column>
          <el-table-column align="left" label="学生姓名" prop="stuName" width="100"></el-table-column>
          <el-table-column label="打卡数据详情">
            <template slot-scope="scope">
              <el-table :data="JSON.parse(detailTable[scope.$index].detail)" :row-class-name="innerClass">
                <el-table-column
                  v-for="(item,index) in JSON.parse(detailTable[scope.$index].detail)"
                  :key="index"
                  :label="item.day"
                  align="center"
                  width="100">
                  <template>
                    <!-- <span>{{scope.$index}}</span> -->
                    <span v-bind:style="{color:item.isSign===0?'red':'green'}">{{item.isSign===0?'未打卡':'已打卡'}}</span>
                  </template>
                </el-table-column>
              </el-table>
            </template>
          </el-table-column>
        </el-table>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

某公司摸鱼前端

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值