<template>
  <div class="app-container">
    <el-card>
      <el-row>
        <span>机床编号:</span>
        <el-select v-model="machineNumberValue" filterable placeholder="机床编号" size="small" clearable @change="selecttable()">
          <el-option
            v-for="item in machineNumber"
            :key="item.value"
            :label="item.label"
            :value="item.value">
            <div style="float: left">{{ item.label }}</div>
            <div style="float: right; color: #8492a6; font-size: 13px">{{ item.name }}</div>
          </el-option>
        </el-select>
      </el-row>
    </el-card>
    <el-card>
      <el-table :data="tableData1" border size="mini" highlight-current-row style="width: 100%;margin-top: 15px" height="600px">
        <el-table-column label="项目名称" align="center">
          <template slot-scope="scope">
            {{ scope.row.项目名称 }}
          </template>
        </el-table-column>
        <el-table-column label="机床编号" align="center">
          <template slot-scope="scope">
            {{ scope.row.机床图号 }}
          </template>
        </el-table-column>
        <el-table-column label="机床名称" align="center">
          <template slot-scope="scope">
            {{ scope.row.机床名称 }}
          </template>
        </el-table-column>
        <el-table-column label="机床数量" align="center">
          <template slot-scope="scope">
            {{ scope.row.机床数量 }}
          </template>
        </el-table-column>
        <el-table-column label="注意事项" align="center">
          <template slot-scope="scope">
            {{ scope.row.注意事项 }}
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="250px" fixed="right">
          <template slot-scope="scope">
            <el-button v-if="scope.row.发货状态===null || scope.row.发货状态===0" type="success" size="small" @click="handlconfirm(scope.row)">确认发货</el-button>
            <el-button v-else-if="scope.row.发货状态===1" disabled="true" type="danger" size="small">待审批</el-button>
            <el-button v-else type="info" size="small" >已审批</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { initProject, selecttable, updatestate } from '@/api/Assembly/DeliveryApplication'
// import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      machineNumberValue: '',
      machineNumber: [],
      groupNumberValue: '',
      groupNumber: [],
      tableData1: [],
      tableData2: []
    }
  },
  created() {

  },
  mounted() {
    this.initProject()
  },
  methods: {
    initProject() {
      initProject().then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.machineNumber.push({
            label: response.data[i].机床图号,
            name: response.data[i].项目名称,
            value: response.data[i].机床流水号
          })
        }
      })
    },
    selecttable() {
      this.tableData1 = []
      if (this.machineNumberValue !== '' && this.machineNumberValue !== null) { this.check2 = 1 } else { this.check2 = 0 }
      selecttable(this.check2, this.machineNumberValue).then(response => {
        this.tableData1 = response.data
        console.log(response.data)
      })
    },
    handlconfirm(row) {
      updatestate(row.机床流水号, 1).then(response => {
        this.selecttable()
      })
    }
  }
}

</script>

<style scoped>

</style>
