<template>
  <div class="app-container">
    <el-card class="topCard">
      <div class="topDiv">
        <el-button type="primary" plain size="small" icon="el-icon-refresh" @click="searchOrder()">刷新</el-button>
      </div>
      <el-table
        v-loading="loading"
        ref="multipleTable"
        :data="tableData"
        :header-cell-style="{background:'#eef1f6',color:'#606266'}"
        :cell-class-name="tableRowClassName"
        element-loading-text="数据加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(0, 0, 0, 0.2)"
        class="main"
        tooltip-effect="dark"
        height="720px"
        style="width: 100%;"
        border
        size="mini">
        <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-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-column align="center" label="机型代码">
          <template slot-scope="scope">
            {{ scope.row.机型代码 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="是否有件">
          <template slot-scope="scope">
            <el-select v-model="scope.row.是否有件" filterable size="small" style="width: 90%;" @change="ModifyData(scope.row)">
              <el-option
                v-for="item in stationNumber"
                :key="item.value"
                :label="item.label"
                :value="item.value"
                size="mini"/>
            </el-select>
          </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 src="../../../utils/setMethods.js"></script>-->
<script>
export default {
  data() {
    return {
      loading: true,
      tableData: [], // 总数据数组
      stationNumber: [{
        value: 0,
        label: '否'
      }, {
        value: 1,
        label: '是'
      }]
    }
  },
  created() {
    this.searchOrder()
  },
  mounted() {
  },
  methods: {
    // 表格颜色变化
    tableRowClassName({ row, rowIndex }) {
      // console.log(row, rowIndex)
      if (rowIndex % 2 === 0) {
        return 'black'
      } else {
        return 'red'
      }
    },
    // 查询订单
    searchOrder() {
      this.loading = true
      this.tableData = []
      var param = []
      var Data = this.CreateData('11', '思源库位管理_管理软件查询', param)
      this.ExecDatabase(Data).then(response => {
        console.log(response, 66)
        if (response.data.length !== 0) {
          this.tableData = response.data
        }
        this.loading = false
      })
    },
    ModifyData(row) {
      var param = []
      param[0] = ['ID', row.ID]
      param[1] = ['是否有件', row.是否有件]
      console.log(param, '思源库位管理_管理软件修改param')
      var Data = this.CreateData('12', '思源库位管理_管理软件修改', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '状态修改成功',
            type: 'success'
          })
        } else {
          this.$message.error('状态修改失败！')
        }
      })
    }
  }
}
</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;
  }
</style>

