<template>
  <div class="app-container">
    <el-card style="height: 850px">
      <el-tabs
        v-model="PartType"
        style="height: 850px"
        type="border-card"
        @tab-click="pageCurrent=1;pageCurrent1=1;getData()">
        <el-tab-pane label="调拨单查询" name="调拨单查询">
          <el-col style="width: 701px">
            <div style="margin-top: 7px; margin-bottom: 7px">
              <span style="font-size: 13px;color: black">调拨日期</span>
              <el-date-picker
                v-model="dateRange"
                align="center"
                end-placeholder="结束日期"
                format="yyyy-MM-dd"
                range-separator="～"
                size="small"
                start-placeholder="开始日期"
                style="width: 240px;"
                type="daterange"
                value-format="yyyy-MM-dd"
                @change="searchTable"/>
              <el-select
                v-model="outsourcingManufacturersValue"
                clearable
                filterable
                placeholder="外协厂家"
                size="small"
                style="width:100px"
                @change="pageCurrent=1;getTransferNotes();searchTable()">
                <el-option
                  v-for="item in outsourcingManufacturers"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
              <el-select
                v-model="selectTheDialListValue"
                clearable
                filterable
                placeholder="调拨单号"
                size="small"
                style="width:150px"
                @change="pageCurrent=1;searchTable()">
                <el-option
                  v-for="item in transferNotes"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"/>
              </el-select>
            </div>
            <div>
              <el-table
                v-loading="loading"
                :data="tableData"
                border
                height="700px"
                highlight-current-row
                size="small"
                stripe
                style="width: 751px"
                @row-click="searchTable2">
                <el-table-column :width="setColumnWidth('状态')" align="center" label="调拨状态">
                  <template slot-scope="scope">
                    {{ scope.row.调拨状态 }}
                  </template>
                </el-table-column>
                <el-table-column
                  :width="setColumnWidth('品名/规格/型号')"
                  align="center"
                  label="调拨单号"
                  show-overflow-tooltip>
                  <template slot-scope="scope">
                    {{ scope.row.调拨单号 }}
                  </template>
                </el-table-column>
                <el-table-column
                  :width="setColumnWidth('外协厂家')"
                  align="center"
                  label="外协厂家"
                  show-overflow-tooltip>
                  <template slot-scope="scope">
                    {{ scope.row.外协厂家 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('日期')" align="center" label="调拨日期" prop="调拨日期">
                  <template slot-scope="scope">
                    {{ scope.row.调拨日期 }}
                  </template>
                </el-table-column>
                <el-table-column align="center" label="调拨备注" prop="调拨备注">
                  <template slot-scope="scope">
                    {{ scope.row.调拨备注 }}
                  </template>
                </el-table-column>
                <el-table-column align="center" label="操作" width="115px">
                  <template slot-scope="scope">
                    <el-tooltip :open-delay="500" content="查看图片" effect="dark" placement="top">
                      <el-button
                        icon="el-icon-picture-outline"
                        size="mini"
                        style="margin-right: 10px"
                        type="text"
                        @click="handlePicture(scope.row)"/>
                    </el-tooltip>
                    <el-tooltip :open-delay="500" content="打印调拨单" effect="dark" placement="top">
                      <el-button
                        icon="el-icon-printer"
                        size="mini"
                        style="margin-right: 10px"
                        type="text"
                        @click="exportTable()"/>
                    </el-tooltip>
                    <el-tooltip :open-delay="500" content="删除调拨单" effect="dark" placement="top">
                      <el-button
                        :disabled="(Number(scope.row.单据状态) > 1) || (jobNumber != '1002')"
                        icon="el-icon-delete"
                        size="mini"
                        type="text"
                        @click="handleDelete(scope.row)"/>
                    </el-tooltip>
                  </template>
                </el-table-column>
              </el-table>
              <div class="block" style="margin-top: 10px;">
                <el-pagination
                  :current-page="pageCurrent"
                  :page-size="pageSize"
                  :page-sizes="[10, 20, 30, 40, 100]"
                  :total="total"
                  layout="total, sizes, prev, pager, next, jumper"
                  @size-change="handleSizeChanges"
                  @current-change="handleCurrentChanges"/>
              </div>
            </div>
          </el-col>
          <el-col style="width: 951px;margin-left: 10px">
            <div style="margin-top: 45px">
              <el-table
                v-loading="loading"
                ref="table"
                :data="tableData2"
                :header-cell-style="{background: '#2283D4',color: 'white'}"
                border
                highlight-current-row
                show-summary
                size="small"
                stripe
                style="width: 946px">
                <!--            <el-table-column :width="setColumnWidth('序号')" label="选出" align="center">-->
                <!--              <template slot-scope="scope">-->
                <!--                <el-button type="text" size="mini" @click="deleteProduct(scope.row)"><svg-icon icon-class="箭头2" class="is-rotate" style="width: 20px;height: 20px"/></el-button>-->
                <!--              </template>-->
                <!--            </el-table-column>-->
                <el-table-column align="center" label="状态" prop="状态" width="55px">
                  <template slot-scope="scope">
                    {{ scope.row.状态 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('名称')" align="center" label="工件名称" show-overflow-tooltip>
                  <template slot-scope="scope">
                    {{ scope.row.工件名称 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('数量')" align="center" label="工序" prop="工序">
                  <template slot-scope="scope">
                    {{ scope.row.工序 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('单位')" align="center" label="单位" prop="单位">
                  <template slot-scope="scope">
                    {{ scope.row.单位 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('数量')" align="center" label="数量" prop="调拨数量">
                  <template slot-scope="scope">
                    {{ scope.row.调拨数量 }}
                  </template>
                </el-table-column>
                <el-table-column align="center" label="外协价格" prop="外协价格" width="90px">
                  <template slot-scope="scope">
                    {{ scope.row.外协价格 }}
                  </template>
                </el-table-column>
                <el-table-column align="center" label="总价" prop="总价" width="90px">
                  <template slot-scope="scope">
                    {{ scope.row.调拨数量 * scope.row.外协价格 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('数量')" align="center" label="到货数" prop="已到货数量">
                  <template slot-scope="scope">
                    {{ scope.row.已到货数量 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('备注')" align="center" label="备注">
                  <template slot-scope="scope">
                    {{ scope.row.备注 }}
                  </template>
                </el-table-column>
                <el-table-column :width="setColumnWidth('日期')" align="center" label="到货日期">
                  <template slot-scope="scope">
                    {{ scope.row.到货日期 }}
                  </template>
                </el-table-column>
                <el-table-column align="center" label="操作" width="90px">
                  <template slot-scope="scope">
                    <el-button icon="el-icon-edit" size="mini" type="text" @click="editProduct(scope.row)">编辑
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-col>
        </el-tab-pane>
        <el-tab-pane label="调拨件查询" name="调拨件查询">
          <div style="margin-top: 7px; margin-bottom: 7px">
            <span style="font-size: 13px;color: black">调拨日期</span>
            <el-date-picker
              v-model="dateRange"
              align="center"
              end-placeholder="结束时间"
              format="yyyy-MM-dd"
              range-separator="～"
              size="small"
              start-placeholder="开始时间"
              style="width: 240px;"
              type="daterange"
              value-format="yyyy-MM-dd"
              @change="searchTable1"/>
            <el-select
              v-model="outsourcingManufacturersValue"
              clearable
              filterable
              placeholder="外协厂家"
              size="small"
              style="width:150px;margin-right: 0"
              @change="searchTable1()">
              <el-option
                v-for="item in outsourcingManufacturers"
                :key="item.value"
                :label="item.label"
                :value="item.value"/>
            </el-select>
            <el-select
              v-model="orderNumberValue"
              :remote-method="getOrderNumberValue"
              clearable
              filterable
              remote
              placeholder="订单号"
              size="small"
              style="width:150px;margin-right: 0"
              @change="searchTable1();getProductPartName()">
              <el-option
                v-for="item in orderNumber"
                :key="item.value"
                :label="item.label"
                :value="item.value"/>
            </el-select>
            <el-select
              v-model="productPartNameValue"
              clearable
              filterable
              placeholder="产品/部件名称"
              size="small"
              style="width:100px;margin-right: 0"
              @change="searchTable1()">
              <el-option
                v-for="item in productPartName"
                :key="item.value"
                :label="item.label"
                :value="item.value"/>
            </el-select>
            <el-select
              v-model="transferStatusValue"
              clearable
              filterable
              placeholder="调拨状态"
              size="small"
              style="width:100px"
              @change="searchTable1()">
              <el-option
                v-for="item in transferStatus"
                :key="item.value"
                :label="item.label"
                :value="item.value"/>
            </el-select>
            <el-input
              v-model="partName"
              clearable
              placeholder="工件名称"
              size="small"
              style="width: 200px"
              @keyup.enter.native="searchTable1()"/>
            <el-input
              v-model="partNumber"
              clearable
              placeholder="图号"
              size="small"
              style="width: 200px"
              @keyup.enter.native="searchTable1()"/>
          </div>
          <div style="width: 1521px">
            <el-table
              v-loading="loading"
              ref="table1"
              :data="tableData1"
              border
              height="700px"
              highlight-current-row
              show-summary
              size="small"
              stripe
              style="width: 1601px"
              @sort-change="sortChange">
              <el-table-column :width="setColumnWidth('状态')" align="center" label="状态" show-overflow-tooltip>
                <template slot-scope="scope">
                  {{ scope.row.状态 }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="工件名称"
                prop="工件名称"
                show-overflow-tooltip
                sortable="工件名称"
                width="160px">
                <template slot-scope="scope">
                  {{ scope.row.工件名称 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('图号或型号')" align="center" label="图号">
                <template slot-scope="scope">
                  {{ scope.row.图号 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('工序')" align="center" label="工序">
                <template slot-scope="scope">
                  {{ scope.row.工序 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('单位')" align="center" label="单位">
                <template slot-scope="scope">
                  {{ scope.row.单位 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('数量')" align="center" label="调拨数" prop="调拨数量">
                <template slot-scope="scope">
                  {{ scope.row.调拨数量 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('数量')" align="center" label="到货数" prop="已到货数量">
                <template slot-scope="scope">
                  {{ scope.row.已到货数量 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('外协厂家')" align="center" label="外协厂家">
                <template slot-scope="scope">
                  {{ scope.row.外协厂家 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('日期')" align="center" label="任务生成">
                <template slot-scope="scope">
                  {{ scope.row.任务生成 }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="调拨日期" prop="调拨日期" sortable="调拨日期" width="110px">
                <template slot-scope="scope">
                  {{ scope.row.调拨日期 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('日期')" align="center" label="到货日期">
                <template slot-scope="scope">
                  {{ scope.row.到货日期 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('调拨单号')" align="center" label="调拨单号">
                <template slot-scope="scope">
                  {{ scope.row.调拨单号 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('订单号')" align="center" label="订单号">
                <template slot-scope="scope">
                  {{ scope.row.订单号 }}
                </template>
              </el-table-column>
              <el-table-column :width="setColumnWidth('工件名称')" 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-size="pageSize1"
                :page-sizes="[10, 20, 30, 40, 100]"
                :total="total1"
                layout="total, sizes, prev, pager, next, jumper"
                @size-change="handleSizeChanges1"
                @current-change="handleCurrentChanges1"/>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-card>
    <el-card v-show="false">
      <div style="width:900px;margin-left: 350px">
        <el-card>
          <div id="WGBLD" style="width: 880px;margin: 0 auto">
            <div style="width: 117px;margin: 0 auto 20px">
              <!--              调整这一个即可解决 打印出来表头布局中的问题-->
              <h3>仓库调拨单</h3>
            </div>
            <div style="margin-bottom: 10px">
              <span style="float: left;margin-left: 10px;font-size: 16px">日期：{{ date }}</span><span
                style="float: right;font-size: 16px;margin-right: 20px">编号：{{ number }}</span>
            </div>
            <table align="center" border="1 solid black" cellspacing="0px" width="100%">
              <tr id="tablehead12" style="height: 35px">
                <td colspan="3" style="text-align: center;width: 14%;font-size: 16px">物料代码</td>
                <td colspan="4" style="text-align: center;width: 20%;font-size: 16px">物料名称</td>
                <td colspan="4" style="text-align: center;width: 20%;font-size: 16px">规格型号</td>
                <td colspan="2" style="text-align: center;width: 10%;font-size: 16px">调出仓库</td>
                <td colspan="3" style="text-align: center;width: 14%;font-size: 16px">调入仓库</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">单位</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">单价</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">数量</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">总价</td>
                <td colspan="2" style="text-align: center;width: 8%;font-size: 16px">备注</td>
              </tr>
              <tr v-for="(list, index) in returns" :key="index" style="height: 35px">
                <td colspan="3" style="text-align: center;width: 14%;font-size: 16px">{{ list.物料代码 }}</td>
                <td colspan="4" style="text-align: center;width: 20%;font-size: 16px">{{ list.物料名称 }}</td>
                <td colspan="4" style="text-align: center;width: 20%;font-size: 16px">{{ list.规格型号 }}</td>
                <td colspan="2" style="text-align: center;width: 10%;font-size: 16px">{{ list.调出仓库 }}</td>
                <td colspan="3" style="text-align: center;width: 14%;font-size: 16px">{{ list.调入仓库 }}</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">{{ list.单位 }}</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">{{ list.外协价格 }}</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">{{ list.数量 }}</td>
                <td colspan="1" style="text-align: center;width: 5%;font-size: 16px">{{
                  list.数量 * list.外协价格
                }}
                </td>
                <td colspan="2" style="text-align: center;width: 5%;font-size: 16px">{{ list.备注 }}</td>
              </tr>
            </table>
            <div style="margin-top: 20px"><span style="margin-left: 10px;font-size: 16px">审核：</span><span
              style="margin-left: 15%;font-size: 16px">记账：</span><span
                style="margin-left: 15%;font-size: 16px">验收：</span><span
                  style="margin-left: 15%;font-size: 16px">保管：</span><span
                    style="margin-left: 15%;font-size: 16px">制单：</span></div>
          </div>
        </el-card>
      </div>
    </el-card>
    <el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible" center style="" title="图片" width="600px">
      <el-image
        v-for="url in urls"
        :key="url"
        :preview-src-list="urls"
        :src="url"
        lazy
        style="width: 500px; height: 500px"/>
    </el-dialog>
    <el-dialog v-el-drag-dialog :visible.sync="dialogFormVisible3" center title="编辑" width="360px">
      <el-form ref="form" :model="form" class="demo-ruleForm" label-position="center" label-width="100px">
        <el-form-item label="外协价格">
          <el-input v-model="form.外协价格" clearable size="small" style="width:150px;" type="number"/>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="form.备注" clearable size="small" style="width:150px;"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogFormVisible3=false">取消</el-button>
        <el-button size="small" type="distribution" @click="submitUpdate()">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import $ from 'jquery'
import Cookie from 'js-cookie'

export default {
  data() {
    return {
      type: '',
      date: '',
      number: '',
      PartType: '调拨单查询',
      returns: [],
      partName: '',
      partNumber: '',
      outsourcingManufacturersValue: '', // 外协厂家
      outsourcingManufacturers: [], // 外协厂家数组
      orderNumberValue: '', // 订单号
      orderNumber: [], // 订单号数组
      selectTheDialListValue: '',
      transferNotes: [],
      productPartNameValue: '', // 产品部件名称
      productPartName: [], // 产品部件名称数组
      transferStatusValue: '', // 调拨状态
      transferStatus: [], // 调拨状态数组
      checked: false,
      showInput: false,
      dialogFormVisible: false,
      dialogFormVisible3: false,
      NumberValue: '',
      waixiechangjia: '',
      materialValue: '',
      form: {
        外协价格: '',
        备注: ''
      },
      urls: [],
      dateRange: '', // 提交日期
      loading: false, // 数据加载
      total: 0, // 分页总数
      total1: 0, // 分页总数
      tableData: [],
      tableData1: [],
      tableData2: [],
      pageCurrent: 1, // 分页当前页
      pageSize: 50, // 分页每页显示条数
      pageCurrent1: 1, // 分页当前页
      pageSize1: 50, // 分页每页显示条数
      orderName: '', // 排序列名
      order: '', // 排序方式
      jobNumber: 0
    }
  },
  computed: {
    ...mapGetters([
      'id',
      'token'
    ])
  },
  updated() {
    this.$nextTick(() => {
      this.$refs['table'].doLayout()
      this.$refs['table1'].doLayout()
    })
  },
  created() {
    this.getOrderNumberValue('')
    this.getTransferStatus()
    this.getOutsourcingManufacturers()
    this.searchTable()

    this.jobNumber = Cookie.get('jobNumber')
  },
  methods: {
    editProduct(row) {
      this.form.外协价格 = row.外协价格
      this.form.备注 = row.备注
      this.materialValue = row.外协调拨单明细流水号
      this.dialogFormVisible3 = true
    },
    submitUpdate() {
      var param = []
      param[0] = ['外协调拨单明细流水号', this.materialValue]
      param[1] = ['外协价格', this.form.外协价格]
      param[2] = ['备注', this.form.备注]
      var Data = this.CreateData('12', '仓储管理_外协调拨单明细_编辑', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message.success('编辑成功')
          var param = []
          param[0] = ['外协调拨单流水号', this.NumberValue]
          var Data = this.CreateData('11', '仓储管理_外协调拨单明细_查询', param)
          this.ExecDatabase(Data).then(response => {
            this.returns = []
            for (let i = 0; i < response.data.length; i++) {
              this.returns.push({
                物料代码: response.data[i].物料编码,
                物料名称: response.data[i].工件名称,
                规格型号: response.data[i].图号,
                调出仓库: '精工车间',
                调入仓库: this.waixiechangjia,
                单位: response.data[i].单位,
                外协价格: response.data[i].外协价格 ? response.data[i].外协价格 : 0,
                数量: response.data[i].调拨数量,
                备注: response.data[i].备注
              })
            }
            console.log(this.returns, 222)
            this.tableData2 = response.data
          })
          this.dialogFormVisible3 = false
        } else {
          this.$message.error('编辑失败')
        }
      })
    },
    exportTable() {
      const htmlNode = $('#WGBLD').html()
      const body = $('body')
      body.children().hide()
      const printNode = $(htmlNode)
      body.append(printNode)
      window.print()
      body.children().not('script').show()
      body.children().not('#app').hide()
      printNode.remove()
    },
    // 外协厂家查询
    getOutsourcingManufacturers() {
      var param = []
      var Data = this.CreateData('11', '外协厂家_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.outsourcingManufacturers.push({
            label: response.data[i].外协厂家简称,
            value: response.data[i].外协厂家流水号
          })
        }
      })
    },
    getTransferNotes() {
      this.transferNotes = []
      this.selectTheDialListValue = ''
      if (this.outsourcingManufacturersValue) {
        var param = []
        param[0] = ['外协厂家流水号', this.outsourcingManufacturersValue]
        var Data = this.CreateData('11', '仓储管理_外协调拨单列表_全部查询', param)
        this.ExecDatabase(Data).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            this.transferNotes.push({
              label: response.data[i].调拨单号,
              value: response.data[i].外协调拨单流水号
            })
          }
        })
      }
    },
    getOrderNumberValue(query) {
      this.orderNumber = []
      var param = []
      param[0] = ['订单编号', query]
      var Data = this.CreateData('11', '订单信息_列表_查询数据_bak', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.orderNumber.push({
            label: response.data[i].订单编号,
            value: response.data[i].订单流水号
          })
        }
      })
    },
    getProductPartName() {
      this.productPartName = []
      this.productPartNameValue = ''
      if (this.orderNumberValue) {
        var param = []
        param[0] = ['订单流水号', this.orderNumberValue]
        var Data = this.CreateData('11', '订单信息_产品信息_查询数据', param)
        this.ExecDatabase(Data).then(response => {
          for (let i = 0; i < response.data.length; i++) {
            this.productPartName.push({
              label: response.data[i].产品名称,
              value: response.data[i].组件流水号
            })
          }
        })
      }
    },
    getTransferStatus() {
      var param = []
      var Data = this.CreateData('11', '仓储管理_外协调拨单状态_查询', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          this.transferStatus.push({
            label: response.data[i].调拨状态,
            value: response.data[i].调拨状态
          })
        }
      })
    },
    getData() {
      if (this.PartType === '调拨单查询') {
        this.searchTable()
      } else if (this.PartType === '调拨件查询') {
        this.searchTable1()
      }
    },
    searchTable() {
      let outsourcingManufacturersValue_check, dateRange_check, selectTheDialListValue_check
      this.outsourcingManufacturersValue ? outsourcingManufacturersValue_check = 1 : outsourcingManufacturersValue_check = 0
      this.selectTheDialListValue ? selectTheDialListValue_check = 1 : selectTheDialListValue_check = 0
      this.dateRange ? dateRange_check = 1 : (dateRange_check = 0, this.dateRange = '')
      var param = []
      param[0] = ['外协厂家流水号', this.outsourcingManufacturersValue]
      param[1] = ['开始时间', this.dateRange[0]]
      param[2] = ['结束时间', this.dateRange[1]]
      param[3] = ['外协厂家_check', outsourcingManufacturersValue_check]
      param[4] = ['调拨日期_check', dateRange_check]
      param[5] = ['调拨单号_check', selectTheDialListValue_check]
      param[6] = ['调拨单号流水号', this.selectTheDialListValue]
      var Data = this.CreateData('11', '仓储管理_外协调拨单_查询', param, this.pageSize, this.pageCurrent)
      this.ExecDatabase(Data).then(response => {
        this.tableData = response.data.rows
        this.total = response.data.total
      })
    },
    handlePicture(row) {
      this.dialogFormVisible = true
      this.urls = []
      var param = []
      param[0] = ['外协调拨单流水号', row.外协调拨单流水号]
      var Data = this.CreateData('11', '外协调拨单_图片_查询数据', param)
      this.ExecDatabase(Data).then(response => {
        for (let i = 0; i < response.data.length; i++) {
          if (response.data[i].文件内容 !== null) {
            this.urls.push('data:image/png;base64,' + response.data[i].文件内容)
          }
        }
      })
    },
    handleDelete(row) {
      this.$confirm('是否删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['外协调拨单流水号', row.外协调拨单流水号]
        var Data = this.CreateData('12', '仓储管理_外协调拨_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('删除成功')
            this.searchTable()
            this.tableData2 = []
          } else {
            this.$message.error('删除失败')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    searchTable2(row) {
      console.log('调拨查询调拨单信息', row)
      this.date = row.调拨日期
      this.number = row.调拨单号
      this.NumberValue = row.外协调拨单流水号
      this.waixiechangjia = row.外协厂家
      var AA = row.外协厂家
      var param = []
      param[0] = ['外协调拨单流水号', row.外协调拨单流水号]
      var Data = this.CreateData('11', '仓储管理_外协调拨单明细_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.returns = []
        for (let i = 0; i < response.data.length; i++) {
          this.returns.push({
            物料代码: response.data[i].物料编码,
            物料名称: response.data[i].工件名称,
            规格型号: response.data[i].图号,
            调出仓库: '精工车间',
            调入仓库: AA,
            单位: response.data[i].单位,
            外协价格: response.data[i].外协价格 ? response.data[i].外协价格 : 0,
            数量: response.data[i].调拨数量,
            备注: response.data[i].备注
          })
        }
        this.tableData2 = response.data
      })
    },
    searchTable1() {
      let outsourcingManufacturerValue_check, dateRange_check, orderNumberValue_check, productPartNameValue_check,
        transferStatusValue_check, partName_check, partNumber_check
      this.outsourcingManufacturersValue ? outsourcingManufacturerValue_check = 1 : outsourcingManufacturerValue_check = 0
      this.dateRange ? dateRange_check = 1 : (dateRange_check = 0, this.dateRange = '')
      this.orderNumberValue ? orderNumberValue_check = 1 : orderNumberValue_check = 0
      this.productPartNameValue ? productPartNameValue_check = 1 : productPartNameValue_check = 0
      this.transferStatusValue ? transferStatusValue_check = 1 : transferStatusValue_check = 0
      this.partName ? partName_check = 1 : partName_check = 0
      this.partNumber ? partNumber_check = 1 : partNumber_check = 0
      var param = []
      param[0] = ['外协厂家流水号', this.outsourcingManufacturersValue]
      param[1] = ['订单流水号', this.orderNumberValue]
      param[2] = ['组件流水号', this.productPartNameValue]
      param[3] = ['调拨状态', this.transferStatusValue]
      param[4] = ['开始时间', this.dateRange[0]]
      param[5] = ['结束时间', this.dateRange[1]]
      param[6] = ['外协厂家_check', outsourcingManufacturerValue_check]
      param[7] = ['调拨日期_check', dateRange_check]
      param[8] = ['订单号_check', orderNumberValue_check]
      param[9] = ['产品名称_check', productPartNameValue_check]
      param[10] = ['调拨状态_check', transferStatusValue_check]
      param[11] = ['排序名称', this.orderName]
      param[12] = ['排序方式', this.order]
      param[13] = ['工件名称_check', partName_check]
      param[14] = ['工件名称', this.partName]
      param[15] = ['图号_check', partNumber_check]
      param[16] = ['图号', this.partNumber]
      var Data = this.CreateData('11', '仓储管理_外协调拨件_查询', param, this.pageSize1, this.pageCurrent1)
      this.ExecDatabase(Data).then(response => {
        this.tableData1 = response.data.rows
        this.total1 = response.data.total
      })
    },
    sortChange(column) {
      if (column.prop === '工件名称') {
        this.orderName = 1
      } else if (column.prop === '调拨日期') {
        this.orderName = 2
      } else {
        this.orderName = 0
      }
      if (column.order === 'ascending') {
        this.order = 1
      } else if (column.order === 'descending') {
        this.order = 2
      } else {
        this.order = ''
      }
      this.searchTable()
    },
    handleSizeChanges(val) {
      this.pageCurrent = 1
      this.pageSize = val
      this.searchTable()
    },
    handleCurrentChanges(val) {
      this.pageCurrent = val
      this.searchTable()
    },
    handleSizeChanges1(val) {
      this.pageCurrent1 = 1
      this.pageSize1 = val
      this.searchTable1()
    },
    handleCurrentChanges1(val) {
      this.pageCurrent1 = val
      this.searchTable1()
    }
  }
}
</script>
<style lang="scss" scoped>
/deep/ .el-card__body {
  padding: 0px !important;
}
</style>
