【第012篇】vue+elementui表格高亮显示

1、在表格上增加 :row-class-name=“tableRowClassName” 属性。

<el-table v-loading="dataListLoading" max-height="550" :data="dataList" border @selection-change="dataListSelectionChangeHandle" :row-class-name="tableRowClassName" style="width: 100%;" size="small">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="xzmc" label="乡镇级名称" header-align="center" align="center" :show-tooltip-when-overflow="true" width="120"></el-table-column>
        <el-table-column prop="cmc" label="村级名称" header-align="center" align="center" :show-tooltip-when-overflow="true" width="120"></el-table-column>
        <el-table-column prop="suyqrdm" label="所有权人代码" header-align="center" align="center" :show-tooltip-when-overflow="true" width="200"></el-table-column>
        <el-table-column prop="suyqrmc" label="所有权人名称" header-align="center" align="center" :show-tooltip-when-overflow="true" width="250"></el-table-column>
        <el-table-column prop="suyqxz" label="所有权性质" header-align="center" align="center" :show-tooltip-when-overflow="true" width="120">
          <template slot-scope="scope">
            {{ $getDictLabel("ownership_type_ah", scope.row.suyqxz) }}
          </template>
        </el-table-column>
        <el-table-column prop="dbrxm" label="代表人姓名" header-align="center" align="center" :show-tooltip-when-overflow="true" width="120"></el-table-column>
        <el-table-column prop="dbrzjhm" label="代表人证件号码" header-align="center" align="center" :show-tooltip-when-overflow="true" width="150"></el-table-column>
        <el-table-column prop="dbrlxdh" label="代表人电话" header-align="center" align="center" :show-tooltip-when-overflow="true" width="120"></el-table-column>
        <el-table-column prop="dbrtxdz" label="代表人地址" header-align="center" align="center" :show-tooltip-when-overflow="true" width="150"></el-table-column>
        <el-table-column prop="dbryzbm" label="邮政编码" header-align="center" align="center" :show-tooltip-when-overflow="true" width="120"></el-table-column>
        <el-table-column prop="sfclncjtjjzz" label="是否成立集体经济组织" header-align="center" align="center" :show-tooltip-when-overflow="true" width="150">
          <template slot-scope="scope">
            {{ $getDictLabel("is_dictionaries", scope.row.sfclncjtjjzz) }}
          </template>
        </el-table-column>
        <el-table-column prop="update_name" label="调查员" header-align="center" align="center" :show-tooltip-when-overflow="true" width="120"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="200">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('rhdc:zjdsuyqr:info')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id, 1)">查看</el-button>
            <el-button v-if="$hasPermission('rhdc:zjdsuyqr:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id, 2)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('rhdc:zjdsuyqr:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('deleteBatch') }}</el-button>
          </template>
        </el-table-column>
      </el-table>

2、在脚本中增加 tableRowClassName 方法:

methods: {
    // 高亮显示
    tableRowClassName ({ row, rowIndex }) {
	  if (rowIndex === 1) {
		return 'warning-row'
	  } else if (rowIndex === 3) {
		return 'success-row'
	  }
      return ''
    }
  }

3、增加样式:

<style scoped>
/deep/.el-table .warning-row {
  background: red;
}
/deep/.el-table .success-row {
  background: green;
}
</style>

4、页面效果:
在这里插入图片描述
5、关键代码截图
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

嘉&年华

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

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

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

打赏作者

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

抵扣说明:

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

余额充值