<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-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['system:orderdetailBak:add']"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['system:orderdetailBak:edit']"
          >修改</el-button>
        </el-col>
        <el-col :span="1.5">
        <el-button
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['system:orderdetailBak:remove']"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="multiple"
            @click="handleEnable"
            v-hasPermi="['system:orderdetailBak:edit']"
          >启用</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDisabled"
            v-hasPermi="['system:orderdetailBak:remove']"
          >禁用</el-button>
        </el-col>
        -->
        <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 v-if="rightToolbarShow" :showSearch.sync="showSearch" @queryTable="getList" showColumnsType="transfer" :columns="columns" :businessCode="businessCodeTrk" :tableNo="tableNo" ></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="主表id" prop="orderId">
                    <el-input
                        v-model="queryParams.orderId"
                        placeholder="请输入主表id"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="子需求编号" prop="businessId">
                    <el-input
                        v-model="queryParams.businessId"
                        placeholder="请输入子需求编号"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="物料编号" prop="goodsId">
                    <el-select v-model="queryParams.goodsId" placeholder="请选择物料编号" clearable>
                      <el-option
                          v-for="dict in dict.type.sys_normal_disable"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="物料名称" prop="goodsName">
                    <el-input
                        v-model="queryParams.goodsName"
                        placeholder="请输入物料名称"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="库位编号" prop="locationId">
                    <el-select v-model="queryParams.locationId" placeholder="请选择库位编号" clearable>
                      <el-option
                          v-for="dict in dict.type.sys_normal_disable"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="规格" prop="specification">
                    <el-input
                        v-model="queryParams.specification"
                        placeholder="请输入规格"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="单位" prop="unit">
                    <el-select v-model="queryParams.unit" placeholder="请选择单位" clearable>
                      <el-option
                          v-for="dict in dict.type.goods_unit"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="仓库" prop="storageId">
                    <el-select v-model="queryParams.storageId" placeholder="请选择仓库" clearable>
                      <el-option
                          v-for="dict in dict.type.sys_normal_disable"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="订单需求数量" prop="shelvesNum">
                    <el-input
                        v-model="queryParams.shelvesNum"
                        placeholder="请输入订单需求数量"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="本次出库数量" prop="goodsNum">
                    <el-input
                        v-model="queryParams.goodsNum"
                        placeholder="请输入本次出库数量"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="呼叫数量" prop="callShelvesNum">
                    <el-input
                        v-model="queryParams.callShelvesNum"
                        placeholder="请输入呼叫数量"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="标准价" prop="price">
                    <el-input
                        v-model="queryParams.price"
                        placeholder="请输入标准价"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="物料分类" prop="goodsTypeId">
                    <el-select v-model="queryParams.goodsTypeId" placeholder="请选择物料分类" clearable>
                      <el-option
                          v-for="dict in dict.type.goods_type"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="供应商：特殊标识为K时候必填" prop="providerId">
                    <el-select v-model="queryParams.providerId" placeholder="请选择供应商：特殊标识为K时候必填" clearable>
                      <el-option
                          v-for="dict in dict.type.goods_type"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                      />
                    </el-select>
                  </el-form-item>
                  <el-form-item label="物料描述" prop="recoil">
                    <el-input
                        v-model="queryParams.recoil"
                        placeholder="请输入物料描述"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="库区" prop="storageAreaId">
                    <el-input
                        v-model="queryParams.storageAreaId"
                        placeholder="请输入库区"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="总出库数量" prop="pickNum">
                    <el-input
                        v-model="queryParams.pickNum"
                        placeholder="请输入总出库数量"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="确认出库数量" prop="trNum">
                    <el-input
                        v-model="queryParams.trNum"
                        placeholder="请输入确认出库数量"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="条形码" prop="barcode">
                    <el-input
                        v-model="queryParams.barcode"
                        placeholder="请输入条形码"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="AGV站台" prop="toLoc">
                    <el-input
                        v-model="queryParams.toLoc"
                        placeholder="请输入AGV站台"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="到期时间" prop="expiryDate">
                    <el-date-picker clearable
                                    v-model="queryParams.expiryDate"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    placeholder="请选择到期时间">
                    </el-date-picker>
                  </el-form-item>
                  <el-form-item label="库存数量" prop="stockNum">
                    <el-input
                        v-model="queryParams.stockNum"
                        placeholder="请输入库存数量"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="呼叫任务号" prop="taskId">
                    <el-input
                        v-model="queryParams.taskId"
                        placeholder="请输入呼叫任务号"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
    </el-form>
    </div>
    <div class="table-container">
      <div ref="mainTablePanel" :style="{height: mainTableDivHeight}">
        <el-table v-loading="loading" border size="mini" :height="mainTableHeight" :data="orderdetailBakList"
        @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="出库单号" align="center" prop="id" v-if="columns[0].visible"/>
              <el-table-column label="主表id" align="center" prop="orderId" v-if="columns[1].visible"/>
              <el-table-column label="子需求编号" align="center" prop="businessId" v-if="columns[2].visible"/>
              <el-table-column label="物料编号" align="center" prop="goodsId" v-if="columns[3].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.goodsId"/>
                </template>
              </el-table-column>
              <el-table-column label="物料名称" align="center" prop="goodsName" v-if="columns[4].visible"/>
              <el-table-column label="库位编号" align="center" prop="locationId" v-if="columns[5].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.locationId"/>
                </template>
              </el-table-column>
              <el-table-column label="规格" align="center" prop="specification" v-if="columns[6].visible"/>
              <el-table-column label="单位" align="center" prop="unit" v-if="columns[7].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.goods_unit" :value="scope.row.unit"/>
                </template>
              </el-table-column>
              <el-table-column label="仓库" align="center" prop="storageId" v-if="columns[8].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.storageId"/>
                </template>
              </el-table-column>
              <el-table-column label="订单需求数量" align="center" prop="shelvesNum" v-if="columns[9].visible"/>
              <el-table-column label="本次出库数量" align="center" prop="goodsNum" v-if="columns[10].visible"/>
              <el-table-column label="呼叫数量" align="center" prop="callShelvesNum" v-if="columns[11].visible"/>
              <el-table-column label="备注" align="center" prop="remark" v-if="columns[12].visible"/>
              <el-table-column label="标准价" align="center" prop="price" v-if="columns[13].visible"/>
              <el-table-column label="物料分类" align="center" prop="goodsTypeId" v-if="columns[14].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.goods_type" :value="scope.row.goodsTypeId"/>
                </template>
              </el-table-column>
              <el-table-column label="供应商：特殊标识为K时候必填" align="center" prop="providerId" v-if="columns[15].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.goods_type" :value="scope.row.providerId"/>
                </template>
              </el-table-column>
              <el-table-column label="物料描述" align="center" prop="recoil" v-if="columns[16].visible"/>
              <el-table-column label="库区" align="center" prop="storageAreaId" v-if="columns[17].visible"/>
              <el-table-column label="总出库数量" align="center" prop="pickNum" v-if="columns[18].visible"/>
              <el-table-column label="确认出库数量" align="center" prop="trNum" v-if="columns[19].visible"/>
              <el-table-column label="条形码" align="center" prop="barcode" v-if="columns[20].visible"/>
              <el-table-column label="状态" align="center" prop="status" v-if="columns[21].visible"/>
              <el-table-column label="AGV站台" align="center" prop="toLoc" v-if="columns[22].visible"/>
              <el-table-column label="出库状态" align="center" prop="confirmStatus" v-if="columns[23].visible"/>
              <el-table-column label="到期时间" align="center" prop="expiryDate" width="180" v-if="columns[24].visible">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.expiryDate, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="库存数量" align="center" prop="stockNum" v-if="columns[25].visible"/>
              <el-table-column label="呼叫任务号" align="center" prop="taskId" v-if="columns[26].visible"/>
        </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="主表id" prop="orderId">
                          <el-input v-model="form.orderId" placeholder="请输入主表id" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="子需求编号" prop="businessId">
                          <el-input v-model="form.businessId" placeholder="请输入子需求编号" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="物料编号" prop="goodsId">
                          <el-select v-model="form.goodsId" placeholder="请选择物料编号">
                            <el-option
                                v-for="dict in dict.type.sys_normal_disable"
                                :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="goodsName">
                          <el-input v-model="form.goodsName" placeholder="请输入物料名称" />
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
                      <el-col :span="6">
                        <el-form-item label="库位编号" prop="locationId">
                          <el-select v-model="form.locationId" placeholder="请选择库位编号">
                            <el-option
                                v-for="dict in dict.type.sys_normal_disable"
                                :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="unit">
                          <el-select v-model="form.unit" placeholder="请选择单位">
                            <el-option
                                v-for="dict in dict.type.goods_unit"
                                :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="storageId">
                          <el-select v-model="form.storageId" placeholder="请选择仓库">
                            <el-option
                                v-for="dict in dict.type.sys_normal_disable"
                                :key="dict.value"
                                :label="dict.label"
                                :value="dict.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
                      <el-col :span="6">
                        <el-form-item label="订单需求数量" prop="shelvesNum">
                          <el-input v-model="form.shelvesNum" placeholder="请输入订单需求数量" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="本次出库数量" prop="goodsNum">
                          <el-input v-model="form.goodsNum" placeholder="请输入本次出库数量" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="呼叫数量" prop="callShelvesNum">
                          <el-input v-model="form.callShelvesNum" 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-row>
                        <el-row>
                      <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="goodsTypeId">
                          <el-select v-model="form.goodsTypeId" placeholder="请选择物料分类">
                            <el-option
                                v-for="dict in dict.type.goods_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="供应商：特殊标识为K时候必填" prop="providerId">
                          <el-select v-model="form.providerId" placeholder="请选择供应商：特殊标识为K时候必填">
                            <el-option
                                v-for="dict in dict.type.goods_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="recoil">
                          <el-input v-model="form.recoil" placeholder="请输入物料描述" />
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
                      <el-col :span="6">
                        <el-form-item label="库区" prop="storageAreaId">
                          <el-input v-model="form.storageAreaId" placeholder="请输入库区" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="总出库数量" prop="pickNum">
                          <el-input v-model="form.pickNum" placeholder="请输入总出库数量" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="确认出库数量" prop="trNum">
                          <el-input v-model="form.trNum" placeholder="请输入确认出库数量" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="条形码" prop="barcode">
                          <el-input v-model="form.barcode" placeholder="请输入条形码" />
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
                      <el-col :span="6">
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="AGV站台" prop="toLoc">
                          <el-input v-model="form.toLoc" placeholder="请输入AGV站台" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="到期时间" prop="expiryDate">
                          <el-date-picker clearable
                                          v-model="form.expiryDate"
                                          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="stockNum">
                          <el-input v-model="form.stockNum" placeholder="请输入库存数量" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="呼叫任务号" prop="taskId">
                          <el-input v-model="form.taskId" placeholder="请输入呼叫任务号" />
                        </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 { listOrderdetailBak, getOrderdetailBak, delOrderdetailBak, addOrderdetailBak, updateOrderdetailBak, disabled, enabled, changeStatus } from "@/api/system/orderdetailBak";
  import { listCOLUMN } from "@/api/system/column";

  export default {
    name: "OrderdetailBak",
        dicts: ['goods_unit', 'sys_normal_disable', 'goods_type'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 出库物料明细表格数据
              orderdetailBakList: [],
        // 弹出层标题
        title: "",
        mainTableHeight:"0px",
        mainTableDivHeight:"0px",
        businessCodeTrk: "orderdetailBak",
        rightToolbarShow: false,
        tableNo: 0,
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 100,
          orderId: null,
          businessId: null,
          goodsId: null,
          goodsName: null,
          locationId: null,
          specification: null,
          unit: null,
          storageId: null,
          shelvesNum: null,
          goodsNum: null,
          callShelvesNum: null,
          price: null,
          goodsTypeId: null,
          providerId: null,
          recoil: null,
          storageAreaId: null,
          pickNum: null,
          trNum: null,
          barcode: null,
          status: null,
          toLoc: null,
          confirmStatus: null,
          expiryDate: null,
          stockNum: null,
          taskId: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
                        orderId: [
                    { required: true, message: "主表id不能为空", trigger: "blur" }
                  ],
        },
        columns: [
            { key: 0, label: `出库单号`, visible: true, columnName: "id" },
            { key: 1, label: `主表id`, visible: true, columnName: "order_id" },
            { key: 2, label: `子需求编号`, visible: true, columnName: "business_id" },
            { key: 3, label: `物料编号`, visible: true, columnName: "goods_id" },
            { key: 4, label: `物料名称`, visible: true, columnName: "goods_name" },
            { key: 5, label: `库位编号`, visible: true, columnName: "location_id" },
            { key: 6, label: `规格`, visible: true, columnName: "specification" },
            { key: 7, label: `单位`, visible: true, columnName: "unit" },
            { key: 8, label: `仓库`, visible: true, columnName: "storage_id" },
            { key: 9, label: `订单需求数量`, visible: true, columnName: "shelves_num" },
            { key: 10, label: `本次出库数量`, visible: true, columnName: "goods_num" },
            { key: 11, label: `呼叫数量`, visible: true, columnName: "call_shelves_num" },
            { key: 12, label: `备注`, visible: true, columnName: "remark" },
            { key: 13, label: `标准价`, visible: true, columnName: "price" },
            { key: 14, label: `物料分类`, visible: true, columnName: "goods_type_id" },
            { key: 15, label: `供应商：特殊标识为K时候必填`, visible: true, columnName: "provider_id" },
            { key: 16, label: `物料描述`, visible: true, columnName: "recoil" },
            { key: 17, label: `库区`, visible: true, columnName: "storage_area_id" },
            { key: 18, label: `总出库数量`, visible: true, columnName: "pick_num" },
            { key: 19, label: `确认出库数量`, visible: true, columnName: "tr_num" },
            { key: 20, label: `条形码`, visible: true, columnName: "barcode" },
            { key: 21, label: `状态`, visible: true, columnName: "status" },
            { key: 22, label: `AGV站台`, visible: true, columnName: "to_loc" },
            { key: 23, label: `0未出库 1：部分出库 2：出库完成`, visible: true, columnName: "confirm_status" },
            { key: 24, label: `到期时间`, visible: true, columnName: "expiry_date" },
            { key: 25, label: `库存数量`, visible: true, columnName: "stock_num" },
            { key: 26, label: `呼叫任务号`, visible: true, columnName: "task_id" },
            { key: 27, label: `更新时间`, visible: true, columnName: "update_time" },
        ]
      };
    },
    created() {
      this.getList();
    },
    mounted() {
      this.computedTableHeight();
    },
    watch:{
      'showSearch': function() {
        this.computedTableHeight();
      }
    },
    methods: {
      /** 查询用户展示字段定义管理列表 */
      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;
        });
      },
      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;
        listOrderdetailBak(this.queryParams).then(response => {
          this.orderdetailBakList = response.rows;
          this.total = response.total;
          this.loading = false;
          this.getHideColumn();
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
                        id: null,
                        orderId: null,
                        businessId: null,
                        goodsId: null,
                        goodsName: null,
                        locationId: null,
                        specification: null,
                        unit: null,
                        storageId: null,
                        shelvesNum: null,
                        goodsNum: null,
                        callShelvesNum: null,
                        remark: null,
                        price: null,
                        goodsTypeId: null,
                        providerId: null,
                        recoil: null,
                        storageAreaId: null,
                        pickNum: null,
                        trNum: null,
                        barcode: null,
                        status: null,
                        toLoc: null,
                        confirmStatus: null,
                        expiryDate: null,
                        stockNum: null,
                        taskId: null,
                        updateTime: 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
        getOrderdetailBak(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改出库物料明细";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              updateOrderdetailBak(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addOrderdetailBak(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 delOrderdetailBak(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/orderdetailBak/export', {
      ...this.queryParams
    }, `orderdetailBak_${new Date().getTime()}.xlsx`)
  }
  }
  };
</script>
<style scoped>
 .app-container {
  height: calc(100vh - 84px);
 }
</style>
