<template>
  <basic-container>
    <div class="avue-crud">
      <el-divider>托 盘 信 息</el-divider>
      <!--      <avue-form :option="propertyoption"  ref="myForm" v-model="dataForm"  @row-update="rowUpdate" >-->
      <!--        <template #input="{row}">-->
      <!--          <el-tag>序号:{{row.$index}}-数据:{{row.input}}</el-tag>-->
      <!--        </template>-->
      <!--      </avue-form>-->
      <el-row :gutter="24" class="rows">
        <el-col :xl="7" :lg="7" :md="8" :sm="24">
          <span>托盘码：{{ traydata.palletCode }} </span>
        </el-col>
        <el-col :xl="7" :lg="7" :md="8" :sm="24">
          <span>类 型：{{ traydata.$type }} </span>
        </el-col>
      </el-row>

      <el-divider>历 史 在 托 货 物</el-divider>
      <el-tabs type="border-card" v-model="activeTab" @tab-click="handleTabClick">
        <el-tab-pane label="包 件 列 表" name="tab1">
          <!-- 列表模块 -->
          <tablecmt
            :columnList="wrapoptioncolumn"
            :tableData="packdata"
            :loading="loading"
            @inputTxt="inputsc"
            @timeCheck="timesc"
            @btnCheck="btnsc"
            @selectCheck="selectsc"
            @selection="selectionChange"
          >
            <template #default="slotProps">
              <!-- <el-text
                type="primary"
                text
                icon="el-icon-view"
                @click="handlePrintDetail(slotProps.scope.row)"
                >打印</el-text
              > -->
            </template>
          </tablecmt>
          <div class="avue-crud__pagination" style="width: 100%">
            <!-- 分页模块 -->
            <el-pagination
              align="right"
              background
              @size-change="psizeChange"
              @current-change="pcurrentChange"
              :current-page="packpage.currentPage"
              :page-sizes="[30, 50, 80, 120]"
              :page-size="packpage.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="packpage.total"
            >
            </el-pagination>
          </div>
        </el-tab-pane>
        <el-tab-pane label="库 存 品 列 表" name="tab2">
          <!-- 列表模块 -->
          <tablecmt
            :columnList="inventoryoptioncolumn"
            :tableData="inventorydata"
            :loading="loading"
            @inputTxt="inputsc"
            @timeCheck="timesc"
            @btnCheck="btnsc"
            @selectCheck="selectsc"
            @selection="selectionChange"
          >
            <template #default="slotProps">
              <!-- <el-text
                type="primary"
                text
                icon="el-icon-view"
                @click="handlePrintDetail(slotProps.scope.row)"
                >打印</el-text
              > -->
            </template>
          </tablecmt>

          <div class="avue-crud__pagination" style="width: 100%">
            <!-- 分页模块 -->
            <el-pagination
              align="right"
              background
              @size-change="isizeChange"
              @current-change="icurrentChange"
              :current-page="inventorypage.currentPage"
              :page-sizes="[30, 50, 80, 120]"
              :page-size="inventorypage.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="inventorypage.total"
            >
            </el-pagination>
          </div>
        </el-tab-pane>
        <el-tab-pane label="零 担 列 表" name="tab3">
          <!-- 列表模块 -->
          <tablecmt
            :columnList="optioncolumn"
            :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-view"
                @click="handlePrintDetail(slotProps.scope.row)"
                >打印</el-text
              > -->
            </template>
          </tablecmt>
          <div class="avue-crud__pagination" style="width: 100%">
            <!-- 分页模块 -->
            <el-pagination
              align="right"
              background
              @size-change="sizeChange"
              @current-change="currentChange"
              :current-page="page.currentPage"
              :page-sizes="[30, 50, 80, 120]"
              :page-size="page.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="page.total"
            >
            </el-pagination>
          </div>
        </el-tab-pane>
      </el-tabs>

      <el-row> </el-row>
    </div>
  </basic-container>
</template>

<script>
import {
  getDetail,
  add,
  update,
  remove,
  getpackListhistory,
  getinventoryListhistory,
  getlclListhistory,
} from '@/api/basicdata/basicdataTray';

import option from '@/option/basic/basicPdarecords';
import { mapGetters } from 'vuex';
import { getDictionaryBiz } from '@/api/system/dict';
import dayjs from 'dayjs';

export default {
  data() {
    return {
      height: 300,
      // 弹框标题
      title: '',
      signtitle: '',
      // 是否展示弹框
      box: false,
      //签收是否显示
      signBox: false,
      //签收类型
      signBoxO: false,
      dataForm: {},
      // 是否显示查询
      search: true,
      //是否显示新增
      isadd: false,
      traydata: {},
      // 加载中
      loading: true,
      //查看按钮
      edt: false,
      activeTab: 'tab1',
      previousTab: null,
      trayId: null,
      //隐藏
      pake: false,
      cus: true,
      ord: false,
      inventory: false,
      //查看pda
      padview: false,
      // 是否为查看模式。。
      view: false,
      // 签收。。
      signView: false,
      // 查询信息
      query: {},
      inputTypeData: [],
      // 分页信息
      page: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      // 表单数据
      form: {},
      // 签收表单数据
      signform: {},
      // 选择行
      selectionList: [],
      isLiabilityData: [],
      //状态列表
      stateData: [],
      // 表单配置
      option: {
        expand: false,
        index: true,
        border: true,
        selection: true,
        column: [
          {
            label: '经销商名称',
            prop: 'dealerName',
            search: true,
            width: '100px',
          },
          {
            label: '运单号',
            prop: 'waybillNumber',
            search: true,
            width: '100px',
          },
          {
            label: '经销商编码',
            prop: 'dealerCode',
            search: true,
            width: '100px',
          },
          {
            label: '运单收货人',
            prop: 'consigneePerson',
            search: true,
            width: '100px',
          },
          {
            label: '运单收货地址',
            prop: 'consigneeAddress',
            search: true,
            width: '100px',
          },

          {
            label: '运单收货电话',
            prop: 'consigneeMobile',
            search: true,
            width: '100px',
          },
          {
            label: '货位信息',
            prop: 'goodsAllocationName',
            search: true,
            width: '100px',
          },
          {
            label: '所在列',
            prop: 'columnNum',
            search: true,
            width: '100px',
          },
          {
            label: '所在行',
            prop: 'layerNum',
            search: true,
            width: '100px',
          },
          {
            label: '关系类型',
            prop: 'bindingType',
            width: '100px',
          },
          {
            label: '操作时间',
            prop: 'operateTime',
            width: '100px',
          },
          {
            label: '操作人',
            prop: 'operateUserName',
            width: '100px',
          },
          {
            label: '操作数量',
            prop: 'num',
            width: '100px',
          },
        ],
      },

      // 表单配置
      wrapoption: {
        expand: false,
        index: true,
        border: true,
        selection: true,
        column: [
          {
            label: '服务号',
            prop: 'serviceNumber',
            search: true,
            width: '100px',
          },
          {
            label: '运单号',
            prop: 'waybillNumber',
            search: true,
            width: '100px',
          },
          {
            label: '包条码',
            prop: 'orderPackageCode',
            search: true,
            width: '100px',
          },
          {
            label: '仓库',
            prop: 'warehouse',
            search: true,
            width: '100px',
          },
          {
            label: '一级品类',
            prop: 'firsts',
            search: true,
            width: '100px',
          },
          {
            label: '二级品类',
            prop: 'second',
            search: true,
            width: '100px',
          },
          {
            label: '三级品类',
            prop: 'thirdProduct',
            search: true,
            width: '100px',
          },
          {
            label: '物品编号',
            prop: 'materialCode',
            search: true,
            width: '100px',
          },
          {
            label: '物品名称',
            prop: 'materialName',
            search: true,
            width: '100px',
          },
          {
            label: '品牌',
            prop: 'brandName',
            search: true,
            width: '100px',
          },
          {
            label: '包件状态',
            prop: 'orderPackageStatusName',
            search: true,
            width: '100px',
          },
          {
            label: '包件冻结状态',
            prop: 'orderPackageFreezeStatusName',
            search: true,
            width: '100px',
          },
          {
            label: '包件上架状态',
            prop: 'orderPackageGroundingStatusName',
            search: true,
            width: '100px',
          },
          {
            label: '包件备货状态',
            prop: 'orderPackageStockupStatusName',
            search: true,
            width: '100px',
          },
          {
            label: '包件预约状态',
            prop: 'orderPackageReservationStatusName',
            search: true,
            width: '100px',
          },
          {
            label: '包件装车状态',
            prop: 'orderPackageLoadingStatusName',
            search: true,
            width: '100px',
          },
          // {
          //   label: "托盘码",
          //   prop: "pallet",
          //   width:"100px"
          // },
          {
            label: '库位名称',
            prop: 'goodsAllocationName',
            width: '100px',
          },
          {
            label: '所在列',
            prop: 'columnNum',
            width: '100px',
          },
          {
            label: '所在层',
            prop: 'layerNum',
            width: '100px',
          },
          {
            label: '关系类型',
            prop: 'bindingType',
            width: '100px',
          },
          {
            label: '操作时间',
            prop: 'operateTime',
            width: '100px',
          },
          {
            label: '操作人',
            prop: 'operateUserName',
            width: '100px',
          },
          {
            label: '操作数量',
            prop: 'num',
            width: '100px',
          },
        ],
      },
      // 库存品表单配置
      inventoryoption: {
        expand: false,
        index: true,
        border: true,
        selection: true,
        column: [
          {
            label: 'sku',
            prop: 'sku',
            search: true,
            width: '100px',
          },
          {
            label: '物料名称',
            prop: 'descriptionGoods',
            search: true,
            width: '100px',
          },
          {
            label: '物料编号',
            prop: 'cargoNumber',
            search: true,
            width: '100px',
          },
          {
            label: '规格',
            prop: 'cargoNorms',
            search: true,
            width: '100px',
          },
          {
            label: '单位',
            prop: 'cargoUnit',
            search: true,
            width: '100px',
          },
          {
            label: '仓库',
            prop: 'warehouseName',
            search: true,
            width: '100px',
          },
          {
            label: '商场名称',
            prop: 'marketName',
            search: true,
            width: '100px',
          },
          {
            label: '库位名称',
            prop: 'goodsAllocationName',
            width: '100px',
          },
          {
            label: '所在列',
            prop: 'columnNum',
            width: '100px',
          },
          {
            label: '所在层',
            prop: 'layerNum',
            width: '100px',
          },
          {
            label: '关系类型',
            prop: 'bindingType',
            width: '100px',
          },
          {
            label: '操作时间',
            prop: 'operateTime',
            width: '100px',
          },
          {
            label: '操作人',
            prop: 'operateUserName',
            width: '100px',
          },
          {
            label: '操作数量',
            prop: 'num',
            width: '100px',
          },
        ],
      },

      //包肩分页信息
      wpage: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      //包肩分页信息
      packpage: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      ordpage: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      inventorypage: {
        currentPage: 1,
        pageSize: 30,
        total: 40,
      },
      // 表单列表
      data: [],
      // 签收列表
      signdata: [],
      //客户id
      wid: null,
      //客户详情
      wrapdata: [],
      //包条列表
      packdata: [],
      //订单列表
      orddata: [],
      //库存品列表
      inventorydata: [],
      wrapoptioncolumn: [
        {
          prop: 'serviceNumber',
          label: '服务号',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'waybillNumber',
          label: '运单号',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageCode',
          label: '包条码',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'warehouse',
          label: '仓库',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'firsts',
          label: '一级品类',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'second',
          label: '二级品类',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'thirdProduct',
          label: '三级品类',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'materialCode',
          label: '物品编号',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'materialName',
          label: '物品名称',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'brandName',
          label: '品牌',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageStatusName',
          label: '包件状态',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageFreezeStatusName',
          label: '包件冻结状态',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageGroundingStatusName',
          label: '包件上架状态',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageStockupStatusName',
          label: '包件备货状态',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageReservationStatusName',
          label: '包件预约状态',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'orderPackageLoadingStatusName',
          label: '包件装车状态',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'goodsAllocationName',
          label: '库位名称',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'columnNum',
          label: '所在列',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'layerNum',
          label: '所在层',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'bindingType',
          label: '关系类型',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'operateTime',
          label: '操作时间',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'operateUserName',
          label: '操作人',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'num',
          label: '操作数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
      ],
      inventoryoptioncolumn: [
        {
          prop: 'sku',
          label: 'sku',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'descriptionGoods',
          label: '物料名称',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'cargoNumber',
          label: '物料编号',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'cargoNorms',
          label: '规格',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'cargoUnit',
          label: '单位',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'warehouseName',
          label: '仓库',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'marketName',
          label: '商场名称',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'goodsAllocationName',
          label: '库位名称',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'columnNum',
          label: '所在列',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'layerNum',
          label: '所在层',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'bindingType',
          label: '关系类型',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'operateTime',
          label: '操作时间',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'operateUserName',
          label: '操作人',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'num',
          label: '操作数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
      ],
      optioncolumn: [
        {
          prop: 'dealerName',
          label: '经销商名称',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'waybillNumber',
          label: '运单号',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'dealerCode',
          label: '经销商编码',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'consigneePerson',
          label: '运单收货人',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'consigneeAddress',
          label: '运单收货地址',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'consigneeMobile',
          label: '运单收货电话',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'goodsAllocationName',
          label: '货位信息',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'columnNum',
          label: '所在列',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'layerNum',
          label: '所在行',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'bindingType',
          label: '关系类型',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'operateTime',
          label: '操作时间',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'operateUserName',
          label: '操作人',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
        {
          prop: 'num',
          label: '操作数量',
          type: 1,
          values: '',
          width: '150',
          checkarr: [],
          fixed: false,
          sortable: true,
          head: false,
        },
      ],
    };
  },
  watch: {
    // eslint-disable-next-line no-unused-vars
    $route(to, from) {
      // this.isadd =false;
      // this.query.masterId = null;
      // this.masterId = null;
      // if (!!this.$route.query.data) {
      //   //   //做一些路由变化的响应
      //   //   //   this.isadd =true;
      //   //   this.query.masterId = this.$route.query.data;
      //   //   this.masterId = this.$route.query.data;
      //   //重新获取数据
      //   this.onLoad(this.page);
      // } else {
      // }
    },
  },
  mounted() {
    this.init();
    this.onLoad();
    // let arr = [];
    // this.option.column.map(item => {
    //   if (!item.hide) {
    //     arr.push({
    //       prop: item.prop,
    //       label: item.label,
    //       type: 1,
    //       values: '',
    //       width: '150',
    //       checkarr: [],
    //       fixed: false,
    //       sortable: true,
    //       head: false,
    //     });
    //   }
    // });
    // console.log(JSON.stringify(arr));
  },
  created() {
    // //查询字典
    // this.queryDictionary();
  },
  computed: {
    ...mapGetters(['permission']),
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(',');
    },
  },
  methods: {
    beforeOpen(done, type) {
      if (['edit', 'view'].includes(type)) {
        getDetail(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
      done();
    },
    //修改
    rowUpdate(row, index, done, loading) {
      console.log('row>>>>>>>>', row);
    },
    queryDictionary() {
      getDictionaryBiz('yes_no').then(res => {
        this.isLiabilityData = res.data.data;
      });
      getDictionaryBiz('basic_in_type').then(res => {
        this.inputTypeData = res.data.data;
      });
    },
    //返回
    handleViewpda() {},
    //取消
    cancellation() {
      this.signBox = false;
    },
    init() {
      this.height = this.setPx(document.body.clientHeight - 340);
    },
    handleTabClick(tab, event) {
      console.log('tab>>>>>>>>', tab.paneName);
      let tabName = tab.paneName;
      switch (tabName) {
        case 'tab1':
          console.log('ssss');
          break;
        case 'tab2':
          console.log('ssss');
          break;
        case 'tab3':
          console.log('ssss');
          break;
        case 'tab4':
          console.log('ssss');
          break;
      }
    },
    searchHide() {
      this.search = !this.search;
    },
    searchChange() {
      this.onLoad(this.page);
    },
    searchReset() {
      this.query = {};
      this.page.currentPage = 1;
      this.onLoad(this.page);
    },
    handleSubmit() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.form.stringValue = jsonString;
          if (!this.form.id) {
            this.form.masterId = this.propertyformdata.id;
            add(this.form).then(() => {
              this.box = false;
              this.onLoad(this.page);
              this.$message({
                type: 'success',
                message: '操作成功!',
              });
              let str = {
                val: false,
              };
              this.$emit('returnproperty', str);
            });
          } else {
            update(this.form).then(() => {
              this.box = false;
              this.onLoad(this.page);
              this.$message({
                type: 'success',
                message: '操作成功!',
              });
              let str = {
                val: false,
              };
              this.$emit('returnproperty', str);
            });
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },

    //客户列表
    handleCustom() {
      this.cus = true;
      this.pake = false;
      this.ord = false;
      this.inventory = false;
    },
    //订单列表
    handleOrder(page) {
      let params = {};
      params.deliveryId = this.traydata.id;
      getorddetail(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        console.log('查看>>>>>订单>>', res.data.data);
        const data = res.data.data;
        this.orddata = data.records;
        this.ordpage.total = data.total;
      });
    },
    //包件列表
    handlePackagehistory(page) {
      let params = {};
      params.id = this.traydata.id;
      getpackListhistory(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
        res => {
          console.log('包件res.data.data>>>>>>>>>>>{}', res.data.data);
          const data = res.data.data;
          this.packdata = data.records;
          this.packpage.total = data.total;
        }
      );
    },
    //零担列表
    handlelcl(page) {
      let params = {};
      params.id = this.traydata.id;
      getlclListhistory(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
        res => {
          const data = res.data.data;
          this.data = data.records;
          this.page.total = data.total;
        }
      );
    },
    //库存列表
    handleInventory(page) {
      let params = {};
      params.id = this.traydata.id;
      getinventoryListhistory(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then(res => {
        console.log('查看>>>>>库存>>', res.data.data);
        const data = res.data.data;
        this.inventorydata = data.records;
        this.inventorypage.total = data.total;
      });
    },
    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) {
      console.log('查看>>>>>>>>>>', row);
      this.title = '查看';
      this.view = true;
      this.box = true;
      this.wid = row.id;
      this.getWrapdetails(this.wpage);
    },
    handleSign(row) {
      console.log('签收>>>>>>>>>>', row);
      this.signtitle = '复核签收';
      // this.view = true;
      this.signform = row;
      this.signBox = true;
      //  this.wid= row.id
      // this.getWrapdetails(this.wpage)
    },

    getWrapdetails(page) {
      let params = {};
      params.reservationId = this.wid;
      getWrapdetail(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(
        res => {
          console.log('查看>>>>>>>', res.data.data);
          const data = res.data.data;
          this.wrapdata = data.records;
          this.wpage.total = data.total;
        }
      );
    },

    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('sllsls');
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.table.clearSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page);
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      this.onLoad(this.page);
    },
    wcurrentChange(currentPage) {
      this.wpage.currentPage = currentPage;
      this.getWrapdetails(this.wpage);
    },
    wsizeChange(pageSize) {
      this.wpage.pageSize = pageSize;
      this.getWrapdetails(this.wpage);
    },
    pcurrentChange(currentPage) {
      this.packpage.currentPage = currentPage;
      this.handlePackagehistory(this.packpage);
    },
    psizeChange(pageSize) {
      this.packpage.pageSize = pageSize;
      this.handlePackagehistory(this.packpage);
    },
    ocurrentChange(currentPage) {
      this.ordpage.currentPage = currentPage;
      this.handleordpage(this.ordpage);
    },
    osizeChange(pageSize) {
      this.inventorypage.pageSize = pageSize;
      this.handleordpage(this.inventorypage);
    },
    icurrentChange(currentPage) {
      this.inventorypage.currentPage = currentPage;
      this.handleordpage(this.inventorypage);
    },
    isizeChange(pageSize) {
      this.inventorypage.pageSize = pageSize;
      this.handleordpage(this.inventorypage);
    },
    onLoad() {
      //查询详情
      const data = decodeURIComponent(this.$route.query.data);
      this.traydata = JSON.parse(data);
      console.log('data>>>>>>>>', this.traydata);
      this.loading = true;
      // getDetail(id).then(res => {
      //   console.log("res.data>>>>>>>>>>>>",res.data.data);
      //   const data = res.data.data
      //   //this.traydata = data
      //   this.data = data.reservationList
      // });
      this.handlelcl(this.page);
      this.handlePackagehistory(this.packpage);
      this.handleInventory(this.inventorypage);
      this.loading = false;
    },
  },
};
</script>
