vue2中table满足条件的行变红

效果图:

 提问时间超过四十八小时未回复整行文字变红

html代码:

主要是这个api设置样式:row-class-name="tableAddClass"

<template>
<el-table
      v-loading="loading"
      border
      :data="dataList"
      :row-class-name="tableAddClass"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column :label="$t('LIMS.dy.question')" prop="questions" />
      <el-table-column :label="$t('LIMS.dy.reply')" prop="replyContent" />
      <el-table-column
        :label="$t('LIMS.dy.questionCcategorization')"
        prop="classifyName"
      />
      <el-table-column
        :label="$t('LIMS.dy.questioner')"
        prop="questionUserName"
      />
      <el-table-column :label="$t('LIMS.dy.questionTime')" width="180">
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{m}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('LIMS.dy.replier')" prop="replyUserName" />
      <el-table-column :label="$t('LIMS.dy.recoveryTime')" width="180">
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.replyTime, "{y}-{m}-{d} {h}:{m}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('LIMS.dy.state')" prop="questionStatus">
        <template slot-scope="scope">
          <span
            v-if="scope.row.questionStatus == 0"
            class="status-wait-for-reply"
            >{{ $t("status.waitForReply") }}</span
          >
          <span
            v-else-if="scope.row.questionStatus == 1"
            class="status-replied"
            >{{ $t("status.replied") }}</span
          >
          <span
            v-else-if="scope.row.questionStatus == 3"
            class="status-unsolved"
            >{{ $t("status.unsolved") }}</span
          >
          <span
            v-else-if="scope.row.questionStatus == 2"
            class="status-resolved"
            >{{ $t("status.resolved") }}</span
          >
        </template>
      </el-table-column>
      <el-table-column
        :label="$t('common.operation')"
        class-name="small-padding fixed-width"
        fixed="right"
      >
        <template slot-scope="scope">
          <!-- 详情 -->
          <el-button
            size="mini"
            type="text"
            v-hasPermi="['question:answerManage:query']"
            @click="onOpen('detail', scope.row.questionAnswerId)"
          >
            {{ $t("common.details") }}
          </el-button>
       
          <!-- 删除 -->
          <el-button
            size="mini"
            type="text"
            @click="onOpen('delete', scope.row.questionAnswerId)"
          >
            {{ $t("common.delete") }}
          </el-button>
          <!-- 未解决 -->
          <el-button
            size="mini"
            type="text"
            v-show="scope.row.questionStatus == 1"
            v-hasPermi="['question:answerManage:noSolve']"
            @click="onOpen('unsolved', scope.row.questionAnswerId)"
          >
            {{ $t("status.unsolved") }}
          </el-button>
          <!-- 已解决 -->
          <el-button
            size="mini"
            type="text"
            v-show="scope.row.questionStatus == 1"
            v-hasPermi="['question:answerManage:solve']"
            @click="onOpen('resolved', scope.row.questionAnswerId)"
          >
            {{ $t("status.resolved") }}
          </el-button>
          <!-- 回复 -->
          <el-button
            size="mini"
            type="text"
            v-show="scope.row.questionStatus != 2"
            v-hasPermi="['question:answerManage:reply']"
            @click="onOpen('reply', scope.row.questionAnswerId)"
          >
            {{ $t("LIMS.dy.reply") }}
          </el-button>
        </template>
      </el-table-column>
    </el-table>
</template>

js代码:

create(){
//获取当前时间戳
this.timestamp = Date.parse(new Date());
}

 tableAddClass({ row, rowIndex }) {
//判断当前时间戳减去提问时间戳是否大于48小时,是就引用tr-red className样式
      if (
        row.questionStatus == 0 &&
        (this.timestamp - new Date(row.createTime).getTime()) /
          (60 * 60 * 1000) >
          48
      ) {
        return "tr-red";
      }
      return "";
    },

css代码

<style scoped>
.app-container /deep/ .el-table .tr-red {
  color: red !important;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值