<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:rkRecevinggoods: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:rkRecevinggoods: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:rkRecevinggoods: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:rkRecevinggoods: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:rkRecevinggoods: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="入库通知单号" prop="noticeId">
                    <el-input
                        v-model="queryParams.noticeId"
                        placeholder="请输入入库通知单号"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="交货单号" prop="deliveryId">
                    <el-input
                        v-model="queryParams.deliveryId"
                        placeholder="请输入交货单号"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="供应商编号" prop="providerId">
                    <el-input
                        v-model="queryParams.providerId"
                        placeholder="请输入供应商编号"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="供应商名称" prop="providerName">
                    <el-input
                        v-model="queryParams.providerName"
                        placeholder="请输入供应商名称"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="发货单号" prop="purchaseId">
                    <el-input
                        v-model="queryParams.purchaseId"
                        placeholder="请输入发货单号"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="发货组织" prop="shippingDept">
                    <el-input
                        v-model="queryParams.shippingDept"
                        placeholder="请输入发货组织"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="采购组织" prop="purchaseDept">
                    <el-input
                        v-model="queryParams.purchaseDept"
                        placeholder="请输入采购组织"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="收货人" prop="receiver">
                    <el-input
                        v-model="queryParams.receiver"
                        placeholder="请输入收货人"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="申请人" prop="applicant">
                    <el-input
                        v-model="queryParams.applicant"
                        placeholder="请输入申请人"
                        clearable
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                  <el-form-item label="收货组织" prop="produclotId">
                    <el-input
                        v-model="queryParams.produclotId"
                        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="rkRecevinggoodsList"
        @selection-change="handleSelectionChange"
          @row-dblclick="handleMainTableClick"
        >
          <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="入库通知单号" align="center" prop="noticeId" v-if="columns[1].visible"/>
              <el-table-column label="交货单号" align="center" prop="deliveryId" v-if="columns[2].visible"/>
              <el-table-column label="供应商编号" align="center" prop="providerId" v-if="columns[3].visible"/>
              <el-table-column label="供应商名称" align="center" prop="providerName" v-if="columns[4].visible"/>
              <el-table-column label="发货单号" align="center" prop="purchaseId" v-if="columns[5].visible"/>
              <el-table-column label="发货组织" align="center" prop="shippingDept" v-if="columns[6].visible"/>
              <el-table-column label="联系人" align="center" prop="contact" v-if="columns[7].visible"/>
              <el-table-column label="联系方式" align="center" prop="telephone" v-if="columns[8].visible"/>
              <el-table-column label="收货地址" align="center" prop="receiveAddr" v-if="columns[9].visible"/>
              <el-table-column label="发货日期" align="center" prop="sendeDate" width="180" v-if="columns[10].visible">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.sendeDate, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="采购组织" align="center" prop="purchaseDept" 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="receivingArea" v-if="columns[13].visible"/>
              <el-table-column label="使用单位收货人" align="center" prop="useReceiver" v-if="columns[14].visible"/>
              <el-table-column label="使用单位保管员" align="center" prop="useCustodian" v-if="columns[15].visible"/>
              <el-table-column label="使用单位主管" align="center" prop="useLeader" v-if="columns[16].visible"/>
              <el-table-column label="收货人" align="center" prop="receiver" v-if="columns[17].visible"/>
              <el-table-column label="申请人" align="center" prop="applicant" v-if="columns[18].visible"/>
              <el-table-column label="收货组织" align="center" prop="produclotId" v-if="columns[19].visible"/>
              <el-table-column label="收货人部门" align="center" prop="receiverDept" v-if="columns[20].visible"/>
              <el-table-column label="招标员" align="center" prop="tenderer" v-if="columns[21].visible"/>
              <el-table-column label="需求组织" align="center" prop="operatorId" v-if="columns[22].visible"/>
              <el-table-column label="状态" align="center" prop="status" v-if="columns[25].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.common_status" :value="scope.row.status"/>
                </template>
              </el-table-column>
              <el-table-column label="收货状态" align="center" prop="receivingStatus" v-if="columns[26].visible">
                <template slot-scope="scope">
                      <dict-tag :options="dict.type.receive_status" :value="scope.row.receivingStatus"/>
                </template>
              </el-table-column>
        </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 ref="subTablePanel" :style="{height: subTableDivHeight}">
        <el-row class="mb5">
          <label class="subTableTitle"><i class="el-icon-notebook-1"/>收货单明细信息</label>
        </el-row>
        <el-table border :height="subTableHeight" size="mini" :data="tRkReceivingGoodsTabList" :row-class-name="rowTRkReceivingGoodsTabIndex" @selection-change="handleTRkReceivingGoodsTabSelectionChange" ref="tRkReceivingGoodsTab">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
                      <el-table-column label="子需求编号" prop="salesOrderNumber" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.salesOrderNumber" placeholder="请输入子需求编号" />
                        </template>
                      </el-table-column>
                      <el-table-column label="物料编号" prop="goodsId" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.goodsId" placeholder="请输入物料编号" />
                        </template>
                      </el-table-column>
                      <el-table-column label="物料名称" prop="goodsName" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.goodsName" placeholder="请输入物料名称" />
                        </template>
                      </el-table-column>
                      <el-table-column label="单位" prop="unit" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.unit" placeholder="请输入单位" />
                        </template>
                      </el-table-column>
                      <el-table-column label="规格型号" prop="specification" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.specification" placeholder="请输入规格型号" />
                        </template>
                      </el-table-column>
                      <el-table-column label="物料描述" prop="recoil" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.recoil" placeholder="请输入物料描述" />
                        </template>
                      </el-table-column>
                      <el-table-column label="品牌" prop="brand" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.brand" placeholder="请输入品牌" />
                        </template>
                      </el-table-column>
                      <el-table-column label="计划单价" prop="price" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.price" placeholder="请输入计划单价" />
                        </template>
                      </el-table-column>
                      <el-table-column label="计划金额" prop="totalMoney" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.totalMoney" placeholder="请输入计划金额" />
                        </template>
                      </el-table-column>
                      <el-table-column label="到货数量" prop="arraMount" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.arraMount" placeholder="请输入到货数量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="签收数量" prop="recNum" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.recNum" placeholder="请输入签收数量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="工程项目" prop="project" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.project" placeholder="请输入工程项目" />
                        </template>
                      </el-table-column>
                      <el-table-column label="需求部门" prop="needDept" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.needDept" placeholder="请输入需求部门" />
                        </template>
                      </el-table-column>
                      <el-table-column label="用途" prop="useType" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.useType" placeholder="请选择用途">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="测量单位" prop="scaleUnit" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.scaleUnit" placeholder="请输入测量单位" />
                        </template>
                      </el-table-column>
                      <el-table-column label="总量" prop="totalVolume" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.totalVolume" placeholder="请输入总量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="毛重" prop="totalRoughWeight" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.totalRoughWeight" placeholder="请输入毛重" />
                        </template>
                      </el-table-column>
                      <el-table-column label="净重" prop="totalNetWeigh" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.totalNetWeigh" placeholder="请输入净重" />
                        </template>
                      </el-table-column>
                      <el-table-column label="数量" prop="amount" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.amount" placeholder="请输入数量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="上报时间" prop="productionDate" width="240">
                        <template slot-scope="scope">
                          <el-date-picker clearable v-model="scope.row.productionDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择上报时间" />
                        </template>
                      </el-table-column>
                      <el-table-column label="仓库ID" prop="storageId" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.storageId" placeholder="请输入仓库ID" />
                        </template>
                      </el-table-column>
                      <el-table-column label="库区" prop="storageAreaId" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.storageAreaId" placeholder="请输入库区" />
                        </template>
                      </el-table-column>
                      <el-table-column label="技术需求附件" prop="packageId" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.packageId" placeholder="请输入技术需求附件" />
                        </template>
                      </el-table-column>
                      <el-table-column label="物料分类" prop="goodsTypeId" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.goodsTypeId" placeholder="请输入物料分类" />
                        </template>
                      </el-table-column>
                      <el-table-column label="重量" prop="goodsVolume" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.goodsVolume" placeholder="请输入重量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="打印状态" prop="printSts" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.printSts" placeholder="请输入打印状态" />
                        </template>
                      </el-table-column>
                      <el-table-column label="打印次数" prop="printCs" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.printCs" placeholder="请输入打印次数" />
                        </template>
                      </el-table-column>
                      <el-table-column label="重量" prop="netWeigh" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.netWeigh" placeholder="请输入重量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="冻结数量" prop="kindNum" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.kindNum" placeholder="请输入冻结数量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="需求时间" prop="expiryDate" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.expiryDate" placeholder="请输入需求时间" />
                        </template>
                      </el-table-column>
                      <el-table-column label="创建时间" prop="operateDate" width="240">
                        <template slot-scope="scope">
                          <el-date-picker clearable v-model="scope.row.operateDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择创建时间" />
                        </template>
                      </el-table-column>
                      <el-table-column label="物料状态" prop="productStatus" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.productStatus" placeholder="请选择物料状态">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="收货状态" prop="receivingStatus" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.receivingStatus" placeholder="请选择收货状态">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="内部状态" prop="inStatus" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.inStatus" placeholder="请选择内部状态">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="容器号" prop="ctl" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.ctl" placeholder="请输入容器号" />
                        </template>
                      </el-table-column>
                      <el-table-column label="质检日期" prop="qualityInspectionDate" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.qualityInspectionDate" placeholder="请输入质检日期" />
                        </template>
                      </el-table-column>
                      <el-table-column label="状态" prop="status" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.status" placeholder="请选择状态">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="累计入库数量" prop="acceNum" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.acceNum" placeholder="请输入累计入库数量" />
                        </template>
                      </el-table-column>
                      <el-table-column label="质检状态" prop="qualityInspecStatus" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.qualityInspecStatus" placeholder="请选择质检状态">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="订单类型" prop="orderType" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.orderType" placeholder="请选择订单类型">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="申请人" prop="applicant" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.applicant" placeholder="请输入申请人" />
                        </template>
                      </el-table-column>
                      <el-table-column label="申请部门" prop="supplier" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.supplier" placeholder="请输入申请部门" />
                        </template>
                      </el-table-column>
                      <el-table-column label="是否合格" prop="qualified" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.qualified" placeholder="请输入是否合格" />
                        </template>
                      </el-table-column>
                      <el-table-column label="计划日期" prop="planDate" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.planDate" placeholder="请输入计划日期" />
                        </template>
                      </el-table-column>
                      <el-table-column label="计划时间" prop="planTime" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.planTime" placeholder="请输入计划时间" />
                        </template>
                      </el-table-column>
                      <el-table-column label="需求周期" prop="needCycle" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.needCycle" placeholder="请输入需求周期" />
                        </template>
                      </el-table-column>
                      <el-table-column label="需求类型" prop="needType" width="150">
                        <template slot-scope="scope">
                          <el-select v-model="scope.row.needType" placeholder="请选择需求类型">
                            <el-option label="请选择字典生成" value="" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="批次号" prop="batchNo" width="150">
                        <template slot-scope="scope">
                          <el-input v-model="scope.row.batchNo" placeholder="请输入批次号" />
                        </template>
                      </el-table-column>
                      <el-table-column label="上报时间" prop="reportTime" width="240">
                        <template slot-scope="scope">
                          <el-date-picker clearable v-model="scope.row.reportTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择上报时间" />
                        </template>
                      </el-table-column>
            </el-table>
      </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="noticeId">
                          <el-input v-model="form.noticeId" placeholder="请输入入库通知单号" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="交货单号" prop="deliveryId">
                          <el-input v-model="form.deliveryId" 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="providerName">
                          <el-input v-model="form.providerName" placeholder="请输入供应商名称" />
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
                      <el-col :span="6">
                        <el-form-item label="发货单号" prop="purchaseId">
                          <el-input v-model="form.purchaseId" placeholder="请输入发货单号" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="发货组织" prop="shippingDept">
                          <el-input v-model="form.shippingDept" placeholder="请输入发货组织" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="联系人" prop="contact">
                          <el-input v-model="form.contact" placeholder="请输入联系人" />
                        </el-form-item>
                      </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-row>
                        <el-row>
                      <el-col :span="6">
                        <el-form-item label="收货地址" prop="receiveAddr">
                          <el-input v-model="form.receiveAddr" placeholder="请输入收货地址" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="发货日期" prop="sendeDate">
                          <el-date-picker clearable
                                          v-model="form.sendeDate"
                                          type="date"
                                          value-format="yyyy-MM-dd"
                                          placeholder="请选择发货日期">
                          </el-date-picker>
                        </el-form-item>
                      </el-col>
                      <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="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="receivingArea">
                          <el-input v-model="form.receivingArea" placeholder="请输入送货区域" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="使用单位收货人" prop="useReceiver">
                          <el-input v-model="form.useReceiver" placeholder="请输入使用单位收货人" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="使用单位保管员" prop="useCustodian">
                          <el-input v-model="form.useCustodian" placeholder="请输入使用单位保管员" />
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="使用单位主管" prop="useLeader">
                          <el-input v-model="form.useLeader" placeholder="请输入使用单位主管" />
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
                      <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="申请人" prop="applicant">
                          <el-input v-model="form.applicant" placeholder="请输入申请人" />
                        </el-form-item>
                      </el-col>
                      <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="receiverDept">
                          <el-input v-model="form.receiverDept" placeholder="请输入收货人部门" />
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
                      <el-col :span="6">
                        <el-form-item label="招标员" prop="tenderer">
                          <el-input v-model="form.tenderer" placeholder="请输入招标员" />
                        </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="status">
                          <el-select v-model="form.status" placeholder="请选择状态">
                            <el-option
                                v-for="dict in dict.type.common_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="receivingStatus">
                          <el-select v-model="form.receivingStatus" placeholder="请选择收货状态">
                            <el-option
                                v-for="dict in dict.type.receive_status"
                                :key="dict.value"
                                :label="dict.label"
                                :value="dict.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                        </el-row>
                        <el-row>
          </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 { listRkRecevinggoods, getRkRecevinggoods, delRkRecevinggoods, addRkRecevinggoods, updateRkRecevinggoods, disabled, enabled, changeStatus } from "@/api/system/rkRecevinggoods";
  import { listCOLUMN } from "@/api/system/column";

  export default {
    name: "RkRecevinggoods",
        dicts: ['receive_status', 'common_status'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
            // 子表选中数据
            checkedTRkReceivingGoodsTab: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 收货单表格数据
              rkRecevinggoodsList: [],
            // 收货单明细表格数据
                  tRkReceivingGoodsTabList: [],
        // 弹出层标题
        title: "",
        mainTableHeight:"0px",
        mainTableDivHeight:"0px",
        subTableHeight:"0px",
        subTableDivHeight: "0px",
        businessCodeTrk: "rkRecevinggoods",
        rightToolbarShow: false,
        tableNo: 0,
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 100,
          noticeId: null,
          deliveryId: null,
          providerId: null,
          providerName: null,
          purchaseId: null,
          shippingDept: null,
          purchaseDept: null,
          receiver: null,
          applicant: null,
          produclotId: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        },
        columns: [
            { key: 0, label: `主键`, visible: true, columnName: "id" },
            { key: 1, label: `入库通知单号`, visible: true, columnName: "notice_id" },
            { key: 2, label: `交货单号`, visible: true, columnName: "delivery_id" },
            { key: 3, label: `供应商编号`, visible: true, columnName: "provider_id" },
            { key: 4, label: `供应商名称`, visible: true, columnName: "provider_name" },
            { key: 5, label: `发货单号`, visible: true, columnName: "purchase_id" },
            { key: 6, label: `发货组织`, visible: true, columnName: "shipping_dept" },
            { key: 7, label: `联系人`, visible: true, columnName: "contact" },
            { key: 8, label: `联系方式`, visible: true, columnName: "telephone" },
            { key: 9, label: `收货地址`, visible: true, columnName: "receive_addr" },
            { key: 10, label: `发货日期`, visible: true, columnName: "sende_date" },
            { key: 11, label: `采购组织`, visible: true, columnName: "purchase_dept" },
            { key: 12, label: `备注`, visible: true, columnName: "remark" },
            { key: 13, label: `送货区域`, visible: true, columnName: "receiving_area" },
            { key: 14, label: `使用单位收货人`, visible: true, columnName: "use_receiver" },
            { key: 15, label: `使用单位保管员`, visible: true, columnName: "use_custodian" },
            { key: 16, label: `使用单位主管`, visible: true, columnName: "use_leader" },
            { key: 17, label: `收货人`, visible: true, columnName: "receiver" },
            { key: 18, label: `申请人`, visible: true, columnName: "applicant" },
            { key: 19, label: `收货组织`, visible: true, columnName: "produclot_id" },
            { key: 20, label: `收货人部门`, visible: true, columnName: "receiver_dept" },
            { key: 21, label: `招标员`, visible: true, columnName: "tenderer" },
            { key: 22, label: `需求组织`, visible: true, columnName: "operator_id" },
            { key: 23, label: `工厂ID`, visible: true, columnName: "factory_id" },
            { key: 24, label: `存储模式`, visible: true, columnName: "storage_mode" },
            { key: 25, label: `状态`, visible: true, columnName: "status" },
            { key: 26, label: `收货状态`, visible: true, columnName: "receiving_status" },
            { key: 27, label: `订单类型`, visible: true, columnName: "order_type" },
            { key: 28, label: `创建人`, visible: true, columnName: "create_by" },
            { key: 29, label: `录入人`, visible: true, columnName: "update_by" },
            { key: 30, label: `创建时间`, visible: true, columnName: "create_time" },
            { key: 31, 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;

            var mainHeight = tablePanelHeight/2;
            this.mainTableDivHeight = mainHeight + "px";
            this.mainTableHeight = (mainHeight - 25) + "px";
            this.subTableDivHeight = tablePanelHeight - mainHeight + "px";
            this.subTableHeight = tablePanelHeight - mainHeight -20 - 5 + "px";

          })
      },
      /** 查询收货单列表 */
      getList() {
        this.loading = true;
        listRkRecevinggoods(this.queryParams).then(response => {
          this.rkRecevinggoodsList = response.rows;
          this.total = response.total;
          this.loading = false;
          this.getHideColumn();
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
                        id: null,
                        noticeId: null,
                        deliveryId: null,
                        providerId: null,
                        providerName: null,
                        purchaseId: null,
                        shippingDept: null,
                        contact: null,
                        telephone: null,
                        receiveAddr: null,
                        sendeDate: null,
                        purchaseDept: null,
                        remark: null,
                        receivingArea: null,
                        useReceiver: null,
                        useCustodian: null,
                        useLeader: null,
                        receiver: null,
                        applicant: null,
                        produclotId: null,
                        receiverDept: null,
                        tenderer: null,
                        operatorId: null,
                        factoryId: null,
                        storageMode: null,
                        status: null,
                        receivingStatus: null,
                        orderType: null,
                        createBy: null,
                        updateBy: null,
                        createTime: null,
                        updateTime: null
        };
            this.tRkReceivingGoodsTabList = [];
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 增加主表行双击事件,查询子表数据
      handleMainTableClick(row) {
        const id = row.id
        getRkRecevinggoods(id).then(response => {
            this.tRkReceivingGoodsTabList = response.data.tRkReceivingGoodsTabList;
        });
      },
      // 多选框选中数据
      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
        getRkRecevinggoods(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改收货单";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            this.form.tRkReceivingGoodsTabList = this.tRkReceivingGoodsTabList;
            if (this.form.id != null) {
              updateRkRecevinggoods(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addRkRecevinggoods(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 delRkRecevinggoods(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(() => { });
      },

  /** 收货单明细序号 */
  rowTRkReceivingGoodsTabIndex({ row, rowIndex }) {
    row.index = rowIndex + 1;
  },
  /** 收货单明细添加按钮操作 */
  handleAddTRkReceivingGoodsTab() {
    let obj = {};
    obj.salesOrderNumber = "";
    obj.goodsId = "";
    obj.goodsName = "";
    obj.unit = "";
    obj.specification = "";
    obj.recoil = "";
    obj.brand = "";
    obj.price = "";
    obj.totalMoney = "";
    obj.arraMount = "";
    obj.recNum = "";
    obj.project = "";
    obj.needDept = "";
    obj.useType = "";
    obj.scaleUnit = "";
    obj.totalVolume = "";
    obj.totalRoughWeight = "";
    obj.totalNetWeigh = "";
    obj.amount = "";
    obj.productionDate = "";
    obj.storageId = "";
    obj.storageAreaId = "";
    obj.packageId = "";
    obj.remark = "";
    obj.goodsTypeId = "";
    obj.barcode = "";
    obj.goodsVolume = "";
    obj.printSts = "";
    obj.printCs = "";
    obj.netWeigh = "";
    obj.kindNum = "";
    obj.expiryDate = "";
    obj.operateDate = "";
    obj.productStatus = "";
    obj.receivingStatus = "";
    obj.inStatus = "";
    obj.ctl = "";
    obj.qualityInspectionDate = "";
    obj.status = "";
    obj.acceNum = "";
    obj.qualityInspecStatus = "";
    obj.orderType = "";
    obj.applicant = "";
    obj.supplier = "";
    obj.qualified = "";
    obj.planDate = "";
    obj.planTime = "";
    obj.needCycle = "";
    obj.needType = "";
    obj.batchNo = "";
    obj.reportTime = "";
    this.tRkReceivingGoodsTabList.push(obj);
  },
  /** 收货单明细删除按钮操作 */
  handleDeleteTRkReceivingGoodsTab() {
    if (this.checkedTRkReceivingGoodsTab.length == 0) {
      this.$modal.msgError("请先选择要删除的收货单明细数据");
    } else {
      const tRkReceivingGoodsTabList = this.tRkReceivingGoodsTabList;
      const checkedTRkReceivingGoodsTab = this.checkedTRkReceivingGoodsTab;
      this.tRkReceivingGoodsTabList = tRkReceivingGoodsTabList.filter(function(item) {
        return checkedTRkReceivingGoodsTab.indexOf(item.index) == -1
      });
    }
  },
  /** 复选框选中数据 */
  handleTRkReceivingGoodsTabSelectionChange(selection) {
    this.checkedTRkReceivingGoodsTab = selection.map(item => item.index)
  },
  /** 导出按钮操作 */
  handleExport() {
    this.download('system/rkRecevinggoods/export', {
      ...this.queryParams
    }, `rkRecevinggoods_${new Date().getTime()}.xlsx`)
  }
  }
  };
</script>
<style scoped>
 .app-container {
  height: calc(100vh - 84px);
 }
</style>
