<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="仓库编号" prop="storageId">
        <el-input
          v-model="queryParams.storageId"
          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="locationId">
        <el-input
          v-model="queryParams.locationId"
          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="storageMode">
        <el-select v-model="queryParams.storageMode" placeholder="请选择入库类型" clearable>
          <el-option
            v-for="dict in dict.type.warehouse_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="单据编号" prop="doctNumber">
        <el-input
          v-model="queryParams.doctNumber"
          placeholder="请输入单据编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <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="goodsName">
        <el-input
          v-model="queryParams.goodsName"
          placeholder="请输入物料名称
"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
          <el-option
            v-for="dict in dict.type.stock_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="生产批号" prop="batchNo">
        <el-input
          v-model="queryParams.batchNo"
          placeholder="请输入生产批号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工厂ID" prop="factoryId">
        <el-input
          v-model="queryParams.factoryId"
          placeholder="请输入工厂ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">刷新</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!---
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['system:tMiStockbak:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['system:tMiStockbak:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['system:tMiStockbak:remove']"
        >删除</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="multiple"
            @click="handleEnable"
            v-hasPermi="['system:tMiStockbak:edit']"
        >启用</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDisabled"
            v-hasPermi="['system:tMiStockbak:remove']"
        >禁用</el-button>
      </el-col>
      -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:tMiStockbak:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="tMiStockbakList" @selection-change="handleSelectionChange">
      <el-table-column sortable type="selection" width="55" align="center"/>
      <el-table-column sortable label="主键" align="center" prop="id"/>
      <el-table-column sortable label="仓库编号" align="center" prop="storageId"/>
      <el-table-column sortable label="库区编号" align="center" prop="storageAreaId"/>
      <el-table-column sortable label="库位编号" align="center" prop="locationId"/>
      <el-table-column sortable label="物料编号" align="center" prop="goodsId"/>
      <el-table-column sortable label="数量" align="center" prop="shelvesNum"/>
      <el-table-column sortable label="备注 物资计划明细备注
" align="center" prop="remark"/>
      <el-table-column label="版本号" align="center" prop="version"/>
      <el-table-column label="入库类型" align="center" prop="storageMode">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.warehouse_type" :value="scope.row.storageMode"/>
        </template>
      </el-table-column>
      <el-table-column label="中标供应商" align="center" prop="providerId"/>
      <el-table-column label="生产日期" align="center" prop="productionDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.productionDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="入库时间" align="center" prop="wareDate"/>
      <el-table-column label="单据编号" align="center" prop="doctNumber"/>
      <el-table-column label="商品体积" align="center" prop="goodsVolume"/>
      <el-table-column label="已占用数量" align="center" prop="occupyNum"/>
      <el-table-column label="通知单号" align="center" prop="noticeId"/>
      <el-table-column label="物料描述" align="center" prop="oriBill"/>
      <el-table-column label="占用容器" align="center" prop="ctl"/>
      <el-table-column label="条形码" align="center" prop="barcode"/>
      <el-table-column label="宽" align="center" prop="wgh"/>
      <el-table-column label="高" align="center" prop="high"/>
      <el-table-column label="物料名称
" align="center" prop="goodsName"/>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.stock_type" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="招标员
" align="center" prop="customerId"/>
      <el-table-column label="生产批号" align="center" prop="batchNo"/>
      <el-table-column label="过期时间" align="center" prop="dueDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dueDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="检查时间" align="center" prop="checkDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.checkDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="标准" align="center" prop="standard"/>
      <el-table-column label="标注过期" align="center" prop="flag"/>
      <el-table-column label="过期天数" align="center" prop="mark"/>
      <el-table-column label="订单数量" align="center" prop="orderNum"/>
      <el-table-column label="物料问题" align="center" prop="problem"/>
      <el-table-column label="计划单价" align="center" prop="price"/>
      <el-table-column label="工厂ID" align="center" prop="factoryId"/>
      <el-table-column label="销售订单" align="center" prop="salesOrderNo"/>
      <el-table-column label="子需求编号" align="center" prop="salesOrderNumber"/>
      <el-table-column label="申请部门
" align="center" prop="supplier"/>
      <el-table-column label="在途数量" align="center" prop="onOrder"/>
      <el-table-column label="操作人" align="center" prop="recordPerson"/>
      <el-table-column label="单位
" align="center" prop="unit"/>
      <el-table-column label="规格" align="center" prop="specification"/>
      <el-table-column label="库龄" align="center" prop="goodsAge"/>
      <el-table-column label="需求数量" align="center" prop="arraMount"/>
      <el-table-column label="物料描述" align="center" prop="recoil"/>
      <el-table-column label="需求组织" align="center" prop="operatorId"/>
      <el-table-column label="申请单号" align="center" prop="purchaseId"/>
      <el-table-column label="申请人" align="center" prop="applicant"/>
      <el-table-column label="主管部门" align="center" prop="respDept"/>
      <el-table-column label="计划日期" align="center" prop="planDate"/>
      <el-table-column label="计划时间" align="center" prop="planTime"/>
      <el-table-column label="需求周期" align="center" prop="needCycle"/>
      <el-table-column label="需求类型" align="center" prop="needType"/>
      <el-table-column label="物料分类" align="center" prop="goodsTypeId"/>
      <el-table-column label="品牌" align="center" prop="brand"/>
      <el-table-column label="计划金额" align="center" prop="totalMoney"/>
      <el-table-column label="需求时间" align="center" prop="expiryDate"/>
      <el-table-column label="建议供应商名称" align="center" prop="providerName"/>
      <el-table-column label="收货人" align="center" prop="receiver"/>
      <el-table-column label="需求部门" align="center" prop="needDept"/>
      <el-table-column label="采购组织" align="center" prop="purchaseDept"/>
      <el-table-column label="收货组织" align="center" prop="produclotId"/>
      <el-table-column label="收货人部门" align="center" prop="receiverDept"/>
      <el-table-column label="送货区域" align="center" prop="receivingArea"/>
      <el-table-column label="技术需求附件" align="center" prop="packageId"/>
      <el-table-column label="用途" align="center" prop="useType"/>
      <el-table-column label="中标供应商联系方式" align="center" prop="telephone"/>
      <el-table-column label="总重量" align="center" prop="totalVolume"/>
      <el-table-column label="毛重" align="center" prop="totalRoughWeight"/>
      <el-table-column label="净重" align="center" prop="totalNetWeigh"/>
      <el-table-column label="默认存储库区" align="center" prop="defaultStorageAreaId"/>
      <el-table-column label="质检状态" align="center" prop="qualityInspecStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.inspect_status" :value="scope.row.qualityInspecStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="保质期单位" align="center" prop="periodUnit"/>
      <el-table-column label="保质期" align="center" prop="period"/>
      <el-table-column label="上报时间" align="center" prop="reportTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.reportTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:tMiStockbak:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:tMiStockbak:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改库存备份对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="仓库编号" prop="storageId">
          <el-input v-model="form.storageId" placeholder="请输入仓库编号"/>
        </el-form-item>
        <el-form-item label="库区编号" prop="storageAreaId">
          <el-input v-model="form.storageAreaId" placeholder="请输入库区编号"/>
        </el-form-item>
        <el-form-item label="库位编号" prop="locationId">
          <el-input v-model="form.locationId" placeholder="请输入库位编号"/>
        </el-form-item>
        <el-form-item label="物料编号" prop="goodsId">
          <el-input v-model="form.goodsId" placeholder="请输入物料编号"/>
        </el-form-item>
        <el-form-item label="数量" prop="shelvesNum">
          <el-input v-model="form.shelvesNum" placeholder="请输入数量"/>
        </el-form-item>
        <el-form-item label="备注 物资计划明细备注
" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
        <el-form-item label="版本号" prop="version">
          <el-input v-model="form.version" placeholder="请输入版本号"/>
        </el-form-item>
        <el-form-item label="入库类型" prop="storageMode">
          <el-select v-model="form.storageMode" 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-form-item label="中标供应商" prop="providerId">
          <el-input v-model="form.providerId" placeholder="请输入中标供应商"/>
        </el-form-item>
        <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-form-item label="入库时间" prop="wareDate">
          <el-input v-model="form.wareDate" placeholder="请输入入库时间"/>
        </el-form-item>
        <el-form-item label="单据编号" prop="doctNumber">
          <el-input v-model="form.doctNumber" placeholder="请输入单据编号"/>
        </el-form-item>
        <el-form-item label="商品体积" prop="goodsVolume">
          <el-input v-model="form.goodsVolume" placeholder="请输入商品体积"/>
        </el-form-item>
        <el-form-item label="已占用数量" prop="occupyNum">
          <el-input v-model="form.occupyNum" placeholder="请输入已占用数量"/>
        </el-form-item>
        <el-form-item label="通知单号" prop="noticeId">
          <el-input v-model="form.noticeId" placeholder="请输入通知单号"/>
        </el-form-item>
        <el-form-item label="物料描述" prop="oriBill">
          <el-input v-model="form.oriBill" placeholder="请输入物料描述"/>
        </el-form-item>
        <el-form-item label="占用容器" prop="ctl">
          <el-input v-model="form.ctl" placeholder="请输入占用容器"/>
        </el-form-item>
        <el-form-item label="条形码" prop="barcode">
          <el-input v-model="form.barcode" placeholder="请输入条形码"/>
        </el-form-item>
        <el-form-item label="宽" prop="wgh">
          <el-input v-model="form.wgh" placeholder="请输入宽"/>
        </el-form-item>
        <el-form-item label="高" prop="high">
          <el-input v-model="form.high" placeholder="请输入高"/>
        </el-form-item>
        <el-form-item label="物料名称
" prop="goodsName">
          <el-input v-model="form.goodsName" placeholder="请输入物料名称
"/>
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-select v-model="form.status" placeholder="请选择状态">
            <el-option
              v-for="dict in dict.type.stock_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="招标员
" prop="customerId">
          <el-input v-model="form.customerId" placeholder="请输入招标员
"/>
        </el-form-item>
        <el-form-item label="生产批号" prop="batchNo">
          <el-input v-model="form.batchNo" placeholder="请输入生产批号"/>
        </el-form-item>
        <el-form-item label="过期时间" prop="dueDate">
          <el-date-picker clearable
                          v-model="form.dueDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择过期时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="检查时间" prop="checkDate">
          <el-date-picker clearable
                          v-model="form.checkDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择检查时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="标准" prop="standard">
          <el-input v-model="form.standard" placeholder="请输入标准"/>
        </el-form-item>
        <el-form-item label="标注过期" prop="flag">
          <el-input v-model="form.flag" placeholder="请输入标注过期"/>
        </el-form-item>
        <el-form-item label="过期天数" prop="mark">
          <el-input v-model="form.mark" placeholder="请输入过期天数"/>
        </el-form-item>
        <el-form-item label="订单数量" prop="orderNum">
          <el-input v-model="form.orderNum" placeholder="请输入订单数量"/>
        </el-form-item>
        <el-form-item label="物料问题" prop="problem">
          <el-input v-model="form.problem" placeholder="请输入物料问题"/>
        </el-form-item>
        <el-form-item label="计划单价" prop="price">
          <el-input v-model="form.price" placeholder="请输入计划单价"/>
        </el-form-item>
        <el-form-item label="测量单位" prop="scaleUnit">
          <el-input v-model="form.scaleUnit" placeholder="请输入测量单位"/>
        </el-form-item>
        <el-form-item label="物料SKU" prop="goodsSku">
          <el-input v-model="form.goodsSku" placeholder="请输入物料SKU"/>
        </el-form-item>
        <el-form-item label="工厂ID" prop="factoryId">
          <el-input v-model="form.factoryId" placeholder="请输入工厂ID"/>
        </el-form-item>
        <el-form-item label="销售订单" prop="salesOrderNo">
          <el-input v-model="form.salesOrderNo" placeholder="请输入销售订单"/>
        </el-form-item>
        <el-form-item label="子需求编号" prop="salesOrderNumber">
          <el-input v-model="form.salesOrderNumber" placeholder="请输入子需求编号"/>
        </el-form-item>
        <el-form-item label="申请部门
" prop="supplier">
          <el-input v-model="form.supplier" placeholder="请输入申请部门
"/>
        </el-form-item>
        <el-form-item label="在途数量" prop="onOrder">
          <el-input v-model="form.onOrder" placeholder="请输入在途数量"/>
        </el-form-item>
        <el-form-item label="操作人" prop="recordPerson">
          <el-input v-model="form.recordPerson" placeholder="请输入操作人"/>
        </el-form-item>
        <el-form-item label="入库任务ID" prop="lotId">
          <el-input v-model="form.lotId" placeholder="请输入入库任务ID"/>
        </el-form-item>
        <el-form-item label="堆垛机编号" prop="decid">
          <el-input v-model="form.decid" placeholder="请输入堆垛机编号"/>
        </el-form-item>
        <el-form-item label="单位
" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位
"/>
        </el-form-item>
        <el-form-item label="规格" prop="specification">
          <el-input v-model="form.specification" placeholder="请输入规格"/>
        </el-form-item>
        <el-form-item label="库龄" prop="goodsAge">
          <el-input v-model="form.goodsAge" placeholder="请输入库龄"/>
        </el-form-item>
        <el-form-item label="需求数量" prop="arraMount">
          <el-input v-model="form.arraMount" placeholder="请输入需求数量"/>
        </el-form-item>
        <el-form-item label="物料描述" prop="recoil">
          <el-input v-model="form.recoil" placeholder="请输入物料描述"/>
        </el-form-item>
        <el-form-item label="需求组织" prop="operatorId">
          <el-input v-model="form.operatorId" placeholder="请输入需求组织"/>
        </el-form-item>

        <el-form-item label="申请单号" prop="purchaseId">
          <el-input v-model="form.purchaseId" placeholder="请输入申请单号"/>
        </el-form-item>
        <el-form-item label="申请人" prop="applicant">
          <el-input v-model="form.applicant" placeholder="请输入申请人"/>
        </el-form-item>
        <el-form-item label="主管部门" prop="respDept">
          <el-input v-model="form.respDept" placeholder="请输入主管部门"/>
        </el-form-item>
        <el-form-item label="计划日期" prop="planDate">
          <el-input v-model="form.planDate" placeholder="请输入计划日期"/>
        </el-form-item>
        <el-form-item label="计划时间" prop="planTime">
          <el-input v-model="form.planTime" placeholder="请输入计划时间"/>
        </el-form-item>
        <el-form-item label="需求周期" prop="needCycle">
          <el-input v-model="form.needCycle" placeholder="请输入需求周期"/>
        </el-form-item>
        <el-form-item label="物料分类" prop="goodsTypeId">
          <el-input v-model="form.goodsTypeId" placeholder="请输入物料分类"/>
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入品牌"/>
        </el-form-item>
        <el-form-item label="计划金额" prop="totalMoney">
          <el-input v-model="form.totalMoney" placeholder="请输入计划金额"/>
        </el-form-item>
        <el-form-item label="需求时间" prop="expiryDate">
          <el-input v-model="form.expiryDate" placeholder="请输入需求时间"/>
        </el-form-item>
        <el-form-item label="建议供应商名称" prop="providerName">
          <el-input v-model="form.providerName" placeholder="请输入建议供应商名称"/>
        </el-form-item>
        <el-form-item label="收货人" prop="receiver">
          <el-input v-model="form.receiver" placeholder="请输入收货人"/>
        </el-form-item>
        <el-form-item label="需求部门" prop="needDept">
          <el-input v-model="form.needDept" placeholder="请输入需求部门"/>
        </el-form-item>
        <el-form-item label="采购组织" prop="purchaseDept">
          <el-input v-model="form.purchaseDept" placeholder="请输入采购组织"/>
        </el-form-item>
        <el-form-item label="收货组织" prop="produclotId">
          <el-input v-model="form.produclotId" placeholder="请输入收货组织"/>
        </el-form-item>
        <el-form-item label="收货人部门" prop="receiverDept">
          <el-input v-model="form.receiverDept" placeholder="请输入收货人部门"/>
        </el-form-item>
        <el-form-item label="送货区域" prop="receivingArea">
          <el-input v-model="form.receivingArea" placeholder="请输入送货区域"/>
        </el-form-item>
        <el-form-item label="技术需求附件" prop="packageId">
          <el-input v-model="form.packageId" placeholder="请输入技术需求附件"/>
        </el-form-item>
        <el-form-item label="中标供应商联系方式" prop="telephone">
          <el-input v-model="form.telephone" placeholder="请输入中标供应商联系方式"/>
        </el-form-item>
        <el-form-item label="总重量" prop="totalVolume">
          <el-input v-model="form.totalVolume" placeholder="请输入总重量"/>
        </el-form-item>
        <el-form-item label="毛重" prop="totalRoughWeight">
          <el-input v-model="form.totalRoughWeight" placeholder="请输入毛重"/>
        </el-form-item>
        <el-form-item label="净重" prop="totalNetWeigh">
          <el-input v-model="form.totalNetWeigh" placeholder="请输入净重"/>
        </el-form-item>
        <el-form-item label="默认存储库区" prop="defaultStorageAreaId">
          <el-input v-model="form.defaultStorageAreaId" placeholder="请输入默认存储库区"/>
        </el-form-item>
        <el-form-item label="质检状态" prop="qualityInspecStatus">
          <el-select v-model="form.qualityInspecStatus" placeholder="请选择质检状态">
            <el-option
              v-for="dict in dict.type.inspect_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="保质期单位" prop="periodUnit">
          <el-input v-model="form.periodUnit" placeholder="请输入保质期单位"/>
        </el-form-item>
        <el-form-item label="保质期" prop="period">
          <el-input v-model="form.period" placeholder="请输入保质期"/>
        </el-form-item>
        <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-form>
      <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 {
  listTMiStockbak,
  getTMiStockbak,
  delTMiStockbak,
  addTMiStockbak,
  updateTMiStockbak,
  disabled,
  enabled,
  changeStatus
} from "@/api/system/tMiStockbak";

export default {
  name: "TMiStockbak",
  dicts: ['warehouse_type', 'inspect_status', 'stock_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 库存备份表格数据
      tMiStockbakList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        storageId: null,
        storageAreaId: null,
        locationId: null,
        goodsId: null,
        storageMode: null,
        doctNumber: null,
        noticeId: null,
        goodsName: null,
        status: null,
        batchNo: null,
        factoryId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询库存备份列表 */
    getList() {
      this.loading = true;
      listTMiStockbak(this.queryParams).then(response => {
        this.tMiStockbakList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        storageId: null,
        storageAreaId: null,
        locationId: null,
        goodsId: null,
        shelvesNum: null,
        remark: null,
        version: null,
        storageMode: null,
        providerId: null,
        productionDate: null,
        wareDate: null,
        doctNumber: null,
        goodsVolume: null,
        occupyNum: null,
        noticeId: null,
        oriBill: null,
        ctl: null,
        barcode: null,
        wgh: null,
        high: null,
        goodsName: null,
        status: null,
        customerId: null,
        batchNo: null,
        dueDate: null,
        checkDate: null,
        standard: null,
        flag: null,
        mark: null,
        orderNum: null,
        problem: null,
        price: null,
        packingNum: null,
        boxType: null,
        scaleUnit: null,
        goodsSku: null,
        factoryId: null,
        salesOrderNo: null,
        salesOrderNumber: null,
        supplier: null,
        onOrder: null,
        recordPerson: null,
        lotId: null,
        decid: null,
        unit: null,
        specification: null,
        goodsAge: null,
        arraMount: null,
        recoil: null,
        operatorId: null,
        operateDate: null,
        purchaseId: null,
        applicant: null,
        respDept: null,
        planDate: null,
        planTime: null,
        needCycle: null,
        needType: null,
        goodsTypeId: null,
        brand: null,
        totalMoney: null,
        expiryDate: null,
        providerName: null,
        receiver: null,
        needDept: null,
        purchaseDept: null,
        produclotId: null,
        receiverDept: null,
        receivingArea: null,
        packageId: null,
        useType: null,
        telephone: null,
        totalVolume: null,
        totalRoughWeight: null,
        totalNetWeigh: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null,
        defaultStorageAreaId: 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
      getTMiStockbak(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) {
            updateTMiStockbak(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTMiStockbak(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 delTMiStockbak(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/tMiStockbak/export', {
        ...this.queryParams
      }, `tMiStockbak_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

