<template>
  <basic-container v-loading="Selfpickuploading" element-loading-text="正在处理中...">
    <div class="avue-crud" :style="`height:` + height + ';overflow:auto;'">
      <el-form :disabled="view" ref="form" :model="form" label-width="120px" :rules="rules">
        <!-- 表单字段 -->
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="提货时间" prop="pickUpTime">
              <!--              <el-input v-model="form.pickUpTime" placeholder="请输入提货时间"/>-->
              <el-date-picker
                style="width: 100%"
                v-model="form.pickUpTime"
                type="datetime"
                placeholder="请输入提货时间"
                format="YYYY-MM-DD hh:mm:ss"
                value-format="YYYY-MM-DD hh:mm:ss"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提货人" prop="consignee">
              <el-input v-model="form.consignee" placeholder="请输入提货人" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="提货车牌号码" prop="pickUpPlate" label-width="120px">
              <el-input v-model="form.pickUpPlate" placeholder="请输入提货车牌" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提货证件号码" prop="deliveryDocument" label-width="120px">
              <el-input v-model="form.deliveryDocument" placeholder="请输入提货证件" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="证件类型" prop="certificateType">
              <el-select
                v-model="form.certificateType"
                clearable
                placeholder="请选择证件类型"
                style="width: 100%"
              >
                <el-option
                  v-for="item in certificateType"
                  :key="item.dictKey"
                  :label="item.dictValue"
                  :value="item.dictKey"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="备注">
              <el-input type="textarea" v-model="form.remark" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="费用" prop="freightMark">
              <el-checkbox-group v-model="form.freightMark" @change="handleCheckedCitiesChange">
                <el-checkbox
                  style="min-width: 16%; margin-bottom: 8px"
                  v-for="(item, index) in clientType"
                  :key="item.dictKey"
                  :label="item.dictKey"
                  >{{ item.dictValue }}
                  <el-input
                    type="number"
                    v-model="item.remark"
                    placeholder="请输入费用"
                    :disabled="this.form?.freightMark?.indexOf(item.dictKey) === -1"
                    @change="textbox($event, index)"
                    min="0"
                    style="width: 70%"
                  />
                </el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="费用合计" prop="totalCost">
              <el-input v-model="form.totalCost" placeholder="费用合计" disabled />
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label-width="0" prop="certificateType">
          <el-tabs @tab-click="handleChlickTab" style="width: 100%">
            <el-tab-pane label="定制品">
              <el-button
                type="primary"
                text
                icon="el-icon-view"
                @click="handleAddOrder"
                v-if="orderAdd"
                >新 增</el-button
              >
              <tablecmt
                class="tablesc"
                :columnList="columnListedit"
                :tableData="dataList"
                :loading="loading"
                @inputTxt="inputsc"
                @timeCheck="timesc"
                @btnCheck="btnsc"
                @selectCheck="selectsc"
                @selection="selectionChange"
              >
                <template #default="slotProps">
                  <el-button
                    v-if="slotProps.scope.row.isZero === '1'"
                    type="primary"
                    text
                    icon="el-icon-delete"
                    @click.stop="handleZeroOrder(slotProps.scope.row)"
                    >录入预约数量</el-button
                  >
                  <!-- <el-button
                    v-if="
                      slotProps.scope.row.isZero === '1' && Number(this.$route.query.type) !== 2
                    "
                    type="primary"
                    text  
                    icon="el-icon-delete"
                    @click.stop="handleStockZeroOrder(slotProps.scope.row)"
                    >维护在库数量</el-button
                  > -->
                  <el-button
                    type="primary"
                    text
                    icon="el-icon-delete"
                    @click="rowOrder(slotProps.scope.row)"
                    >移除</el-button
                  >
                  <!-- 零担订单时不能选择包件 -->
                  <el-button
                    v-if="Number(slotProps.scope.row.isZero) !== 1"
                    type="primary"
                    @click="handleChooseOrder(slotProps.scope.row)"
                    text
                    icon="el-icon-delete"
                    >选择包件</el-button
                  >
                </template>
              </tablecmt>
            </el-tab-pane>
            <el-tab-pane label="库存品" @tab-click="handleChlickTab">
              <el-button type="primary" text icon="el-icon-view" @click="handleAddView(row)"
                >新 增</el-button
              >
              <tablecmt
                class="tablesc"
                :columnList="columnStock"
                :tableData="data"
                :loading="loading"
                @inputTxt="inputsc"
                @timeCheck="timesc"
                @btnCheck="btnsc"
                @selectCheck="selectsc"
                @selection="selectionChange"
              >
                <template #default="slotProps">
                  <el-text
                    type="primary"
                    text
                    icon="el-icon-delete"
                    @click="rowStock(slotProps.scope.row)"
                    >移除</el-text
                  >
                </template>
              </tablecmt>
            </el-tab-pane>
          </el-tabs>
        </el-form-item>

        <el-row :gutter="20" class="toscontent">
          <el-col v-if="!view" :span="8">
            <el-form-item label="提货证件" label-width="120px">
              <el-upload
                v-model:file-list="fileListSell"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="
                  (response, file, fileList) => {
                    uploadSuccess(fileListSell);
                  }
                "
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col v-if="!view" :span="8">
            <el-form-item label="文员确定图片" label-width="120px">
              <el-upload
                v-model:file-list="fileListClerk"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="
                  (response, file, fileList) => {
                    uploadSuccess(fileListClerk);
                  }
                "
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col v-if="!view" :span="8">
            <el-form-item label="库管签收图片" label-width="120px">
              <el-upload
                v-model:file-list="fileListLibrary"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="
                  (response, file, fileList) => {
                    uploadSuccess(fileListLibrary);
                  }
                "
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div v-if="view">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="提货证件" label-width="120px">
              <el-upload
                v-model:file-list="fileListSell"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="
                  (response, file, fileList) => {
                    uploadSuccess(fileListSell);
                  }
                "
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="文员确定图片" label-width="120px">
              <el-upload
                v-model:file-list="fileListClerk"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="
                  (response, file, fileList) => {
                    uploadSuccess(fileListClerk);
                  }
                "
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="库管签收图片" label-width="120px">
              <el-upload
                v-model:file-list="fileListLibrary"
                class="upload-demo"
                :action="action"
                :headers="headers"
                multiple
                :on-preview="handlePreview"
                :on-success="
                  (response, file, fileList) => {
                    uploadSuccess(fileListLibrary);
                  }
                "
                :on-remove="handleRemove"
                list-type="picture"
              >
                <el-button type="primary" :disabled="!view">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </template>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </div>

      <!--      &lt;!&ndash; 表单按钮 &ndash;&gt; v-if="!view || viewSC"-->
      <div class="foot" :disabled="view">
        <div class="dialog-footer">
          <el-button type="primary" @click="lastpage" icon="CircleClose">返 回</el-button>
          <el-button type="primary" icon="el-icon-circle-check" @click="handleSubmit('form')">
            提 交
          </el-button>
          <!--          <el-button icon="el-icon-circle-close" @click="box = false">取 消</el-button>-->
        </div>
      </div>
    </div>

    <!-- 添加库存品 -->
    <el-dialog v-model="dialogFormVisible" title="添加库存品" style="width: 80%">
      <tablecmt
        class="addTable"
        :columnList="option.columnStock"
        :tableData="dataOwn"
        :loading="loading"
        @inputTxt="inputsc"
        @timeCheck="timesc"
        @btnCheck="btnsc"
        @selectCheck="selectsc"
        @selection="selectionChange"
      >
        <template #default="slotProps">
          <template v-if="slotProps.scope.column.label === '操作'">
            <div class="ElBtnClass">
              <el-button @click="view(slotProps.scope)">查看</el-button>
            </div>
          </template>

          <template v-if="slotProps.scope.column.label === '添加数量'">
            <!-- <el-input
              v-model="slotProps.scope.row.inventoryQuantity"
              @blur="handleNumberRange($event, slotProps)"
            ></el-input> -->
            <el-input-number
              v-model="slotProps.scope.row.inventoryQuantity"
              :precision="0"
              :min="0"
              :max="slotProps.scope.row.available"
              :step="1"
              @blur="handleNumberRange($event, slotProps)"
            />
          </template>
        </template>
      </tablecmt>

      <!-- <el-table
        ref="table"
        v-loading="loading"
        @selection-change="selectionChangeStock"
        @row-click="handleHighlightChangeTable"
        :data="dataOwn"
        style="width: 100%"
        :border="option.border"
      >
       <el-table-column
          type="selection"
          v-if="option.selection"
          width="50"
          align="center"
        ></el-table-column>
        <el-table-column type="expand" v-if="option.expand" align="center"></el-table-column>
        <el-table-column v-if="option.index" label="序号" type="index" width="70" align="center">
        </el-table-column>
        <template v-for="(item, index) in option.columnStock">

          <el-table-column
            v-if="item.hide !== true"
            :prop="item.prop"
            :label="item.label"
            :width="item.width"
            :key="index"
          >
          </el-table-column>
        </template>
        <el-table-column prop="menu" label="添加数量" :width="220" align="center">
          <template #="{ row }">
            <el-input
              v-model="row.inventoryQuantity"
              @blur="handleNumberRange($event, row)"
            ></el-input>
          </template>
        </el-table-column>
      </el-table> -->
      <div class="avue-crud__pagination" style="width: 100%">
        <!-- 分页模块 -->
        <el-pagination
          align="right"
          background
          @size-change="sizeChangeStock"
          @current-change="currentChangeStock"
          :current-page="pageStock.currentPage"
          :page-sizes="[30, 50, 80, 120]"
          :page-size="pageStock.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageStock.total"
        >
        </el-pagination>
      </div>

      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取消</el-button>
          <!--        <el-button type="primary" @click="dialogFormVisible = false"> 确定 </el-button>-->
          <el-button type="primary" @click="callFordelivery('1')"> 确定 </el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 添加订单 -->
    <el-dialog v-model="dialogFormOrderVisible" title="添加订单" style="width: 80%">
      <tablecmt
        class="addTable"
        ref="multipleTable"
        :columnList="columnList"
        :tableData="dataOrder"
        :loading="loading"
        @inputTxt="inputsc"
        @timeCheck="timesc"
        @btnCheck="btnsc"
        @selectCheck="selectsc"
        @selection="selectionChange"
      >
        <template #default="slotProps">
          <!--     <el-button type="primary" text icon="el-icon-view" @click="handleView(slotProps.scope)">查看</el-button>
          <el-button type="primary" text icon="el-icon-edit" @click="handleCallDeliveryOwn(slotProps.scope)">修改客户信息</el-button>-->
        </template>
      </tablecmt>
      <div class="avue-crud__pagination" style="width: 100%">
        <!-- 分页模块 -->
        <el-pagination
          align="right"
          background
          @size-change="sizeChangeOrder"
          @current-change="currentChangeOrder"
          :current-page="pageOrder.currentPage"
          :page-sizes="[30, 50, 80, 120]"
          :page-size="pageOrder.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageOrder.total"
        >
        </el-pagination>
      </div>

      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogFormOrderVisible = false">取消</el-button>
          <!--        <el-button type="primary" @click="dialogFormVisible = false"> 确定 </el-button>-->
          <el-button type="primary" @click="callFordeliveryOrder('1')"> 确定 </el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 零担订单信息修改 -->
    <el-dialog v-model="dialogFormZeroOrderVisible" title="零担订单信息" center style="width: 50%">
      <!-- <template v-if="zeroOrderFormList">
        <div style="display: flex; align-items: center; text-align: center">
          <div style="width: 120px; display: flex">名称</div>
          <div style="display: flex">数量</div>
        </div>
        <el-form-item
          :label="item.firsts"
          label-width="120px"
          v-for="item in zeroOrderFormList"
          :key="item"
        >
          <el-input-number :min="0" :max="item.maxNum" v-model="item.quantity" />
        </el-form-item>
      </template> -->

      <el-table :data="zeroOrderFormList" border style="width: 100%">
        <el-table-column fixed prop="firsts" label="名称" />
        <el-table-column prop="quantity" label="数量" />
        <el-table-column prop="libraryQuantity" label="在库数量" />
        <el-table-column prop="deliveryQuantity" label="冻结数量" />
        <!-- <el-table-column prop="deliveryQuantity" label="出库数量" /> -->
        <el-table-column label="可用数量">
          <template #default="props">
            <span> {{ props.row.libraryQuantity - props.row.deliveryQuantity }}</span>
          </template>
        </el-table-column>
        <!-- 在库=冻结-出库 -->

        <el-table-column fixed="right" label="数量操作">
          <template #default="scope">
            <el-input-number
              size="small"
              v-model="scope.row.tiQuantity"
              :min="0"
              :max="scope.row.maxNum"
            />
          </template>
        </el-table-column>
      </el-table>

      <div style="text-align: center">
        <el-button @click="dialogFormZeroOrderVisible = false">取消</el-button>
        <el-button type="primary" @click="handleRowZeroOrder">录入数量</el-button>
      </div>
    </el-dialog>

    <!-- 零担订单在库信息修改 -->
    <el-dialog v-model="zeroOrderVisible" title="零担品类信息" center width="50%">
      <div Class="iszer">
        <el-table :data="zeroOrderData" border style="width: 100%">
          <el-table-column fixed prop="firsts" label="名称" />
          <el-table-column prop="quantity" label="数量" />
          <el-table-column prop="libraryQuantity" label="在库数量" />
          <el-table-column prop="deliveryQuantity" label="冻结数量" />

          <el-table-column fixed="right" label="数量操作">
            <template #default="scope">
              <el-input-number
                size="small"
                v-model="scope.row.tiQuantity"
                :min="0"
                :max="scope.row.maxNum"
              />
            </template>
          </el-table-column>
        </el-table>
        <div style="text-align: center">
          <el-button icon="el-icon-circle-close" @click="zeroOrderVisible = false">返 回</el-button>
          <el-button icon="el-icon-check" color="#172e60" type="success" @click="onSubmitZeroOrder"
            >维护在库数量</el-button
          >
        </div>
      </div>
    </el-dialog>

    <!-- 选择包件 -->
    <!-- 此v-if解决关闭后选择不回显的问题 -->
    <template v-if="dialogChooseOrderVisible">
      <el-dialog v-model="dialogChooseOrderVisible" title="选择包件" center style="width: 80%">
        <tablecmt
          ref="orderChooseTable"
          :columnList="order.columnOrderList"
          :tableData="order.orderDetails"
          :checkselect="order.selectList"
          :loading="order.orderChooseLoading"
          @inputTxt="orderInputSc"
          @timeCheck="orderTimesc"
          @btnCheck="btnsc"
          @selectCheck="orderSelectSc"
          @selection="orderSelectChange"
        >
        </tablecmt>
        <div class="avue-crud__pagination" style="width: 100%">
          <!-- 分页模块 -->
          <el-pagination
            align="right"
            background
            @size-change="sizeChangeOrderChoose"
            @current-change="currentChangeOrderChoose"
            :current-page="order.currentPage"
            :page-sizes="[30, 50, 80, 120]"
            :page-size="order.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="order.total"
          >
          </el-pagination>
        </div>

        <template #footer>
          <span class="dialog-footer">
            <el-button @click="dialogChooseOrderVisible = false">取消</el-button>
            <!--        <el-button type="primary" @click="dialogFormVisible = false"> 确定 </el-button>-->
            <el-button type="primary" @click="handleChooseOrderConfirm()"> 确定 </el-button>
          </span>
        </template>
      </el-dialog>
    </template>
    <div class="LoadIMG">
      <el-dialog v-model="dialogImg">
        <img w-full :src="Imgurl" alt="Preview Image" />
      </el-dialog>
    </div>
  </basic-container>
</template>

<script>
import {
  getDetail,
  add,
  update,
  remove,
  zeroMaterial,
  zeroUpdateMaterial,
} from '@/api/distribution/distrilbutionBillLading';
import { ElMessage } from 'element-plus';
import { getListOwn, getList, getEditList } from '@/api/distribution/distributionParcelList';
import option from '@/option/distribution/distrilbutionBillLading';
import { mapGetters } from 'vuex';
import { getDictionaryBiz } from '@/api/system/dict';
import { getToken } from '@/utils/auth';
import { getListStockList } from '@/api/distribution/distributionStockList';
import { getListOne ,$_getListOne} from '@/api/distribution/distributionStockArticle';
import dayjs from 'dayjs';
import { detail } from '@/api/flow/flow';
import { nextTick, ref } from 'vue';
import { useStore } from 'vuex';
import { setNodeHeight } from '@/utils/util.js';
const $store = useStore();
export default {
  name: '/distribution/inventory/distrilbutionBillLading',
  data() {
    return {
      tabletit: '', //记录当前点击的标题栏
      dialogImg: false,
      Imgurl: undefined,
      Selfpickuploading: false, //页面加载
      OrdercolumnList: [
        {
          prop: 'serviceNumber',
          label: '服务号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: true,
          sortable: true,
          head: false,
        },
      ],
      zeroOrderFormList: [],
      dialogFormVisible: false,
      dialogFormOrderVisible: false, //订单详细
      dialogFormZeroOrderVisible: false, // 零担订单弹出层
      // 选择包件弹出层
      dialogChooseOrderVisible: false,
      height: 0,
      // 弹框标题
      title: '',
      // 是否展示弹框
      box: false,
      // 是否显示查询
      search: true,
      orderAdd: false,
      // 加载中
      loading: false,
      // 是否为查看模式
      view: false,
      // 是否为上传模式
      viewSC: false,
      // 查询信息
      query: {},
      queryOrder: {},
      dataOrder: [],
      // 分页信息
      page: {
        currentPage: 1,
        pageSize: 30,
        total: 0,
      },
      pageOrder: {
        currentPage: 1,
        pageSize: 30,
        total: 0,
      },
      // 分页信息
      pageStock: {
        currentPage: 1,
        pageSize: 30,
        total: 0,
      },
      pageOrderChoose: {
        currentPage: 1,
        pageSize: 30,
        total: 0,
      },
      // 表单数据
      form: { freightMark: [] },
      orderChooseId: '',
      // 选择行
      selectionList: [],
      stockupDate: [], // 时间
      selectionListStock: [], // 库存品选择

      // 表单配置
      option: option,
      // 表单列表
      data: [],
      dataList: [],
      dataOwn: [],
      clientType: [],
      costList: [],
      costListName: [],
      certificateType: [],
      fileListLibrary: [],
      fileListSell: [],
      fileListClerk: [],
      fileList: [
        //   {
        //   name: 'food.jpeg',
        //   url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
        // },
        //   {
        //     name: 'food2.jpeg',
        //     url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
        //   },
      ],
      rules: {
        pickUpTime: [
          { type: 'date', required: true, message: '请选择提货时间', trigger: 'change' },
        ],
        consignee: [
          { required: true, message: '请输入提货人', trigger: 'blur' },
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        pickUpPlate: [{ required: true, message: '请输入提货车牌号', trigger: 'change' }],
        deliveryDocument: [
          { required: false, message: '请输入提货证件码', trigger: 'change' },
          // { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        certificateType: [{ required: false, message: '请选择证件类型', trigger: 'change' }],
        freightMark: [{ required: true, message: '请选择费用', trigger: 'change' }],
        totalCost: [{ required: true, message: '请输入费用合计', trigger: 'change' }],
        deliveryDocuments: [{ required: true, message: '请上传提货证件', trigger: 'change' }],
      },
      columnList: [
        {
          prop: '',
          label: '序号',
          type: 0,
          values: '',
          width: 55,
          checkarr: [],
          fixed: true,
        },
        {
          prop: 'serviceNumber',
          label: '服务号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: true,
          sortable: true,
          head: false,
        },
        {
          prop: 'waybillNumber',
          label: '运单号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: true,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderCode',
          label: '订单自编号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'mallName',
          label: '商场名称',
          type: 2,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'descriptionGoods',
          label: '货物名称',
          type: 2,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'warehouse',
          label: '所在仓库',
          type: 2,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'warehouseEntryTime',
          label: '入库时间',
          type: 4,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'warehouseEntryTimeEnd',
          label: '最新入库时间',
          type: 4,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'storeTime',
          label: '在库时间',
          type: 1,
          values: '',
          width: '180',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'totalNumber',
          label: '订单总件数',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          isshowSummary: true,
        },
        {
          prop: 'handQuantity',
          label: '在库件数',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          isshowSummary: true,
          sortable: true,
        },

        {
          prop: 'consigneeUnit',
          label: '收货单位',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'consigneePerson',
          label: '收货人',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },

        // {
        //   prop: 'availableQuantity',
        //   label: '可用数量',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   isshowSummary: true,
        //   sortable: true,
        // },
        // {
        //   prop: 'notReceived',
        //   label: '未入库数量',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   isshowSummary: true,
        //   sortable: true,
        // },
        // {
        //   prop: 'sortingQuantity',
        //   label: '分拣数量',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   isshowSummary: true,
        //   sortable: true,
        // },
        // {
        //   prop: 'deliveryQuantity',
        //   label: '配送数量',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   isshowSummary: true,
        //   sortable: true,
        // },
        // {
        //   prop: 'transferQuantity',
        //   label: '中转数量',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   isshowSummary: true,
        //   sortable: true,
        // },
        // {
        //   prop: 'signinQuantity',
        //   label: '签收数量',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   isshowSummary: true,
        //   sortable: true,
        // },
        {
          prop: 'groundingStatusName',
          label: '上架状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'allocation',
          label: '货区-货位-货架',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'resource',
          label: '订单来源',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'trays',
          label: '所在托盘',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'freezeStatusName',
          label: '冻结状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [
            {
              value: '1',
              label: '已冻结',
            },
            {
              value: '0',
              label: '未冻结',
            },
          ],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'orderStatusName',
          label: '订单状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'reservationStatusName',
          label: '预约状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'stockupStatusName',
          label: '备货状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'completeSetName',
          label: '是否齐套',
          type: 3,
          values: '',
          width: '150',
          checkarr: [
            {
              value: '2',
              label: '是',
            },
            {
              value: '1',
              label: '否',
            },
          ],
          fixed: false,
          sortable: true,
        },
        // {
        //   prop: 'brand',
        //   label: '品牌',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // },
        // {
        //   prop: 'typeServerName',
        //   label: '服务类型',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // },
        {
          prop: 'notificationName',
          label: '通知状态',
          type: 3,
          values: '',
          width: '150',
          checkarr: [
            {
              value: '2',
              label: '已通知',
            },
            {
              value: '1',
              label: '未通知',
            },
          ],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'customerName',
          label: '顾客名字',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'customerTelephone',
          label: '顾客电话',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'customerAddress',
          label: '顾客地址',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'fee',
          label: '增值服务',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'createUserName',
          label: '创建人',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        {
          prop: 'createTime',
          label: '创建时间',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
        },
        // {
        //   prop: 'inventoryDate',
        //   label: '最新盘点时间',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // }, {
        //   prop: 'inventoryPerson',
        //   label: '盘点人',
        //   type: 1,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        // },
        // {
        //   prop: '',
        //   label: '操作',
        //   type: 6,
        //   values: '',
        //   width: '230',
        //   checkarr: [],
        //   fixed: 'right',
        //   hide: true,
        // },
        // 更多列的配置...
      ],
      columnListedit: [
        {
          prop: '',
          label: '序号',
          type: 0,
          values: '',
          width: 55,
          checkarr: [],
          fixed: true,
        },
        {
          prop: 'serviceNumber',
          label: '服务号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'waybillNumber',
          label: '运单号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageCode',
          label: '包条码',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderCode',
          label: '订单自编号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'mallName',
          label: '商场名称',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'descriptionGoods',
          label: '货物名称',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'warehouse',
          label: '所在仓库',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'warehouseEntryTime',
          label: '入库时间',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'warehouseEntryTimeEnd',
          label: '最新入库时间',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'storeTime',
          label: '在库时间',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'totalNumber',
          label: '订单总件数',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          isshowSummary: true,
          head: false,
        },
        {
          prop: 'handQuantity',
          label: '在库件数',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          isshowSummary: true,
          head: false,
        },
        {
          prop: 'reservationNum',
          label: '计划数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          isshowSummary: true,
          sortable: true,
        },
        {
          prop: 'consigneeUnit',
          label: '收货单位',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'consigneePerson',
          label: '收货人',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },

        // {
        //   prop: 'availableQuantity',
        //   label: '可用数量',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        //   isshowSummary: true,
        //   head: false,
        // },
        // {
        //   prop: 'notReceived',
        //   label: '未入库数量',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        //   isshowSummary: true,
        //   head: false,
        // },
        // {
        //   prop: 'sortingQuantity',
        //   label: '分拣数量',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        //   isshowSummary: true,
        //   head: false,
        // },
        // {
        //   prop: 'deliveryQuantity',
        //   label: '配送数量',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        //   isshowSummary: true,
        //   head: false,
        // },
        // {
        //   prop: 'transferQuantity',
        //   label: '中转数量',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        //   isshowSummary: true,
        //   head: false,
        // },
        // {
        //   prop: 'signinQuantity',
        //   label: '签收数量',
        //   type: 2,
        //   values: '',
        //   width: '150',
        //   checkarr: [],
        //   fixed: false,
        //   sortable: true,
        //   isshowSummary: true,
        //   head: false,
        // },
        {
          prop: 'groundingStatusName',
          label: '上架状态',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'allocation',
          label: '货区-货位-货架',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'resource',
          label: '订单来源',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'trays',
          label: '所在托盘',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'freezeStatusName',
          label: '冻结状态',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderStatusName',
          label: '订单状态',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'reservationStatusName',
          label: '预约状态',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'stockupStatusName',
          label: '备货状态',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'completeSetName',
          label: '是否齐套',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'notificationName',
          label: '通知状态',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'customerName',
          label: '顾客名字',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'customerTelephone',
          label: '顾客电话',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'customerAddress',
          label: '顾客地址',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'fee',
          label: '增值服务',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'createUserName',
          label: '创建人',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'createTime',
          label: '创建时间',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: '',
          label: '操作',
          type: 6,
          values: '',
          width: '300',
          checkarr: [],
          fixed: 'right',
          hide: true,
        },
      ],
      columnStock: [
        {
          prop: 'orderCode',
          label: '订单自编号',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: true,
          sortable: true,
          head: false,
        },
        {
          prop: 'marketName',
          label: '商场名称',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'descriptionGoods',
          label: '货物名称',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'cargoUnit',
          label: '货物单位',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'available',
          label: '可用数量',
          type: 2,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'inventoryQuantity',
          label: '添加数量',
          type: 10,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
          lessThanNum: 'available',
        },
        {
          prop: '',
          label: '操作',
          type: 6,
          values: '',
          width: '150',
          checkarr: [],
          fixed: 'right',
          hide: true,
        },
      ],
      order: {
        columnOrderList: [
          {
            label: '复选',
            prop: 'id',
            type: 0,
            values: '',
            width: '55',
            checkarr: [],
            fixed: true,
            sortable: true,
            head: false,
          },
          {
            label: '创建时间',
            prop: 'createTime',
            type: 4,
            values: '',
            width: '180',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '仓库',
            prop: 'warehouse',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '包条码',
            prop: 'orderPackageCode',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '货位信息',
            prop: 'goodsAllocation',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '所在托盘',
            prop: 'pallet',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '一级品',
            prop: 'firsts',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '二级品',
            prop: 'second',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '三级品',
            prop: 'thirdProduct',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '物料',
            prop: 'materialName',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '数量',
            prop: 'quantity',
            type: 1,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
          {
            label: '车次号',
            prop: 'trainNumber',
            type: 2,
            values: '',
            width: '150',
            checkarr: [],
            fixed: false,
            sortable: true,
            head: false,
          },
        ],
        // 列表数据
        orderDetails: [],
        // loading是否开启
        orderChooseLoading: false,
        query: {},
        packquery: {},
        // 当前页
        currentPage: 1,
        // 本页数
        pageSize: 30,
        // 总数
        total: 0,
        // 复选框选中数据
        selectList: [],
        /**
         * 修改 -- 原有数据
         */
        originalList: [],
        /**
         * 修改 -- 删除的数据
         */
        delList: [],
        /**
         * 修改 -- 新增的数据
         */
        newList: [],
      },
      // 零担在库录入弹窗开启
      zeroOrderVisible: false,
      zeroOrderData: [{}],
    };
  },
  mounted() {
    console.log('123 :>> ', 123);
    this.setTableHeight();

    this.init();

    if (this.$route.query.type == '2') {
      //查询提货编辑数据
      this.getDetailOen();
    } else if (this.$route.query.type == '1') {
      this.onLoad(this.page);
    } else if (this.$route.query.type == '3') {
      this.onLoadCj();
    } else if (this.$route.query.type == '4') {
      //查询提货编辑数据
      this.view = true;
      this.getDetailOen();
    }
    /**
     * 初始化获取本地缓存的编辑隐藏的列表
     *  固定搭配，不能更改
     */
    // let checkList=[]
    // this.columnList.map(item => {
    //     item.head = false;
    // });
    let checkListnewarr = this.$functions.getStorage(window.location.pathname + 'checkList');
    let flexListnewarr = this.$functions.getStorage(window.location.pathname + 'flexList');
    let sortlistnewarr = this.$functions.getStorage(window.location.pathname + 'sortlist');
    if (checkListnewarr) {
      this.columnList.map(item => {
        item.head = false;
      });
      checkListnewarr.map(ite => {
        this.columnList.map(item => {
          if (ite == item.label) {
            item.head = true;
          }
        });
      });
    } else {
      let arr = [];
      this.columnList.map(item => {
        if (item.head) {
          arr.push(item.label);
        }
      });
      this.$functions.setStorage(window.location.pathname + 'checkList', arr);
    }
    if (flexListnewarr) {
      this.columnList.map(item => {
        item.fixed = false;
      });
      flexListnewarr.map(ite => {
        this.columnList.map(item => {
          if (ite == item.label) {
            if (item.type == 6) {
              item.fixed = 'right';
            } else {
              item.fixed = true;
            }
          }
        });
      });
    } else {
      let arr = [];
      this.columnList.map(item => {
        if (item.fixed) {
          arr.push(item.label);
        }
      });
      this.$functions.setStorage(window.location.pathname + 'flexList', arr);
    }
    if (sortlistnewarr) {
      this.columnList.map(item => {
        item.sortable = false;
      });
      sortlistnewarr.map(ite => {
        this.columnList.map(item => {
          if (ite == item.label) {
            item.sortable = true;
          }
        });
      });
    } else {
      let arr = [];
      this.columnList.map(item => {
        if (item.sortable) {
          arr.push(item.label);
        }
      });
      this.$functions.setStorage(window.location.pathname + 'sortlist', arr);
    }
  },
  // watch: {
  //   '$route.query.id': {
  //     handler(newVal, oldVal) {
  //       if (this.$route.query.type == '2') {
  //         //查询提货编辑数据
  //         this.getDetailOen();
  //       } else if (this.$route.query.type == '1') {
  //         this.onLoad(this.page);
  //       } else if (this.$route.query.type == '3') {
  //         this.onLoadCj();
  //       }
  //     },
  //     deep: true,
  //     immediate: true,
  //   },
  // },
  computed: {
    ...mapGetters(['permission', 'tagWel', 'tagList', 'tag']),
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(',');
    },
    stockIds() {
      let ids = [];
      this.selectionListStock.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(',');
    },
    headers() {
      return {
        'Blade-Auth': 'Bearer ' + getToken(),
      };
    },
    action() {
      // return '/api/logpm-basicdata/common/uploadFile'
      return '/api/blade-resource/oss/endpoint/put-file';
    },
  },
  methods: {
    async setTableHeight() {
      await this.$nextTick();

      const _nodeList1 = document.querySelectorAll('.tablesc');
      const _nodeList2 = document.querySelectorAll('.addTable');
      setNodeHeight(_nodeList1, '600px');
      setNodeHeight(_nodeList2, '600px');
    },

    // 点击tab栏事件
    handleChlickTab(val) {
      this.tabletit = val.props.label;
      console.log(this.tabletit, '当前点击的标题栏');
      this.query = {}; //重置搜索参数

      this.setTableHeight();
    },
    showdrawer(value) {
      this.drawerShow = value;
    },
    /**
     * 弹窗的勾选回调，用于更改头部数组
     * 固定搭配，只需要更换   columnList
     */
    setnewcolum(newarr, headarr, type) {
      if (type == 1) {
        this.columnList = newarr;
        this.$functions.setStorage(window.location.pathname + 'checkList', headarr);
      } else if (type == 2) {
        this.columnList = newarr;
        this.$functions.setStorage(window.location.pathname + 'flexList', headarr);
      } else if (type == 3) {
        this.columnList = newarr;
        this.$functions.setStorage(window.location.pathname + 'sortlist', headarr);
      }
    },
    selectionsc(value) {
      console.log(value);
    },
    delectsolt(scope) {
      const { row } = scope;
      console.log(row);
    },
    editsolt(scope) {
      const { row } = scope;
      console.log(row);
    },
    btnsc(index, row) {
      console.log(index, row);
    },
    selectsc(index, row) {
      if (row.prop === 'freezeStatusName') {
        this.queryOrder['freezeStatus'] = index;
      } else if (row.prop === 'completeSetName') {
        this.queryOrder['completeSet'] = index;
      } else if (row.prop === 'reservationStatusName') {
        this.queryOrder['reservationStatus'] = index;
      } else if (row.prop === 'groundingStatusName') {
        this.queryOrder['groundingStatus'] = index;
      } else if (row.prop === 'stockupStatusName') {
        this.queryOrder['stockupStatus'] = index;
      } else if (row.prop === 'orderStatusName') {
        this.queryOrder['orderStatus'] = index;
      } else if (row.prop === 'notificationName') {
        this.queryOrder['notification'] = index;
      } else if (row.prop === 'typeName') {
        this.queryOrder['typeService'] = index;
      } else {
        this.queryOrder[row.prop] = index;
      }
      this.onLoadOrder(this.pageOrder);
    },
    timesc(index, row) {
      if (!!index) {
        index = dayjs(index).format('YYYY-MM-DD');
      }
      this.query[row.prop] = index;
      if (!index) {
        delete this.query[row.prop];
      }
      this.pageOrder.currentPage = 1;
      this.onLoadOrder(this.pageOrder, this.pageOrder);
    },
    inputsc(index, row) {
      this.query[row.prop] = index;
      this.pageOrder.currentPage = 1;
      if (this.tabletit == '库存品') {
        this.onLoadList(this.query);
      } else {
        this.onLoadOrder(this.pageOrder, this.query);
      }
    },
    orderInputSc(index, row) {
      console.log('123 :>> ', 123);
      this.order.query[row.prop] = index;
      const _type = this.$route.query.type;
      // 编辑状态
      if (Number(_type) === 2) {
        this.onLoadEditChoose();
      } else this.onLoadOrderChoose();
    },
    orderSelectSc(index, row) {
      console.log('index :>> ', index);
      console.log('row :>> ', row);
      // this.order.selectList = [];
    },
    orderSelectChange(list) {
      this.order.selectList = list;
    },
    orderTimesc(index, row) {
      if (!!index) {
        index = dayjs(index).format('YYYY-MM-DD');
      }
      this.order.query[row.prop] = index;
      if (!index) {
        delete this.query[row.prop];
      }
      const _type = this.$route.query.type;
      // 编辑状态
      if (Number(_type) === 2) {
        this.onLoadEditChoose();
      } else this.onLoadOrderChoose();
    },

    //查询提货详情信息
    getDetailOen() {
      this.orderAdd = true;
      getDetail(this.$route.query.id).then(res => {
        let s = res.data.data;
        console.log(res,'res');
        this.form = s;
        let f = [];
        if(s.chargeList){
          s.chargeList.forEach(c => {
          let a = this.clientType.find(i => c.cost == i.dictKey);

          if (!!c.cost && c.cost != '-1') {
            f.push(c.cost);
          }
          if (!!a) {
            a.remark = c.money.substring(0, c.money.lastIndexOf('.'));
            this.costList[c.cost] = a.remark;
          }
        });
        }

        this.form.freightMark = f;
        this.costListName = f;
        this.form.totalCost = s.totalCost.substring(0, s.totalCost.lastIndexOf('.'));
        this.dataList = s.stockArticleVOS;
        this.data = s.stockListVOS;
        this.data.forEach(i => {
          i.available = i.quantityStock - i.quantityOccupied;
        });
        if (!!s.printVOS) {
          let le1 = [];
          let le2 = [];
          let le3 = [];

          const genreMapping = {
            1: le1, // 提
            2: le2, // 文
            3: le3, // 库
          };
          s.printVOS.forEach(i => {
            if (i.genre in genreMapping) {
              const q = {
                name: i.siteName,
                url: i.site,
              };
              genreMapping[i.genre].push(q);
            }
          });

          this.fileListLibrary = genreMapping['3'];
          this.fileListSell = genreMapping['1'];
          this.fileListClerk = genreMapping['2'];
        }
        this.loading = false;
      });
    },
    //移除数据
    rowStock(row) {
      this.data.forEach(i => {
        if (i.id === row.id) {
          this.data;
        }
      });
      let id1 = this.data.findIndex(item => {
        if (item.id == row.id) {
          return true;
        }
      });
      this.data.splice(id1, 1);
    },
    //移除数据
    rowOrder(row) {
      this.dataList.forEach(i => {
        if (i.id === row.id) {
          this.dataList;
        }
      });
      let id1 = this.dataList.findIndex(item => {
        if (item.id == row.id) {
          return true;
        }
      });
      this.dataList.splice(id1, 1);
    },
    //订单选择确定
    callFordeliveryOrder() {
      console.log('111 :>> ', 111);
      let st = false;
      let sts = false;
      let ad = false;
      let consigneePerson = '';
      this.selectionList.some(i => {
        if (this.dataList.length > 0) {
          let w = this.dataList.find(c => {
            console.log('i :>> ', i);
            console.log('c :>> ', c);
            return c.consigneePerson == i.consigneePerson;
          });
          if (!w) {
            ad = true;
          }
        }
        if (i.reservationStatusName === '已预约') {
          st = true;
          this.$message.warning(i.orderCode + '已预约，请勿重复预约！！！');
        }
        if (!consigneePerson) {
          consigneePerson = i.consigneePerson;
        } else {
          if (consigneePerson != i.consigneePerson) {
            sts = true;
          }
        }
      });
      //待打开
      if (ad) {
        this.$message.warning('请选择同一收货人！！');
        return;
      }
      if (st) {
        return;
      }
      if (sts) {
        this.$message.warning('收货人不相同，请选择相同的收货人！！！');
        return;
      }

      let isa = false;
      this.selectionList.some(i => {
        let a = this.dataList.filter(ele => ele.id == i.id).length >= 1;
        if(!this.$route.query.id){
          i.reservationNum=i.handQuantity
        } 
       
        if (!a) {
          this.dataList.push(i);
        }
      });
      if (!isa) {
        this.dialogFormOrderVisible = false;
      }
    },
    //确定
    callFordelivery(inde) {
      if (!this.selectionList.length) {
        console.log(this.selectionListStock, '23');
        this.$message.warning('至少选择一条数据！');
        return;
      }
      let isa = false;
      this.selectionList.some(i => {
        if (parseInt(i.inventoryQuantity) > parseInt(i.quantityStock)) {
          // this.$message.warning("添加数量大于可以数量");
          isa = true;
          return;
        }
        let a = this.data.filter(ele => ele.id == i.id).length >= 1;
        if (!a) {
          this.data.push(i);
        } else if (a) {
          this.data.forEach(ii => {
            if (
              ii.id == i.id &&
              parseInt(ii.inventoryQuantity) + parseInt(i.inventoryQuantity) < ii.quantityStock
            ) {
              ii.inventoryQuantity = parseInt(ii.inventoryQuantity) + parseInt(i.inventoryQuantity);
            }
          });
        }
      });

      if (!isa) {
        this.dialogFormVisible = false;
      }
    },
    // 选择包件
    async handleChooseOrder(row) {
      console.log('row :>> ', row);
      // 页面类型
      const _type = this.$route.query.type;
      this.orderChooseId = row.id;
      // 编辑状态
      if (Number(_type) === 2) {
        await this.onLoadEditChoose({}, row);
      } else await this.onLoadOrderChoose();
      this.dialogChooseOrderVisible = true;
    },
    // 每页数量改变
    sizeChangeOrderChoose(size) {
      this.order.pageSize = size;
      ('');
      const _type = this.$route.query.type;
      // 编辑状态
      if (Number(_type) === 2) {
        this.onLoadEditChoose();
      } else this.onLoadOrderChoose();
    },
    // 页码改变
    currentChangeOrderChoose(current) {
      // console.log('current :>> ', current);
      this.order.currentPage = current;
      const _type = this.$route.query.type;
      // 编辑状态
      if (Number(_type) === 2) {
        this.onLoadEditChoose();
      } else this.onLoadOrderChoose();
    },
    // 请求包件数据 -- 新增
    async onLoadOrderChoose(params = {}) {
      this.order.orderChooseLoading = true;
      this.order.query.stockArticleId = this.orderChooseId;
      this.order.query.conditions = '1';
      this.order.query.orderPackageReservationStatus = '10';
      await getList(this.order.currentPage, this.order.pageSize, {
        ...params,
        ...this.order.query,
      }).then(res => {
        console.log('res :>> ', res);
        console.log(res.data.data.records, '获取到的包件');

        const data = res.data.data;
        this.order.total = data.total;
        this.order.orderDetails = data.records;
        this.order.orderChooseLoading = false;
        this.order.selectList = [];
        this.order.selectList = res.data.data.records; //包件自动勾选
        this.selectionClear();
      });
      return null;
    },
    /**
     * 请求包件数据 -- 修改
     */
    async onLoadEditChoose(params = {}, row) {
      this.order.orderChooseLoading = true;
      this.order.query.stockArticleId = this.orderChooseId;
      this.order.query.reservationId = this.$route.query.id;
      this.order.query.conditions = '1';
      await getEditList(this.order.currentPage, this.order.pageSize, {
        ...params,
        ...this.order.query,
      }).then(res => {
        console.log('res :>> ', res);
        const data = res.data.data;
        this.order.total = data.total;
        this.order.orderDetails = data.records;

        // 被选中的包件的id list
        row.originalIdList = [];

        // 回显
        this.order.selectList = this.order.orderDetails.filter(val => {
          console.log('val :>> ', val);
          if (val.choice) row.originalIdList.push(val.id);
          return val.choice;
        });
        // 深拷贝数据
        console.log('this.order.selectList :>> ', this.order.selectList);
        row.originalList = JSON.parse(JSON.stringify(this.order.selectList));
        this.order.orderChooseLoading = false;
      });
      return null;
    },
    /**
     * 确认选择包件
     */
    handleChooseOrderConfirm() {
      console.log('111 :>> ', 111);
      if (this.order.selectList.length === 0) {
        return this.$message({ type: 'warning', message: '最少选择一项数据' });
      }
      // billPackageEntityList
      console.log('this.order.dataList :>> ', this.dataList);
      this.dataList.find(val => val.id === this.orderChooseId).billPackageEntityList =
        this.order.selectList.map(val => {
          console.log('val :>> ', val);
          return {
            parceListId: val.id,
            stockArticleId: val.stockArticleId,
            packetBarCode: val.orderPackageCode,
          };
        });
      this.dialogChooseOrderVisible = false;
    },
    // 数量校验
    handleNumberRange(e, row) {
      console.log(e, 'ee=====');
      console.log(row, 'row====');
      if (row.scope.row.inventoryQuantity > row.scope.row.available) {
        this.$message.error('数量不能大于可用数量');
        row.scope.row.inventoryQuantity = 0;
        return;
      }
      // if (e.target.value) {
      //   e.target.value = e.target.value.replace(/[^\.\d]/g, ''); //替换掉与数字无关的字符（中英文与符号都会被替换掉，只留下数字，此时值类型为字符串）
      //   if (e.target.value) {
      //     //如果替换后还有值
      //     e.target.value = parseInt(e.target.value); //把字符型转成整数型
      //   }
      //   if (e.target.value > row.available) {
      //     this.$message.error('数量不能大于可用数量');
      //     return;
      //   }
      // }
    },
    uploadSuccess(fileList) {
      // this.form.fileName =
      // this.$set(row, 'imageCos', fileList);
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
      this.Imgurl = file.url;
      this.dialogImg = true;
    },
    textbox(e, index) {
      let nu = index + 1;
      let a = this.costListName[index];
      this.costList[nu] = e;
      if (!!a) {
        //计算合计费用
        let n = 0;
        this.costList.forEach(i => {
          n = n + (!!i ? parseInt(i) : 0);
        });
        this.form.totalCost = n;
      }
    },
    handleCheckedCitiesChange(value) {
      if (value.length < 1) {
        this.costListName = [];
      }
      this.clientType.forEach(i => {
        if (value.includes(i.dictKey)) {
          i.pitch = true;
          this.costListName = value;
        }
      });
      let n = 0;
      value.forEach(s => {
        let a = this.costList[s];
        if (!!a) {
          n = n + parseInt(a);
        }
      });
      this.form.totalCost = n;
    },
    init() {
      this.height = this.setPx(document.body.clientHeight - 160);
      //字典
      getDictionaryBiz('delivery_cost').then(res => {
        this.clientType = res.data.data;
      }); //字典
      getDictionaryBiz('certificate_type').then(res => {
        this.certificateType = res.data.data;
      });
      getDictionaryBiz('distribution_type').then(res => {
        this.distributionType = res.data.data;
      });
      getDictionaryBiz('logpm_unit').then(res => {
        //单位
        this.logpmUnit = res.data.data;
      });
      getDictionaryBiz('order_status').then(res => {
        this.deliveryOrderStatus = res.data.data;
        this.$functions.checkcColumnList('orderStatusName', this.columnList).checkarr =
          res.data.data.map(item => {
            item.value = item.dictKey;
            item.label = item.dictValue;
            return item;
          });
      });
      getDictionaryBiz('basic_grounding').then(res => {
        this.$functions.checkcColumnList('groundingStatusName', this.columnList).checkarr =
          res.data.data.map(item => {
            item.value = item.dictKey;
            item.label = item.dictValue;
            return item;
          });
      });
      getDictionaryBiz('freeze_status').then(res => {
        this.$functions.checkcColumnList('freezeStatusName', this.columnList).checkarr =
          res.data.data.map(item => {
            item.value = item.dictKey;
            item.label = item.dictValue;
            return item;
          });
      });
      getDictionaryBiz('stockup_status').then(res => {
        this.$functions.checkcColumnList('stockupStatusName', this.columnList).checkarr =
          res.data.data.map(item => {
            item.value = item.dictKey;
            item.label = item.dictValue;
            return item;
          });
      });
      getDictionaryBiz('order_reservation_status').then(res => {
        this.$functions.checkcColumnList('reservationStatusName', this.columnList).checkarr =
          res.data.data.map(item => {
            item.value = item.dictKey;
            item.label = item.dictValue;
            return item;
          });
      });
    },
    searchHide() {
      this.search = !this.search;
    },
    searchChange() {
      this.onLoad(this.page);
    },
    searchReset() {
      this.query = {};
      this.page.currentPage = 1;
      this.onLoad(this.page);
    },
    bianLier(costListName, clientType, costList, fei) {
      this.pan = false;
      for (let i = 0; i < costListName.length; i++) {
        if (!costList) {
          this.pan = true;
          return;
        }
        for (let a = 0; a < clientType.length; a++) {
          if (clientType[a].dictKey == costListName[i]) {
            let zhi = costList[costListName[i]];
            if (!zhi) {
              this.pan = true;
              continue;
            } else {
              //2.添加
              fei.set(clientType[a].dictKey, zhi);
            }
          }
        }
      }
    },
    lastpage(){
      this.$router.push('/distribution/inventory/distrilbutionBillLadingList')
    },
    // 最后提交
    async handleSubmit() {

      // console.log(this.dataList,'this.dataList');

      // if (this.$route.query.type !== '2') {
      //   // 当有零担订单物料数量没操作时
      //   const wrongZeroOrder = zeroOrderList.find(val => !val.ParcelLisList);
      //   console.log();
      //   console.log('zeroOrderList :>> ', zeroOrderList);
      //   console.log('wrongZeroOrder :>> ', wrongZeroOrder);
      //   if (wrongZeroOrder) {
      //     return this.$message({
      //       type: 'error',
      //       message: `订单自编号为${wrongZeroOrder.orderCode}的物料数量未编辑`,
      //     });
      //   }
      //   if (zeroOrderList) {
      //     // 双层循环查看每一个物料数量是否被填写
      //     const isSubmit = zeroOrderList.every(item => {
      //       return item.ParcelLisList.every(val => val.quantity);
      //     });
      //     if (!isSubmit)
      //       return this.$message({
      //         type: 'error',
      //         message: '有零担物料未填写',
      //       });
      //   }
      //   // if ()
      // }



      this.$refs.form.validate(async valid => {





        if (valid) {

          if(!this.dataList.length){
          return ElMessage({
              message: '请选择定制品',
              type: 'warning',
            });
        }


        let resState=this.dataList.find(res=>!res.reservationNum)
        console.log(resState,'123');
        if(resState){
       return ElMessage({
          message: `单自编号为${resState.orderCode}的计划数量为0请移除或者重新录入预约数量`,
          type: 'warning',
         plain: true,
        })
        }

        const zeroOrderList = this.dataList.filter(val => val.isZero === '1');
        if (this.data.length) {
          const allQuantitiesAreFalsy = this.data.every(item => item.inventoryQuantity);
          console.log(allQuantitiesAreFalsy, 'allQuantitiesAreFalsy');
          if (!allQuantitiesAreFalsy) {
            return ElMessage({
              message: '请移除添加数量为0的订单',
              type: 'warning',
            });
         
          }
        }




          if (!this.form.id) {
  
            // if (this.fileListSell.length === 0) {
            //   this.$message.warning('请上传提货证件！！！');
            //   return;
            // }
            let fei = new Map();
            console.log('123 :>> ', 123);
            this.bianLier(this.costListName, this.clientType, this.costList, fei);
            console.log('321 :>> ', 321);
            this.form.fei = Object.fromEntries(fei);

            // 检测费用信息
            if (Object.keys(this.form.fei).length === 0) {
              return this.$message.warning('请选择并填写费用信息！！！');
            } else {
              // if ()
              let _flag = false;
              for (const iterator of this.form.freightMark) {
                if (!this.form.fei[iterator]) {
                  console.log('iterator :>> ', iterator);
                  _flag = true;
                  break;
                }
              }

              if (_flag) return this.$message.warning('请填写正确的费用信息！！！');
            }
            this.form.stockArticleId = !this.$route.query.id ? null : this.$route.query.id; //订单ID
            this.form.stockDTOList = this.data;
            let o = [];
            if (this.fileListClerk.length > 0) {
              this.fileListClerk.forEach(i => {
                let num = {};
                num.state = '2';
                num.name = i.name;
                num.url = i.response.data.link;
                o.push(num);
              });
            }
            if (this.fileListLibrary.length > 0) {
              this.fileListLibrary.forEach(i => {
                let num = {};
                num.state = '3';
                num.name = i.name;
                num.url = i.response.data.link;
                o.push(num);
              });
            }
            if (this.fileListSell.length > 0) {
              this.fileListSell.forEach(i => {
                let num = {};
                num.state = '1';
                num.name = i.name;
                num.url = i.response.data.link;
                o.push(num);
              });
            }
            this.form.printList = o.length > 0 ? o : [];
            if (this.dataList.length === 0 && this.data.length === 0) {
              this.$message.warning('请填写需要自提的物品！！');
            }
            if (this.orderAdd && this.dataList.length > 0) {
              let a = this.dataList.map(i => i.id);
              this.form.stockArticleId =
                this.form.stockArticleId != null
                  ? this.form.stockArticleId + a.join(',')
                  : a.join(',');
            } 
            // ParcelLisList
            const submitFormData = this.form;
            // 当有零担数据时
            console.log(zeroOrderList,'zeroOrderList');
            if (zeroOrderList.length !== 0) {
              console.log(zeroOrderList,'zeroOrderList222');
              // console.log(1);
              submitFormData.parcelLisList = [];
              submitFormData.zeroType = '2';
              zeroOrderList.forEach(valE => {
                console.log(valE,'valE==>');
                if(valE.ParcelLisList){
                  if(valE.ParcelLisList.length){
                     submitFormData.parcelLisList = [...submitFormData.parcelLisList, ...valE.ParcelLisList];
                }
                } 
             
              });
              // submitFormData.parcelLisList.forEach(val => (val.quantity = val.tiQuantity));
            } else {
              submitFormData.zeroType = '1';
            }

            let _billPackageEntityList = [];
            // submitFormData.billPackageEntityList
            this.dataList.forEach(val => {
              console.log('val :>> ', val);
              if (val.billPackageEntityList && val.billPackageEntityList.length !== 0)
                _billPackageEntityList = [..._billPackageEntityList, ...val.billPackageEntityList];
            });
            submitFormData.billPackageEntityList = _billPackageEntityList;
            // SM24010411
            console.log(submitFormData,'submitFormData');
            this.Selfpickuploading = true; //开启加载效果
        
            add(submitFormData)
              .then(res => {
                this.Selfpickuploading = false; //开启加载效果
                this.box = false;
                this.onLoad(this.page);
                this.$message({
                  type: 'success',
                  message: '操作成功!',
                });
                this.contextmenuFlag = false;
                this.Selfpickuploading = false; //关闭加载效果
                console.log(this.Selfpickuploading, '当前状态');
                this.$store.commit('DEL_TAG_CURRENT');
                this.$router.push('/distribution/inventory/distrilbutionBillLadingList');
              })
              .catch(res => {
                this.Selfpickuploading = false; //开启加载效果
              });
          } else {
            console.log('111 :>> ', 111);
            // return
            let fei = new Map();
            this.bianLier(this.costListName, this.clientType, this.costList, fei);
            this.form.fei = Object.fromEntries(fei);
            console.log('this.form.fei :>> ', this.form.fei);

            // 检测费用信息
            if (Object.keys(this.form.fei).length === 0) {
              return this.$message.warning('请选择并填写费用信息！！！');
            } else {
              // if ()
              let _flag = false;
              for (const iterator of this.form.freightMark) {
                if (!this.form.fei[iterator]) {
                  console.log('iterator :>> ', iterator);
                  _flag = true;
                  break;
                }
              }

              if (_flag) return this.$message.warning('请填写正确的费用信息！！！');
            }
             
            this.form.stockDTOList = this.data;
            let o = [];
            const fileListMapping = {
              fileListClerk: '2', // 文员
              fileListLibrary: '3', // 库管
              fileListSell: '1', // 提货
            };
            let mark = false;
            Object.entries(fileListMapping).forEach(([fileList, state]) => {
              if (this[fileList].length > 0) {
                this[fileList].forEach(i => {
                  let num = {
                    state,
                  };
                  if (!!i.response) {
                    num.name = i.name;
                    num.url = i.response.data.link;
                    mark = true;
                  } else {
                    num.name = i.name;
                    num.url = i.url;
                  }
                  o.push(num);
                });
              }
            });
            this.form.printList = o.length > 0 ? o : [];
            let up = {};
            up.printList = o.length > 0 ? o : [];
            up.fei = this.form.fei;
            up.stockDTOList = this.form.stockDTOList;
            up.id = this.form.id;
            up.pickUpPlate = this.form.pickUpPlate;
            up.pickUpTime = this.form.pickUpTime;
            up.consignee = this.form.consignee;
            up.deliveryDocument = this.form.deliveryDocument;
            up.certificateType = this.form.certificateType;
            up.totalCost = this.form.totalCost;
            up.mark = mark;
            up.stockArticleList = this.dataList;
            // 当有零担数据时
            if (zeroOrderList.length !== 0) {
              console.log(1);
              up.parcelLisList = [];
              up.zeroType = '2';
              zeroOrderList.forEach(val => {
                if (val.ParcelLisList) {
                  up.parcelLisList = [...up.parcelLisList, ...val.ParcelLisList];
                }
                // val.ParcelLisList.forEach(item => {
                //   up.parcelLisList.push(item);
                // });
              });
            } else {
              up.zeroType = '1';
            }
            // 新增列表
            let _billPackageEntityList = [];
            // 删除列表
            let _unBillPackageEntityList = [];
            // submitFormData.billPackageEntityList
            this.dataList.forEach(val => {
              if (val.originalIdList) {
                val.billPackageEntityList.forEach(item => {
                  // 新增
                  if (!val.originalIdList.includes(item.parceListId)) {
                    _billPackageEntityList.push(item);
                  }
                });
                // 删除
                val.originalList.forEach(item => {
                  const _flag = val.billPackageEntityList.findIndex(
                    value => value.parceListId === item.id
                  );
                  if (_flag === -1) {
                    _unBillPackageEntityList.push({
                      parceListId: item.id,
                      stockArticleId: item.stockArticleId,
                      packetBarCode: item.orderPackageCode,
                    });
                  }
                });
              }
            });
            up.billPackageEntityList = _billPackageEntityList;
            up.unBillPackageEntityList = _unBillPackageEntityList;
            this.Selfpickuploading = true; //开启加载效果
            update(up)
              .then(() => {
                this.Selfpickuploading = false; //开启加载效果
                this.$message({
                  type: 'success',
                  message: '操作成功!',
                });
                this.Selfpickuploading = false; //关闭加载效果
                this.$store.commit('DEL_TAG_CURRENT');
                this.$router.push('/distribution/inventory/distrilbutionBillLadingList');
              })
              .catch(res => {
                this.Selfpickuploading = false; //开启加载效果
              });
            return;
          }
        }
      });
    },
    findTag(fullPath) {
      let tag = this.tagList.find(item => item.fullPath === fullPath);
      let key = this.tagList.findIndex(item => item.fullPath === fullPath);
      return { tag, key };
    },
    handleAdd() {
      this.title = '新增';
      this.form = {};
      this.box = true;
    },
    handleEdit(row) {
      this.title = '编辑';
      this.box = true;
      getDetail(row.id).then(res => {
        this.form = res.data.data;
      });
    },
    handleView(row) {
      this.title = '查看';
      this.view = true;
      this.box = true;
      getDetail(row.id).then(res => {
        this.form = res.data.data;
      });
    },
    //查询自提订单
    handleAddOrder() {
      this.selectionList = [];
      this.dialogFormOrderVisible = true;
      //查询自提订单
      this.onLoadOrder(this.pageOrder);

      this.setTableHeight();
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    onLoadOrder(page, params = {}) {
      this.loading = true;
      if (this.stockupDate.length > 0) {
        let startDate = this.stockupDate[0];
        let entDate = this.stockupDate[1];
        params.startDate = this.getTime(startDate.toString());
        params.entDate = this.getTime(entDate.toString());
      }
      params.genre = 1;
      params.typeService = 3;
      params.isAll = 0;
      $_getListOne(page.currentPage, page.pageSize, Object.assign(params, this.queryOrder)).then(
        res => {
          console.log(res,'res===>');
          if(res.data.code !=200 || !res.data.data){
            
            return
          }
          const data = res.data.data;
          this.pageOrder.total = data.total || 0;
          this.dataOrder = data.records || [];
          this.dataOrder = this.dataOrder.map(i => {
            const notificationMap = {
              1: '已通知',
              2: '未通知',
              default: '无',
            };
            const nuMap = {
              '-1': '0',
            };
            i.notificationName = notificationMap[i.notification] || notificationMap.default;
            i.handQuantity = nuMap[i.handQuantity] || i.handQuantity;
            i.sortingQuantity = nuMap[i.sortingQuantity] || i.sortingQuantity;
            i.deliveryQuantity = nuMap[i.deliveryQuantity] || i.deliveryQuantity;
            i.signinQuantity = nuMap[i.signinQuantity] || i.signinQuantity;
            i.transferQuantity = nuMap[i.transferQuantity] || i.transferQuantity;
            i.availableQuantity = nuMap[i.availableQuantity] || i.availableQuantity;
            i.notReceived = parseInt(i.totalNumber) - parseInt(i.handQuantity);
            return i;
          });
          this.dataOrder.forEach(i => {
            let asas = this.dataList.find(l => l.id == i.id);
            if (!!asas) {
              this.selectionList.push(i.id);
            }
          });
          this.$nextTick(() => {
            this.toggleSelection(this.selectionList);
          });
          this.loading = false;
          this.selectionClear();
        }
      ).catch(res=>{

      }).finally(()=>{
        this.loading = false;
      });
    },
    //库存品
    handleAddView(row) {
      if (this.dataList.length === 0) {
        return this.$message.warning('请选择最少一条定制品');
      }
      this.selectionList = [];
      this.dialogFormVisible = true;
      this.onLoadList();

      this.setTableHeight();
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.selectionClear();
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!',
          });
        });
    },
    rowDel(row) {
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: 'success',
            message: '操作成功!',
          });
        });
    },
    beforeClose(done) {
      done();
      this.form = {};
      this.view = false;
    },
    selectionChange(list) {
      console.log(list, '勾选的数据');
      this.selectionList = list;
    },
    handleHighlightChangeTable(row) {
      if (!row.disabled) {
        this.$refs.table.toggleRowSelection(row);
      }
    },
    selectionChangeStock(list) {
      this.selectionListStock = list;
    },
    selectionClear() {
      this.selectionList = [];
      // this.$refs.table.clearSelection();
    },
    // 库存品新增 -- 页码改变
    currentChangeStock(currentPage) {
      this.pageStock.currentPage = currentPage;
      this.onLoadList();
    },
    sizeChangeStock(pageSize) {
      this.pageStock.pageSize = pageSize;
      this.onLoadList();
    },
    // 定制品新增 -- 页码改变
    currentChangeOrder(currentPage) {
      this.pageOrder.currentPage = currentPage;
      this.onLoadOrder(this.pageOrder);
    },
    sizeChangeOrder(pageSize) {
      this.pageOrder.pageSize = pageSize;
      this.onLoadOrder(this.pageOrder);
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page);
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      this.onLoad(this.page);
    },

    onLoad(page, params = {}) {
      this.loading = true;
      params.ids = this.$route.query.id;
      this.orderAdd = false;
      getListOne(page.currentPage, page.pageSize, params).then(res => {
        console.log('执行了二次操作');
        const data = res.data.data;
        this.dataList = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    /**
     * 创建自提
     * @param page
     * @param params
     */
    onLoadCj(page, params = {}) {
      this.orderAdd = true;
    },
    //库存品
    onLoadList(dataso) {
      console.log('111 :>> ', 111);
      this.loading = true;
      let a = {};
      if (this.$route.query.type == '1') {
        a = this.dataList[0];
      } else if (this.$route.query.type === '2') {
        a = this.dataList[0];
      } else if (this.$route.query.type == '3') {
        a = this.dataList[0];
      }
      console.log('a :>> ', a);
      console.log(' this.dataOrder :>> ', this.dataOrder);
      // let a = this.dataList[0];
      if (!!a.mallId) {
        // params.marketId = a.mallId;
        // params.warehouseId = a.warehouseId;
        let data = {
          current: this.pageStock.currentPage,
          size: this.pageStock.pageSize,
          marketId: a.mallId,
          warehouseId: a.warehouseId,
          ...dataso,
        };
        console.log(data, '处理好的值');
        // return
        getListStockList(data).then(res => {
          const dataOwn = res.data.data;
          this.pageStock.total = dataOwn.total;
          this.dataOwn = dataOwn.records;
          this.dataOwn.forEach(i => {
            i.available = i.quantityStock - i.quantityOccupied;
          });
          this.loading = false;
          this.selectionClear();
        });
      } else {
        this.$message({
          type: 'warning',
          message: '无法获取商场信息',
        });
        this.loading = false;
        this.pageStock.total = 0;
      }
    },
    //包件信息
    onLoadOwn(page, params = {}) {
      this.loading = true;
      this.query.stockArticleIds = this.$route.query.id;
      getListOwn(page.currentPage, page.pageSize, { ...params, ...this.query }).then(res => {
        const dataList = res.data.data;
        this.page.total = dataList.total;
        this.dataList = dataList.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    // 开启修改零担弹框
    async handleZeroOrder(row) {
      console.log('this.zeroOrderVisible :>> ', this.zeroOrderVisible);

      const handleParcelLisList = this.dataList.find(val => val.id === row.id).ParcelLisList;
      // 当此次为二次修改时, 不进行请求
      if (handleParcelLisList) {
        this.zeroOrderFormList = handleParcelLisList;
        this.dialogFormZeroOrderVisible = true;
        return;
      }

      // 请求零担数据详情
      const res = await zeroMaterial({
        stockArticleId: row.id,
        reservationId: this.$route.query.id,
      });
      console.log('res :>> ', res);
      const { code, data } = res.data;
      if (code === 200) {
        this.zeroOrderFormList = data.map(val => {
          // zeroOrder = {
          //   stockArticleId: val.stockArticleId,
          //   // 物料id
          //   id: val.id,
          //   // 物料最大限数
          //   maxNum: val.quantity,
          //   // 物料件数
          //   quantity: val.quantity,
          //   // 物料名称
          //   firsts: val.firsts,
          // };
          const zeroOrder = val;
          // 记录传入行的id   
          zeroOrder.stockArticleId = val.stockArticleId;
          // 物料最大限数
          zeroOrder.maxNum = val.libraryQuantity - val.deliveryQuantity;
          // 新增时, 检测是否齐套
          // if (row.completeSetName !== '是' && Number(this.$route.query.type) === 3){
          //   zeroOrder.tiQuantity =zeroOrder.tiQuantity;
          //   console.log('a=>>>>');
          // }
         
          // else if (val.deliveryQuantity && Number(this.$route.query.type) === 2) {
          //   zeroOrder.tiQuantity = val.tiQuantity;
          //   console.log('b=>>>>');
          // }
          return zeroOrder;
        });
      }
      // 开启零担蒙层弹窗
      this.dialogFormZeroOrderVisible = true;
    },
    // 修改零担零担信息
    handleRowZeroOrder() {
      console.log(this.zeroOrderFormList,'12121212');
      let sum =0
      this.zeroOrderFormList.forEach(res=>{
        sum+= res.tiQuantity
      })
      console.log(sum,'总和');
      this.dataList.find(res=>res.id==this.zeroOrderFormList[0].stockArticleId).reservationNum=sum

     
      // 将修改的零担信息存入dataList中
      this.dataList.find(val => val.id === this.zeroOrderFormList[0].stockArticleId).ParcelLisList = this.zeroOrderFormList;
      

      // 关闭零担蒙层弹框
      this.dialogFormZeroOrderVisible = false;

    },
    /**
     * 显示维护在库零担数量
     */
    async handleStockZeroOrder(row) {
      // 请求零担数据详情
      const res = await zeroMaterial({
        stockArticleId: row.id,
        reservationId: this.$route.query.id,
      });
      console.log('res :>> ', res);
      const { code, data } = res.data;
      if (code === 200) {
        this.zeroOrderData = data.map(val => {
          // zeroOrder = {
          //   stockArticleId: val.stockArticleId,
          //   // 物料id
          //   id: val.id,
          //   // 物料最大限数
          //   maxNum: val.quantity,
          //   // 物料件数
          //   quantity: val.quantity,
          //   // 物料名称
          //   firsts: val.firsts,
          // };
          const zeroOrder = val;
          // 记录传入行的id
          zeroOrder.stockArticleId = val.stockArticleId;
          // 物料最大限数 (总数减去冻结数量)
          zeroOrder.maxNum = val.quantity - val.deliveryQuantity;
          // 新增时, 检测是否齐套
          zeroOrder.tiQuantity = val.libraryQuantity;
          return zeroOrder;
        });
        console.log('this.zeroOrderFormList :>> ', this.zeroOrderFormList);
      }
      // 开启零担蒙层弹窗
      this.zeroOrderVisible = true;
    },
    /**
     * 在库零担维护提交
     */
    async onSubmitZeroOrder() {
      try {
        if (this.zeroOrderData.length === 0) {
          return (this.zeroOrderVisible = false);
        }
        const submitData = {
          stockArticleId: this.zeroOrderData[0].stockArticleId,
          distributionParcelListZeroVO: [],
        };
        submitData.distributionParcelListZeroVO = this.zeroOrderData.map(val => {
          val.TiQuantity = val.tiQuantity;
          return val;
        });

        const res = await zeroUpdateMaterial(submitData);
        const { code } = res.data;
        if (code === 200) {
          this.$message.success(res.data.msg);
        }
      } catch (error) {
        console.log('error :>> ', error);
      } finally {
        this.zeroOrderVisible = false;
      }
    },
  },
};
</script>
<style>
.foot {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 999;
  height: 60px;
}
.foot .dialog-footer {
  margin-bottom: 130px;
  text-align: center;
}
.ca .el-radio__inner {
  top: -18px;
  left: -19px;
  border-radius: 0;
  border: 0;
  width: 170px;
  height: 34px;
  background-color: transparent;
  cursor: pointer;
  box-sizing: border-box;
  position: absolute;
}

.ca .el-radio__input.is-checked .el-radio__inner {
  background: transparent;
}
</style>

<style scoped lang="scss">
:deep(.el-date-editor.el-input, .el-date-editor.el-input__wrapper) {
  height: 100% !important;
}

.el-checkbox {
  margin-left: 0;
}

.el-input-number {
  width: 100%;
}

.toscontent {
  :deep(.el-form-item__content) {
    height: 200px;
    overflow-y: scroll;
    align-items: flex-start;
  }
  :deep(.el-tabs) {
    height: 100% !important;
  }
}
.LoadIMG {
  img {
    width: 100%;
    height: 100%;
  }
}
</style>
