<template>
  <div class="app-container" ref="appPanel">
    <div ref="toolPanel">
      <el-row :gutter="10" class="mb8">

        <el-col :span="1.5">
          <el-button
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            >导出</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button icon="el-icon-search" size="mini" @click="handleQuery"
            >搜索</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >刷新</el-button
          >
        </el-col>
        <right-toolbar ref="toolBarRef" @customCols="customColsHandler" :showSearch.sync="showSearch"
                       showColumnsType="transfer" :columns="columns"></right-toolbar>
      </el-row>
    </div>
    <div class="search-container" ref="searchPanel">
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="mini"
        :inline="true"
        v-show="showSearch"
        label-width="68px"
      >
        <el-form-item label="任务号" prop="plcId">
          <el-input
            v-model="queryParams.plcId"
            placeholder="请输入任务号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item label="仓库ID" prop="storageId">
          <el-input
            v-model="queryParams.storageId"
            placeholder="请输入仓库ID"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="库位编号" prop="locationId">
          <el-input
            v-model="queryParams.locationId"
            placeholder="请输入库位编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item label="容器号" prop="ctl">
          <el-input
            v-model="queryParams.ctl"
            placeholder="请输入容器号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料编码" prop="goodsId">
          <el-input
            v-model="queryParams.goodsId"
            placeholder="请输入物料编码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单据日期" prop="date">
          <div class="block">
            <el-date-picker
              v-model="queryParams.date"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              @keyup.enter.native="handleQuery"
              value-format="yyyy-MM-dd">
            </el-date-picker>
          </div>
        </el-form-item>
      </el-form>
    </div>



    <div class="table-container">
      <div ref="mainTablePanel" :style="{ height: mainTableDivHeight }">
        <el-table :key="rndKey" v-loading="loading" border size="mini" :height="mainTableHeight"
                  :data="ongoodsShelfBakList" @header-dragend="handleHeaderDragEnd">
          <el-table-column type="selection" width="55" align="center"/>
          <template>
            <el-table-column sortable v-for="item in columns"  :key="item.seq" :label="item.label" align="center"
                             :prop="item.columnName" v-if="item.visible" :width="item.width"
                             :filters="item.filters" :filter-method="filterHandler">
              <template v-slot="scope">
                <dict-tag v-if="item.columnName === 'purchaseType'" v-slot="scope" :options="dict.type.warehouse_type"
                          :value="scope.row[item.columnName]"/>
                <dict-tag v-else-if="item.columnName === 'confirmStatus'" v-slot="scope" :options="dict.type.task_status"
                          :value="scope.row[item.columnName]"/>
                <span v-else>{{ scope.row[item.columnName] }}</span>
              </template>
            </el-table-column>
          </template>
        </el-table>
        <div class="pagePanel">
          <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </div>
      </div>
    </div>

    <!-- 添加或修改入库任务历史对话框 -->
    <el-dialog
      id="dialog-container"
      :title="title"
      :visible.sync="open"
      width="1000px"
      append-to-body
    >
      <div class="edit-container">
        <el-form ref="form" :model="form" :rules="rules" label-width="85px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="申请单号" prop="lotId">
                <el-input v-model="form.lotId" placeholder="请输入申请单号" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="物料编码" prop="goodsId">
                <el-input v-model="form.goodsId" placeholder="请输入物料编码" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="中标供应商" prop="providerId">
                <el-input
                  v-model="form.providerId"
                  placeholder="请输入中标供应商"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="库位" prop="locationId">
                <el-input v-model="form.locationId" placeholder="请输入库位" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="需求数量" prop="stoNum">
                <el-input v-model="form.stoNum" placeholder="请输入需求数量" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="容器号" prop="ctl">
                <el-input v-model="form.ctl" placeholder="请输入容器号" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="物料描述" prop="recoil">
                <el-input v-model="form.recoil" placeholder="请输入物料描述" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="入库数量" prop="accNum">
                <el-input v-model="form.accNum" placeholder="请输入入库数量" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="库存数量" prop="stockNum">
                <el-input
                  v-model="form.stockNum"
                  placeholder="请输入库存数量"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="入库时间" prop="ondate">
                <el-input v-model="form.ondate" placeholder="请输入入库时间" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="收货人" prop="receiver">
                <el-input v-model="form.receiver" placeholder="请输入收货人" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="仓库ID" prop="storageId">
                <el-input v-model="form.storageId" placeholder="请输入仓库ID" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="库区ID" prop="storageAreaId">
                <el-input
                  v-model="form.storageAreaId"
                  placeholder="请输入库区ID"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="需求组织" prop="operatorId">
                <el-input
                  v-model="form.operatorId"
                  placeholder="请输入需求组织"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="存储模式" prop="storageMode">
                <el-input
                  v-model="form.storageMode"
                  placeholder="请输入存储模式"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="物料体积" prop="goodsVolume">
                <el-input
                  v-model="form.goodsVolume"
                  placeholder="请输入物料体积"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="条形码" prop="barcode">
                <el-input v-model="form.barcode" placeholder="请输入条形码" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="招标员" prop="customerId">
                <el-input
                  v-model="form.customerId"
                  placeholder="请输入招标员"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="物资计划明细备注" prop="remark">
                <el-input
                  v-model="form.remark"
                  type="textarea"
                  placeholder="请输入内容"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="需求部门" prop="needDept">
                <el-input
                  v-model="form.needDept"
                  placeholder="请输入需求部门"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="收货组织" prop="produclotId">
                <el-input
                  v-model="form.produclotId"
                  placeholder="请输入收货组织"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="单位" prop="unit">
                <el-input v-model="form.unit" placeholder="请输入单位" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="主管部门" prop="respDept">
                <el-input
                  v-model="form.respDept"
                  placeholder="请输入主管部门"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="PLC编号" prop="plcId">
                <el-input v-model="form.plcId" placeholder="请输入PLC编号" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="申请部门" prop="supplier">
                <el-input
                  v-model="form.supplier"
                  placeholder="请输入申请部门"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="物料名称" prop="goodsName">
                <el-input
                  v-model="form.goodsName"
                  placeholder="请输入物料名称"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="站台" prop="instand">
                <el-input v-model="form.instand" placeholder="请输入站台" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="品牌" prop="brand">
                <el-input v-model="form.brand" placeholder="请输入品牌" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="任务类型" prop="taskType">
                <el-select v-model="form.taskType" placeholder="请选择任务类型">
                  <el-option
                    v-for="dict in dict.type.warehouse_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="申请人" prop="applicant">
                <el-input v-model="form.applicant" placeholder="请输入申请人" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="包装数量" prop="packingNum">
                <el-input
                  v-model="form.packingNum"
                  placeholder="请输入包装数量"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="损害数量" prop="damageNum">
                <el-input
                  v-model="form.damageNum"
                  placeholder="请输入损害数量"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="采购组织" prop="purchaseDept">
                <el-input
                  v-model="form.purchaseDept"
                  placeholder="请输入采购组织"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="计划单价" prop="price">
                <el-input v-model="form.price" placeholder="请输入计划单价" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="测量单位" prop="scaleUnit">
                <el-input
                  v-model="form.scaleUnit"
                  placeholder="请输入测量单位"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="总量" prop="totalVolume">
                <el-input v-model="form.totalVolume" placeholder="请输入总量" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="毛重" prop="totalRoughWeight">
                <el-input
                  v-model="form.totalRoughWeight"
                  placeholder="请输入毛重"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="净重" prop="totalNetWeigh">
                <el-input
                  v-model="form.totalNetWeigh"
                  placeholder="请输入净重"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="计划金额" prop="totalMoney">
                <el-input
                  v-model="form.totalMoney"
                  placeholder="请输入计划金额"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="wms订单号" prop="acceId">
                <el-input v-model="form.acceId" placeholder="请输入wms订单号" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6"> </el-col>
            <el-col :span="6">
              <el-form-item label="标志" prop="flag">
                <el-input v-model="form.flag" placeholder="请输入标志" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="标准箱" prop="standard">
                <el-input v-model="form.standard" placeholder="请输入标准箱" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="本场批次" prop="innerBatchNo">
                <el-input
                  v-model="form.innerBatchNo"
                  placeholder="请输入本场批次"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="打印次数" prop="printCs">
                <el-input v-model="form.printCs" placeholder="请输入打印次数" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="打印状态" prop="printSts">
                <el-input
                  v-model="form.printSts"
                  placeholder="请输入打印状态"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="入库类型" prop="purchaseType">
                <el-select
                  v-model="form.purchaseType"
                  placeholder="请选择入库类型"
                >
                  <el-option
                    v-for="dict in dict.type.warehouse_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="人工码盘" prop="manualTrayState">
                <el-input
                  v-model="form.manualTrayState"
                  placeholder="请输入人工码盘"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="规格" prop="spec">
                <el-input v-model="form.spec" placeholder="请输入规格" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="采购入库单号" prop="wmsOrderId">
                <el-input
                  v-model="form.wmsOrderId"
                  placeholder="请输入采购入库单号"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="批次号" prop="batchNo">
                <el-input v-model="form.batchNo" placeholder="请输入批次号" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="破损库位" prop="damageLocation">
                <el-input
                  v-model="form.damageLocation"
                  placeholder="请输入破损库位"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="状态" prop="status">
                <el-select v-model="form.status" placeholder="请选择状态">
                  <el-option
                    v-for="dict in dict.type.task_status"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="规格型号" prop="specification">
                <el-input
                  v-model="form.specification"
                  placeholder="请输入规格型号"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="物料分类" prop="goodsTypeId">
                <el-input
                  v-model="form.goodsTypeId"
                  placeholder="请输入物料分类"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="创建时间" prop="operateDate">
                <el-date-picker
                  clearable
                  v-model="form.operateDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择创建时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="计划日期" prop="planDate">
                <el-input
                  v-model="form.planDate"
                  placeholder="请输入计划日期"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="计划时间" prop="planTime">
                <el-input
                  v-model="form.planTime"
                  placeholder="请输入计划时间"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="需求周期" prop="needCycle">
                <el-input
                  v-model="form.needCycle"
                  placeholder="请输入需求周期"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="需求类型" prop="needType">
                <el-input
                  v-model="form.needType"
                  placeholder="请输入需求类型"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="需求时间" prop="expiryDate">
                <el-input
                  v-model="form.expiryDate"
                  placeholder="请输入需求时间"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="建议供应商名称" prop="providerName">
                <el-input
                  v-model="form.providerName"
                  placeholder="请输入建议供应商名称"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="收货人部门" prop="receiverDept">
                <el-input
                  v-model="form.receiverDept"
                  placeholder="请输入收货人部门"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="送货区域" prop="receivingArea">
                <el-input
                  v-model="form.receivingArea"
                  placeholder="请输入送货区域"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="技术需求附件" prop="packageId">
                <el-input
                  v-model="form.packageId"
                  placeholder="请输入技术需求附件"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6"> </el-col>
            <el-col :span="6">
              <el-form-item label="中标供应商联系方式" prop="telephone">
                <el-input
                  v-model="form.telephone"
                  placeholder="请输入中标供应商联系方式"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="生产日期" prop="productionDate">
                <el-date-picker
                  clearable
                  v-model="form.productionDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择生产日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="宽" prop="wgh">
                <el-input v-model="form.wgh" placeholder="请输入宽" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="高" prop="high">
                <el-input v-model="form.high" placeholder="请输入高" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="质检状态" prop="qualityInspecStatus">
                <el-radio-group v-model="form.qualityInspecStatus">
                  <el-radio
                    v-for="dict in dict.type.inspect_status"
                    :key="dict.value"
                    :label="dict.value"
                    >{{ dict.label }}</el-radio
                  >
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="保质期" prop="periodUnit">
                <el-input
                  v-model="form.periodUnit"
                  placeholder="请输入保质期"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="保质期单位" prop="period">
                <el-input
                  v-model="form.period"
                  placeholder="请输入保质期单位"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="上报时间" prop="reportTime">
                <el-date-picker
                  clearable
                  v-model="form.reportTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择上报时间"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="特殊标志 空：一般库存、E 销售订单库存、K 寄售库存"
                prop="consignment"
              >
                <el-input
                  v-model="form.consignment"
                  placeholder="请输入特殊标志 空：一般库存、E 销售订单库存、K 寄售库存"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listOngoodsShelfBak,
  getOngoodsShelfBak,
  delOngoodsShelfBak,
  addOngoodsShelfBak,
  updateOngoodsShelfBak,
  disabled,
  enabled,
  changeStatus,
} from "@/api/system/ongoodsShelfBak";
import { listCOLUMN } from "@/api/system/column";
import TableMixin from "@/api/tableMixin";


export default {
  name: "OngoodsShelfBak",
  dicts: ["warehouse_type", "task_status", "inspect_status"],
  mixins:[TableMixin],

  data() {
    return {
      rndKey:0,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 入库任务历史表格数据
      ongoodsShelfBakList: [],
      // 弹出层标题
      title: "",
      mainTableHeight: "0px",
      mainTableDivHeight: "0px",
      businessCodeTrk: "ongoodsShelfBak",
      rightToolbarShow: false,
      tableNo: 0,
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        date: null,
        operateDate: null,
        lotId: null,
        goodsId: null,
        providerId: null,
        locationId: null,
        ctl: null,
        storageId: null,
        storageAreaId: null,
        goodsName: null,
        taskType: null,
        purchaseType: null,
        wmsOrderId: null,
        batchNo: null,
        status: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      columns: [],
    };
  },
  created() {
    this.getList();
  },
  mounted() {
    this.computedTableHeight();
    this.generateFilters();
  },
  watch: {
    showSearch: function () {
      this.computedTableHeight();
    },
  },
  methods: {
    /** 查询用户展示字段定义管理列表 */
    computedTableHeight() {
      this.$nextTick(() => {
        var totalHeight = this.$refs.appPanel.clientHeight;
        var toolHeight = this.$refs.toolPanel.clientHeight;
        var searchHeight = this.$refs.searchPanel.clientHeight;

        var tablePanelHeight = totalHeight - toolHeight - searchHeight - 14 - 5;

        this.mainTableDivHeight = tablePanelHeight + "px";
        this.mainTableHeight = tablePanelHeight - 25 + "px";
      });
    },
    /** 查询入库任务历史列表 */
    getList() {
      this.loading = true;
      listOngoodsShelfBak(this.queryParams).then((response) => {
        if (this.columns.length === 0) {
          this.columns = response.columns;
        }
        this.ongoodsShelfBakList = response.rows;
        this.columns = response.columns;
        this.total = response.total;

        this.generateFilters();
        // this.getHideColumn();
        this.loading = false;
      });
    },
    handleHeaderDragEnd(newWidth, oldWidth, column, event) {
      this.columns.forEach((obj) => {
        if (obj.columnName === column.property) obj.width = newWidth;
      });
      this.$refs.toolBarRef.saveConfig(this.columns);
    },
    generateFilters() {
      this.columns.forEach(column => {
        const uniqueValues = [...new Set(this.ongoodsShelfBakList.map(item => item[column.columnName]))];
        column.filters = uniqueValues.map(value => ({text: value, value}));
        column.filterMethod = (value, row) => row[column.columnName] === value;
      });
    },
    filterHandler(value, row, column) {
      const property = column['property'];
      return row[property] === value;
    },
      /** 查询用户展示字段定义管理列表 */
      getHideColumn() {
      var queryHideColumnParams = {
        pageNum: 1,
        pageSize: 100,
        businessCode: this.businessCodeTrk,
        tableNo: this.tableNo
      };
      listCOLUMN(queryHideColumnParams).then(response => {
        if(response.rows.length > 0) {
          var row = response.rows[0];
          var columnHide = row.columnHide.split(",");
          if (columnHide.length > 0) {
            for (let item in this.columns) {
              if (columnHide.indexOf(this.columns[item].columnName) > -1) {
                this.columns[item].visible = false;
              }
            }
          }
        }
        this.rightToolbarShow = true;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        lotId: null,
        goodsId: null,
        providerId: null,
        locationId: null,
        stoNum: null,
        ctl: null,
        recoil: null,
        accNum: null,
        stockNum: null,
        ondate: null,
        receiver: null,
        storageId: null,
        storageAreaId: null,
        operatorId: null,
        storageMode: null,
        goodsVolume: null,
        barcode: null,
        customerId: null,
        remark: null,
        needDept: null,
        produclotId: null,
        unit: null,
        respDept: null,
        plcId: null,
        supplier: null,
        goodsName: null,
        instand: null,
        brand: null,
        taskType: null,
        applicant: null,
        packingNum: null,
        damageNum: null,
        purchaseDept: null,
        price: null,
        scaleUnit: null,
        totalVolume: null,
        totalRoughWeight: null,
        totalNetWeigh: null,
        totalMoney: null,
        acceId: null,
        inStatus: null,
        flag: null,
        standard: null,
        innerBatchNo: null,
        printCs: null,
        printSts: null,
        purchaseType: null,
        manualTrayState: null,
        spec: null,
        wmsOrderId: null,
        batchNo: null,
        damageLocation: null,
        status: null,
        updateTime: null,
        specification: null,
        goodsTypeId: null,
        operateDate: null,
        planDate: null,
        planTime: null,
        needCycle: null,
        needType: null,
        expiryDate: null,
        providerName: null,
        receiverDept: null,
        receivingArea: null,
        packageId: null,
        useType: null,
        telephone: null,
        productionDate: null,
        wgh: null,
        high: null,
        createTime: null,
        createBy: null,
        updateBy: null,
        qualityInspecStatus: null,
        periodUnit: null,
        period: null,
        reportTime: null,
        consignment: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加入库任务历史";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getOngoodsShelfBak(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改入库任务历史";
      });
    },
    customColsHandler(columns) {
      this.columns = columns;
      this.rndKey = Math.random();
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateOngoodsShelfBak(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOngoodsShelfBak(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除入库任务历史编号为"' + ids + '"的数据项？')
        .then(function () {
          return delOngoodsShelfBak(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },

    /** 用户状态修改 */
    handleStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用";
      this.$modal
        .confirm('确认要"' + text + '"id为"' + row.id + '"数据项？')
        .then(function () {
          return changeStatus(row.id, row.status);
        })
        .then(() => {
          this.$modal.msgSuccess(text + "成功");
        })
        .catch(function () {
          row.status = row.status === "0" ? "1" : "0";
        });
    },
    /** 启用按钮操作 */
    handleEnable(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认启用入库任务历史编号为"' + ids + '"的数据项？')
        .then(function () {
          return enabled(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("启用成功");
        })
        .catch(() => {});
    },
    /** 禁用按钮操作 */
    handleDisabled(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认禁用入库任务历史编号为"' + ids + '"的数据项？')
        .then(function () {
          return disabled(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("禁用成功");
        })
        .catch(() => {});
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/tOnGoodsShelfbak/export",
        {
          ...this.queryParams,
        },
        `ongoodsShelfBak_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style scoped>
.app-container {
  height: calc(100vh - 84px);
}
</style>
