<template>
  <div class="innerCheckdetail" ref="detailview">
    <p-spin :spinning="spinning" style="margin-top: 16px">
      <div :style="isStyle" ref="Main" class="Main">
        <div class="header">
          <a-space :style="{ marginBottom: '16px' }">
            <!--<p-button :disabled="editStatus" @click="itemNumeven">修改</p-button>
					 <p-button @click="printEvent" type="primary">自动拼箱</p-button> -->
            <p-button @click="printEvent" type="primary">拼箱</p-button>
            <!-- <p-button @click="viewQuery" type="primary">拼箱查询</p-button> -->
            <p-button @click="wholepiecesplit" type="primary">整件拆分</p-button>
            <p-button @click="checkConfirm" type="primary">复核确认</p-button>
            <p-button v-if="printDataVisibal" @click="printDatas" type="primary">打印面单</p-button>
            <p-button @click="checksuperviseCode" :disabled="!superoisedBtn" type="primary">扫描监管码</p-button>
            <template v-if="barcodeDListMore.lcls.length < 8">
              <p-button
                @click="viewLcninfo(item)"
                v-for="item in barcodeDListMore.lcls"
                :key="item.index"
                :type="item.lclNo === barcodeDListMore.currLclNo ? 'danger' : 'primary'"
              >
                {{ item.lclNo == 0 ? '整' : '拼' + item.lclNo }}
              </p-button>
            </template>
            <template v-if="barcodeDListMore.lcls.length > 7">
              <p-button
                @click="viewLcninfo(item)"
                v-for="item in barcodeDList.lcls"
                :key="item.index"
                :type="item.lclNo === barcodeDList.currLclNo ? 'danger' : 'primary'"
              >
                {{ item.lclNo == 0 ? '整' : '拼' + item.lclNo }}
              </p-button>
            </template>
            <a v-if="barcodeDListMore.lcls.length > 7" @click="moreview()">更多</a>

            <!-- <p-button>保存</p-button> -->
          </a-space>
          <a-space :style="{ marginBottom: '16px' }">
            <!-- <a-form>
           <a-form-item label="" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol"> -->
            <a-select
              @change="handleChange"
              :getPopupContainer="
                (triggerNode) => {
                  return triggerNode.parentNode || document.body
                }
              "
              default-value="1"
              class="itemw"
              placeholder="请选择复核模式"
              :style="{ width: '150px' }"
              disabled
            >
              <a-select-option value="1">按商品复核</a-select-option>
              <!-- <a-select-option value="2"> 按批号复核</a-select-option> -->
              <a-select-option value="3">扫描计数复核</a-select-option>
            </a-select>
            <!-- </a-form-item> 
          </a-form> -->
            <span class="itemw" style="font-weight: bold">
              <a-icon style="margin-right: 5px" type="desktop" />
              工作台: {{ stationCode }}
            </span>
            <span class="itemw" style="font-weight: bold">
              <a-icon style="font-weight: bold" class="input-icon" type="user" />
              复核员：{{ workerInfo.username }}
            </span>
            <p-button class="itemw" @click="exit">退出</p-button>
            <span class="squery"
              ><a-icon @click="qpclick" class="iconqp" style="font-size: 25px; color: white" type="arrows-alt"
            /></span>
          </a-space>
        </div>
        <!-- 中间主体 -->
        <a-row class="middle" :gutter="16">
          <!-- 中间左边 -->
          <a-col style="height: 621px" class="wrapperCol" span="6">
            <p-card style="height: 100%">
              <a-form :form="form" style="margin-top: 40px" layout="horizontal" class="scanForm">
                <!-- <div>spbm005: 调试专用</div> <div>整箱</div> <div>202104250005</div> <div>单个</div> <div>202104250006</div> -->
                <a-form-item label="容器" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
                  <a-input
                    ref="inputContainerCode"
                    size="large"
                    @change="ContainerCodeChange"
                    allow-clear
                    @pressEnter="entercontainer"
                    placeholder="请扫描容器"
                    v-decorator="['containerCode']"
                  />
                </a-form-item>
                <a-form-item label="扫码" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
                  <a-input
                    ref="inputitemBarCode"
                    :disabled="disabled_Barcode"
                    size="large"
                    @change="itemBarCodeChange"
                    allow-clear
                    @pressEnter="entergoods"
                    placeholder="请扫描条码/编码/助记码"
                    v-decorator="['itemBarcode']"
                  />
                </a-form-item>
                <a-form-item label="补打" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
                  <a-input
                    ref="LCLBarCode"
                    size="large"
                    allow-clear
                    @change="LCLBarCodeChange"
                    @pressEnter="enterLclinfo"
                    placeholder="请输入订单编码"
                    v-decorator="['billGroupId']"
                  />
                </a-form-item>
                <!-- <a-form-item label="商品编码" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol" >
						<a-input ref="inputitemCode" @pressEnter="entergoods" placeholder="请扫描" v-decorator="['itemCode']" />
					</a-form-item> -->
              </a-form>
              <div class="scan">
                <div class="icon" v-show="scan == 0">
                  <a-icon type="barcode" />
                  <div class="scanText">请扫描容器...</div>
                </div>
                <div class="icon" v-show="scan == 1">
                  <a-icon type="scan" />
                  <div class="scanText">待复核...</div>
                </div>
                <div class="iconOK" v-show="scan == 2">
                  <a-icon type="check" />
                  <div class="scanText">OK...</div>
                </div>
                <div class="iconErr" v-show="scan == 3">
                  <a-icon type="close" />
                  <div class="scanText">扫码错误...</div>
                </div>
                <a-result v-show="scan == 4" style="margin-top: 30px" status="success" title="复核完成"></a-result>
                <div class="totalNum" style="bottom: 15px">
                  <dl style="height: 45px">
                    <dt class="leftDt">已检查：</dt>
                    <dd>{{ containerVO.checkedNum }}</dd>
                  </dl>
                  <dl style="height: 45px">
                    <dt class="leftDt">冲红数量：</dt>
                    <dd>{{ containerVO.redNum ? containerVO.redNum : 0 }}</dd>
                  </dl>
                  <dl style="height: 45px">
                    <dt class="leftDt">总数量：</dt>
                    <dd>{{ containerVO.totalNum }}</dd>
                  </dl>
                </div>
              </div>
            </p-card>
          </a-col>
          <a-col style="height: 483px" span="18">
            <a-row :gutter="16">
              <a-col span="13">
                <p-card title="当前工作台信息">
                  <div class="num-group">
                    <div class="num-item">
                      <div class="title">待索取</div>
                      <div class="num">{{ orderInfo.askFor }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">待拣选</div>
                      <div class="num">{{ orderInfo.choose }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">待复核索取</div>
                      <div class="num">{{ orderInfo.reviewed }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">待复核确认</div>
                      <div class="num">{{ orderInfo.confirmed }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">完成</div>
                      <div class="num">{{ orderInfo.complete }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">订单待复核</div>
                      <div class="num">{{ orderInfo.orderUncheckedTaskNum ? orderInfo.orderUncheckedTaskNum : 0 }}</div>
                    </div>
                  </div>
                </p-card>
              </a-col>
              <a-col span="11">
                <p-card title="当前容器信息">
                  <div class="num-group">
                    <div class="num-item">
                      <!-- containerVO.numOfNotInStation -->
                      <div class="title">总数量</div>
                      <div class="num">{{ containerVO.totalNum }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">已检数量</div>
                      <div class="num">{{ containerVO.checkedNum }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">总品种</div>
                      <div class="num">{{ containerVO.totalVarieties }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">已检品种数</div>
                      <div class="num">{{ containerVO.checkedVarieties }}</div>
                    </div>
                    <div class="num-item">
                      <div class="title">已检批号</div>
                      <div class="num">{{ containerVO.checkedLot }}</div>
                    </div>
                  </div>
                </p-card>
              </a-col>
            </a-row>

            <p-card style="height: 100%">
              <!-- <h3 class="show-title">复核商品信息</h3> -->
              <div class="info">
                <a-row>
                  <a-col style="margin: 13px 0" :sm="18" :md="18" :lg="18" :xl="18">
                    <div class="item">
                      <div class="label">商品名称：</div>
                      <div class="blod-font">{{ itemsDetail.itemName }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="6" :md="6" :lg="6" :xl="6">
                    <div class="item">
                      <div class="label">计划数量：</div>
                      <div class="blod-font">{{ itemsDetail.qty }}</div>
                    </div>
                  </a-col>

                  <a-col style="margin: 13px 0" :sm="18" :md="18" :lg="18" :xl="18">
                    <div class="item">
                      <div class="label">生产厂家：</div>
                      <div class="blod-font">{{ itemsDetail.manufacturerId }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="6" :md="6" :lg="6" :xl="6">
                    <div class="item">
                      <div class="label">已拣数量：</div>
                      <div class="blod-font">{{ itemsDetail.pickQty }}</div>
                    </div>
                  </a-col>

                  <a-col style="margin: 13px 0" :sm="18" :md="18" :lg="18" :xl="18">
                    <div class="item">
                      <div class="label">规格：</div>
                      <div class="blod-font">{{ itemsDetail.specification }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="6" :md="6" :lg="6" :xl="6">
                    <div class="item">
                      <div class="label">复核数量：</div>
                      <div class="blod-font">{{ itemsDetail.checkQty }}</div>
                    </div>
                  </a-col>

                  <a-col style="margin: 13px 0" :sm="17" :md="17" :lg="17" :xl="17">
                    <div class="item">
                      <div class="label">批号：</div>
                      <div class="blod-font">{{ itemsDetail.lotNo }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="6" :md="6" :lg="6" :xl="6">
                    <div class="item">
                      <div class="label">复核数量(双人)：</div>
                      <div class="blod-font">{{ itemsDetail.check2Qty }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="24" :md="24" :lg="24" :xl="24">
                    <div class="item">
                      <div class="label">单位:</div>
                      <div class="blod-font">{{ itemsDetail.uom ? itemsDetail.uom : '' }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="7" :md="7" :lg="7" :xl="7">
                    <div class="item">
                      <div class="thin-label">订单编码：</div>
                      <div class="thin-font">{{ itemsDetail.billCode }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="item">
                      <div class="thin-label">货主名称：</div>
                      <div class="thin-font">{{ itemsDetail.cargoOwnerName }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="5" :md="5" :lg="5" :xl="5">
                    <div class="item">
                      <div class="thin-label">备注：</div>
                      <div class="thin-font">{{ itemsDetail.remark }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 13px 0" :sm="4" :md="4" :lg="4" :xl="4">
                    <div class="item">
                      <div class="thin-label">是否双人复核：</div>
                      <div class="thin-font">
                        {{
                          itemsDetail.itemHealthIsDouble == '1'
                            ? '是'
                            : itemsDetail.itemHealthIsDouble == '0'
                            ? '否'
                            : ''
                        }}
                      </div>
                    </div>
                  </a-col>

                  <a-col style="margin: 10px 0" :sm="7" :md="7" :lg="7" :xl="7">
                    <div class="item">
                      <div class="thin-label">账期类型：</div>
                      <div class="thin-font">{{ itemsDetail.paymentType }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 10px 0" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="item">
                      <div class="thin-label">客户名称：</div>
                      <div class="thin-font">{{ itemsDetail.shipperName }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 10px 0" :sm="5" :md="5" :lg="5" :xl="5">
                    <div class="item">
                      <div class="thin-label">业务员:</div>
                      <div class="thin-font">{{ itemsDetail.salespersonName ? itemsDetail.salespersonName : '' }}</div>
                    </div>
                  </a-col>
                  <a-col style="margin: 10px 0" :sm="4" :md="4" :lg="4" :xl="4">
                    <div class="item">
                      <div class="thin-label">开票员：</div>
                      <div class="thin-font">{{ itemsDetail.createby }}</div>
                    </div>
                  </a-col>
                </a-row>
              </div>
            </p-card>
          </a-col>
        </a-row>
        <!-- 底部明细表格 -->
        <a-row :gutter="0">
          <a-col style="" class="wrapperCol" span="24">
            <div class="inner-table">
              <!--主键innercheckDId  @checkRow="checkRow"  :customRow="Rowclick" :row-selection="rowSelection1"-->
              <div style="margin-bottom: 10px">
                <p-button v-if="saveBtnStatus"  @click="saveInnerCheckDetails" :disabled="tableData.length < 1" type="primary">保存</p-button>
              </div>
              <p-table-edit-pro
                dragle
                auto-width
                hasRowSelectCheck
                size="small"
                :columns="columns"
                rowKey="_row_count"
                :data-source="tableData"
                :pagination="100"
                :rowSelectType="2"
                :scroll="{ x: 3500 }"
                :selectedRowKeys.sync="selectedRowKeys"
                :customRow="Rowclick"
                :row-selection="rowSelection1"
                :rowClassName="setRowClassName"
                bordered
              >
                <!-- <template slot="index" slot-scope="text, record, index">{{ index + 1 }}</template> -->
                <div slot="action" href="javascript:;" slot-scope="text">
                  <a slot="action" style="margin: 0 5px" @click.stop="bartNoCheck(text)">冲红</a>
                  <a slot="action" style="margin: 0 5px" @click.stop="itemDet(text)">商品维护</a>
                </div>
              </p-table-edit-pro>
            </div>
          </a-col>
        </a-row>
      </div>
    </p-spin>
    <!-- //解锁弹窗 -->
    <workerLogin
      :loginVisible="loginVisible"
      :isSupervisedData="isSupervisedData"
      @loginResult="loginResult"
      @handleCancel="handleCancel"
    ></workerLogin>
    <!-- //拼箱弹窗 -->
    <a-modal
      width="700px"
      title=""
      ok-text="打印"
      :visible="LCLinfoVisible"
      :confirm-loading="confirmLoading"
      @cancel="handleCancel"
    >
      <template slot="footer">
        <div v-if="isCaseOrPiece" class="printclass">
          <span>打印份数:</span>
          <p-input class="printinput" v-model="printNum" type="number" />
        </div>
        <a-button @click="handleCancel">取消</a-button>
        <a-button type="primary" @click="handleOkPrint('2')">打印</a-button>
        <a-button type="primary" v-if="!isCaseOrPiece" @click="handleDetailPrint">明细打印</a-button>
        <a-button type="primary" v-if="!isCaseOrPiece" @click="deleteLcl">拼箱删除</a-button>
        <a-button type="primary" v-if="!isCaseOrPiece" @click="eidthandleOk">确认</a-button>
      </template>
      <p style="margin-top: 35px; padding-right: 10px">
        <lCLinfo
          ref="lCLtable"
          v-if="LCLinfoVisible"
          :isCaseOrPiece="isCaseOrPiece"
          :makeUpStatus="makeUpStatus"
          :data="lCLdata"
          :selectedRows="selectedRowsLcninfo"
        ></lCLinfo>
      </p>
    </a-modal>
    <!-- //补打拼箱弹窗 -->
    <a-modal
      :getContainer="
        (triggerNode) => {
          return $refs.detailview
        }
      "
      width="700px"
      title=""
      ok-text="打印"
      :visible="makeUpinfoVisible"
      :confirm-loading="confirmLoading"
      @cancel="handleCancel"
    >
      <template slot="footer">
        <div v-if="isCaseOrPiece" class="printclass">
          <span>打印份数:</span>
          <p-input class="printinput" v-model="printNum" type="number" />
        </div>
        <a-button @click="handleCancel">取消</a-button>
        <a-button type="primary" @click="handleOkPrint('2')">打印</a-button>
        <a-button type="primary" v-if="!isCaseOrPiece" @click="handleDetailPrint">明细打印</a-button>
      </template>
      <p style="margin-top: 35px; padding-right: 10px">
        <lCLinfo
          ref="lCLtable"
          v-if="makeUpinfoVisible"
          :isCaseOrPiece="isCaseOrPiece"
          :makeUpStatus="makeUpStatus"
          :data="lCLdata"
          :selectedRows="selectedRowsLcninfo"
        ></lCLinfo>
      </p>
    </a-modal>
    <!-- //红冲弹窗 -->
    <a-modal
      :getContainer="
        (triggerNode) => {
          return $refs.detailview
        }
      "
      title=""
      :visible="HCVisible"
      :confirm-loading="confirmLoading"
      @ok="handleOkHC"
      @cancel="handleCancelHC"
    >
      <p style="margin-top: 35px; padding-right: 10px">
        <p-grid-form
          ref="modelForm"
          :span="20"
          :label-col="{ span: 8 }"
          :items="items"
          @submit.prevent="hchanlderSubmit"
        ></p-grid-form>
      </p>
    </a-modal>
    <!-- //拼箱展示弹窗 -->
    <a-modal
      :getContainer="
        (triggerNode) => {
          return $refs.detailview
        }
      "
      title=""
      width="600px"
      :footer="null"
      :visible="LCLVisible"
      :confirm-loading="confirmLoading"
      @ok="handleCancel"
      @cancel="LCLhandleCancel"
    >
      <p style="margin-top: 35px; padding-right: 10px">
        <p-button
          @click="viewLcninfo(item)"
          style="margin: 10px"
          v-for="item in barcodeDListMore.lcls"
          :key="item.index"
          :type="item.lclNo === barcodeDListMore.currLclNo ? 'danger' : 'primary'"
        >
          {{ item.lclNo == 0 ? '整' : '拼' + item.lclNo }}
        </p-button>
      </p>
    </a-modal>
    <!-- //补打拼箱展示弹窗 -->
    <a-modal
      :getContainer="
        (triggerNode) => {
          return $refs.detailview
        }
      "
      title="补打拼箱展示"
      width="600px"
      :footer="null"
      :visible="makeUpVisible"
      :confirm-loading="confirmLoading"
      @cancel="makeUphandleCancel"
      @ok="handleCancel"
    >
      <p style="padding-right: 10px">
        <p-button
          @click="viewLcninfo(item, true)"
          style="margin: 10px"
          v-for="item in makeUpData.lcls"
          :key="item.index"
          :type="item.lclNo === makeUpData.currLclNo ? 'danger' : 'primary'"
        >
          {{ item.lclNo == 0 ? '整' : '拼' + item.lclNo }}
        </p-button>
      </p>
    </a-modal>
    <scan-code v-model="scanVisible" ref="scan" :stage="stage" :scanTable="scanTableList"></scan-code>
    <itemDetail ref="detailItem" :itemId="itemId" />

    <p-modal
      title="商品维护"
      :visible="maintainVisible"
      :dialogStyle="{ top: '20px' }"
      :width="'90%'"
      @ok="handleOk"
      @cancel="handleCancel"
    >
      <div class="box-p20-bg">
        <Editor
          v-if="maintainVisible"
          ref="itemsEditor"
          :detailItem="detailItem"
          :isSingle="true"
          @changeStep="handleItemsComplete"
        />
      </div>
    </p-modal>
    <p-modal
      title="箱型维护"
      :visible="boxTypeVisible"
      :dialogStyle="{ top: '20px' }"
      :width="500"
      @ok="handleOkboxType"
      cancelText=""
      @cancel="boxTypeVisible = false"
    >
      <div class="boxTypeClass">
        <a-radio-group size="large" v-model:value="boxTypevalue" v-for="(item, index) in boxTypeData" :key="index">
          <a-radio :value="item.dictCode">{{ item.dictName }}</a-radio>
        </a-radio-group>
      </div>
      <!-- <p-radio-group :options="boxTypeData" size="large" @change="(e) => onChangeCheckbox(e, item)" /> -->
      <!-- <div class="box-p20-bg" v-for="(item, index) in boxTypeData" :key="index">
        <p-checkbox @change="(e) => onChangeCheckbox(e, item)"> {{ item.dictName }} </p-checkbox>
      </div> -->
    </p-modal>
    <containerdialog
      v-model="containerdialogvisible"
      v-if="containerdialogvisible"
      :containerArray="containerArray"
      @clickContainer="clickContainer"
    />
  </div>
</template>
<script>
import Vue from 'vue'
import { message } from 'ant-design-vue'
import { mapState, mapActions, mapGetters } from 'vuex'
import { fullScreen, eleFullScreen, checkFull, queryFormItems, columns, printcolumns, items } from './config'
import lCLinfo from './LCLinfo'
import workerLogin from './workerLogin'
import scanCode from '../../../components/scanCode.vue'
import itemDetail from '@/views/kzyWMS/components/itemDetail'
import { getBusiness } from '@/views/kzyWMS/api/business'
import containerdialog from './containerdialog.vue'

import {
  postchecLogout,
  getContainer,
  getItemdetail,
  getItemConfirm,
  getItem,
  getItemnum,
  checkLclBarcode,
  postchecLogin,
  LclQuery,
  saveRedhc,
  getPrintInfo,
  getDetailPrintInfo,
  eidtlclNum,
  postpieceBreak,
  deleteLclNo,
  pagebyRelated,
  search_noPage,
  isShowSupervised,
  isSupervised,
  getWholePrintInfo,
  getLocationType,
  postsaveInnerCheckDetails,
  getDicts,
  queryFuncRoomPrintList,
  innerCheckConfig
} from '../api'
import { toPrintServer, tempType } from '@/views/kzyWMS/utils/printServer.js'
import { sorter } from '@/views/kzyWMS/utils/sort.js'
import { upcloud_base_wh_outbound } from '@/config/serviceSettings'
import Editor from '../../../../basedata/goodsManager/editor.vue'

export default {
  name: 'innerCheckdetail',
  components: { lCLinfo, workerLogin, scanCode, itemDetail, Editor, containerdialog },
  data() {
    return {
      columns: sorter(columns),
      rowSelectType: false,
      boxTypevalue: '',
      boxTypeFlag: 0, //1开启，0关闭；
      selectedRowKeys: ['0021185309'], //当前选中行id 0021145181,
      promise_res1: null,
      promise_res2: null,
      printDataVisibal: false,
      boxTypeVisible: false, // 箱子维护弹窗
      disabled_Barcode: false, // 判断容器复核确认后再次复核，则禁止扫码。
      scan: 0,
      params: {
        url: upcloud_base_wh_outbound + '/wave/bill/query',
        params: {
          pageNum: 1,
          pageSize: 10,
        },
        timeout: 30000,
        //  headers: {
        //   'Content-Type': 'application/JSON'
        // },
        method: 'get',
      },
      rowKey: 'id',
      formItemLayout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 18 },
      },
      orderInfo: { askFor: 0, choose: 0, reviewed: 0, confirmed: 0, complete: 0, billGroupId: '', containerCode: '' },
      containerVO: {
        checkedLot: 0, //已经检查的批号
        checkedNum: 0, //已检数量
        checkedVarieties: 0, //已经检查的品种数量
        containerCode: null,
        totalLot: 0,
        orderUncheckedTaskNum: 0, // 订单待复合数
        totalNum: 0, //总数量
        totalVarieties: 0, //总品种
        unCheckedLot: 0,
        unCheckedNum: 0,
        unCheckedVarieties: 0,
      },
      tableData: [],
      itemsDetail: {
        itemName: null,
        manufacturerId: null,
        specification: null,
        billCode: null,
        lotNo: null,
        itemHealthIsDouble: null,
        cargoOwnerName: null,
        qty: 0,
        pickQty: 0,
        checkQty: 0,
        check2Qty: 0,
      },
      checkNum: 0,
      itemsData: {
        billGroupId: '',
        containerCode: '',
        itemBarcode: '202104250005',
        lclNo: '',
        pickTaskDId: '',
        qty: 1,
        stationCode: '14',
        userNames: [],
      },
      checkType: '1', //按商品复核
      batchNum: '',
      form: this.$form.createForm(this),
      loginform: this.$form.createForm(this),
      // items: items(this),
      items: items(this),
      businessData: '',
      printcolumns: printcolumns,
      printData: [],
      itemId: '',
      // tableVisible: false,
      loginVisible: false,
      confirmLoading: false,
      LCLinfoVisible: false,
      HCVisible: false,
      LCLVisible: false,
      isShow: 1,
      screen: false,
      spinning: false,
      resData: {},
      itemCode: '',
      videoDom: '',
      ContainerCodefocus: null,
      itemBarCodefocus: null,
      isStyle: {},
      doubleCheck: [],
      lclNo: '',
      barcodeDListMore: { lcls: [] },
      barcodeDList: {
        lcls: [],
      },
      lCLdata: {},
      makeUpData: { lcls: [] },
      makeUpVisible: false,
      makeUpStatus: false,
      makeUpinfoVisible: false,
      stempStatus: {
        containerstatus: false,
        goodsInfoStatus: false,
      },
      isSupervisedData: {},
      itemHealthIsDouble: '',
      editStatus: false,
      refData: {},
      scanTableList: [],
      scanVisible: false,
      selectedRowKeys1: [],
      selectedRows1: [],
      selectedRows: [],
      selectedRowsLcninfo: [],
      workertwo: {},
      workerInfo: {},
      superoisedBtn: false,
      boxTypeData: [], // 箱子类型数据
      stage: 2, //扫码阶段：0=入库质检 1=PC拣货 2=PC内复核 3=PC外复核 4=补录 5=PDA拣货 6=PDA内复核 7=PDA外复核
      tiemID: null,
      timer: null,
      isCaseOrPiece: false,
      printNum: 1, //整件打印份数
      shipperName: '',

      maintainVisible: false,
      detailItem: null,
      business: '',
      containerdialogvisible: false,
      containerArray: [],
      saveBtnStatus: true,
    }
  },
  created() {
    // 获取上方左侧工作台信息
    this.workbench()
    this.pushUserInfo()
    // console.log(this.warehouse,'warehouse')
    this.itemsData.stationCode = this.stationCode
    this.itemsData.workCode = this.$store.getters.userInfo.employeeNo
    this.workerInfo = this.$store.getters.userInfo
    this.itemsData.warehouseId = this.warehouse.warehouseId
    this.isShowSupervised() // 判断监管码弹窗是否显示
    // 根据控制规则来显示 红冲方式    //统一所有环境都添加红冲方式
    // let params = { regCode: 'outbound_no_use_red_do_method', warehouseId: this.warehouse.warehouseId }
    // getLocationType(params).then((res) => {
    //   let data = res.data.data
    //   // res.data.regValue 如果为0则显示，1则不显示
    //   if (!data || data.regValue == 1) {
    //     this.items = items(this).slice(0, 2)
    //   } else {
    //     this.items = items(this)
    //   }
    // })
    getBusiness().then((business) => {
      // 企业参数
      console.log(business, 'business')
      this.businessData = business
    })
    getBusiness('BOX_TYPE_FLAG').then((res) => {
      //箱子类型标识
      console.log(res, 'resresresresres')
      this.boxTypeFlag = res
    })
  },
  mounted() {
    ;(window.onresize = () => {
      if (!checkFull()) {
        this.screen = false
      }
    }),
      setTimeout(() => {
        console.log(this.$store.getters.screen)
        if (this.$store.getters.screen) {
          eleFullScreen(this.$refs.detailview, true)
          this.isStyle = {
            padding: '15px',
          }
        }
      }, 100)
    this.$refs.inputContainerCode.focus()
  },
  computed: {
    ...mapState({
      chekUser: (state) => state.outBound.checkPerson,
      stationCode: (state) => state.outBound.stationCode, // 工作台
      businesstype: (state) => state.outBound.businesstype,
      worktype: (state) => state.outBound.worktype,
      warehouseId: (state) => state.outBound.warehouseId,
    }),
    ...mapGetters({
      warehouse: 'warehouse',
    }),
    rowSelection1() {
      let _this = this
      return {
        selectedRowKeys: _this.selectedRowKeys1,
        onSelectAll(selected, selectedRows, changeRows) {
          console.log('onSelectAll:', selected, selectedRows, changeRows)
          var checked = selected
          var key = changeRows.map((item) => item.id)
        },
        onSelect(record, selected, selectedRows, nativeEvent) {
          console.log('onSelect:', record, selected, selectedRows, nativeEvent)
          // _this.selectedRows = selectedRows
        },
        onChange(selectedRowKeys, selectedRows) {
          console.log('onChange:', selectedRowKeys, selectedRows)
          _this.selectedRowKeys1 = selectedRowKeys
          _this.selectedRows1 = selectedRows
        },
      }
    },
    isDoubleCheck() {
      return this.$store.state.outBound.isDoubleCheck
    },
  },
  methods: {
    ...mapActions(['CheckLoginIn']),
    checkRow(selectedRowKeys, selectedRows, cc, dd) {
      // console.log('checkRow:', selectedRowKeys, selectedRows);
      // if(selectedRowKeys.length > 0) {
      // }
      // this.selectedRows = selectedRows
    },
    handleOkboxType() {
      // 确认保存箱型
      if (!this.boxTypevalue) return this.$message.warning('请选择箱型！')
      this.boxTypeVisible = false
      this.confirmFun()
    },
    queryFun() {
      // 查询
      let params = {
        dicttypeCodes: 'BOX_TYPE',
      }
      getDicts(params).then((res) => {
        console.log(res, '11111111111111')
        this.boxTypeData = res.data?.data
      })
    },
    onChangeCheckbox(e, record) {
      //
    },
    Rowclick(record, index) {
      return {
        on: {
          click: () => {},
          dblclick: () => {
            console.log(record)
            this.dblclickisSupervise(record)
          },
        },
      }
    },
    async dblclickisSupervise(record) {
      if (record.isSupervise != '1') {
        this.$message.info('无需扫描监管码')
        return
      }
      let SupervisedList = [record]
      if (SupervisedList.length > 0) {
        let isSupervisedStatus = await this.isSupervised(SupervisedList)
        console.log(isSupervisedStatus)
        if (isSupervisedStatus) {
          return
        }
      }
      // let data = [record]
      // this.scanTableList = data.filter(item => {
      // 	item.refBillId = item.billCode;
      // 	item.refBillLineId = item.pickTaskDId;
      // 	item.pieceQty = item.qty;
      // 	item.itemNum = item.itemCode;
      // 	item.itemSpecs = item.specification;
      // 	item.srcCode = item.billCode;
      // 	item.manufacturerLotNum = item.lotNo;
      // 	return item.isSupervise;
      // });
      // this.scanVisible = true;
    },
    pushUserInfo() {
      if (this.doubleCheck.length > 0) {
        this.doubleCheck.forEach((items) => {
          console.log(items)
          console.log(this.chekUser)
          if (items.userId !== this.chekUser.userId) {
            this.doubleCheck.push(this.chekUser)
            this.itemsData.userNames.push(this.chekUser.username)
          } else {
            this.$message.error('请不要重复登录')
          }
        })
      } else {
        this.doubleCheck.push(this.chekUser)
        this.itemsData.userNames.push(this.chekUser.username)
      }
    },
    handleChange(val) {
      this.checkType = val
    },
    isShowSupervised() {
      // isShowSupervised({ id: this.warehouse.warehouseId }).then((res) => {
      //   if (res.data.scanSupervisionCodeStage == 2 || res.data.scanSupervisionCodeStage == 3) {
      //     this.superoisedBtn = true
      //   }
      // })
      innerCheckConfig({ warehouseId: this.warehouse.warehouseId }).then(res =>{
        if (res.data.scanSupervisionCodeStage == 2 || res.data.scanSupervisionCodeStage == 3) {
          this.superoisedBtn = true
        }
        this.saveBtnStatus = res.data.pickWay == '0' ? true : false
        if(!this.saveBtnStatus) {
          columns.forEach(item => {
          if(item.dataIndex == 'lclNo') {
              item.disabled = true
            }
          })
          this.columns = sorter(columns)
        }
      })
    },
    async isSupervised(data, checkCode) {
      let list = data.map((item) => {
        const obj = {
          refBillId: item.billCode, //拣选任务主表id
          refBillLineId: item.pickTaskDId, //拣选任务明细id
          ...item,
        }
        return obj
      })
      let res = await isSupervised(list)
      if (res.success) {
        this.scanTableList = data.filter((item) => {
          item.refBillId = item.billCode
          item.refBillLineId = item.pickTaskDId
          item.pieceQty = item.pickQty - (item.redQty ? item.redQty : 0)
          item.itemNum = item.itemCode
          item.itemSpecs = item.specification
          item.containerCode = this.itemsData.containerCode
          item.srcCode = item.billCode
          item.manufacturerLotNum = item.lotNo
          return item.isSupervise
        })
        if (res.data !== true && list.length) {
          this.scanVisible = true
          return false
        } else {
          if (checkCode == 'checkCode') {
            this.scanVisible = true
            return false
          } else {
            // this.$message.error('监管码已经全部扫描完成');
            return true
          }
        }
      }
    },
    login(Show, screen, videoDom) {
      this.isShow = Show
      this.videoDom = videoDom
      this.screen = screen
    },
    fullscreenEven(Show, screen, videoDom) {
      eleFullScreen(this.$refs.detailview, !checkFull())
      if (screen == false) {
        this.screen = true
        eleFullScreen(videoDom, this.screen)
      } else {
        this.screen = false
        eleFullScreen(videoDom, screen)
      }
      // }
    },
    qpclick() {
      eleFullScreen(this.$refs.detailview, !checkFull())
      this.screen = checkFull()
      if (!checkFull()) {
        this.isStyle = {
          padding: '15px',
        }
      } else {
        this.isStyle = {
          padding: 0,
        }
      }
    },
    resetData() {
      this.selectedRows1 = [] //复核确认后清空商品勾选数据
      this.selectedRowKeys1 = [] // 清空勾选数据
      this.itemsDetail = {}
      this.containerVO = {
        totalNum: 0,
        orderUncheckedTaskNum: 0,
        checkedNum: 0,
        totalVarieties: 0,
        checkedVarieties: 0,
        checkedLot: 0,
      }
      this.tableData = []
      this.form.resetFields()
    },
    itemDet(data) {
      console.log(data, 'xiangqing')
      this.detailItem = { itemId: data.itemId }
      this.maintainVisible = true
      // this.itemId = data.itemId
      // this.$refs.detailItem.open()
    },
    editorchekNum() {},

    // 获取上方左侧工作台信息
    workbench() {
      let params = {
        num: 'innerCheckTaskQuery',
        params: {
          warehouseId: this.warehouse.warehouseId,
          stationCode: this.stationCode,
        },
      }
      search_noPage(params).then((res) => {
        // 状态 0：待索取askFor  1：待拣选choose 2：待复核索取reviewed   3.待复核确认confirmed  10：完成complete
        // status: "1"  totalNum: 1
        if (res.data.success) {
          if (!res.data.data) {
            return
          }
          res.data.data.forEach((item) => {
            switch (item.status) {
              case '0':
                this.orderInfo.askFor = item.totalNum
                // console.log('工作台askFor：', this.orderInfo.askFor); //待索取
                break
              case '1':
                this.orderInfo.choose = item.totalNum
                // console.log('工作台choose：', this.orderInfo.choose); //待拣选
                break
              case '2':
                this.orderInfo.reviewed = item.totalNum
                // console.log('工作台reviewed：', this.orderInfo.reviewed); //待复核索取
                break
              case '3':
                this.orderInfo.confirmed = item.totalNum
                // console.log('工作台confirmed：', this.orderInfo.confirmed); //待复核确认
                break
              case '10':
                this.orderInfo.complete = item.totalNum
                break //完成
            }
          })
        }
      })
    },

    // 扫描容器号 new Promise 同步方法  left join主表
    first_promise(params) {
      return new Promise((reslove, reject) => {
        getContainer(params).then((res) => {
          this.spinning = false
          if (res.success) {
            //上方左侧工作台信息
            // this.orderInfo = res.data
            //上方右侧容器信息
            console.log(res, 'resresresresresresresres')
            this.containerVO = res.data.containerInfo
            //最下方表格数据
            this.promise_res1 = res.data.innerCheckTaskDVOS
            //  以下过滤主键商品id找到当前行 ，赋值给右上角展示面板
            this.disabled_Barcode = false
            this.stempStatus.containerstatus = true
            this.itemsData.billGroupId = res.data.billGroupId //订单分组id (必填)
            this.shipperName = res.data.shipperName // 获取客户名称
            return reslove(res.data)
          } else {
            this.disabled_Barcode = false
            this.$message.error(res.message)
            return reject(res)
          }
        })
      })
    },
    printDatas() {
      //
      let params = {
        billNo: this.itemsData.billGroupId,
      }
      queryFuncRoomPrintList(params).then((res) => {
        console.log(res, '22222222222')
        toPrintServer(res.data, this.$store.getters.warehouse.warehouseId, 'itemList.dataMark').then((res) => {
          if (!res.success) {
            this.$exception(res)
            return
          }
          this.$message.success(res.message)
        })
      })
    },

    // left join 右表，商品信息
    two_promise(params) {
      return new Promise((reslove, reject) => {
        pagebyRelated(params).then((res) => {
          if (res.data.success) {
            this.promise_res2 = res.data
            // console.log('this.promise_res2:',this.promise_res2)
            return reslove(res.data)
          } else {
            return reject(res.message)
          }
        })
      })
    },
    ContainerCodeChange(val) {
      // 去掉前后空格
      val.target.value = val.target.value.trim()
      if (val.type == 'click') {
        this.$refs.inputContainerCode.focus()
      }
    },
    itemBarCodeChange(val) {
      // 去掉前后空格
      val.target.value = val.target.value.trim()
      if (val.type == 'click') {
        this.$refs.inputitemBarCode.focus()
      }
    },
    LCLBarCodeChange(val) {
      // 去掉前后空格
      val.target.value = val.target.value.trim()
      if (val.type == 'click') {
        this.$refs.LCLBarCode.focus()
      }
    },
    // 扫描容器号
    entercontainer(e, itemSanning) {
      this.scan = 1
      let _this = this
      this.spinning = true
      // this.$refs.inputitemBarCode.focus();
      this.$refs.inputContainerCode.blur()
      // this.$refs.inputContainerCode.focus()
      this.form.validateFields((err, values) => {
        if (!err) {
          this.first_promise({ containerCode: values.containerCode, stationCode: this.itemsData.stationCode })
            .then((res) => {
              // 判断容器全部扫完，提示弹出复核确认
              // disabled_Barcode:false, // 判断容器复核确认后再次复核，则禁止扫码。
              if (this.containerVO.checkedNum == this.containerVO.totalNum) {
                this.scan = 4
                this.disabled_Barcode = true
                this.$message.success('当前容器商品已全部复核完成！')
                //判断监管码弹窗关闭后
                // if(!this.scanVisible && itemSanning == 'scanningItem'){
                // 	setTimeout(()=>{
                // 		this.checkConfirm(); // 再弹出复核确认
                // 	},1000)
                // };
              }
              this.itemsData.containerCode = values.containerCode
              // map传入参数并去重  "itemIds": ["0021161881","0021160528"],
              let params = Array.from(new Set(res.innerCheckTaskDVOS.map((item) => item.itemId)))
              this.two_promise({ itemIds: params })
                .then((res2) => {
                  // this.tableData表格主数据    this.promise_res2或res2合并商品数据
                  // this.tableData = this.promise_res1
                  this.tableData.length = 0
                  this.promise_res1.forEach((item) => {
                    let rows = this.promise_res2.data.list.find((it) => item.itemId == it.itemId)
                    this.tableData.push({ ...rows, ...item })
                  })
                  this.viewQuery()
                  this.selectedRowKeys1 = [] // 清空勾选数据
                  this.selectedRows1 = [] // 清空勾选数据
                  console.log('合并：', this.tableData)
                })
                .catch((err) => {
                  console.log('promise2捕获错误：', err)
                })
            })
            .catch((err) => {
              console.log('promise1捕获错误：', err)
            })
        } //if
      })
    },
    // 自动/手动查询商品编码
    entergoods(e) {
      // this.$refs.inputContainerCode.focus()
      if (this.business !== 'cube') {
        this.$refs.inputitemBarCode.blur()
      }
      clearTimeout(this.tiemID)
      this.tiemID = setTimeout(() => {
        console.log('执行节流函数')
        if (!this.stempStatus.containerstatus) {
          this.$message.error('请扫描容器号')
          return
        }
        console.log(this.checkType)
        if (this.checkType == '1') {
          this.form.validateFields((err, values) => {
            if (!err) {
              let rows = this.tableData.find((item) => {
                // 找行id的逻辑是，根据商品找到list，顺序判断商品的复核数量 + 冲红数量等于拣货数量的跳过，
                // 复核数量有两个字段，cherqty，checher2qty,是二次复核的时候选checker2qty,否则选checkQty
                // 判断是否扫描过
                // console.log(item,'itemitemitemitemitemitemitemitemitemitem')
                const isDoubleCheck = this.$store.state.outBound.isDoubleCheck
                let checkNum = isDoubleCheck == '0' ? item.checkQty + item.redQty : item.check2Qty + item.redQty
                if (!(checkNum == item.pickQty)) {
                  if (
                    item['itemBarcode'] == values.itemBarcode ||
                    item['pieceBarcode'] == values.itemBarcode ||
                    item['caseBarcode'] == values.itemBarcode ||
                    item['barCode'] == values.itemBarcode ||
                    item['barcodeOld'] == values.itemBarcode ||
                    (item.itemCode ? item['itemCode'].indexOf(values.itemBarcode) != -1 : false) ||
                    (item.itemAssistantCode ? item['itemAssistantCode'].indexOf(values.itemBarcode) != -1 : false)
                  ) {
                    console.log('测试222')
                    console.log(item)
                    return true
                  }
                }
              })
              //  判断当前商品条码扫描结果
              if (rows) {
                this.itemsDetail = rows
                this.itemsDetail.shipperName = this.shipperName //给商品信息 客户名称赋值
                this.scan = 2
                // 让当前选中
                this.selectedRowKeys.length = 0
                // 复核任务/数量复核商品 接口/inner/check/item/number
                getItemnum({
                  workCode: this.$store.getters.userInfo.employeeNo, //员工号
                  isDoubleCheck: this.$store.state.outBound.isDoubleCheck, //是否双人复核
                  qty: rows.pickQty - (rows.redQty ? rows.redQty : 0), //拣货数量
                  // qty		      : 3,		//计划数量
                  innerCheckDId: rows.innerCheckDId, //内复核明细行id
                  containerCode: this.form.getFieldsValue().containerCode, //当前拣货容器号
                  stationCode: this.itemsData.stationCode, //复核台编号
                  billGroupId: this.itemsData.billGroupId, //订单分组id
                  itemCode: rows.itemCode,
                  pickTaskDId: rows.pickTaskDId,
                }).then((res) => {
                  if (res.success) {
                    let wholestatus = rows.pickTaskType == 0 ? 'wholestatus' : ''
                    console.log(rows, 'rowrowrowrowrow')
                    console.log(wholestatus, 'wholestatuswholestatuswholestatus')
                    // if(rows.pickTaskType == 0) {
                    //   this.wholePrint(rows.pickTaskDId)
                    // }
                    this.entercontainer(null, 'scanningItem') //扫描容器号
                    this.form.setFieldsValue({ itemBarcode: '' })
                    //遍历当前复核商品明细
                    const currentRow = res.data.innerCheckTaskDVOS.filter((item) => {
                      return item.pickTaskDId == rows.pickTaskDId
                    })
                    this.itemsDetail.check2Qty = currentRow[0].check2Qty
                    this.itemsDetail.checkQty = currentRow[0].checkQty
                    this.scan = 2 // 将扫描状态置为OK.
                    // this.entergoods();			//自动/手动扫描商品编码
                    console.log('准备扫描下一条商品条码前：', res)
                  } else {
                    this.$exception(res)
                  }
                })
                if (rows.isSupervise) {
                  //  this.checksuperviseCode(rows); //自动弹出扫描监管码
                  this.dblclickisSupervise(rows)
                }
              } else {
                this.scan = 3
                this.itemsDetail = this.tableData[0]
                this.itemsDetail.shipperName = this.shipperName //给商品信息 客户名称赋值
              }
            }
          })
        }
      }, 1000)
    },
    enterLclinfo() {
      this.form.validateFields((err, values) => {
        if (!err) {
          const params = {
            stationCode: this.itemsData.stationCode,
            billGroupId: values.billGroupId,
          }
          LclQuery(params).then((res) => {
            if (res.success) {
              if (!res.data) {
                //   this.$message.error(res.message);
                return
              }
              this.makeUpData = res.data
              this.makeUpVisible = true
              // if (res.data.lcls.length > 7) {
              // 	let arr = [];
              // 	res.data.lcls.forEach((item, index) => {
              // 		if (index < 7) {
              // 			arr.push(item);
              // 		}
              // 	});

              // 	this.barcodeDList = { currLclNo: res.data.currLclNo, lcls: arr };
              // }
              // this.barcodeDListMore = res.data;
            }
          })
        } //if
      })
    },
    setRowClassName(record, index) {
      // 找行id的逻辑是，根据商品找到list，顺序判断商品的复核数量 + 冲红数量等于拣货数量的跳过，
      // 复核数量有两个字段，cherqty，checher2qty,是二次复核的时候选checker2qty,否则选checkQty
      const isDoubleCheck = this.$store.state.outBound.isDoubleCheck
      if (isDoubleCheck == '0') {
        if (record.checkQty + record.redQty == record.pickQty) {
          return 'rowcolorGray'
        }
      } else {
        if (record.check2Qty + record.redQty == record.pickQty) {
          return 'rowcolorGray'
        }
      }
      // if ( (record.checkQty+record.redQty) == record.pickQty ||
      // 		(record.check2Qty+record.redQty) == record.pickQty
      // 	) {
      // 	return 'rowcolorGray';
      // }
    },
    VueDebounce() {
      clearTimeout(this.tiemID)
      this.tiemID = setTimeout(() => {
        console.log('执行节流函数')
      }, 1000)
    },
    clickContainer(data) {
      this.form.setFieldsValue({ containerCode: data })
    },
    async checkConfirm() {
      let SupervisedList = this.tableData.filter((item) => {
        return item.isSupervise == '1'
      })
      if (SupervisedList.length > 0) {
        let isSupervisedStatus = await this.isSupervised(SupervisedList)
        if (!isSupervisedStatus) {
          return
        }
      }
      this.viewQuery()
      this.confirmFun()
    },
    confirmFun() {
      // 复合确认
      let params = this.itemsData
      params.innerCheckTaskDVOS = this.tableData
      params.boxType = this.boxTypevalue ? this.boxTypevalue : ''
      let _this = this
      console.log(this.$confirm)
      this.$confirm({
        title: '复核确认',
        content: '您要复核确认吗？',
        getContainer: () => {
          return _this.$refs.detailview
        },
        onOk() {
          getItemConfirm(params).then((res) => {
            if (res.success) {
              _this.resetData()
              _this.barcodeDListMore = { lcls: [] }
              _this.barcodeDList = { lcls: [] }
              _this.$message.success(res.message)
              if (res.data && res.data.length > 0) {
                _this.containerArray = res.data
                _this.containerdialogvisible = true
              }
              // 清空容器码
              _this.form.setFieldsValue({ containerCode: '' })
              // _this.$refs.inputContainerCode.focus()
            } else {
              _this.$exception(res)
            }
          })
        },
        onCancel() {},
      })
    },
    wholepiecesplit() {
      if (!this.stempStatus.containerstatus) {
        this.$message.error('请扫描容器号')
        return
      }
      const params = {
        stationCode: this.itemsData.stationCode,
        billGroupId: this.itemsData.billGroupId,
        containerCode: this.itemsData.containerCode,
      }
      postpieceBreak(params).then((res) => {
        if (res.success) {
          this.entercontainer() //扫描容器号
          this.$message.success(res.message)
          this.viewQuery()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    printEvent() {
      console.log(this)
      // this.tableVisible = true;
      const params = {
        containerCode: this.itemsData.containerCode,
        stationCode: this.itemsData.stationCode,
        billGroupId: this.itemsData.billGroupId,
      }
      checkLclBarcode(params).then((res) => {
        console.log(res)
        if (res.success) {
          this.printData = res.data.barcodeDList
          this.lclNo = res.data.lclNo
          this.viewQuery()
          this.entercontainer() //扫描容器号
        }
      })
    },
    viewQuery() {
      // if (!this.stempStatus.goodsInfoStatus ) {
      //   this.$message.error('请扫描商品条码')
      //   return
      // }
      const params = {
        stationCode: this.itemsData.stationCode,
        billGroupId: this.itemsData.billGroupId,
        containerCode: this.itemsData.containerCode,
        lclNo: this.lclNo,
      }
      LclQuery(params).then((res) => {
        if (res.success) {
          if (!res.data) {
            //   this.$message.error(res.message);
            this.barcodeDListMore.lcls = []
            return
          }
          if (res.data.lcls.length > 7) {
            let arr = []
            res.data.lcls.forEach((item, index) => {
              if (index < 7) {
                arr.push(item)
              }
            })

            this.barcodeDList = { currLclNo: res.data.currLclNo, lcls: arr }
          }
          this.barcodeDListMore = res.data
        }
      })
    },
    wholePrint(pickTaskDId) {
      this.$message.success('自动打印整单')
      let params = {
        warehouseId: this.$store.getters.warehouse.warehouseId,
        type: 0, //"type":"类型：0-拣货 1-补货"
        pickTaskDIds: [pickTaskDId],
      }
      getWholePrintInfo(params).then((res) => {
        toPrintServer(res.data[0].data, this.$store.getters.warehouse.warehouseId, tempType.pick_tag).then((res) => {
          if (!res.success) {
            this.$exception(res)
            return
          }
          this.$message.success(res.message)
        })
      })
    },
    deleteLcl() {
      let _this = this
      let lclRow = this.barcodeDListMore.lcls.find((item) => {
        return (item.lclNo = this.$refs.lCLtable.data.lclNo)
      })
      console.log(lclRow)
      if (lclRow.status != '1') {
        this.deleteLCLFun()
        return
      }
      this.$confirm({
        title: '拼箱删除',
        content: '该拼箱已打印,您确定要删除吗？',
        // getContainer: () => {
        //   return _this.$refs.detailview
        // },
        onOk: () => {
          // _this.tableVisible = false;
          this.deleteLCLFun()
        },
        onCancel() {},
      })
    },
    deleteLCLFun() {
      this.LCLinfoVisible = false
      const params = {
        containerCode: this.itemsData.containerCode,
        stationCode: this.$refs.lCLtable.data.stationCode,
        billGroupId: this.$refs.lCLtable.data.billGroupId,
        lclNo: this.$refs.lCLtable.data.lclNo,
      }
      deleteLclNo(params).then((res) => {
        if (res.success) {
          this.viewQuery()
          this.entercontainer() //扫描容器号
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    },
    handleDetailPrint() {
      // this.tableVisible = false;
      // this.LCLinfoVisible = false;
      console.log(this.$refs.lCLtable)
      const params = {
        stationCode: this.$refs.lCLtable.data.stationCode,
        billGroupId: this.$refs.lCLtable.data.billGroupId,
        containerCode: this.$refs.lCLtable.data.containerCode,
        lclNo: this.$refs.lCLtable.data.lclNo,
      }
      getDetailPrintInfo(params).then((res) => {
        toPrintServer(res.data.data, this.$store.getters.warehouse.warehouseId, tempType.pxmx).then((res) => {
          if (!res.success) {
            this.$exception(res)
            return
          }
          this.$message.success(res.message)
        })
      })
    },
    async handleOkPrint() {
      // this.tableVisible = false;
      // this.LCLinfoVisible = false;
      console.log(this.$refs.lCLtable)
      let params = {
        containerCode: this.itemsData.containerCode,
        billGroupId: this.$refs.lCLtable.data.billGroupId,
        containerCode: this.$refs.lCLtable.data.containerCode,
        lclNo: this.$refs.lCLtable.data.lclNo,
      }
      for (const key in params) {
        if (Object.hasOwnProperty.call(params, key)) {
          if (!params[key]) {
            delete params[key]
          }
        }
      }
      if (this.isCaseOrPiece) {
        let list = this.$refs.lCLtable.selectedListRowKeys
        let wholelist = this.$refs.lCLtable.selectedPickTaskIdRows
        // console.log(list,'this.$refs.selectedListRowsthis.$refs.selectedListRows')
        if (list.length < 1) {
          this.$message.error('请至少选择一条数据')
          return
        }
        let params = {
          warehouseId: this.$store.getters.warehouse.warehouseId,
          type: 0, //"type":"类型：0-拣货 1-补货"
          pickTaskDIds: wholelist,
        }
        if (this.printNum < 1) {
          this.$message.error('打印数量必须大于0')
          return
        }
        if (this.printNum % 1 !== 0) {
          this.$message.error('请输入整数')
          return
        }
        // 		if (!(/(^[1-9]\d*$)/.test(this.printNum))) {
        //            this.$message.error('输入的不是正整数');
        // 　　　　　　return false;
        // 　　　　 }
        const hookFun = (params) => {
          params.count = this.printNum
          return params
        }
        getWholePrintInfo(params).then((res) => {
          this.viewQuery()
          console.log()
          this.$refs.lCLtable.data.status = '1'
          toPrintServer(
            res.data[0].data,
            this.$store.getters.warehouse.warehouseId,
            tempType.pick_tag,
            null,
            hookFun
          ).then((res) => {
            if (!res.success) {
              this.$exception(res)
              return
            }
            this.$message.success(res.message)
            //打印次数添加
            list.forEach((item) => {
              this.$refs.lCLtable.tableData.forEach((t) => {
                if (t.barcodeDId == item) {
                  t.printCount = t.printCount + Number(this.printNum)
                }
              })
            })
          })
        })
      } else {
        getPrintInfo(params).then((res) => {
          console.log(res.data.data)
          this.$refs.lCLtable.data.status = '1'
          this.viewQuery()
          toPrintServer(res.data.data, this.$store.getters.warehouse.warehouseId, tempType.assimble_tag).then((res) => {
            if (!res.success) {
              this.$exception(res)
              return
            }
            //打印次数添加
            this.$refs.lCLtable.tableData.forEach((t) => {
              t.printCount = t.printCount + 1
            })
            this.$message.success(res.message)
          })
        })
      }
    },
    eidthandleOk() {
      this.LCLinfoVisible = false
      const data = this.$refs.lCLtable.data
      const list = this.$refs.lCLtable.tableData
      if (list.length < 1) {
        return
      }
      const params = list.map((item) => {
        const obj = {
          billGroupId: this.itemsData.billGroupId,
          lclNo: data.lclNo,
          itemCode: item.itemCode,
          itemId: item.itemId,
          containerCode: item.containerCode,
          pickTaskDId: item.pickTaskDId,
          qty: item.qty,
        }
        return obj
      })
      console.log(this.$refs.lCLtable)
      eidtlclNum(params).then((res) => {
        if (res.success) {
          this.viewQuery()
          this.entercontainer() //扫描容器号
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    },
    handleOkHC() {
      // this.hchanlderSubmit()
      this.HCVisible = true
      let redQty = this.$refs.modelForm.form.getFieldsValue().redQty
      if (redQty % 1 !== 0) {
        this.$message.error('红冲数量必为整数')
        return
      }
      let _this = this
      this.$refs.modelForm.form.validateFields((err, values) => {
        if (!err) {
          console.log(values)
          this.$confirm({
            title: '冲红',
            content: '商品冲红后需要重新调整拼箱数量,您确定要冲红吗？',
            getContainer: () => {
              return _this.$refs.detailview
            },
            onOk() {
              _this.itemsData.redReason = values.redReason
              _this.itemsData.redQty = values.redQty
              _this.itemsData.redDoMethod = values.redDoMethod
              _this.itemsData = { ..._this.itemsData, ..._this.workertwo }
              const params = { ..._this.itemsData, ..._this.resData }
              saveRedhc(params).then((res) => {
                if (res.success) {
                  const currentNum = res.data.innerCheckTaskDVOS[0].redQty
                  const redReason = res.data.innerCheckTaskDVOS[0].redReason
                  const itemid = res.data.innerCheckTaskDVOS[0].itemId
                  _this.tableData.forEach((item) => {
                    if (item.itemId == itemid) {
                      item.redQty = currentNum
                      item.redReason = redReason
                    }
                  })
                  _this.$refs.modelForm.form.resetFields()
                  _this.itemsDetail = res.data.innerCheckTaskDVOS[0]
                  _this.itemsDetail.shipperName = _this.shipperName //给商品信息 客户名称赋值
                  _this.viewQuery()
                  _this.HCVisible = false
                  _this.entercontainer()
                  _this.$message.success(res.message)
                } else {
                  _this.$message.error(res.message)
                }
              })
            },
            onCancel() {},
          })
        }
      })
    },
    //拼箱号修改保存
    saveInnerCheckDetails() {
      if (this.selectedRows1.length < 1) {
        this.$message.error('请至少选择一条数据')
        return
      }
      const params = {
        ...this.itemsData,
        innerCheckTaskDVOS: this.selectedRows1,
      }
      postsaveInnerCheckDetails(params).then((res) => {
        this.viewQuery()
        // this.selectedRowKeys1 = []
        this.entercontainer() //扫描容器号
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    },
    bartNoCheck(data) {
      this.isSupervisedData = {
        specialWorkType: '内复核红冲',
        warehouseId: this.warehouse.warehouseId,
      }
      this.loginVisible = true
      // this.HCVisible = true
      // console.log(this.$refs.detailview)
      this.resData = {
        billId: data.billId,
        billDId: data.billDId,
        srcId: data.srcId,
        srcLineId: data.srcLineId,
        pickTaskDId: data.pickTaskDId,
      }
      // console.log(this.resData);
      this.refData = this.$refs.detailview
      this.itemsData.itemCode = data.itemCode
    },
    itemNumeven(data) {
      // console.log(data)
    },

    handleCancel() {
      console.log('取消')
      // this.$refs.modelForm.form.resetFields();
      this.makeUpinfoVisible = false
      // this.tableVisible = false;
      this.loginVisible = false
      this.LCLinfoVisible = false
      this.HCVisible = false
    },
    handleCancelHC() {
      this.HCVisible = false
    },
    makeUphandleCancel() {
      this.makeUpVisible = false
    },
    LCLhandleCancel() {
      this.LCLVisible = false
    },
    hchanlderSubmit() {},
    loginResult(data, value) {
      if (!data) {
        this.workertwo = {
          workCode: value.workercode,
          userId: '',
          username: value.workercode,
        }
        console.log(value)
        this.loginVisible = data
        this.HCVisible = true
      }
    },
    moreview() {
      this.LCLVisible = true
    },
    loginevent() {
      this.loginform.validateFields((err, values) => {
        if (!err) {
          values.businesstype = this.businesstype
          values.worktype = this.worktype
          values.stationCode = this.stationCode
          values.warehouseId = this.warehouseId
          console.log(values)
          this.confirmLoading = true
          this.CheckLoginIn(values)
            .then((res) => {
              // this.$message.success(res.message)
              console.log(res)
              this.pushUserInfo()
              this.confirmLoading = false
              this.loginVisible = false
              this.HCVisible = true
            })
            .catch((error) => {
              this.$message.error('登录失败')
            })
        }
      })
    },
    // 扫描监管码
    checksuperviseCode(rows) {
      if (!this.stempStatus.containerstatus) {
        this.$message.error('请扫描容器号')
        return
      }
      // 判断是否当前一行扫码自动弹出
      if (rows.itemCode) {
        this.tableData.length = 0
        this.tableData[0] = { ...rows }
      }
      let SupervisedList = this.selectedRows1.filter((item) => {
        return item.isSupervise == '1'
      })
      if (SupervisedList.length < 1) {
        this.$message.error('请至少选择一条可用数据')
        return
      }
      this.isSupervised(SupervisedList, 'checkCode')
      // console.log("当前监管码：",this.tableData);
      // this.scanTableList = this.tableData.filter(item => {
      // 	item.refBillId = item.billCode;
      // 	item.refBillLineId = item.pickTaskDId;
      // 	item.pieceQty = item.pickQty - (item.redQty? item.redQty : 0 );
      // 	item.itemNum = item.itemCode;
      // 	item.itemSpecs = item.specification;
      // 	item.containerCode = this.itemsData.containerCode;
      // 	item.srcCode = item.billCode;
      // 	item.manufacturerLotNum = item.lotNo;
      // 	return item.isSupervise;
      // });
      // this.scanVisible = true;
    },
    viewLcninfo(data, status) {
      console.log(this.selectedRows1, 'selectedRows1selectedRows1')
      console.log(data, 'datadatadatadatadatadatadatadatadatadatadatadatadatadata')
      this.LCLVisible = false
      this.isCaseOrPiece = data.lclNo == 0 ? true : false
      if (!status) {
        this.LCLinfoVisible = true
        if (this.selectedRows1.length > 0) {
          this.selectedRowsLcninfo = this.selectedRows1.map((item) => {
            const obj = {
              barcodeDId: '_cusId' + Math.random() * 10000,
              barcodeId: item.barcodeId,
              itemCode: item.itemCode,
              itemName: item.itemName,
              itemId: item.itemId,
              containerCode: this.itemsData.containerCode,
              pickTaskDId: item.pickTaskDId,
              qty: 0,
            }
            return obj
          })
          let obj = {}
          this.selectedRowsLcninfo = this.selectedRowsLcninfo.reduce((item, next) => {
            if (!obj[next.pickTaskDId]) {
              item.push(next)
              obj[next.pickTaskDId] = true
            }
            return item
          }, [])
        } else {
          this.selectedRowsLcninfo = []
        }
      } else {
        this.makeUpinfoVisible = true
      }
      this.makeUpStatus = status ? true : false
      console.log(this.selectedRowsLcninfo, 'datadatadatadata')
      this.lCLdata = data
    },
    exit() {
      this.$store.getters.screen = checkFull()
      this.$emit('exit', 1)
    },

    /* 商品维护 */
    handleOk(e) {
      this.$refs.itemsEditor.getDetailData()
    },
    handleCancel(e) {
      this.maintainVisible = false
      this.makeUpinfoVisible = false
      this.LCLinfoVisible = false
    },
    handleItemsComplete() {
      this.maintainVisible = false
    },
  },
}
</script>

<style lang="less" scoped>
.boxTypeClass {
  text-align: center;
  padding: 30px 0;
}
/deep/.boxTypeClass .ant-radio-wrapper {
  font-size: 16px;
}
.scanForm {
  /deep/ .ant-row.ant-form-item:last-child {
    margin-top: 0px;
  }
  /deep/ .ant-form-item-label label {
    font-size: 20px;
  }
  input {
    height: 40px;
    font-size: 20px;
    font-weight: bold;
  }
}
.scan {
  text-align: center;
  position: relative;
  height: calc(600px - 240px);
  margin-top: 50px;
  // display: flex;
  .icon {
    margin: auto;
    color: rgba(0, 174, 240, 0.5);
    // animation: my 2s infinite;
    .anticon {
      font-size: 100px;
    }
    .scanText {
      font-size: 30px;
      margin-top: 20px;
      letter-spacing: 5px;
    }
  }
  .iconErr {
    margin: auto;
    color: rgba(255, 0, 0, 0.8);
    .anticon {
      font-size: 100px;
    }
    .scanText {
      font-size: 30px;
      margin-top: 20px;
      letter-spacing: 5px;
    }
  }
  .iconOK {
    margin: auto;
    color: rgba(0, 255, 0, 0.8);
    .anticon {
      font-size: 100px;
    }
    .scanText {
      font-size: 50px;
      margin-top: 20px;
      letter-spacing: 5px;
    }
  }
  .totalNum {
    width: 100%;
    margin-top: 20px;
    position: absolute;
    bottom: 0;
    dl {
      dt {
        font-size: 20px;
        height: 40px;
        line-height: 40px;
        display: inline-block;
      }
      dd {
        font-size: 40px;
        height: 40px;
        line-height: 40px;
        display: inline-block;
        color: #2b80ff;
      }
    }
  }
  @keyframes my {
    0% {
      color: rgba(0, 174, 240, 0.1);
    }
    // 50% { color:rgba(0,174,240,0.1); }
    100% {
      color: rgba(0, 174, 240, 0.8);
    }
  }
}
::v-deep {
  .ant-table-row-selected {
    // background:green !important;
    // color: white !important;
  }
}
.inner-table {
  background: #fff;
  margin-top: 16px;
  padding: 20px 18px;
  height: 36%;
}
.printclass {
  display: inline-block;
  width: 120px;
  margin: 0 5px;
}
.printinput {
  width: 60px;
  margin-left: 5px;
}
.squery {
  // position: absolute;
  // right: 20px;
  // top: 20px;
  display: inline-block;
  background: rgb(170, 187, 200);
}
.innerCheckdetail {
  // background: #ffffff;
  // height: 100vh;
  /deep/ .rowcolorGray {
    color: white;
    background: green;
  }
  .rowcolor2 {
    color: darkgray;
  }
  .header {
    display: flex;
    justify-content: space-between;
    height: 5%;
  }
  .middle {
    // height: 55%;
  }
  .Main {
    background: #f0f2f5;
    height: 100%;
  }
  .itemw {
    display: inline-block;
    margin-right: 10px;
  }
  /deep/ .ant-result-title {
    font-family: PingFangSC-Medium;
    font-size: 30px;
    color: #52c41a;
  }
  /deep/ .ant-card-head-title {
    font-family: PingFangSC-Medium;
    font-size: 16px;
    color: #666666;
  }
  /deep/ .ant-descriptions-title {
    font-size: 20px;
    color: #1890ff;
  }
  .wrapperCol {
  }
  .blod-font {
    font-family: PingFangSC-Medium;
    font-size: 28px;
    color: #333333;
    line-height: 32px;
  }
  .thin-font {
    font-family: PingFangSC-Medium;
    font-size: 18px;
    color: #333333;
  }
  .show-title {
    font-family: PingFangSC-Medium;
    font-size: 20px;
    color: #1890ff;
  }
  .info {
    .item {
      display: flex;
      align-items: center;
      // margin-bottom: 8px;
      .label {
        font-family: PingFangSC-Medium;
        font-size: 24px;
        color: #666666;
      }
      .thin-label {
        font-family: PingFangSC-Medium;
        font-size: 18px;
        color: #666666;
      }
    }
  }
}
.num-group {
  display: flex;
  justify-content: space-between;
  .num-item {
    position: relative;
    flex: 1;
    &::after {
      position: absolute;
      content: '';
      height: 30px;
      width: 1px;
      background: #d8d8d8;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
    }
    &:last-child {
      &::after {
        display: none;
      }
    }
    .title {
      font-size: 14px;
      color: #666666;
      text-align: center;
    }
    .num {
      font-family: Rubik-Medium;
      font-size: 18px;
      color: #333333;
      text-align: center;
      margin-top: 4px;
    }
  }
}
.leftDt {
  width: 130px;
  text-align: right;
  padding-right: 20px;
}
</style>
