<template>
  <div class="inventoryCheckSelfDiskList-wrap">
    <a-spin :spinning="spinning" tip="Loading...">
      <a-page-header :ghost="false" :backIcon="false" class="inventoryCheckSelfDiskList-back" >
        <!-- 自定义的二级文字标题 -->
        <template slot="subTitle">
          <a id="inventoryCheckSelfDiskList-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
          <span class="billno">单号：{{ basicInfoData&&basicInfoData.checkWarehouseNo }}</span>
          <a-tag color="blue">{{ basicInfoData&&basicInfoData.stateDictValue }}</a-tag>
        </template>
      </a-page-header>
      <!-- 基础信息 -->
      <a-card size="small" :bordered="false" class="inventoryCheckSelfDiskList-cont">
        <a-collapse defaultActiveKey="1">
          <a-collapse-panel key="1" header="基础信息">
            <a-descriptions :column="3">
              <a-descriptions-item label="盘点类型">{{ (basicInfoData&&basicInfoData.checkTypeDictValue) || '--' }}</a-descriptions-item>
              <a-descriptions-item label="是否区分仓库">{{ (basicInfoData&&basicInfoData.warehouseFlagDictValue) || '--' }}</a-descriptions-item>
              <a-descriptions-item label="盘点仓库" :span="3" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">{{ (basicInfoData&&basicInfoData.warehouseNameList) || '--' }}</a-descriptions-item>
              <a-descriptions-item label="创建人">{{ (basicInfoData&&basicInfoData.creatorName) || '--' }}</a-descriptions-item>
              <a-descriptions-item label="创建时间">{{ (basicInfoData&&basicInfoData.createDate) || '--' }}</a-descriptions-item>
              <a-descriptions-item label="审核时间">{{ (basicInfoData&&basicInfoData.checkSuperviseTime) || '--' }}</a-descriptions-item>
            </a-descriptions>
          </a-collapse-panel>
        </a-collapse>
      </a-card>
      <a-card size="small" :bordered="false" class="inventoryCheckSelfDiskList-cont">
        <!-- 筛选条件 -->
        <div class="table-page-search-wrapper">
          <a-row>
            <a-col :md="20" :sm="24">
              <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
                <a-row :gutter="15">
                  <a-col :md="6" :sm="24">
                    <a-form-item label="产品编码" prop="productCode">
                      <a-input id="inventoryCheckSelfDiskList-productCode" v-model.trim="queryParam.productCode" placeholder="请输入" allowClear />
                    </a-form-item>
                  </a-col>
                  <a-col :md="6" :sm="24">
                    <a-form-item label="产品名称" prop="productName">
                      <a-input id="inventoryCheckSelfDiskList-productName" v-model.trim="queryParam.productName" placeholder="请输入" allowClear />
                    </a-form-item>
                  </a-col>
                  <a-col :md="6" :sm="24">
                    <a-form-item label="产品品牌">
                      <ProductBrand id="inventoryCheckSelfDiskList-productBrand" v-model="queryParam.brandSn"></ProductBrand>
                    </a-form-item>
                  </a-col>
                  <template v-if="advanced">
                    <a-col :md="6" :sm="24">
                      <a-form-item label="产品分类">
                        <ProductType id="inventoryCheckSelfDiskList-productType" @change="changeProductType" v-model="productType"></ProductType>
                      </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="24" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">
                      <a-form-item label="仓库">
                        <a-select id="inventoryCheckSelfDiskList-warehouseSn" allowClear placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
                          <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
                        </a-select>
                      </a-form-item>
                    </a-col>
                  </template>
                  <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
                    <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckSelfDiskList-refresh">查询</a-button>
                    <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckSelfDiskList-reset">重置</a-button>
                    <a @click="advanced=!advanced" style="margin-left: 5px">
                      {{ advanced ? '收起' : '展开' }}
                      <a-icon :type="advanced ? 'up' : 'down'"/>
                    </a>
                  </a-col>
                </a-row>
              </a-form>
            </a-col>
            <a-col :md="4" :sm="24" style="text-align: right;">
              <a-button size="small" type="primary" class="button-info" @click.stop="handleBatchAdd('batch')" id="chainTransferOutEdit-del-all-btn">批量添加</a-button>
              <a-button
                size="small"
                type="primary"
                class="button-info"
                style="margin-left: 5px"
                @click.stop="handleBatchAdd('all')"
                id="chainTransferOutEdit-del-all-btn">全部添加</a-button>
            </a-col>
          </a-row>
        </div>
        <!-- 列表 -->
        <s-table
          class="sTable"
          ref="table"
          size="small"
          :rowKey="(record) => record.productSn"
          rowKeyName="productSn"
          :row-selection="{ columnWidth: 40 }"
          @rowSelection="rowSelectionFun"
          :columns="columns"
          :customRow="handleClickRow"
          :data="loadData"
          :scroll="{ y: 300 }"
          :defaultLoadData="false"
          bordered>
          <!-- 产品分类 -->
          <template slot="productType" slot-scope="text, record">
            <span v-if="record.dealerProduct.productTypeName2 || record.dealerProduct.productTypeName3">{{ record.dealerProduct.productTypeName2 }} {{ record.dealerProduct.productTypeName3 ? '>' : '' }} {{ record.dealerProduct.productTypeName3 }}</span>
            <span v-else>--</span>
          </template>
          <!-- 操作 -->
          <template slot="action" slot-scope="text, record">
            <a-button size="small" type="primary" class="button-primary" @click="handleAdd(record)" id="inventoryCheckSelfDiskList-add-btn">添加</a-button>
          </template>
        </s-table>
      </a-card>
      <a-card size="small" :bordered="false" class="inventoryCheckSelfDiskList-cont">
        <!-- 总计 -->
        <a-alert type="info" style="margin-bottom:10px">
          <div slot="message">
            总款数： <strong>{{ productTotal&&(productTotal.totalCategory || productTotal.totalCategory==0) ? productTotal.totalCategory : '--' }}</strong> ，
            总数量： <strong>{{ productTotal&&(productTotal.stockQty || productTotal.stockQty==0) ? productTotal.stockQty : '--' }}</strong> ，
            总成本： <strong>{{ productTotal&&(productTotal.checkCost || productTotal.checkCost==0) ? '￥'+productTotal.checkCost : '--' }}</strong>
          </div>
        </a-alert>
        <!-- 筛选条件 -->
        <div class="table-page-search-wrapper">
          <a-row>
            <a-col :md="20" :sm="24">
              <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
                <a-row :gutter="15">
                  <a-col :md="6" :sm="24">
                    <a-form-item label="产品编码" prop="productCode">
                      <a-input id="inventoryCheckSelfDiskList-productCode" v-model.trim="chooseQueryParam.productCode" placeholder="请输入" allowClear />
                    </a-form-item>
                  </a-col>
                  <a-col :md="6" :sm="24">
                    <a-form-item label="产品名称" prop="productName">
                      <a-input id="inventoryCheckSelfDiskList-productName" v-model.trim="chooseQueryParam.productName" placeholder="请输入" allowClear />
                    </a-form-item>
                  </a-col>
                  <a-col :md="6" :sm="24">
                    <a-form-item label="产品品牌">
                      <ProductBrand id="inventoryCheckSelfDiskList-productBrand" v-model="chooseQueryParam.brandSn"></ProductBrand>
                    </a-form-item>
                  </a-col>
                  <template v-if="chooseAdvanced">
                    <a-col :md="6" :sm="24">
                      <a-form-item label="产品分类">
                        <ProductType id="inventoryCheckSelfDiskList-productType" @change="changeChooseProductType" v-model="chooseProductType"></ProductType>
                      </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="24" v-if="basicInfoData&&basicInfoData.warehouseFlag=='1'">
                      <a-form-item label="仓库">
                        <a-select id="inventoryCheckSelfDiskList-warehouseSn" allowClear placeholder="请选择仓库" v-model="chooseQueryParam.warehouseSn" >
                          <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
                        </a-select>
                      </a-form-item>
                    </a-col>
                  </template>
                  <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
                    <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="chooseDisabled" id="inventoryCheckSelfDiskList-refresh">查询</a-button>
                    <a-button style="margin-left: 5px" @click="chooseResetSearchForm" :disabled="chooseDisabled" id="inventoryCheckSelfDiskList-reset">重置</a-button>
                    <a @click="chooseAdvanced=!chooseAdvanced" style="margin-left: 5px">
                      {{ chooseAdvanced ? '收起' : '展开' }}
                      <a-icon :type="chooseAdvanced ? 'up' : 'down'"/>
                    </a>
                  </a-col>
                </a-row>
              </a-form>
            </a-col>
            <a-col :md="4" :sm="24" style="text-align: right;">
              <a-button size="small" type="primary" class="button-error" @click.stop="handleDel('', 'batch')" id="chainTransferOutEdit-del-all-btn">批量删除</a-button>
              <a-button
                size="small"
                type="primary"
                class="button-error"
                style="margin-left: 5px"
                @click.stop="handleDel('', 'all')"
                id="chainTransferOutEdit-del-all-btn">整单删除</a-button>
            </a-col>
          </a-row>
        </div>
        <!-- 列表 -->
        <s-table
          class="sTable"
          ref="chooseTable"
          size="small"
          :rowKey="(record) => record.id"
          :row-selection="{ columnWidth: 40 }"
          @rowSelection="rowChooseSelectionFun"
          :columns="chooseColumns"
          :data="chooseLoadData"
          :scroll="{ y: 300 }"
          :defaultLoadData="false"
          bordered>
          <!-- 产品分类 -->
          <template slot="productType" slot-scope="text, record">
            <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
            <span v-else>--</span>
          </template>
          <!-- 操作 -->
          <template slot="action" slot-scope="text, record">
            <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="inventoryCheckSelfDiskList-del-btn">删除</a-button>
          </template>
        </s-table>
      </a-card>
    </a-spin>
    <div class="affix-cont">
      <a-button
        type="primary"
        id="inventoryCheckSelfDiskList-submit"
        size="large"
        :disabled="spinning"
        class="button-primary"
        @click="handleSubmit"
        style="padding: 0 60px;">提交</a-button>
    </div>
  </div>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
import { STable, VSelect } from '@/components'
import ProductType from '@/views/common/productType.js'
import ProductBrand from '@/views/common/productBrand.js'
import { checkWarehouseDetail, checkWarehouseDetailStockList, checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseDetailSave, checkWarehouseDetailSaveBatch, checkWarehouseDetailDel, checkWarehouseSubmit } from '@/api/checkWarehouse'
export default {
  name: 'CheckWarehouseSelfDisk',
  components: { STable, VSelect, ProductType, ProductBrand },
  mixins: [commonMixin],
  props: {},
  data () {
    return {
      spinning: false,
      advanced: false, // 高级搜索 展开/关闭
      chooseAdvanced: false, // 高级搜索 展开/关闭
      disabled: false,
      chooseDisabled: false,
      queryParam: {
        productCode: '',
        productName: '',
        warehouseSn: undefined,
        brandSn: undefined,
        productTypeSn1: undefined,
        productTypeSn2: undefined,
        productTypeSn3: undefined
      },
      basicInfoData: null, // 基础信息
      productTotal: null,
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.disabled = true
        this.spinning = true
        return checkWarehouseDetailStockList(Object.assign(parameter, this.queryParam, { checkWarehouseId: this.$route.params.id })).then(res => {
          const data = res.data
          const no = (data.pageNo - 1) * data.pageSize
          for (var i = 0; i < data.list.length; i++) {
            data.list[i].no = no + i + 1
          }
          this.listData = data.list || []
          this.disabled = false
          this.spinning = false
          return data
        })
      },
      chooseQueryParam: {
        productCode: '',
        productName: '',
        warehouseSn: undefined,
        brandSn: undefined,
        productTypeSn1: undefined,
        productTypeSn2: undefined,
        productTypeSn3: undefined
      },
      // 加载数据方法 必须为 Promise 对象
      chooseLoadData: parameter => {
        this.chooseDisabled = true
        return checkWarehouseDetailList(Object.assign(parameter, this.chooseQueryParam, { checkWarehouseSn: this.$route.params.sn })).then(res => {
          const data = res.data
          const no = (data.pageNo - 1) * data.pageSize
          for (var i = 0; i < data.list.length; i++) {
            data.list[i].no = no + i + 1
          }
          this.getDetailCount()
          this.chooseDisabled = false
          return data
        })
      },
      productType: [],
      chooseProductType: [],
      warehouseList: [], //  仓库  下拉数据
      listData: [],
      rowSelectionInfo: null,
      rowChooseSelectionInfo: null
    }
  },
  computed: {
    columns () {
      const arr = [
        { title: '产品编码', dataIndex: 'productCode', width: this.basicInfoData && this.basicInfoData.warehouseFlag == '1' ? '12%' : '22%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品名称', dataIndex: 'productName', width: this.basicInfoData && this.basicInfoData.warehouseFlag == '1' ? '15%' : '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '产品品牌', dataIndex: 'brandName', width: this.basicInfoData && this.basicInfoData.warehouseFlag == '1' ? '9%' : '11%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '14%' },
        { title: '单位', dataIndex: 'unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '库存数量', dataIndex: 'currentQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '最后入库时间', dataIndex: 'lastStockTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
      ]
      if (this.basicInfoData && this.basicInfoData.warehouseFlag == '1') {
        arr.splice(4, 0, { title: '仓库', dataIndex: 'warehouseName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } })
        arr.splice(5, 0, { title: '仓位', dataIndex: 'warehouseLocationName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } })
      }
      return arr
    },
    chooseColumns () {
      const arr = [
        { title: '产品编码', dataIndex: 'productCode', width: this.basicInfoData && this.basicInfoData.warehouseFlag == '1' ? '12%' : '22%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品名称', dataIndex: 'productName', width: this.basicInfoData && this.basicInfoData.warehouseFlag == '1' ? '15%' : '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '产品品牌', dataIndex: 'brandName', width: this.basicInfoData && this.basicInfoData.warehouseFlag == '1' ? '9%' : '11%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '14%', align: 'center' },
        { title: '单位', dataIndex: 'productUnit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '库存数量', dataIndex: 'stockQty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '最后入库时间', dataIndex: 'lastStockTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
      ]
      if (this.basicInfoData && this.basicInfoData.warehouseFlag == '1') {
        arr.splice(4, 0, { title: '仓库', dataIndex: 'warehouseName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } })
        arr.splice(5, 0, { title: '仓位', dataIndex: 'warehouseLocationName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } })
      }
      return arr
    }
  },
  methods: {
    // 表格选中项
    rowSelectionFun (obj) {
      this.rowSelectionInfo = obj || null
    },
    rowChooseSelectionFun (obj) {
      this.rowChooseSelectionInfo = obj || null
    },
    //  重置
    resetSearchForm () {
      this.queryParam.productCode = ''
      this.queryParam.productName = ''
      this.queryParam.warehouseSn = undefined
      this.queryParam.brandSn = undefined
      this.queryParam.productTypeSn1 = undefined
      this.queryParam.productTypeSn2 = undefined
      this.queryParam.productTypeSn3 = undefined
      this.productType = []
      this.$refs.table.refresh(true)
    },
    //  添加
    handleAdd (row) {
      const params = {
        checkWarehouseSn: this.$route.params.sn,
        checkCost: row.putCost,
        productSn: row.productSn,
        productCode: row.productCode,
        productOrigCode: row.productOrigCode || undefined,
        productTypeSn1: row.productTypeSn1,
        productTypeSn2: row.productTypeSn2,
        productTypeSn3: row.productTypeSn3,
        brandSn: row.brandSn,
        stockQty: row.currentQty,
        lastStockTime: row.lastStockTime,
        checkProfitLossCost: row.lastStockCost,
        stockBatchNo: row.stockBatchNo || undefined,
        productProduceDate: row.productProduceDate || undefined,
        productExpiryDate: row.productExpiryDate || undefined,
        warehouseSn: row.warehouseSn || undefined,
        warehouseLocationSn: row.warehouseLocationSn || undefined
      }
      this.spinning = true
      checkWarehouseDetailSave(params).then(res => {
        if (res.status == 200) {
          this.$message.success(res.message)
          this.$refs.table.refresh()
          this.$refs.chooseTable.refresh()
          this.spinning = false
        } else {
          this.spinning = false
        }
      })
    },
    //  批量添加/全部添加
    handleBatchAdd (type) {
      const _this = this
      let params = {}
      if (type == 'batch') { //  批量添加
        if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length == 0)) {
          this.$message.warning('请选择需要批量添加的选项值后再操作！')
          return
        }
        params.checkWarehouseSn = _this.$route.params.sn
        params.checkWarehouseDetailEntityList = []
        this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.map(item => {
          params.checkWarehouseDetailEntityList.push({
            checkWarehouseSn: _this.$route.params.sn,
            checkCost: item.putCost,
            productSn: item.productSn,
            productCode: item.productCode,
            productOrigCode: item.productOrigCode || undefined,
            productTypeSn1: item.productTypeSn1,
            productTypeSn2: item.productTypeSn2,
            productTypeSn3: item.productTypeSn3,
            brandSn: item.brandSn,
            stockQty: item.currentQty,
            lastStockTime: item.lastStockTime,
            checkProfitLossCost: item.lastStockCost,
            stockBatchNo: item.stockBatchNo || undefined,
            productProduceDate: item.productProduceDate || undefined,
            productExpiryDate: item.productExpiryDate || undefined,
            warehouseSn: item.warehouseSn || undefined,
            warehouseLocationSn: item.warehouseLocationSn || undefined
          })
        })
      } else if (type == 'all') { //  全部添加
        if (this.listData.length == 0) {
          this.$message.warning('暂时没有可添加的产品')
          return
        }
        params = {
          checkWarehouseSn: _this.$route.params.sn,
          allFlag: true,
          stockDetailDTO: this.queryParam
        }
      }
      this.spinning = true
      checkWarehouseDetailSaveBatch(params).then(res => {
        if (res.status == 200) {
          this.$refs.table.clearSelected() // 清空表格选中项
          this.$message.success(res.message)
          this.$refs.table.refresh()
          this.$refs.chooseTable.refresh()
          this.spinning = false
        } else {
          this.spinning = false
        }
      })
    },
    //  删除
    handleDel (row, isAll) {
      const _this = this
      let content
      if (isAll == 'batch') { // 批量
        if (this.rowChooseSelectionInfo && this.rowChooseSelectionInfo.selectedRowKeys.length == 0) {
          this.$message.warning('请选择需要批量删除的选项值后再操作！')
          return
        }
        content = '删除后不可恢复，确定要进行批量删除吗？'
      } else if (isAll == 'all') { // 全部
        content = '删除后不可恢复，确定要进行整单删除吗？'
      } else { // 单个
        content = '删除后不可恢复，确定要进行删除吗？'
      }
      this.$confirm({
        title: '提示',
        content: content,
        centered: true,
        onOk () {
          _this.spinning = true
          const params = { checkWarehouseSn: _this.$route.params.sn }
          if (isAll == 'batch') { // 批量
            params.idList = _this.rowChooseSelectionInfo && _this.rowChooseSelectionInfo.selectedRowKeys
          } else if (isAll == 'all') { // 全部
            params.allFlag = true
          } else { // 单个
            params.id = row.id
          }
          checkWarehouseDetailDel(params).then(res => {
            if (res.status == 200) {
              _this.$message.success(res.message)
              _this.$refs.table.refresh()
              _this.$refs.chooseTable.refresh()
              if (isAll == 'batch') { // 批量
                _this.$refs.chooseTable.clearSelected() // 清空表格选中项
              }
              _this.spinning = false
            } else {
              _this.spinning = false
            }
          })
        }
      })
    },
    //  返回列表
    handleBack () {
      this.$router.push({ path: '/inventoryManagement/inventoryChecking/list' })
    },
    // 查询基础信息
    getDetail () {
      checkWarehouseDetail({ sn: this.$route.params.sn }).then(res => {
        if (res.status == 200) {
          this.basicInfoData = res.data || null
          this.warehouseList = res.data.warehouseList || []
        } else {
          this.basicInfoData = null
          this.warehouseList = []
        }
      })
    },
    // 已选产品  重置
    chooseResetSearchForm () {
      this.chooseQueryParam.productCode = ''
      this.chooseQueryParam.productName = ''
      this.chooseQueryParam.warehouseSn = undefined
      this.chooseQueryParam.brandSn = undefined
      this.chooseQueryParam.productTypeSn1 = undefined
      this.chooseQueryParam.productTypeSn2 = undefined
      this.chooseQueryParam.productTypeSn3 = undefined
      this.chooseProductType = []
      this.$refs.chooseTable.refresh(true)
    },
    // 合计
    getDetailCount (params) {
      checkWarehouseDetailCount(Object.assign(this.chooseQueryParam, { checkWarehouseSn: this.$route.params.sn })).then(res => {
        if (res.status == 200) {
          this.productTotal = res.data
        } else {
          this.productTotal = null
        }
      })
    },
    //  提交
    handleSubmit () {
      const _this = this
      _this.spinning = true
      checkWarehouseSubmit({ id: this.$route.params.id }).then(res => {
        if (res.status == 200) {
          this.$message.success(res.message)
          setTimeout(() => {
            _this.handleBack()
            _this.spinning = false
          }, 1000)
        } else {
          _this.spinning = false
        }
      })
    },
    //  产品分类  change
    changeProductType (val, opt) {
      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
    },
    changeChooseProductType (val, opt) {
      this.chooseQueryParam.productTypeSn1 = val[0] ? val[0] : ''
      this.chooseQueryParam.productTypeSn2 = val[1] ? val[1] : ''
      this.chooseQueryParam.productTypeSn3 = val[2] ? val[2] : ''
    },
    // 双击快速添加
    handleClickRow (record) {
      return {
        on: {
          dblclick: (event) => {
            this.handleAdd(record)
          }
        }
      }
    }
  },
  mounted () {
    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
      this.getDetail()
      this.resetSearchForm()
      this.chooseResetSearchForm()
    }
  },
  activated () {
    // 如果是新页签打开或者进入新的子页（例：存在列表第2条数据编辑页页签时再打开第4条数据的编辑页），则重置当前页面
    if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
      this.getDetail()
      this.resetSearchForm()
      this.chooseResetSearchForm()
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {})
  }
}
</script>

<style lang="less">
  .inventoryCheckSelfDiskList-wrap{
    position: relative;
    height: 100%;
    padding-bottom: 51px;
    box-sizing: border-box;
    .inventoryCheckSelfDiskList-cont, .inventoryCheckSelfDiskList-back{
      margin-bottom: 10px;
    }
    .billno{
      font-size: 16px;
      font-weight: bold;
      margin: 0 15px;
    }
    >.ant-spin-nested-loading{
      overflow-y: scroll;
      height: 100%;
    }
  }
</style>
