<template>
  <div class="app-container">
    <el-card>
      <el-row>
        <span>项目名称：</span>
        <el-select v-model="projectValue" filterable clearable size="small" placeholder="项目名称" @change="projectChange">
          <el-option
            v-for="item in project"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <span>机床编号:</span>
        <el-select v-model="machineNumberValue" placeholder="机床编号" size="small" clearable @change="machineChange">
          <el-option
            v-for="item in machineNumber"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <span>组号:</span>
        <el-select v-model="groupNumberValue" placeholder="组号" size="small" clearable>
          <el-option
            v-for="item in groupNumber"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <el-button type="success" size="small" icon="el-icon-search" style="margin-left: 15px" @click="searchTable()">查询</el-button>
      </el-row>
    </el-card>
    <el-card>
      <el-table :data="tableData" border size="mini" highlight-current-row style="width: 100%;margin-top: 15px" height="250px" @row-click="searchPart">
        <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>
      <!--<div class="block" style="margin-top: 10px;">-->
      <!--<el-pagination-->
      <!--@size-change="handleSizeChange"-->
      <!--@current-change="handleCurrentChange"-->
      <!--:current-page="pageCurrent"-->
      <!--:page-sizes="[10, 20, 30, 40, 50]"-->
      <!--:page-size="pageSize"-->
      <!--layout="total, sizes, prev, pager, next, jumper"-->
      <!--:total="total">-->
      <!--</el-pagination>-->
      <!--</div>-->
    </el-card>
    <el-card>
      <el-tabs type="border-card" @tab-click="selectPart">
        <el-tab-pane label="基本件">
          <el-table :data="tableData1" border size="mini" style="width: 100%" height="300px" @selection-change="handleSelectionChange">
            <el-table-column align="center" width="50" type="selection"/>
            <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">
              <template slot-scope="scope">
                {{ scope.row.备注 }}
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="外购件">
          <el-table :data="tableData2" border size="mini" style="width: 100%" height="300px" @selection-change="handleSelectionChange">
            <el-table-column align="center" width="50" type="selection"/>
            <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">
              <template slot-scope="scope">
                {{ scope.row.备注 }}
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="标准件">
          <el-table :data="tableData3" border size="mini" style="width: 100%" height="300px" @selection-change="handleSelectionChange">
            <el-table-column align="center" width="50" type="selection"/>
            <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">
              <template slot-scope="scope">
                {{ scope.row.备注 }}
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <span>物料计划到货时间：</span>
      <el-date-picker
        v-model="time"
        size="small"
        type="date"
        format="yyyy-MM-dd"
        value-format="yyyy-MM-dd"
        placeholder="选择日期"/>
      <el-button type="success" size="small" icon="el-icon-star-off" style="margin-top: 15px; margin-left: 15px" @click="purchaseRequisition()">车间请购</el-button>
      <el-button type="primary" size="small" icon="el-icon-star-off" style="margin-top: 15px; margin-left: 15px" @click="PurchasingDepartment()">采购部门采购</el-button>
      <el-button type="warning" size="small" icon="el-icon-star-off" style="margin-top: 15px; margin-left: 15px" @click="Production()">车间生产</el-button>
    </el-card>
    <el-card>
      <el-row>
        <span>请购单号：</span>
        <el-input v-model="PurchaseOrder" size="small" style="width: 200px" placeholder="请购单号" clearable/>
        <el-button type="success" size="small" icon="el-icon-search" style="margin-left: 15px" @click="searchTable1()">查询</el-button>
        <el-button type="primary" size="small" icon="el-icon-circle-plus-outline" style="margin-left: 15px" @click="handleAdd()">创建</el-button>
        <el-button type="warning" size="small" icon="el-icon-download">导出Excel</el-button>
      </el-row>
    </el-card>
    <el-card>
      <el-table :data="tableData4" border size="mini" style="width: 100%" height="200px" highlight-current-row @row-click="searchDetailed">
        <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 type="primary" size="mini" icon="el-icon-edit" @click="handleEdit(scope.row)">编辑</el-button>
            <el-button type="danger" size="mini" icon="el-icon-delete" style="margin-left: 15px" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card>
      <el-table :data="tableData5" border size="mini" style="width: 100%" height="300px">
        <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">
          <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 type="danger" size="mini" icon="el-icon-delete" @click="MoveOut(scope.row)">移出</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <el-dialog :title="title" :visible.sync="dialogFormVisible" center style="min-height: 300px" width="400px">
      <el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="110px" class="demo-ruleForm">
        <el-form-item label="请购单编号" prop="请购单编号">
          <el-input
            v-model="form.请购单编号"
            size="small"
            style="width:200px"/>
        </el-form-item>

        <el-form-item label="请购车间" prop="请购车间">
          <el-input
            v-model="form.请购车间"
            size="small"
            style="width:200px"/>
        </el-form-item>

        <el-form-item label="请购人">
          <el-input
            v-model="name"
            size="small"
            readonly
            style="width:200px"/>
        </el-form-item>

        <el-form-item label="请购时间" prop="请购时间">
          <el-date-picker
            v-model="form.请购时间"
            size="small"
            type="date"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel('form')">取消</el-button>
        <el-button v-show="title==='增加'" type="primary" @click="submitAdd('form')">确定</el-button>
        <el-button v-show="title==='编辑'" type="primary" @click="submitEdit('form')">确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { initProject, searchmachine, searchgroup, searchTable, searchPart, searchPart1, searchTable1, addData, editData, deleteData, searchDetailed, purchaseRequisition, purchaseRequisition1, MoveOut, MoveOut1, PurchasingDepartment, Production } from '@/api/ManufacturingCenter/PartAssignment'
import { mapGetters } from 'vuex'
export default {
  inject: ['reload'],
  data() {
    return {
      projectValue: '',
      projectFloatValue: '',
      project: [],
      machineNumberValue: '',
      machineFloatValue: '',
      machineNumber: [],
      machineName: '',
      groupNumberValue: '',
      groupFloatValue: '',
      groupNumber: [],
      PurchaseOrder: '',
      PartType: '基本件',
      tableData: [],
      tableData1: [],
      tableData2: [],
      tableData3: [],
      tableData4: [],
      tableData5: [],
      loading: false,
      title: '',
      dialogFormVisible: false,
      RequisitionList: '',
      form: {
        请购单编号: '',
        请购车间: '',
        请购时间: ''
      },
      rules: {
        请购单编号: [{ required: true, message: '请输入请购单编号', trigger: 'blur' }],
        请购车间: [{ required: true, message: '请输入请购车间', trigger: 'blur' }],
        请购时间: [{ required: true, message: '请选择请购时间', trigger: 'change' }]
      },
      BasicPartsNumber: [],
      StandardPartsAndOutsourcing: [],
      MaterialNum: [],
      MaterialName: [],
      MaterialSpecification: [],
      MaterialModel: [],
      NumberOfParts: [],
      projectName: '',
      MachineToolNumber: '',
      groupName: '',
      time: '',
      result: 0,
      pageSize: '',
      pageCurrent: '',
      total: '',
      check: ''
    }
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar',
      'name',
      'id'
    ])
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.getSelect(initProject, ['项目名称', '项目流水号'], 'project')
    },
    projectChange() {
      this.machineNumberValue = ''
      this.machineNumber = []
      this.groupNumberValue = ''
      this.groupNumber = []
      if (this.projectValue !== '') {
        this.check = 1
        searchmachine(this.projectValue, this.check).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            this.machineNumber.push({
              label: response.data[i].机床图号,
              value: response.data[i].机床流水号
            })
          }
        })
      } else {
        this.check = 0
      }
    },
    machineChange() {
      this.groupNumberValue = ''
      this.groupNumber = []
      searchgroup(this.machineNumberValue).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.groupNumber.push({
            label: response.data[i].组号,
            value: response.data[i].组件流水号
          })
        }
      })
    },
    searchTable() {
      this.loading = true
      if (this.projectValue !== '') {
        this.check1 = 1
      } else { this.check1 = 0 }
      if (this.machineNumberValue !== '') {
        this.check2 = 1
      } else { this.check2 = 0 }
      if (this.groupNumberValue !== '') {
        this.check3 = 1
      } else { this.check3 = 0 }
      searchTable(this.projectValue, this.check1, this.machineNumberValue, this.check2, this.groupNumberValue, this.check3).then(response => {
        this.tableData = response.data
        this.tableData1 = []
        this.tableData2 = []
        this.tableData3 = []
        this.loading = false
      })
    },
    selectPart(val) {
      this.PartType = val.label
      if (this.PartType === '基本件') {
        searchPart(this.groupFloatValue).then(response => {
          this.tableData1 = response.data
        })
      } else if (this.PartType === '外购件') {
        searchPart1(this.groupFloatValue, 2).then(response => {
          this.tableData2 = response.data
        })
      } else if (this.PartType === '标准件') {
        searchPart1(this.groupFloatValue, 1).then(response => {
          this.tableData3 = response.data
        })
      }
    },
    searchPart(row) {
      this.tableData1 = []
      this.tableData2 = []
      this.tableData3 = []
      this.projectName = row.项目名称
      this.projectFloatValue = row.项目流水号
      this.MachineToolNumber = row.机床图号
      this.machineFloatValue = row.机床流水号
      this.groupName = row.组号
      this.groupFloatValue = row.组件流水号
      if (this.PartType === '基本件') {
        searchPart(row.组件流水号).then(response => {
          this.tableData1 = response.data
        })
      } else if (this.PartType === '外购件') {
        searchPart1(row.组件流水号, 2).then(response => {
          this.tableData2 = response.data
        })
      } else if (this.PartType === '标准件') {
        searchPart1(row.组件流水号, 1).then(response => {
          this.tableData3 = response.data
        })
      }
    },
    searchTable1() {
      if (this.PurchaseOrder !== '') {
        this.check4 = 1
      } else {
        this.check4 = 0
      }
      searchTable1(this.PurchaseOrder, this.check4).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          console.log(response.data[i].请购时间)
          if (response.data[i].请购时间 !== '') {
            response.data[i].请购时间 = (response.data[i].请购时间).split(' ')[0]
          }
        }
        this.tableData4 = response.data
      })
    },
    handleAdd() {
      this.addForm('form', [this.dialogFormVisible = true, this.title = '增加'])
    },
    submitAdd(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          addData(this.form.请购单编号, this.form.请购车间, this.name, this.id, this.form.请购时间).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('增加成功')
              this.dialogFormVisible = false
              this.tableData5 = []
              this.searchTable1()
            } else { this.$message.error('增加失败') }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    handleEdit(row) { // 弹出单据编辑
      if (this.$refs['form'] !== undefined) {
        this.$refs['form'].resetFields()
      }
      this.title = '编辑'
      this.dialogFormVisible = true
      this.RequisitionList = row.请购单流水号
      this.form.请购单编号 = row.请购单编号
      this.form.请购车间 = row.请购车间
      this.form.请购时间 = row.请购时间
    },
    submitEdit(formName) { // 提交单据编辑
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.form.请购时间)
          editData(this.RequisitionList, this.form.请购单编号, this.form.请购车间, this.form.请购时间).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('编辑成功')
              this.dialogFormVisible = false
              this.tableData5 = []
              this.searchTable1()
            } else { this.$message.error('编辑失败') }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    handleDelete(row) { // 删除单据
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteData(row.请购单流水号).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('删除成功')
            this.tableData5 = []
            this.searchTable1()
          } else { this.$message.error('删除失败') }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    cancel(formName) {
      this.form = {}
      this.dialogFormVisible = false
      this.$refs[formName].resetFields()
    },
    searchDetailed(row) {
      this.RequisitionList = row.请购单流水号
      searchDetailed(row.请购单流水号).then(response => {
        this.tableData5 = response.data
      })
    },
    handleSelectionChange(val) {
      console.log(val)
      if (this.PartType === '基本件') {
        this.BasicPartsNumber = []
        this.MaterialName = []
        this.MaterialSpecification = []
        this.MaterialModel = []
        this.NumberOfParts = []
        for (let i = 0; i < val.length; i++) {
          this.MaterialNum[i] = val[i].物料流水号
          this.BasicPartsNumber[i] = val[i].基本件流水号
          this.MaterialName[i] = val[i].零件名称
          this.NumberOfParts[i] = val[i].零件数量
        }
      } else if (this.PartType === '外购件') {
        this.StandardPartsAndOutsourcing = []
        this.MaterialName = []
        this.MaterialSpecification = []
        this.MaterialModel = []
        this.NumberOfParts = []
        for (let i = 0; i < val.length; i++) {
          this.StandardPartsAndOutsourcing[i] = val[i].标准件和外购件流水号
          this.MaterialNum[i] = val[i].物料流水号
          this.MaterialName[i] = val[i].物料名称
          this.MaterialSpecification[i] = val[i].物料规格
          this.MaterialModel[i] = val[i].物料型号
          this.NumberOfParts[i] = val[i].零件数量
        }
      } else if (this.PartType === '标准件') {
        this.StandardPartsAndOutsourcing = []
        for (let i = 0; i < val.length; i++) {
          this.StandardPartsAndOutsourcing[i] = val[i].标准件和外购件流水号
          this.MaterialNum[i] = val[i].物料流水号
          this.MaterialName[i] = val[i].物料名称
          this.MaterialSpecification[i] = val[i].物料规格
          this.MaterialModel[i] = val[i].物料型号
          this.NumberOfParts[i] = val[i].零件数量
        }
      }
    },
    purchaseRequisition() {
      if (this.RequisitionList !== '') {
        if (this.time !== '') {
          this.result = 0
          if (this.PartType === '基本件') {
            for (let i = 0; i < this.BasicPartsNumber.length; i++) {
              purchaseRequisition(this.RequisitionList, this.projectName, this.projectFloatValue, this.MachineToolNumber, this.machineFloatValue, this.groupName, this.groupFloatValue, this.BasicPartsNumber[i], this.MaterialName[i], this.NumberOfParts[i], 3, this.time, this.MaterialNum[i]).then(response => {
                this.result += parseInt(response.data[0].result)
                console.log(this.result)
                if (this.result === this.BasicPartsNumber.length) {
                  console.log(1111)
                  this.$message.success('请购成功')
                  searchPart(this.groupFloatValue).then(response => {
                    this.tableData1 = response.data
                  })
                  searchDetailed(this.RequisitionList).then(response => {
                    this.tableData5 = response.data
                  })
                }
              })
            }
          } else if (this.PartType === '外购件') {
            for (let i = 0; i < this.StandardPartsAndOutsourcing.length; i++) {
              purchaseRequisition1(this.RequisitionList, this.projectName, this.projectFloatValue, this.MachineToolNumber, this.machineFloatValue, this.groupName, this.groupFloatValue, this.StandardPartsAndOutsourcing[i], this.MaterialName[i], this.MaterialSpecification[i], this.MaterialModel[i], this.NumberOfParts[i], 2, this.time, this.MaterialNum[i]).then(response => {
                this.result += parseInt(response.data[0].result)
                if (this.result === this.StandardPartsAndOutsourcing.length) {
                  this.$message.success('请购成功')
                  searchPart1(this.groupFloatValue, 2).then(response => {
                    this.tableData2 = response.data
                  })
                  searchDetailed(this.RequisitionList).then(response => {
                    this.tableData5 = response.data
                  })
                }
              })
            }
          } else if (this.PartType === '标准件') {
            for (let i = 0; i < this.StandardPartsAndOutsourcing.length; i++) {
              purchaseRequisition1(this.RequisitionList, this.projectName, this.projectFloatValue, this.MachineToolNumber, this.machineFloatValue, this.groupName, this.groupFloatValue, this.StandardPartsAndOutsourcing[i], this.MaterialName[i], this.MaterialSpecification[i], this.MaterialModel[i], this.NumberOfParts[i], 1, this.time, this.MaterialNum[i]).then(response => {
                this.result += parseInt(response.data[0].result)
                if (this.result === this.StandardPartsAndOutsourcing.length) {
                  this.$message.success('请购成功')
                  searchPart1(this.groupFloatValue, 1).then(response => {
                    this.tableData3 = response.data
                  })
                  searchDetailed(this.RequisitionList).then(response => {
                    this.tableData5 = response.data
                  })
                }
              })
            }
          }
        } else {
          this.$message.warning('请选择计划到货时间')
        }
      } else {
        this.$message.warning('请先选择请购单')
      }
    },
    PurchasingDepartment() {
      if (this.time !== '') {
        for (let i = 0; i < this.StandardPartsAndOutsourcing.length; i++) {
          PurchasingDepartment(this.groupFloatValue, this.StandardPartsAndOutsourcing[i], this.time, this.MaterialNum[i], this.NumberOfParts[i], this.projectFloatValue, this.machineFloatValue).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('请购成功')
              if (this.PartType === '外购件') {
                searchPart1(this.groupFloatValue, 2).then(response => {
                  this.tableData2 = response.data
                })
              } else {
                searchPart1(this.groupFloatValue, 1).then(response => {
                  this.tableData3 = response.data
                })
              }
            } else { this.$message.error('请购失败') }
          })
        }
      } else {
        this.$message.warning('请选择计划到货时间')
      }
    },
    Production() {
      if (this.PartType === '基本件' && this.BasicPartsNumber.length !== 0) {
        for (let i = 0; i < this.BasicPartsNumber.length; i++) {
          Production(this.groupFloatValue, this.BasicPartsNumber[i], this.projectFloatValue, this.machineFloatValue).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('投产成功')
              searchPart(this.groupFloatValue).then(response => {
                this.tableData1 = response.data
              })
            } else {
              this.$message.error('投产失败')
            }
          })
        }
      } else {
        this.$message.warning('请选择基本件')
      }
    },
    MoveOut(row) {
      this.$confirm('此操作将该物料移出, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (row.零件类型 === '3') {
          MoveOut(row.请购单明细流水号, row.基本件流水号).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('移出成功')
              searchPart(this.groupFloatValue).then(response => {
                this.tableData1 = response.data
              })
              searchDetailed(this.RequisitionList).then(response => {
                this.tableData5 = response.data
              })
            } else { this.$message.error('移出失败') }
          })
        } else if (row.零件类型 === '2') {
          MoveOut1(row.请购单明细流水号, row.标准件和外购件流水号).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('移出成功')
              searchPart1(this.groupFloatValue, 2).then(response => {
                this.tableData2 = response.data
              })
              searchDetailed(this.RequisitionList).then(response => {
                this.tableData5 = response.data
              })
            } else { this.$message.error('移出失败') }
          })
        } else if (row.零件类型 === '1') {
          MoveOut1(row.请购单明细流水号, row.标准件和外购件流水号).then(response => {
            if (response.data[0].result === '1') {
              this.$message.success('移出成功')
              searchPart1(this.groupFloatValue, 1).then(response => {
                this.tableData3 = response.data
              })
              searchDetailed(this.RequisitionList).then(response => {
                this.tableData5 = response.data
              })
            } else { this.$message.error('移出失败') }
          })
        }
        searchDetailed(this.RequisitionList).then(response => {
          this.tableData5 = response.data
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消移出'
        })
      })
    },
    handleSizeChange(val) {},
    handleCurrentChange(val) {}
  }
}
</script>

<style scoped>
  span{
    margin: 10px 0px 10px 10px;
  }
</style>
