<template>
  <div class="app-container">
    <el-card>
      <span>项目名称:</span>
      <el-select
        v-model="entryNameValue"
        placeholder="项目名称"
        style="width:200px"
        size="small"
        clearable
        filterable
        @change="empty">
        <el-option
          v-for="item in entryName"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <span>机床号:</span>
      <el-input v-model="machineToolNumber" placeholder="请双击选择" size="small" clearable style="width:200px" @change="empty1" @dblclick.native="SearchMachine"/>
      <span>组号:</span>
      <el-input v-model="groupNumber" placeholder="请双击选择" size="small" clearable style="width:200px" @dblclick.native="searchGroupList"/>
      <span>年:</span>
      <el-date-picker
        v-model="year"
        type="year"
        size="small"
        format="yyyy"
        value-format="yyyy"
        placeholder="选择年"/>
      <span>月:</span>
      <el-select v-model="month" placeholder="选择月" size="small" clearable style="width:180px">
        <el-option
          v-for="item in monthes"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <span>入库时间:</span>
      <el-date-picker
        v-model="time"
        type="date"
        size="small"
        style="margin-top: 20px;width: 200px"
        format="yyyy-MM-dd"
        value-format="yyyy-MM-dd"
        placeholder="选择日期"/>
      <el-button type="success" icon="el-icon-search" size="small" style="margin-top: 15px;margin-left: 10px" @click="total=0;pageSize=10;pageCurrent=1;searchData()">查询</el-button>
    </el-card>
    <el-card>
      <el-table
        v-loading="loading"
        :data="tableData"
        :summary-method="getSummaries"
        style="width: 100%;max-height: 600px"
        height="400"
        show-summary
        highlight-current-row
        border>
        <el-table-column align="center" label="序号" type="index" width="60"/>
        <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="操作" fixed="right">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="processingStatus(scope.row)">查看加工进度</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="pageSize"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </el-card>
    <el-card>
      <el-table
        :data="tableDataPurchase"
        border
        style="width: 100%;"
        height="400">
        <el-table-column
          label="序号"
          align="center"
          type="index"
          width="50"/>
        <el-table-column label="物料名称" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.物料名称 }}
          </template>
        </el-table-column>
        <el-table-column label="物料规格" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.物料规格 }}
          </template>
        </el-table-column>
        <el-table-column label="物料型号" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.物料型号 }}
          </template>
        </el-table-column>
        <el-table-column label="项目名称" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.项目名称 }}
          </template>
        </el-table-column>
        <el-table-column label="机床图号" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.机床图号 }}
          </template>
        </el-table-column>
        <el-table-column label="组号" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.组号 }}
          </template>
        </el-table-column>
        <el-table-column label="零件数量" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.数量 }}
          </template>
        </el-table-column>
        <el-table-column label="到货数量" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.实际到货数量 }}
          </template>
        </el-table-column>
        <el-table-column label="到货时间" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.到货时间 }}
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent4"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize4"
          :total="total4"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange4"
          @current-change="handleCurrentChange4"/>
      </div>
    </el-card>

    <el-card>
      <el-table
        :data="tableData1"
        border
        style="width: 100%;"
        height="400">
        <el-table-column
          label="序号"
          align="center"
          type="index"
          width="50"/>
        <el-table-column label="物料名称" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.物料名称 }}
          </template>
        </el-table-column>
        <el-table-column label="物料规格" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.物料规格 }}
          </template>
        </el-table-column>
        <el-table-column label="物料型号" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.物料型号 }}
          </template>
        </el-table-column>
        <el-table-column label="项目名称" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.项目名称 }}
          </template>
        </el-table-column>
        <el-table-column label="机床图号" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.机床图号 }}
          </template>
        </el-table-column>
        <el-table-column label="组号" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.组号 }}
          </template>
        </el-table-column>
        <el-table-column label="零件数量" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.货位存量 }}
          </template>
        </el-table-column>
        <el-table-column label="零件类型" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.类型名称 }}
          </template>
        </el-table-column>
        <el-table-column label="入库时间" align="center" min-width="80">
          <template slot-scope="scope">
            {{ scope.row.入库时间 }}
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent5"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize5"
          :total="total5"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange5"
          @current-change="handleCurrentChange5"/>
      </div>
    </el-card>
    <el-dialog :visible.sync="dialogFormVisible2" title="选择机床" center style="min-height: 300px">
      <el-table
        :data="tableData6"
        style="width:100%;max-height: 300px;display: inline-block"
        height="300"
        highlight-current-row
        border
        @row-click="selectMachine">
        <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>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent1"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="pageSize1"
          :total="total1"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange1"
          @current-change="handleCurrentChange1"/>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitName">提交</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogFormVisible3" title="选择组号" center style="min-height: 300px">
      <el-table
        :data="tableData7"
        style="width:100%;max-height: 300px;display: inline-block"
        height="300"
        highlight-current-row
        border
        @row-click="selectGroup">
        <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>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          :current-page="pageCurrent2"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="pageSize2"
          :total="total2"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange3"
          @current-change="handleCurrentChange3"/>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitGroup">提交</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogFormVisible4" title="零件加工进度" center style="min-height: 300px">
      <el-table
        :data="tableData5"
        style="width: 100%;max-height: 400px;"
        size="mini"
        height="300"
        highlight-current-row
        border>
        <el-table-column align="center" label="工序顺序" width="100">
          <template slot-scope="scope">
            {{ scope.row.工序顺序 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="工艺名称" width="150">
          <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="工艺是否完成" width="130">
          <template slot-scope="scope">
            <el-tag v-if="parseInt(scope.row.工序状态)===4" type="success" size="small">已完成</el-tag>
            <el-tag v-if="parseInt(scope.row.工序状态)===5" type="warning" size="small">报废</el-tag>
            <el-tag v-if="parseInt(scope.row.工序状态)!==4 && parseInt(scope.row.工序状态)!==5" type="primary" size="small">未完成</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import { initProject, searchTable, searchmachine, searchgroup, searchPurchaseTable, searchTable1, processingStatus, searchTable22 } from '@/api/ManufacturingCenter/GroupMatching'
export default {
  data() {
    return {
      entryNameValue: null, // 项目流水号
      entryName: [], // 项目数组
      machineToolNumber: '', // 机床图号
      machineNumber: '',
      machine: null, // 机床流水号
      groupNumber: '', // 组号
      groupNumber1: '',
      groupNum: null, // 组件流水号
      partNumber: '', // 零件号
      num: null,
      pageCurrent: 1,
      pageSize: 10,
      pageCurrent1: 1,
      pageSize1: 10,
      pageCurrent2: 1,
      pageSize2: 10,
      pageCurrent4: 1,
      pageSize4: 10,
      pageCurrent5: 1,
      pageSize5: 10,
      tableData7: [],
      tableData6: [],
      tableData: [],
      tableData1: [],
      tableData5: [],
      state: null,
      listLoading1: false,
      listLoading2: false,
      total: 0,
      total1: 0,
      total2: 0,
      total4: 0,
      total5: 0,
      title: '',
      totalNum: 0,
      totalNum1: 0,
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      dialogFormVisible4: false,
      check: null,
      check1: null,
      check2: null,
      check3: null,
      check4: null,
      check5: null,
      month: null,
      year: null,
      time: '',
      loading: false,
      monthes: [{
        value: 1,
        label: '1'
      }, {
        value: 2,
        label: '2'
      }, {
        value: 3,
        label: '3'
      }, {
        value: 4,
        label: '4'
      }, {
        value: 5,
        label: '5'
      }, {
        value: 6,
        label: '6'
      }, {
        value: 7,
        label: '7'
      }, {
        value: 8,
        label: '8'
      }, {
        value: 9,
        label: '9'
      }, {
        value: 10,
        label: '10'
      }, {
        value: 11,
        label: '11'
      }, {
        value: 12,
        label: '12'
      }],
      tableDataPurchase: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    searchData() {
      this.totalNum = 0
      this.loading = true
      this.listLoading1 = true
      this.listLoading2 = true
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        if (this.entryNameValue !== null && this.entryNameValue !== '') {
          this.check = 1
        } else {
          this.check = 0
        }
        if (this.machineToolNumber !== '') {
          this.check1 = 1
        } else {
          this.check1 = 0
        }
        if (this.groupNumber !== '') {
          this.check2 = 1
        } else {
          this.check2 = 0
        }
        if (this.year !== null && this.year !== '') {
          this.check3 = 1
        } else {
          this.check3 = 0
        }
        if (this.month !== null && this.month !== '') {
          this.check4 = 1
        } else {
          this.check4 = 0
        }
        if (this.time !== '' && this.time !== null) {
          this.check5 = 1
        } else {
          this.check5 = 0
        }
        searchTable(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent, this.pageSize).then(response => {
          for (let i = 0; i < response.data.rows.length; i++) {
            if (response.data.rows[i].入库时间 !== '') {
              response.data.rows[i].入库时间 = response.data.rows[i].入库时间.split(' ', 2)[0]
            }
            if (response.data.rows[i].计划完成时间 !== '') {
              response.data.rows[i].计划完成时间 = response.data.rows[i].计划完成时间.split(' ', 2)[0]
            }
          }
          this.tableData = response.data.rows
          this.total = parseInt(response.data.total)
          this.loading = false
        })
        searchTable22(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent, this.pageSize).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            console.log(response.data[i].入库时间, 123)
            if (response.data[i].入库时间 !== null) {
              this.totalNum += 1
            }
          }
        })
        searchPurchaseTable(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent, this.pageSize).then(response => {
          for (let i = 0; i < response.data.rows.length; i++) {
            if (response.data.rows[i].到货时间 !== '' || response.data.rows[i].到货时间 !== null) {
              response.data.rows[i].到货时间 = response.data.rows[i].到货时间.split(' ', 2)[0]
            }
          }
          this.tableDataPurchase = response.data.rows
          this.total4 = parseInt(response.data.total)
        })
        searchTable1(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent, this.pageSize).then(response => {
          this.tableData1 = response.data.rows
          this.total5 = parseInt(response.data.total)
        })
      } else {
        this.loading = false
        this.$message.warning('请先选择项目')
      }
    },
    getList() { // 初始化项目名称
      initProject().then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.entryName.push({
            label: response.data[i].项目名称,
            value: response.data[i].项目流水号
          })
        }
      })
    },
    processingStatus(row) {
      this.dialogFormVisible4 = true
      processingStatus(row.工艺计划流水号).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          if (response.data[i].计划日期 !== '' && response.data[i].计划日期 !== null) {
            response.data[i].计划日期 = response.data[i].计划日期.split(' ')[0]
          }
        }
        this.tableData5 = response.data
      })
    },
    empty() {
      this.machineToolNumber = ''
      this.groupNumber = ''
    },
    SearchMachine() { // 查询机床
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        this.dialogFormVisible2 = true
        this.check6 = 1
        searchmachine(this.entryNameValue, this.check6, this.pageCurrent1, this.pageSize1).then(response => {
          for (let i = 0; i < response.data.result; i++) {
            if (response.data.result[i].机床开始时间 !== '') {
              response.data.result[i].机床开始时间 = response.data.result[i].机床开始时间.substr(0, 10)
            }
            if (response.data.result[i].机床结束时间 !== '') {
              response.data.result[i].机床结束时间 = response.data.result[i].机床结束时间.substr(0, 10)
            }
          }
          this.tableData6 = response.data.result
          this.total1 = parseInt(response.data.output[0].ItemCount)
        })
      } else {
        this.$message.warning('请先选择项目')
      }
    },
    selectMachine(row) { // 选择机床号
      this.machine = row.机床流水号
      this.machineNumber = row.机床图号
    },
    submitName() { // 提交机床号
      this.machineToolNumber = this.machineNumber
      this.dialogFormVisible2 = false
    },
    empty1() {
      this.groupNumber = ''
    },
    searchGroupList() { // 查询组号
      if (this.machineToolNumber !== '') {
        this.dialogFormVisible3 = true
        searchgroup(this.machine, this.pageCurrent2, this.pageSize2).then(response => {
          this.tableData7 = response.data.result
          this.total2 = parseInt(response.data.output[0].ItemCount)
        })
      } else {
        this.$message.warning('请先选择机床')
      }
    },
    selectGroup(row) { // 选择组号
      this.groupNumber1 = row.组号
      this.groupNum = row.组件流水号
    },
    submitGroup() { // 提交组号
      this.groupNumber = this.groupNumber1
      this.dialogFormVisible3 = false
    },
    handleSizeChange(val) {
      this.pageCurrent = 1
      this.pageSize = val
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        if (this.entryNameValue !== null && this.entryNameValue !== '') {
          this.check = 1
        } else {
          this.check = 0
        }
        if (this.machineToolNumber !== '') {
          this.check1 = 1
        } else {
          this.check1 = 0
        }
        if (this.groupNumber !== '') {
          this.check2 = 1
        } else {
          this.check2 = 0
        }
        if (this.year !== null && this.year !== '') {
          this.check3 = 1
        } else {
          this.check3 = 0
        }
        if (this.month !== null && this.month !== '') {
          this.check4 = 1
        } else {
          this.check4 = 0
        }
        if (this.time !== '' && this.time !== null) {
          this.check5 = 1
        } else {
          this.check5 = 0
        }
        searchTable(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent, this.pageSize).then(response => {
          for (let i = 0; i < response.data.rows.length; i++) {
            if (response.data.rows[i].入库时间 !== '') {
              response.data.rows[i].入库时间 = response.data.rows[i].入库时间.split(' ', 2)[0]
            }
            if (response.data.rows[i].计划完成时间 !== '') {
              response.data.rows[i].计划完成时间 = response.data.rows[i].计划完成时间.split(' ', 2)[0]
            }
          }
          this.tableData = response.data.rows
          this.total = parseInt(response.data.total)
          this.loading = false
        })
      } else {
        this.loading = false
        this.$message.warning('请先选择项目')
      }
    },
    handleCurrentChange(val) {
      this.pageCurrent = val
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        if (this.entryNameValue !== null && this.entryNameValue !== '') {
          this.check = 1
        } else {
          this.check = 0
        }
        if (this.machineToolNumber !== '') {
          this.check1 = 1
        } else {
          this.check1 = 0
        }
        if (this.groupNumber !== '') {
          this.check2 = 1
        } else {
          this.check2 = 0
        }
        if (this.year !== null && this.year !== '') {
          this.check3 = 1
        } else {
          this.check3 = 0
        }
        if (this.month !== null && this.month !== '') {
          this.check4 = 1
        } else {
          this.check4 = 0
        }
        if (this.time !== '' && this.time !== null) {
          this.check5 = 1
        } else {
          this.check5 = 0
        }
        searchTable(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent, this.pageSize).then(response => {
          for (let i = 0; i < response.data.rows.length; i++) {
            if (response.data.rows[i].入库时间 !== '') {
              response.data.rows[i].入库时间 = response.data.rows[i].入库时间.split(' ', 2)[0]
            }
            if (response.data.rows[i].计划完成时间 !== '') {
              response.data.rows[i].计划完成时间 = response.data.rows[i].计划完成时间.split(' ', 2)[0]
            }
          }
          this.tableData = response.data.rows
          this.total = parseInt(response.data.total)
          this.loading = false
        })
      } else {
        this.loading = false
        this.$message.warning('请先选择项目')
      }
    },
    handleSizeChange1(val) {
      this.pageCurrent1 = 1
      this.pageSize1 = val
      this.SearchMachine()
    },
    handleCurrentChange1(val) {
      this.pageCurrent1 = val
      this.SearchMachine()
    },
    handleSizeChange3(val) {
      this.pageCurrent2 = 1
      this.pageSize2 = val
      this.searchGroupList()
    },
    handleCurrentChange3(val) {
      this.pageCurrent2 = val
      this.searchGroupList()
    },
    handleSizeChange4(val) {
      this.pageCurrent4 = 1
      this.pageSize4 = val
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        if (this.entryNameValue !== null && this.entryNameValue !== '') {
          this.check = 1
        } else {
          this.check = 0
        }
        if (this.machineToolNumber !== '') {
          this.check1 = 1
        } else {
          this.check1 = 0
        }
        if (this.groupNumber !== '') {
          this.check2 = 1
        } else {
          this.check2 = 0
        }
        if (this.year !== null && this.year !== '') {
          this.check3 = 1
        } else {
          this.check3 = 0
        }
        if (this.month !== null && this.month !== '') {
          this.check4 = 1
        } else {
          this.check4 = 0
        }
        if (this.time !== '' && this.time !== null) {
          this.check5 = 1
        } else {
          this.check5 = 0
        }
        searchPurchaseTable(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent4, this.pageSize4).then(response => {
          console.log(response)
          this.tableDataPurchase = response.data.rows
          this.listLoading1 = false
          this.total4 = parseInt(response.data.total)
        })
      } else {
        this.loading = false
        this.$message.warning('请先选择项目')
      }
    },
    handleCurrentChange4(val) {
      this.pageCurrent4 = val
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        if (this.entryNameValue !== null && this.entryNameValue !== '') {
          this.check = 1
        } else {
          this.check = 0
        }
        if (this.machineToolNumber !== '') {
          this.check1 = 1
        } else {
          this.check1 = 0
        }
        if (this.groupNumber !== '') {
          this.check2 = 1
        } else {
          this.check2 = 0
        }
        if (this.year !== null && this.year !== '') {
          this.check3 = 1
        } else {
          this.check3 = 0
        }
        if (this.month !== null && this.month !== '') {
          this.check4 = 1
        } else {
          this.check4 = 0
        }
        if (this.time !== '' && this.time !== null) {
          this.check5 = 1
        } else {
          this.check5 = 0
        }
        searchPurchaseTable(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent4, this.pageSize4).then(response => {
          console.log(response)
          this.tableDataPurchase = response.data.rows
          this.listLoading1 = false
          this.total4 = parseInt(response.data.total)
        })
      } else {
        this.loading = false
        this.$message.warning('请先选择项目')
      }
    },
    handleSizeChange5(val) {
      this.pageCurrent5 = 1
      this.pageSize5 = val
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        if (this.entryNameValue !== null && this.entryNameValue !== '') {
          this.check = 1
        } else {
          this.check = 0
        }
        if (this.machineToolNumber !== '') {
          this.check1 = 1
        } else {
          this.check1 = 0
        }
        if (this.groupNumber !== '') {
          this.check2 = 1
        } else {
          this.check2 = 0
        }
        if (this.year !== null && this.year !== '') {
          this.check3 = 1
        } else {
          this.check3 = 0
        }
        if (this.month !== null && this.month !== '') {
          this.check4 = 1
        } else {
          this.check4 = 0
        }
        if (this.time !== '' && this.time !== null) {
          this.check5 = 1
        } else {
          this.check5 = 0
        }
        searchTable1(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent5, this.pageSize5).then(response => {
          console.log(response)
          this.tableData1 = response.data.rows
          this.listLoading2 = false
          this.total5 = parseInt(response.data.total)
        })
      } else {
        this.loading = false
        this.$message.warning('请先选择项目')
      }
    },
    handleCurrentChange5(val) {
      this.pageCurrent5 = val
      if (this.entryNameValue !== null && this.entryNameValue !== '') {
        if (this.entryNameValue !== null && this.entryNameValue !== '') {
          this.check = 1
        } else {
          this.check = 0
        }
        if (this.machineToolNumber !== '') {
          this.check1 = 1
        } else {
          this.check1 = 0
        }
        if (this.groupNumber !== '') {
          this.check2 = 1
        } else {
          this.check2 = 0
        }
        if (this.year !== null && this.year !== '') {
          this.check3 = 1
        } else {
          this.check3 = 0
        }
        if (this.month !== null && this.month !== '') {
          this.check4 = 1
        } else {
          this.check4 = 0
        }
        if (this.time !== '' && this.time !== null) {
          this.check5 = 1
        } else {
          this.check5 = 0
        }
        searchTable1(this.check, this.entryNameValue, this.check1, this.machine, this.check2, this.groupNum, this.check3, this.year, this.check4, this.month, this.check5, this.time, this.pageCurrent5, this.pageSize5).then(response => {
          console.log(response)
          this.tableData1 = response.data.rows
          this.listLoading2 = false
          this.total5 = parseInt(response.data.total)
        })
      } else {
        this.loading = false
        this.$message.warning('请先选择项目')
      }
    },
    getSummaries(param) {
      const { columns } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 4) {
          sums[index] = '总件数'
          return
        } else if (index === 5) {
          sums[index] = this.total + '件'
        } else if (index === 6) {
          sums[index] = '入库数量'
        } else if (index === 7) {
          sums[index] = this.totalNum + ' 件'
        }
      })
      return sums
    }
  }
}
</script>

<style scoped>
  .el-card{
    margin-bottom: 15px;
  }
  .el-date-editor{
    width:150px
  }
  span{
    margin: 10px 0 10px 10px;
  }
</style>
