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

      <!-- <el-table
        key="LeftContentEquipmentCheck1"
        border
        :data="tableData"
        :header-cell-style="{ background: 'rgba(79,114,136,0.29)' }"
      >
        <el-table-column label="设备名称" prop="eqName" align="center" />
        <el-table-column label="所属产线" prop="pl" align="center" />
        <el-table-column label="提示等级" prop="warningLevel" align="center">
          <template slot-scope="scope">
            <PriorityComponent :injectData="scope.row"></PriorityComponent>
          </template>
        </el-table-column>
        <el-table-column label="巡检内容" prop="checkContent" align="center" />
      </el-table>
    </div> -->

      <!-- <div class="el-table-wrapper">
      <el-table
        key="LeftContentEquipmentCheck2"
        border
        :data="tableData2"
        :header-cell-style="{ background: 'rgba(79,114,136,0.29)' }"
      >
        <el-table-column label="设备名称" prop="eqName" />
        <el-table-column label="所属产线" prop="pl" />
        <el-table-column label="提示等级" prop="warningLevel" />
        <el-table-column label="提示等级" prop="checkContent" />
      </el-table>
    </div> -->
    </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: '2px',
          // padding: '2px 6px',
          // color: '#fff',
          // opacity: '0.6',
          // fontSize: '12px',
          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': 120 },
  { prop: 'pl', label: '所属产线', align: 'center', 'min-width': 100 },
  { prop: 'warningLevel', label: '提示等级', align: 'center', 'min-width': 100, subcomponent: PriorityComponent },
  { prop: 'checkContent', label: '巡检内容', align: 'center', 'min-width': 120 }
]
const tableData = [
  { eqName: 'A下片机', pl: '产线1', priority: 1, checkContent: '巡检内容' },
  { eqName: 'A下片机', pl: '产线1', priority: 2, checkContent: '巡检内容' },
  { eqName: 'A下片机', pl: '产线1', priority: 3, checkContent: '巡检内容' },
  { eqName: 'A下片机', pl: '产线1', priority: 4, checkContent: '巡检内容' },
  { eqName: 'A下片机', pl: '产线1', priority: 4, checkContent: '巡检内容' },
  { eqName: 'A下片机', pl: '产线1', priority: 3, checkContent: '巡检内容' },
  { eqName: '设备B', pl: '产线1', priority: 2, checkContent: '巡检内容' },
  { eqName: '下片机', pl: '产线3', warningLevel: 3, checkContent: '巡检内容' },
  { eqName: '磨片机', pl: '产线2', warningLevel: 2, checkContent: '巡检内容' }
]

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

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

.left-content-equipment-check {
  height: calc(100% - 32px);
  display: flex;
  gap: calc(100vmin / 1920 * 36);
  overflow: hidden;
}

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

.left-content-equipment-check > 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>
