<template>
  <div class="app-container">
    <el-card class="topCard">
      <div class="topDiv">
        <span style="margin-left: 10px">工位号：</span>
        <el-select v-model="stationNumberValue" placeholder="请选择工位号" size="small" style="width: 150px">
          <el-option
            v-for="item in stationNumber"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            size="mini"/>
        </el-select>
        <el-button type="primary" plain size="small" icon="el-icon-search" style="margin-left: 10px" @click="searchTable()">查询</el-button>
      </div>
      <el-table
        ref="multipleTable"
        :data="tableData"
        :header-cell-style="{background:'#eef1f6',color:'#606266'}"
        :cell-class-name="tableRowClassName"
        element-loading-background="rgba(0, 0, 0, 0.2)"
        class="main"
        tooltip-effect="dark"
        height="760px"
        style="width: 100%;max-height: 860px"
        border
        size="mini">
        <el-table-column type="index" width="60" label="序号" align="center"/>
        <el-table-column align="center" label="工位号">
          <template slot-scope="scope">
            {{ scope.row.工位号 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="保养类型名称">
          <template slot-scope="scope">
            {{ scope.row.保养类型名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="计划保养时间">
          <template slot-scope="scope">
            {{ scope.row.保养时间 }}
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      stationNumber: [],
      stationNumberValue: '',
      tableData: []
    }
  },
  created() {
    this.getStationNumber()
    this.searchTable()
  },
  methods: {
    // 表格颜色变化
    tableRowClassName({ row, rowIndex }) {
    },
    // 初始化获取订单号
    getStationNumber() {
      this.stationNumber = []
      var param = []
      var Data = this.CreateData('11', 'MES_计划BOM_工位与名称_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.stationNumber.push({
            label: response.data[i].工位号,
            value: response.data[i].工位号,
            labelName: response.data[i].工序名称
          })
        }
      })
    },
    searchTable() {
      this.tableData = []
      let stationNumberValue_check
      this.stationNumberValue ? (stationNumberValue_check = 1) : (stationNumberValue_check = 0)
      var param = []
      param[0] = ['工位号_check', stationNumberValue_check]
      param[1] = ['工位号', this.stationNumberValue]
      var Data = this.CreateData('11', '设备管理_保养_当前保养类型_综合查询', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response.data)
        this.tableData = response.data
      })
    }
  }
}
</script>

<style scoped>
  .topCard{
    margin: 5px;
  }
  .topDiv{
    margin-bottom: 10px;
  }
  .el-select{
    width:200px
  }
  .el-input{
    width:200px
  }
  .text {
    font-size: 14px;
  }

  .item {
    padding: 18px 0;
  }

  .box-card {
    position: absolute;
    right: 6px;
    top: 80px;
    width: 300px;
  }
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }

  /deep/.el-input.is-disabled .el-input__inner{
    color: #606266!important;
  }
  /deep/.el-input.is-disabled .el-input__inner{
    background-color: white!important;
  }
</style>
