<template>
  <div class="mod-config">
    <!-- 条件查询 -->
    <el-form :inline="true" label-position="top" :model="searchData">
      <el-form-item :label="'单据号'">
        <el-input v-model="searchData.notifyNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <!-- <el-form-item :label="'单据类型'">
        <el-select v-model="searchData.orderType" clearable style="width: 100px">
          <el-option label="采购入库" value="采购入库"></el-option>
          <el-option label="生产入库" value="生产入库"></el-option>
          <el-option label="销售退货" value="销售退货"></el-option>
          <el-option label="其他入库" value="其他入库"></el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item :label="'单据状态'">
        <el-select multiple collapse-tags v-model="searchData.orderStatusList" clearable style="width: 160px">
          <el-option label="草稿" value="UNISSUE"></el-option>
          <el-option label="已下达" value="ISSUE"></el-option>
          <el-option label="已完成" value="FINISH"></el-option>
          <el-option label="已关闭" value="CLOSED"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'申请单日期'">
        <el-date-picker style="width: 120px" v-model="searchData.startDate" type="date" value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item style="margin-top: 23px;">
        <!-- <laber style="margin-left: -9px;font-size: 19px"></laber> -->
         ~
      </el-form-item>
      <el-form-item :label="' '">
        <el-date-picker style="width: 120px" v-model="searchData.endDate" type="date" value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button v-if="!authSearch" type="primary" :loading="searchLoading" @click="getDataList()">查询</el-button>
        <!-- <el-button v-if="!authDelete" type="primary" @click="deleteModal()">删除</el-button> -->
        <!-- <el-button v-if="!authArchive" type="primary" @click="archiveModal()">归档</el-button> -->
      </el-form-item>
      <!-- <el-form-item :label="' '">
        <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
      </el-form-item> -->
    </el-form>

    <!-- 展示列表 -->
    <el-table :height="height" :data="dataList" border v-loading="searchLoading" ref="inboundTable"
      :row-style="rowStyle" @row-click="inboundClickRow" @current-change="changeCurrentRow"
      @selection-change="selectionInbound" style="width: 100%;">
      <el-table-column type="selection" header-align="center" align="center" width="50">
      </el-table-column>
      <el-table-column v-for="(item,index) in columnList" :key="index" :sortable="item.columnSortable"
        :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
              style="width: 100px; height: 80px" /></span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" header-align="center" align="center" width="120" label="操作">
        <template slot-scope="scope">
          <!-- <template v-if="!authUpdate">
            <el-link
              v-if="scope.row.orderStatus === '草稿' || scope.row.orderStatus === '待检验' || scope.row.orderStatus === '编辑中'"
              style="cursor: pointer" @click="updateModal(scope.row)">编辑</el-link>
          </template>
          <template v-if="!authClose">
            <el-link v-if="scope.row.orderStatus !== '草稿' && scope.row.orderStatus !== '已关闭'" style="cursor: pointer"
              @click="closeModal(scope.row)">关闭</el-link>
          </template>
          <template v-if="!authIssue">
            <el-link v-if="scope.row.orderStatus === '草稿' || scope.row.orderStatus === '编辑中'" style="cursor: pointer"
              @click="issueModal(scope.row)">下达</el-link>
          </template> -->
          <template v-if="!authClose">
            <el-link style="cursor: pointer"
              @click="closeModal(scope.row)">关闭</el-link>
          </template>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页栏 -->
    <el-pagination style="margin-top: 0px" @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
      :current-page="pageIndex" :page-sizes="[20, 50, 100, 200, 500]" :page-size="pageSize" :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <!-- 收货入库通知新增/修改 -->
    <el-dialog title="收货入库通知" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="525px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules"
        style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="单据类型" prop="orderType">
          <el-select v-model="modalData.orderType" :disabled="modalDisableFlag" style="width: 100px">
            <el-option label="生产退料" value="生产退料"></el-option>
            <el-option label="生产入库" value="生产入库"></el-option>
            <el-option label="其他入库" value="其他入库"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="要求入库日期" prop="requiredInboundDate">
          <el-date-picker style="width: 120px" v-model="modalData.requiredInboundDate" type="date"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px">
        <el-form-item>
          <!--          <span v-if="modalDisableFlag" slot="label">供应商</span>-->
          <span style="cursor: pointer" slot="label" @click="getBaseList(506)"><a href="#">供应商</a></span>
          <el-input v-model="modalData.supplierId" @change="supplierBlur(506)" style="width: 100px"></el-input>
          <el-input v-model="modalData.supplierName" disabled style="width: 380px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px">
        <el-form-item :label="'备注'">
          <el-input type="textarea" v-model="modalData.remarks" :rows="3" resize='none' show-word-limit
            style="width: 485px;height: 20px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: 55px;text-align:center">
        <el-button type="primary" :loading="saveLoading" @click="saveData()">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 页签 -->
    <el-tabs v-model="activeTable" style="width: 100%" :style="{height: secondHeight + 'px'}" type="border-card"
      @tab-click="tabClick" class="customer-tab">
      <el-tab-pane label="入库明细" name="inboundDetail">
        <!-- <el-form label-position="top" style="margin-left: 2px;">
          <el-button type="primary" @click="deleteInboundDetail()" icon="el-icon-delete">删除</el-button>
        </el-form> -->
        <el-table :data="detailList" :height="secondHeight - 68" border @selection-change="selectionInboundDetail"
          v-loading="searchLoading" style="width: 100%;">
          <el-table-column type="selection" header-align="center" align="center" width="50">
          </el-table-column>
          <el-table-column v-for="(item,index) in columnDetailList" :key="index" :sortable="item.columnSortable"
            :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                  style="width: 100px; height: 80px" /></span>
            </template>
          </el-table-column>
          <!-- <el-table-column prop="requiredQty" header-align="center" align="right" min-width="100" label="要求入库数量">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-input :controls="false" v-model="scope.row.requiredQty"
                  @input="value => scope.row.requiredQty = value.match(/^(\d+\.?\d*|\.\d+)$/) ? value : ''"
                  style="height: 11px; width: 98%;">
                </el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="inWarehouseName" header-align="center" align="center" min-width="180" label="入库仓库">
            <template slot-scope="scope">
              <span v-if="editBatchVisible">
                <el-button type="text" @click="chooseWareHouse(scope.row)"
                  style="width:18%;padding: 3px 7px">选择</el-button>
                <el-input v-model="scope.row.inWarehouseName" readonly style="width:77%"></el-input>
              </span>
              <span v-else>
                <span>{{scope.row[scope.column.property]}}</span>
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="actualStockInQty" header-align="center" align="right" min-width="100" label="实际入库数量">
          </el-table-column> -->
          <el-table-column fixed="right" header-align="center" align="center" width="90" label="操作">
            <template slot-scope="scope">
              <el-link style="cursor: pointer" @click="enterSOSDetail(scope.row)">入库明细</el-link>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <!-- 收获入库单明细新增 -->
    <el-dialog title="收货入库单明细" :close-on-click-modal="false" v-drag :visible.sync="detailModal" width="900px">
      <div style="font-size: 12px">
        <el-form :inline="true" label-position="top" :model="detailSearchData">
          <el-form-item :label="'物料编码'">
            <el-input v-model="detailSearchData.partNo" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'物料名称'">
            <el-input v-model="detailSearchData.partDesc" clearable style="width: 120px"></el-input>
          </el-form-item>
          <template v-if="detailSearchData.orderType === '生产入库'">
            <el-form-item :label="'生产订单'">
              <el-input v-model="detailSearchData.relatedOrderNo" clearable style="width: 120px"></el-input>
            </el-form-item>
            <el-form-item :label="'订单状态'">
              <el-select v-model="detailSearchData.status" clearable style="width: 100px">
                <el-option label="已计划" value="已计划"></el-option>
                <el-option label="已下达" value="已下达"></el-option>
                <el-option label="已排产" value="已排产"></el-option>
                <el-option label="已开工" value="已开工"></el-option>
                <el-option label="已取消" value="已取消"></el-option>
                <el-option label="已停工" value="已停工"></el-option>
                <el-option label="已关闭" value="已关闭"></el-option>
              </el-select>
            </el-form-item>
          </template>
          <el-form-item label=" ">
            <el-button type="primary" @click="searchTypeChange">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-container v-if="detailSearchData.orderType === '其他入库'">
        <el-header style="width: 880px;height: 200px;padding: 0 0 0 0">
          <span style="font-size: 12px">可选物料</span>
          <el-table height="200px" :data="partList1" border ref="partTable1" @selection-change="selectionPart1"
            highlight-current-row style="width: 100%">
            <el-table-column type="selection" header-align="center" align="center" width="50">
            </el-table-column>
            <el-table-column prop="partNo" header-align="center" align="center" min-width="80" label="物料编码">
            </el-table-column>
            <el-table-column prop="partDesc" header-align="center" align="left" min-width="120" label="物料名称">
            </el-table-column>
            <el-table-column prop="unit" header-align="center" align="left" min-width="120" label="物料单位">
            </el-table-column>
          </el-table>
          <!-- 分页-->
          <el-pagination style="margin-top: 5px" @size-change="sizeChangeHandle2" @current-change="currentChangeHandle2"
            :current-page="pageIndex2" :page-sizes="[20, 50, 100, 200, 500]" :page-size="pageSize2" :total="totalPage2"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-header>
        <el-main style="width: 880px;height: 27px;margin-top: 70px;padding: 0 0 0 0;text-align:center">
          <div>
            <el-button type="primary" @click="addPart">添加>></el-button>
            <el-button type="primary" @click="deletePart">删除&lt;&lt;</el-button>
          </div>
        </el-main>
        <el-footer style="width: 880px;height: 200px;padding: 0 0 0 0;">
          <span style="font-size: 12px">已选物料</span>
          <div class="rq">
            <el-table height="200px" :data="partList2" border ref="partTable2" @selection-change="selectionPart2"
              highlight-current-row style="width: 100%">
              <el-table-column type="selection" header-align="center" align="center" width="50">
              </el-table-column>
              <el-table-column prop="partNo" header-align="center" align="center" min-width="80" label="物料编码">
              </el-table-column>
              <el-table-column prop="partDesc" header-align="center" align="left" min-width="120" label="物料名称">
              </el-table-column>
              <el-table-column prop="" header-align="center" align="center" min-width="100" label="要求入库数量">
                <template slot-scope="scope">
                  <el-input :controls="false" v-model="scope.row.requiredQty"
                    @input="value => scope.row.requiredQty = value.match(/^(\d+\.?\d*|\.\d+)$/) ? value : ''"
                    style="height: 11px; width: 98%;">
                  </el-input>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-footer>
      </el-container>
      <el-container v-else-if="detailSearchData.orderType === '生产入库'">
        <el-header style="width: 880px;height: 200px;padding: 0 0 0 0">
          <span style="font-size: 12px">可选物料</span>
          <el-table height="200px" :data="partList1" border ref="partTable1" @selection-change="selectionPart1"
            highlight-current-row style="width: 100%">
            <el-table-column type="selection" header-align="center" align="center" width="50">
            </el-table-column>
            <el-table-column prop="relatedOrderNo" header-align="center" align="left" min-width="100" label="生产订单">
            </el-table-column>
            <el-table-column prop="partNo" header-align="center" align="left" min-width="100" label="物料编码">
            </el-table-column>
            <el-table-column prop="partDesc" header-align="center" align="left" min-width="200" label="物料名称">
            </el-table-column>
            <el-table-column prop="unit" header-align="center" align="left" min-width="80" label="物料单位">
            </el-table-column>
            <el-table-column prop="orderQty" header-align="center" align="right" min-width="80" label="订单数量">
            </el-table-column>
            <el-table-column prop="requiredQty" header-align="center" align="right" min-width="80" label="可入库数">
            </el-table-column>
            <el-table-column prop="countRollNo" header-align="center" align="right" min-width="80" label="可入库卷数">
            </el-table-column>
          </el-table>
          <!-- 分页-->
          <el-pagination style="margin-top: 5px" @size-change="sizeChangeHandle2" @current-change="currentChangeHandle2"
            :current-page="pageIndex2" :page-sizes="[20, 50, 100, 200, 500]" :page-size="pageSize2" :total="totalPage2"
            layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </el-header>
        <el-main style="width: 880px;height: 27px;margin-top: 70px;padding: 0 0 0 0;text-align:center">
          <div>
            <el-button type="primary" @click="addPart">添加>></el-button>
            <el-button type="primary" @click="deletePart">删除&lt;&lt;</el-button>
          </div>
        </el-main>
        <el-footer style="width: 880px;height: 200px;padding: 0 0 0 0;">
          <span style="font-size: 12px">已选物料</span>
          <div class="rq">
            <el-table height="200px" :data="partList2" border ref="partTable2" @selection-change="selectionPart2"
              highlight-current-row style="width: 100%">
              <el-table-column type="selection" header-align="center" align="center" width="50">
              </el-table-column>
              <el-table-column prop="relatedOrderNo" header-align="center" align="center" min-width="80" label="生产订单">
              </el-table-column>
              <el-table-column prop="partNo" header-align="center" align="center" min-width="80" label="物料编码">
              </el-table-column>
              <el-table-column prop="partDesc" header-align="center" align="left" min-width="150" label="物料名称">
              </el-table-column>
              <el-table-column prop="" header-align="center" align="center" min-width="100" label="要求入库数量">
                <template slot-scope="scope">
                  <el-input :controls="false" v-model="scope.row.requiredQty"
                    @input="value => scope.row.requiredQty = value.match(/^(\d+\.?\d*|\.\d+)$/) ? value : ''"
                    style="height: 11px; width: 98%;">
                  </el-input>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-footer>
      </el-container>
      <el-footer style="height:30px;margin-top: 35px;text-align:center">
        <el-button type="primary" :loading="saveLoading" @click="saveInboundDetail">保存</el-button>
        <el-button type="primary" @click="detailModal = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="选择工单" :close-on-click-modal="false" v-drag :visible.sync="seqNoModalFlag" width="1000px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-row :gutter="20">
          <el-col :span="4">
            <el-form-item :label="'生产订单'">
              <el-input v-model="seqNoData.orderno"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item>
              <span slot="label" style="" @click="getBaseList(515)"><a herf="#">机台</a></span>

              <el-input v-model="seqNoData.sResourceid"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item>
              <span slot="label" style="" @click="getBaseList(216)"><a herf="#">加工中心</a></span>
              <el-input v-model="seqNoData.sWorkcenterno"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'派工日期'">
              <el-date-picker style="width: 100%" v-model="seqNoData.startDate" type="date" value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item :label="'到'">
              <el-date-picker style="width: 100%" v-model="seqNoData.endDate" type="date" value-format="yyyy-MM-dd"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" @click="searchSOSRouting()" style="margin-top: 5px" class="">查询</el-button>

            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table :height="400" :data="seqNoList" border style="width: 100%;">
        <el-table-column v-for="(item,index) in columnList2" :key="index" :sortable="item.columnSortable"
          :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                style="width: 100px; height: 80px" /></span>
          </template>
        </el-table-column>
        <el-table-column fixed="left" header-align="center" align="center" width="60" label="操作">
          <template slot-scope="scope">
            <a type="text" size="small" @click="chooseSOS(scope.row)">选择</a>
          </template>
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="seqNoModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="保存工单" :close-on-click-modal="false" v-drag :visible.sync="saveSeqNoModalFlag" width="750px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="'生产订单'">
              <el-input v-model="notifyOrderData.orderNo" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'机台'">
              <el-input v-model="notifyOrderData.sResourceID" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'工单数量'">
              <el-input v-model="notifyOrderData.qtyRequired" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="'物料'">
              <el-input v-model="notifyOrderData.partNo" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="'物料名称'">
              <el-input v-model="notifyOrderData.partDesc" disabled style="width: 204%" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="'要求发料时间'">
              <el-date-picker style="width: 100%" v-model="notifyOrderData.needDate" type="datetime"
                value-format="yyyy-MM-dd HH:mm" placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="机台">
              <el-input v-model="notifyOrderData.locationNo" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="'此次领料数量'">
              <el-input-number v-model="notifyOrderData.issureQty" style="padding: 0px;width: 100%" :controls="false"
                :step="0" :min="0" class="text-right"></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="' '">
              <el-button type="primary" @click="qtyAllForSeqNo()" style="margin-top: 4%;">全数领料</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveSOS()">保存</el-button>
        <el-button type="primary" @click="saveSeqNoModalFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <!-- 入库明细 -->
    <el-dialog title="入库明细" :close-on-click-modal="false" v-drag :visible.sync="detailModal2" width="900px">
      <el-table height="400px" :data="detailList2" border style="width: 100%;">
        <el-table-column v-for="(item,index) in columnDetailList2" :key="index" :sortable="item.columnSortable"
          :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align" :fixed="item.fixed===''?false:item.fixed" :min-width="item.columnWidth"
          :label="item.columnLabel">
        </el-table-column>
      </el-table>
      <el-footer style="height:35px;margin-top: 15px;text-align:center">
        <el-button type="primary" @click="detailModal2 = false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="申请明细" :close-on-click-modal="false" v-drag :visible.sync="materialModalFlag" width="900px">
      <!-- <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item :label="'生产订单号'">
              <el-input v-model="sobomData.orderNo" disabled></el-input>
            </el-form-item>
          </el-col> 
          <el-col :span="6">
            <el-form-item :label="'产品编码'">
              <el-input v-model="sobomData.partNo" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form> -->
      <div class="yzzTable">
        <el-table :height="400" :data="sobomList" border style="width: 100%;">
          <el-table-column v-for="(item,index) in columnList3" :key="index" :sortable="item.columnSortable"
            :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <div v-if="item.columnProp === 'qtyToUnissue'">
                <el-input v-model="scope.row.qtyToUnissue" style="height: 11px; width: 98%;" :step="0" :min="0"></el-input>
              </div>
              <div v-else-if="item.columnProp === 'remark'">
                <el-input v-model="scope.row.remark" style="padding: 0;width: 100%"></el-input>
              </div>
              <div v-else>
                <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
                <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                    style="width: 100px; height: 80px" /></span>

              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="materialModalFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>

  </div>
</template>

<script>
import {
  getSiteAndBuByUserName,
  searchNotifyHeader,
  createNotify,
  getNotifyNoDetail,
  searchNotifyMaterialList,
} from '@/api/orderIssure/inboundNotification.js'
import Chooselist from '@/views/modules/common/Chooselist_eam'
import { getChooselist } from '@/api/chooselist/chooselist.js'
import {
  getTableDefaultListLanguage,
  getTableUserListLanguage,
} from '@/api/table.js'
import {
  getSOScheduledRoutingListForIssure,
  saveSOIssueNotifyOrderList,
} from '@/api/orderIssure/soIssueNotify.js'
export default {
  components: {
    Chooselist,
  },
  data() {
    return {
      columnsProp: ['createBy', 'updateBy'],
      // 导出 start
      exportData: [],
      exportName: '收货入库' + this.dayjs().format('YYYYMMDDHHmmss'),
      exportHeader: ['收货入库'],
      exportFooter: [],
      exportList: [],
      // 导出 end
      tagNo: '',
      tagType: '',
      searchData: {
        site: '',
        userName: this.$store.state.user.name,
        orderNo: '',
        orderType: '',
        orderStatus: '',
        orderStatusList: ['UNISSUE'],
        startDate: '',
        endDate: '',
        page: 1,
        limit: 10,
      },
      detailSearchData: {
        site: '',
        buNo: '',
        orderNo: '',
        partNo: '',
        partDesc: '',
        partNos: '',
        orderType: '',
        relatedOrderNo: '',
        status: '',
        page: 1,
        limit: 10,
      },
      height: 200,
      secondHeight: 200,
      pageIndex: 1,
      pageSize: 20,
      totalPage: 0,
      pageIndex2: 1,
      pageSize2: 20,
      totalPage2: 0,
      modalFlag: false,
      modalDisableFlag: false,
      notifyOrderData: {
        partNo: '',
        orderno: '',
        itemno: '',
        seqno: '',
        partDesc: '',
        qtyrequired: '',
        sResourceid: '',
        issureQty: '',
        locationNo: '',
        needDate: '',
      },
      modalData: {
        site: '',
        bu: '',
        buNo: '',
        flag: '',
        orderNo: '',
        orderType: '',
        orderStatus: '',
        requiredInboundDate: '',
        supplierId: '',
        supplierName: '',
        remarks: '',
        createdBy: '',
        updatedBy: '',
      },
      seqNoData: {
        site: localStorage.getItem('site'),
        bu: '',
        orderno: '',
        seqno: '',
        sResourceid: '',
        sWorkcenterno: '',
        operatorId: '',
        sShiftno: '',
        startDate: '',
        endDate: '',
      },
      dataList: [],
      detailList: [],
      userBuList: [],
      inboundSelection: [],
      inboundDetailSelection: [],
      partSelections1: [],
      partSelections2: [],
      partList1: [],
      partList2: [],
      dataListLoading: false,
      // 展示列集
      columnList: [
        {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1OrderNo',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'notifyNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '单据号',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120,
        },
        /* {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1OrderType',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'orderType',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '单据类型',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        }, */
        {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1OrderStatus',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'status',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '单据状态',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        /* {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1SupplierId',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'supplierId',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '供应商编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1SupplierName',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'supplierName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '供应商名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 200,
        }, */
        {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1RequiredInboundDate',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'notifyDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '申请单日期',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1CreatedDate',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'enteredDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 170,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1CreatedBy',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'username',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '创建人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        /* {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1UpdatedDate',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'updatedDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 170,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 610,
          serialNumber: '610Table1UpdatedBy',
          tableId: '610Table1',
          tableName: '收货入库任务表',
          columnProp: 'updatedBy',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '更新人',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        }, */
      ],
      columnList2: [
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2Orderno',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'orderNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '生产订单',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2Itemno',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'itemNo',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '工序',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 50,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2ItemDesc',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'itemDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '工序名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2PartNo',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'partNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2Qtyrequired',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'qtyRequired',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '工单数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2Qtyreported',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'qtyReported',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '报工数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2SScheduleddate',
          tableId: '701001Table2',
          tableName: '查询工单',
          columnProp: 'sScheduledDate',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '工单日期',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2SWorkcenterno',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'sWorkCenterNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '加工中心编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2WorkCenterDesc',
          tableId: '701001Table2',
          tableName: '查询工单',
          columnProp: 'workCenterDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '加工中心名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2SResourceid',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'sResourceID',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '机台编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2ResourceDesc',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'resourceDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '机台名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2OperatorDesc',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'operatorDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '操作员',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
      ],
      columnList3: [
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table3ComponentPartNo',
          tableId: '701001Table3',
          tableName: '领料申请BOM子表',
          columnProp: 'componentPartNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table3PartDesc',
          tableId: '701001Table3',
          tableName: '领料申请BOM子表',
          columnProp: 'componentPartDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '物料描述',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table3QtyToIssue',
          tableId: '701001Table3',
          tableName: '领料申请BOM子表',
          columnProp: 'qtyToUnissue',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '本次退货数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table3Remark',
          tableId: '701001Table3',
          tableName: '领料申请BOM子表',
          columnProp: 'remark',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '备注',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150,
        },
      ],
      columnDetailList: [
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2Orderno',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'soorderNo',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '生产订单',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2PartNo',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'fgpartNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '物料编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        },
        /* {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2PartNo',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'partDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '物料名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 120,
          showOverflowTooltip: true,
        }, */
        /* {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2Qtyrequired',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'lotSize',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '工单数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        }, */
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2Qtyreported',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'unissureQty',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '退料数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2SScheduleddate',
          tableId: '701001Table2',
          tableName: '查询工单',
          columnProp: 'needDate',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '退料时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
       /*  {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2SScheduleddate',
          tableId: '701001Table2',
          tableName: '查询工单',
          columnProp: 'finishDate',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '工单结束日期',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2SWorkcenterno',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'sWorkCenterNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '加工中心编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 80,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2WorkCenterDesc',
          tableId: '701001Table2',
          tableName: '查询工单',
          columnProp: 'workCenterDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '加工中心名称',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2SResourceid',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'sResourceID',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '机台编码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 60,
        }, 
        {
          userId: this.$store.state.user.name,
          functionId: 701001,
          serialNumber: '701001Table2OperatorDesc',
          tableId: '701001Table2',
          tableName: '查询派工单',
          columnProp: 'operatorDesc',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '操作员',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },*/
      ],
      columnDetailList2: [
        {
          columnProp: 'subNo',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '标签条码',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          columnProp: 'subQty',
          headerAlign: 'center',
          align: 'right',
          columnLabel: '入库数量',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          columnProp: 'orderRef3',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '入库仓库',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150,
        },
        {
          columnProp: 'orderRef4',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '入库库位',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 150,
        },
        {
          columnProp: 'userName',
          headerAlign: 'center',
          align: 'left',
          columnLabel: '操作员',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 100,
        },
        {
          columnProp: 'transDate',
          headerAlign: 'center',
          align: 'center',
          columnLabel: '操作时间',
          columnHidden: false,
          columnImage: false,
          columnSortable: false,
          sortLv: 0,
          status: true,
          fixed: '',
          columnWidth: 170,
        },
      ],
      rules: {
        bu: [
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change'],
          },
        ],
        orderType: [
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change'],
          },
        ],
        requiredInboundDate: [
          {
            required: true,
            message: ' ',
            trigger: ['blur', 'change'],
          },
        ],
      },
      searchLoading: false,
      saveLoading: false,
      activeTable: 'inboundDetail',
      detailModal: false,
      authSearch: false,
      authSave: false,
      authUpdate: false,
      authDelete: false,
      authArchive: false,
      authClose: false,
      authIssue: false,
      editBatchVisible: false,
      menuId: this.$route.meta.menuId,
      tempWareHouseRow: {},
      detailList2: [],
      detailModal2: false,
      currentRow: {},
      seqNoList:[],
      seqNoModalFlag: false,
      saveSeqNoModalFlag: false,
      bomLoadFlag: false,
      sobomList: [],
      itemNo: '',
      materialModalFlag: false,
      sobomData:{},
      notifyNo:'',
    }
  },

  mounted() {
    this.$nextTick(() => {
      this.height = window.innerHeight / 2 - 100
      /*第二个表格高度的动态调整*/
      this.secondHeight = window.innerHeight - this.height - 170
    })
  },

  created() {
    // 按钮控制
    this.getButtonAuthData()
    // 获取用户的 site 和 bu
    //this.getSiteAndBuByUserName()
    // 动态列
    //this.getTableUserColumn(this.$route.meta.menuId + 'table1', 1)
    //this.getTableUserColumn(this.$route.meta.menuId + 'table2', 2)
    if (!this.authSearch) {
      // 获取数据列表
      this.getDataList()
    }
  },

  methods: {
    // 获取用户的bu
    getSiteAndBuByUserName() {
      let tempData = {
        username: this.$store.state.user.name,
      }
      getSiteAndBuByUserName(tempData).then(({ data }) => {
        if (data.code === 0) {
          this.userBuList = data.rows
        }
      })
    },

    // 获取数据列表
    getDataList() {
      this.searchData.limit = this.pageSize
      this.searchData.page = this.pageIndex
      this.searchData.orderStatus = this.searchData.orderStatusList.join(',')
      console.log("this.",this.searchData);
      
      this.searchLoading = true
      searchNotifyHeader(this.searchData)
        .then(({ data }) => {
          if (data.code === 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
            console.log("this.dataList",this.dataList);
            
            // 判断是否全部存在数据
            if (this.dataList.length > 0) {
              // 设置选中行并高亮第一行
              this.$nextTick(() => {
                this.$refs.inboundTable.setCurrentRow(this.dataList[0])
                this.currentRow = JSON.parse(JSON.stringify(this.dataList[0]))
                // 调用getNotifyNoDetail方法获取入库明细
                this.getNotifyNoDetail()
              })
            } else {
              this.currentRow = {}
              this.detailList = []
            }
          }
        })
        .finally(() => {
          this.searchLoading = false
        })
    },

    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },

    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },

    // 子明细每页数
    sizeChangeHandle2(val) {
      this.pageSize2 = val
      this.pageIndex2 = 1
      this.searchTypeChange()
    },

    // 子明细当前页
    currentChangeHandle2(val) {
      this.pageIndex2 = val
      this.searchTypeChange()
    },

    saveModal() {
      this.modalData = {
        flag: '1',
        site: '',
        orderNo: '',
        orderType: '',
        orderStatus: '草稿',
        requiredInboundDate: '',
        supplierId: '',
        supplierName: '',
        remarks: '',
        createdBy: this.$store.state.user.name,
      }
      this.modalDisableFlag = false
      this.modalFlag = true
    },

    updateModal(row) {
      if (this.currentRow.orderType === '采购入库') {
        this.$message.warning('采购入库单据不能编辑！')
        return
      }
      this.modalData = {
        flag: '2',
        site: row.site,
        bu: row.site + '_' + row.buNo,
        buNo: row.buNo,
        orderNo: row.orderNo,
        orderType: row.orderType,
        requiredInboundDate: row.requiredInboundDate,
        supplierId: row.supplierId,
        supplierName: row.supplierName,
        remarks: row.remarks,
        updatedBy: this.$store.state.user.name,
      }
      this.modalDisableFlag = true
      this.modalFlag = true
    },

    saveData() {
      if (this.modalData.orderType === '' || this.modalData.orderType == null) {
        this.$message.warning('请选择单据类型！')
        return
      }
      if (
        this.modalData.requiredInboundDate === '' ||
        this.modalData.requiredInboundDate == null
      ) {
        this.$message.warning('请选择要求入库日期！')
        return
      }
      this.saveLoading = true
      if (this.modalData.flag === '1') {
        // 新增
        this.modalData.orderType = '退料入库'
        this.modalData.site = localStorage.getItem('site')
        createNotify(this.modalData)
          .then(({ data }) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.modalFlag = false
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
          .finally(() => {
            this.saveLoading = false
          })
      } else {
        // 修改
        updateInboundNotification(this.modalData)
          .then(({ data }) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.modalFlag = false
              this.$message.success('操作成功')
            } else {
              this.$message.error(data.msg)
            }
          })
          .finally(() => {
            this.saveLoading = false
          })
      }
    },

    // 删除
    deleteModal() {
      if (this.currentRow.orderType === '采购入库') {
        this.$message.warning('采购入库单据不能编辑！')
        return
      }
      if (this.inboundSelection.length === 0) {
        this.$message.warning('请勾选要删除的单据！')
        return
      }
      this.$confirm(
        `是否删除该 ` + this.inboundSelection.length + ` 条记录?`,
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }
      ).then(() => {
        let tempData = {
          submitList: this.inboundSelection,
        }
        deleteInboundNotification(tempData).then(({ data }) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.inboundSelection = []
            this.$message.success('操作成功')
          } else {
            this.$message.error(data.msg)
          }
        })
      })
    },

    // 归档
    archiveModal() {},

    // 关闭
    closeModal(row) {
      this.$confirm(
        `确认关闭 ` + row.notifyNo + ` 记录?`,
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }
      ).then(() => {
        closeInboundNotification(row).then(({ data }) => {
        if (data && data.code === 0) {
          this.getDataList()
          this.$message.success('操作成功')
        } else {
          this.$message.error(data.msg)
        }
      })
      })
      
    },

    // 下达
    issueModal(row) {
      if (this.currentRow.orderType === '采购入库') {
        this.$message.warning('采购入库单据不能编辑！')
        return
      }
      issueInboundNotification(row).then(({ data }) => {
        if (data && data.code === 0) {
          this.getDataList()
          this.$message.success('操作成功')
        } else {
          this.$message.error(data.msg)
        }
      })
    },

    // 列表表格选择替换
    tabClick(tab, event) {
      // 刷新列表数据
      this.refreshCurrentTabTable()
    },

    // 当前值发生变化的时候修改
    changeCurrentRow(row, oldRow) {
      // 判断是否是获取焦点的事件
      if (row) {
        this.currentRow = JSON.parse(JSON.stringify(row))
        //刷新当前页表
        this.getNotifyNoDetail()
      }
    },

    // 复选
    selectionInbound(val) {
      this.inboundSelection = val
    },

    // 明细复选
    selectionInboundDetail(val) {
      this.inboundDetailSelection = val
    },

    rowStyle({ row }) {
      if (this.currentRow.notifyNo === row.notifyNo) {
        return { 'background-color': '#E8F7F6', cursor: 'pointer' }
      }
    },

    // 单机选中信息
    inboundClickRow(row, column) {
      console.log("row",row);
      
      this.currentRow = JSON.parse(JSON.stringify(row))
      // 点击主表行时，立即刷新并加载入库明细
      this.getNotifyNoDetail()
    },

    // 刷新页签的table数据
    refreshCurrentTabTable() {
      if (this.activeTable === 'inboundDetail') {
        this.getInboundDetail()
      }
    },

    // 查询物料缺陷跟踪
    getInboundDetail() {
      let templateData = {
        site: this.currentRow.site,
        buNo: this.currentRow.buNo,
        orderNo: this.currentRow.orderNo,
      }
      /* getInboundDetail(templateData).then(({ data }) => {
        this.detailList = data.rows
      }) */
    },

    // 新增明细
    addInboundDetailModal() {
      if (this.currentRow.orderType === '采购入库') {
        this.$message.warning('采购入库单据不能编辑！')
        return
      }
      this.detailSearchData = {
        site: this.currentRow.site,
        buNo: this.currentRow.buNo,
        orderNo: this.currentRow.orderNo,
        orderType: this.currentRow.orderType,
        relatedOrderNo: '',
        status: '',
        partNo: '',
        partDesc: '',
        partNos: '',
        page: 1,
        limit: 10,
      }
      this.partSelections1 = []
      this.partSelections2 = []
      this.partList1 = []
      this.partList2 = []
      this.pageIndex2 = 1
      this.pageSize2 = 20
      this.totalPage2 = 0
      if (this.currentRow.orderType === '生产入库') {
        this.detailSearchData.status = '已开工'
      }
      this.handleGetProjectPartList()
    },

    handleGetProjectPartList() {
      this.detailSearchData.limit = this.pageSize2
      this.detailSearchData.page = this.pageIndex2
      getInboundPartList(this.detailSearchData).then(({ data }) => {
        if (data && data.code === 0) {
          this.partList1 = data.page.list
          this.pageIndex2 = data.page.currPage
          this.pageSize2 = data.page.pageSize
          this.totalPage2 = data.page.totalCount
          this.detailModal = true
        }
      })
    },

    chooseSOSModal() {
      this.seqNoData = {
        site: localStorage.getItem('site'),
        orderno: '',
        seqno: '',
        sResourceid: '',
        sWorkcenterno: '',
        operatorId: '',
        sShiftno: '',
        startDate: this.dayjs().format('YYYY-MM-DD'),
        endDate: this.dayjs().format('YYYY-MM-DD'),
      }
      this.searchSOSRouting()
      this.seqNoModalFlag = true
    },
    searchSOSRouting() {
      getSOScheduledRoutingListForIssure(this.seqNoData).then(({ data }) => {
        if (data.code === 0) {
          this.seqNoList = data.rows
        }
      })
    },
    // 可选物料
    partClickRow1(row) {
      this.$refs.partTable1.toggleRowSelection(row)
    },

    // 已有物料
    partClickRow2(row) {
      this.$refs.partTable2.toggleRowSelection(row)
    },

    selectionPart1(val) {
      this.partSelections1 = val
    },

    selectionPart2(val) {
      this.partSelections2 = val
    },
    chooseSOS(row) {
      if (this.dataList.length > 0) {
        let stop = false
        for (let i = 0; i < this.dataList.length; i++) {
          if (this.dataList[i].seqNo == row.seqno) {
            stop = true
          }
        }
        if (stop) {
          this.$alert('已经选择过此派工单，请返回点击明细直接操作！!', '提示', {
            confirmButtonText: '确定',
          })
          return false
        }
      }
      
      this.notifyOrderData.partNo = row.partNo
      this.notifyOrderData.orderNo = row.orderNo
      this.notifyOrderData.itemNo = row.itemNo
      this.notifyOrderData.seqNo = row.seqNo
      this.notifyOrderData.partDesc = row.partDesc
      this.notifyOrderData.qtyRequired = row.qtyRequired
      this.notifyOrderData.sResourceID = row.sResourceID
      this.notifyOrderData.issureQty = ''
      this.notifyOrderData.needDate = this.dayjs().format('YYYY-MM-DD HH:mm')
      this.notifyOrderData.locationNo = row.sResourceID
      this.saveSeqNoModalFlag = true
    },

    qtyAllForSeqNo() {
      this.notifyOrderData.issureQty = this.notifyOrderData.qtyRequired
    },

    saveSOS() {
      if (
        this.notifyOrderData.needDate == null ||
        this.notifyOrderData.needDate == ''
      ) {
        this.$message.warning('请选择时间！')
        return false
      }
      if (
        this.notifyOrderData.issureQty == null ||
        this.notifyOrderData.issureQty == '' ||
        this.notifyOrderData.issureQty <= 0
      ) {
        this.$message.warning('请填写领取数量！')
        return false
      }
      let row = this.notifyOrderData
      if (this.dataList.length > 0) {
        let stop = false
        for (let i = 0; i < this.dataList.length; i++) {
          if (this.dataList[i].seqNo == row.seqno) {
            stop = true
          }
        }
        if (stop) {
          this.$alert('已经选择过此工单，请返回点击明细直接操作！!', '提示', {
            confirmButtonText: '确定',
          })
          return false
        }
      }
      this.$confirm('确定选择工单' + row.seqno + '?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        let inData = {
          site: localStorage.getItem('site'),
          notifyNo: this.notifyNo,
          fGPartNo: row.partNo,
          sOOrderNo: row.orderno,
          opsItemNo: row.itemno,
          seqNo: row.seqno,
          locationNo: row.locationNo,
          needDate: row.needDate,
          issureQty: row.issureQty,
        }
        saveSOIssueNotifyOrderList(inData).then(({ data }) => {
          if (data.code === 0) {
            this.saveSeqNoModalFlag = false
            this.getNotifyNoDetail()
            this.enterSOS(row)
            this.itemNo = data.itemNo
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定',
            })
          }
        })
      })
    },
    getNotifyNoDetail() {
      if (!this.currentRow || !this.currentRow.notifyNo) {
        this.detailList = []
        return
      }
      
      let inData = {
        site: this.currentRow.site || localStorage.getItem('site'),
        notifyNo: this.currentRow.notifyNo,
      }
      
      getNotifyNoDetail(inData).then(({ data }) => {
        if (data.code === 0) {
          this.detailList = data.rows || []
        } else {
          this.detailList = []
        }
      }).catch(() => {
        this.detailList = []
      })
    },
    enterSOS(row) {
      this.seqNoModalFlag = false
      this.materialModalFlag = true
      this.sobomList = []
      this.sobomData = {
        orderno: row.orderno,
        seqno: row.seqno,
        partNo: row.partNo,
      }
      this.bomLoadFlag = true
      let inData = {
        site: localStorage.getItem('site'),
        notifyNo: this.notifyNo,
        orderno: row.orderno,
        seqno: row.seqno,
        partNo: row.partNo,
        itemno: row.itemno,
      }
      getSOSBOMForIssure(inData).then(({ data }) => {
        this.bomLoadFlag = false
        if (data.code === 0) {
          this.sobomList = data.rows
        }
      })
    },
    // 改变事件
    searchTypeChange() {
      // 使用 map 提取 partNo 并加上单引号
      let partNos = this.partList2.map((part) => part.partNo)
      // 使用 join 将 partNo 连接成一个字符串
      this.detailSearchData.partNos = partNos.join(',')
      this.handleGetProjectPartList()
    },

    // 添加物料
    addPart() {
      if (this.partSelections1 == null || this.partSelections1.length === 0) {
        this.$message.warning('请选择可选物料！')
        return
      }
      this.partSelections1.forEach((item) => {
        this.partList2.push(item)
      })
      this.searchTypeChange()
    },

    // 删除物料
    deletePart() {
      if (this.partSelections2 == null || this.partSelections2.length === 0) {
        this.$message.warning('请选择已选物料！')
        return
      }
      this.partSelections2.forEach((item) => {
        // 使用 filter 过滤掉 partList2 中与 selection.part_no 相同的项
        this.partList2 = this.partList2.filter(
          (part) => part.partNo !== item.partNo
        )
      })
      this.searchTypeChange()
    },

    // 新增明细
    saveInboundDetail() {
      let tempData = {
        orderNo: this.detailSearchData.orderNo,
        createdBy: this.$store.state.user.name,
        partList: this.partList2,
      }
      this.saveLoading = true
      saveInboundDetail(tempData)
        .then(({ data }) => {
          if (data && data.code === 0) {
            this.getInboundDetail()
            this.detailModal = false
            this.$message.success('操作成功')
          } else {
            this.$message.error(data.msg)
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },

    // 删除物料缺陷跟踪
    deleteInboundDetail() {
      if (this.currentRow.orderType === '采购入库') {
        this.$message.warning('采购入库单据不能编辑！')
        return
      }
      if (this.inboundDetailSelection.length === 0) {
        this.$message.warning('请勾选要删除的单据！')
        return
      }
      this.$confirm(
        `是否删除该 ` + this.inboundDetailSelection.length + ` 条记录?`,
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }
      ).then(() => {
        let tempData = {
          submitList: this.inboundDetailSelection,
        }
        deleteInboundDetail(tempData).then(({ data }) => {
          if (data && data.code === 0) {
            this.getInboundDetail()
            this.inboundDetailSelection = []
            this.$message.success('操作成功')
          } else {
            this.$message.error(data.msg)
          }
        })
      })
    },

    // 批量编辑模态框
    editBatchModel() {
      if (this.currentRow.orderType === '采购入库') {
        this.$message.warning('采购入库单据不能编辑！')
        return
      }
      if (this.editBatchVisible) {
        this.editBatchVisible = false
      } else {
        this.editBatchVisible = true
      }
    },

    // 批量保存
    batchModel() {
      let params = []
      params = this.detailList
      this.saveLoading = true
      updateInboundDetail(params)
        .then(({ data }) => {
          if (data && data.code === 0) {
            this.getInboundDetail()
            this.$message.success(data.msg)
            this.editBatchVisible = false
          } else {
            this.$message.error(data.msg)
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },

    // 入库明细
    inboundDetailModal(row) {
      getInboundDetail2(row).then(({ data }) => {
        if (data && data.code === 0) {
          this.detailList2 = data.rows
        } else {
          this.detailList2 = []
        }
      })
      this.detailModal2 = true
    },

    // 库位输入校验
    supplierBlur(tagNo) {
      let tempData = {
        tagno: tagNo,
        conditionSql:
          " and SupplierID = '" +
          this.modalData.supplierId +
          "'" +
          " and site = '" +
          this.modalData.site +
          "'",
      }
      getChooselist(tempData).then(({ data }) => {
        if (data && data.code === 0) {
          if (data.baseListData.length > 0) {
            this.modalData.supplierId = data.baseListData[0].SupplierID
            this.modalData.supplierName = data.baseListData[0].SupplierName
          } else {
            this.modalData.supplierName = ''
          }
        }
      })
    },

    chooseWareHouse(row) {
      this.tempWareHouseRow = row
      this.getBaseList(20)
    },

    // 获取基础数据列表S
    getBaseList(val, type) {
      this.tagNo = val
      this.tagType = type
      this.$nextTick(() => {
        let strVal = ''
        if (val === 506) {
          strVal = this.modalData.supplierId
          this.$refs.baseList.init(val, strVal)
        }
        if (val === 20) {
          strVal = this.tempWareHouseRow.inWarehouse
          this.$refs.baseList.init(val, strVal)
        }
      })
    },

    // 列表方法的回调
    getBaseData(val) {
      if (this.tagNo === 506) {
        this.modalData.supplierId = val.SupplierID
        this.modalData.supplierName = val.SupplierName
      }
      if (this.tagNo === 20) {
        this.tempWareHouseRow.inWarehouse = val.WareHouseID
        this.tempWareHouseRow.inWarehouseName = val.WareHouseName
        console.log(this.tempWareHouseRow)
      }
    },

    async exportExcel() {
      this.searchData.limit = -1
      this.searchData.page = 1
      excel.exportTable({
        url: '/inbound/searchInboundNotification',
        columnMapping: this.columnList, //可以直接用table，不需要的列就剔除
        mergeSetting: [], //需要合并的列
        params: this.searchData,
        fileName: this.exportName + '.xlsx',
        rowFetcher: (res) => res.data,
        columnFormatter: [],
        dropColumns: [],
      })
    },

    // 动态列开始 获取 用户保存的 格式列
    async getTableUserColumn(tableId, columnId) {
      let queryTableUser = {
        userId: this.$store.state.user.name,
        functionId: this.$route.meta.menuId,
        tableId: tableId,
        status: true,
        languageCode: this.$i18n.locale,
      }
      await getTableUserListLanguage(queryTableUser).then(({ data }) => {
        if (data.rows.length > 0) {
          switch (columnId) {
            case 1:
              this.columnList = data.rows
              break
          }
        } else {
          this.getColumnList(tableId, columnId)
        }
      })
    },

    enterSOSDetail(row) {
      let rows = {
        site: this.$store.state.user.site,
        notifyNo: this.currentRow.notifyNo,
        soorderNo: row.soorderNo,
        seqNo: row.seqNo,
        partNo: row.fgpartNo,
        itemNo: row.itemNo,
      }

      this.searchUnissueNotifyMaterialList(rows)
    },
    searchUnissueNotifyMaterialList(row){
      this.bomLoadFlag = true
      this.materialModalFlag = true
      searchNotifyMaterialList(row).then(({ data }) => {
        if (data.code === 0) {
          this.sobomList = data.rows    
        }
      }).finally(() => {
        this.bomLoadFlag = false
      })
    },

    // 获取 tableDefault 列
    async getColumnList(tableId, columnId) {
      let queryTable = {
        functionId: this.$route.meta.menuId,
        tableId: tableId,
        languageCode: this.$i18n.locale,
      }
      await getTableDefaultListLanguage(queryTable).then(({ data }) => {
        if (data.rows.length !== 0) {
          switch (columnId) {
            case 1:
              this.columnList = data.rows
              break
          }
        }
      })
    },

    //获取按钮的权限数据
    getButtonAuthData() {
      if (this.$store.state.user.id === 1) {
        return
      }
      let searchFlag = this.isAuth(this.menuId + ':search')
      let saveFlag = this.isAuth(this.menuId + ':save')
      let updateFlag = this.isAuth(this.menuId + ':update')
      let deleteFlag = this.isAuth(this.menuId + ':delete')
      let archiveFlag = this.isAuth(this.menuId + ':archive')
      let closeFlag = this.isAuth(this.menuId + ':close')
      let issueFlag = this.isAuth(this.menuId + ':issue')
      //处理页面的权限数据
      this.authSearch = !searchFlag
      this.authSave = !saveFlag
      this.authUpdate = !updateFlag
      this.authDelete = !deleteFlag
      this.authArchive = !archiveFlag
      this.authClose = !closeFlag
      this.authIssue = !issueFlag
    },
  },
}
</script>
<style scoped>
/deep/ .customer-tab .el-tabs__content {
  padding: 5px !important;
}

.el-table /deep/ .cell {
  height: auto;
  line-height: 1.5;
}
</style>
