<template>
  <div class="right-content-alert">
    <div class="el-table-wrapper fix-table">
      <TechyTable
        key="table-1"
        :showIndex="false"
        :page="1"
        :limit="8"
        :table-config="tableProps"
        :table-data="tableData"
      ></TechyTable>
    </div>
  </div>
</template>

<script>
import TechyTable from './TechyTable.vue'

const PriorityComponent = {
  name: 'PriorityComponent',
  props: {
    injectData: Object
  },
  computed: {
    bgColor() {
      const colors = ['#9c4048', '#ffbd43', '#0b58ff', '#90dd48', '#449028', '#091238']
      return colors[this.injectData.priority - 1]
    },
    priorityText() {
      return ['一级', '二级', '三级', '四级', '五级'][this.injectData.priority - 1]
    }
  },
  methods: {},
  render: function(h) {
    return h(
      'span',
      {
        style: {
          display: 'inline-block',
          borderRadius: 'calc(2px * var(--beilv))',
          padding: 'calc(2px * var(--beilv)) calc(6px * var(--beilv))',
          color: '#fff',
          opacity: '0.6',
          fontSize: 'calc(12px * var(--beilv))',
          lineHeight: 1,
          backgroundColor: this.bgColor
        }
      },
      this.priorityText
    )
  }
}

const tableProps = [
  { prop: 'eqName', label: '设备名称', align: 'center', 'min-width': 90 },
  // { prop: 'plName', label: '所属产线', align: 'center', 'min-width': 90 },
  { prop: 'priority', label: '提示等级', align: 'center', 'min-width': 70, subcomponent: PriorityComponent },
  { prop: 'content', label: '报警内容', align: 'center', 'min-width': 120 },
  { prop: 'duration', label: '累计时间(min)', align: 'center', 'min-width': 125 }
]

const tableData = [
  { eqName: 'B1磨边', plName: 'B', content: '磨轮过载', priority: 1, duration: '30 min' },
  { eqName: 'A2丝印', plName: 'A', content: '网版推出异常', priority: 2, duration: '57 min' },
  { eqName: 'B1打孔后清洗', plName: 'B', content: '毛刷过载', priority: 3, duration: '17 min' },
  { eqName: 'B1固化', plName: 'B', content: '传动变频器故障', priority: 2, duration: '22 min' },
  { eqName: 'A钢化', plName: 'A', content: '加热炉体超温报警', priority: 2, duration: '23 min' },
  { eqName: 'B2磨边', plName: 'B', content: '磨轮过载', priority: 3, duration: '6 min' },
  { eqName: 'B1磨边', plName: 'B', content: '磨轮过载', priority: 2, duration: '23 min' },
  {
    eqName: 'A2磨边后清洗',
    plName: 'A',
    content: '进料检测异常',
    priority: 2,
    duration: '18 min'
  },
  { eqName: 'A3打孔后清洗', plName: 'A', content: '进料检测异常', priority: 1, duration: '48 min' },
  { eqName: 'A3磨边', plName: 'A', content: '磨轮过载', priority: 3, duration: '29 min' },
  { eqName: 'A2钢化后清洗', plName: 'A', content: '进料检测异常', priority: 1, duration: '47 min' },
  { eqName: 'A2下片', plName: 'A', content: '磨轮过载', priority: 2, duration: '49 min' },
  {
    eqName: 'A3钢化后清洗',
    plName: 'A',
    content: '输送变频报警',
    priority: 2,
    duration: '33 min'
  }
]

export default {
  name: 'RightContentAlert',
  components: { TechyTable },
  data() {
    return { tableProps, tableData }
  },
  created() {},
  mounted() {},
  methods: {}
}
</script>

<style scoped>
.fix-table >>> .el-table td .cell {
  width: 80% !important;
  margin: auto;
  text-align: left;
}

.right-content-alert {
  height: calc(100% - calc(32px * var(--beilv)));
  display: flex;
  gap: calc(100vw / 1920 * 16);
  overflow: hidden;
}

.el-table-wrapper {
  flex: 1;
}

.right-content-alert > div {
  overflow: hidden;
  /* overflow-x: scroll; */
}

.el-table-wrapper >>> * {
  background: transparent;
}
.el-table-wrapper >>> .el-table::before,
.el-table-wrapper >>> .el-table--group::after,
.el-table-wrapper >>> .el-table--border::after {
  background: transparent;
}

.el-table-wrapper >>> .el-table {
  font-size: 8px;
  background-color: transparent;
  color: #fff9;
  border: 0;
  height: 100%;
  /* overflow-y: auto; */
}

.el-table-wrapper >>> .el-table th.is-leaf,
.el-table-wrapper >>> .el-table td {
  border-color: #0d1728;
  padding: 0;
}

.el-table__row--striped:hover > td,
.el-table-wrapper >>> .el-table__row:hover > td {
  background-color: rgba(79, 114, 136, 0.29) !important;
}

.el-table-wrapper >>> table {
  border: unset;
}

.el-table-wrapper >>> thead {
  color: #fff;
}
.el-table-wrapper >>> tr {
  background: unset;
}
.el-table-wrapper >>> tbody td > div,
.el-table-wrapper >>> thead th > div {
  white-space: nowrap;
}
.el-table-wrapper >>> th,
.el-table-wrapper >>> td {
  padding: 0;
}

.el-table-wrapper >>> tbody > tr:nth-child(even) {
  background: rgba(76, 97, 123, 0.2);
}
</style>
