<template>
  <div class="salesReturnEdit-wrap">
    <a-spin :spinning="spinning" tip="Loading...">
      <a-page-header :ghost="false" :backIcon="false" class="salesReturnGrabEdit-back" >
        <!-- 自定义的二级文字标题 -->
        <template slot="subTitle">
          <a id="salesReturnGrabEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
          <span style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">退货单号：{{ ordeDetail&&ordeDetail.salesReturnNo||'--' }}</span>
          <a-button id="salesReturnGrabEdit-showDesc-btn" type="link" size="small" class="button-default" @click="isShowBisiceInfo=!isShowBisiceInfo">
            <a-icon :type="isShowBisiceInfo ? 'eye-invisible' : 'eye'"/> {{ isShowBisiceInfo?'隐藏':'查看' }}信息
          </a-button>
          <a-button
            type="link"
            id="salesReturnGrabEdit-editDesc-btn"
            size="small"
            @click="handleEditCustom"
            class="button-info"
            key="0"> <a-icon type="edit"></a-icon> 编辑</a-button>
        </template>
        <!-- 操作区，位于 title 行的行尾 -->
        <template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
          <Print :disabled="chooseLoadData.length==0" @handlePrint="handlePrint"></Print>
        </template>
      </a-page-header>
      <!-- 基础信息 -->
      <a-card size="small" :bordered="false" title="基础信息" v-show="isShowBisiceInfo" class="pages-wrap">
        <a-descriptions size="small" :column="3">
          <a-descriptions-item label="客户名称">{{ ordeDetail&&ordeDetail.buyerNameCurrent?ordeDetail.buyerName?ordeDetail.buyerName==ordeDetail.buyerNameCurrent?ordeDetail.buyerNameCurrent:ordeDetail.buyerNameCurrent+'（'+ordeDetail.buyerName+'）':ordeDetail.buyerNameCurrent:'--' }}</a-descriptions-item>
          <a-descriptions-item label="客户地址">
            <div v-if="ordeDetail&&(ordeDetail.provinceName || ordeDetail.cityName || ordeDetail.countyName || ordeDetail.customerAddr)">
              {{ ordeDetail&&ordeDetail.provinceName || '' }}
              {{ ordeDetail&&ordeDetail.cityName || '' }}
              {{ ordeDetail&&ordeDetail.countyName || '' }}
              {{ ordeDetail&&ordeDetail.customerAddr || '' }}
            </div>
            <span v-else>--</span>
          </a-descriptions-item>
          <a-descriptions-item label="联系电话">{{ ordeDetail&&ordeDetail.contactTel || '--' }}</a-descriptions-item>
          <a-descriptions-item label="退货单号">{{ ordeDetail&&ordeDetail.salesReturnNo || '--' }}</a-descriptions-item>
          <a-descriptions-item label="业务状态">{{ ordeDetail&&ordeDetail.stateDictValue || '--' }}</a-descriptions-item>
          <a-descriptions-item label="是否抓单">{{ ordeDetail&&ordeDetail.grabFlag==1?'抓单':'不抓单' }}</a-descriptions-item>
          <a-descriptions-item label="备注">{{ ordeDetail&&ordeDetail.remarks || '--' }}</a-descriptions-item>
        </a-descriptions>
      </a-card>
      <a-card size="small" :bordered="false" class="pages-wrap">
        <!-- 查询配件列表 -->
        <queryPart
          ref="queryPart"
          grabFlag="1"
          :newLoading="isInster"
          :warehouseCascadeData="warehouseCascadeData"
          @showCellChange="v=> showCell = v"
          @add="saveProduct"></queryPart>
      </a-card>
      <a-card size="small" :bordered="false" class="pages-wrap">
        <!-- alert -->
        <a-alert style="margin-bottom: 10px;" type="info">
          <div slot="message" class="total-bar">
            <div>
              <span>退货总金额：{{ countData&&(countData.totalAmount || countData.totalAmount==0) ? toThousands(countData.totalAmount) : '--' }}；</span>
              <span>总款数：{{ countData&&(countData.totalCategory || countData.totalCategory==0) ? countData.totalCategory : '--' }}；</span>
              <span>总数量：{{ countData&&(countData.totalQty || countData.totalQty==0) ? countData.totalQty : '--' }}；</span>
              <span>废品总数量：{{ countData&&(countData.totalCelQty || countData.totalCelQty==0) ? countData.totalCelQty : '--' }}；</span>
            </div>
            <div>
              <div>
                折扣金额：
                <a-input-number
                  size="small"
                  id="discount"
                  v-model="ordeDetail.discountAmount"
                  :min="0"
                  :precision="2"
                  :max="999999"/>
                <a-button id="salesReturnGrabEdit-discount-btn" size="small" type="primary" @click="salesReturnDiscount" class="button-info">打折</a-button>
              </div>
              <div>
                折扣：<strong>{{ ordeDetail&&(ordeDetail.discountRate || ordeDetail.discountRate==0) ? ordeDetail.discountRate+'%' : '--' }}</strong>；
                折后总售价：<strong>{{ ordeDetail&&(ordeDetail.discountedAmount || ordeDetail.discountedAmount==0) ? toThousands(ordeDetail.discountedAmount) : '--' }}</strong>；
              </div>
            </div>
          </div>
        </a-alert>
        <!-- 搜索条件 -->
        <div class="table-page-search-wrapper">
          <a-row :gutter="15">
            <a-col :span="18">
              <a-form-model layout="inline" :model="productForm" @keyup.enter.native="$refs.table.refresh(true)">
                <a-row :gutter="15">
                  <a-col :md="8" :sm="24">
                    <a-form-model-item label="产品编码">
                      <a-input id="salesReturnGrabEdit-productCode" v-model.trim="productForm.productCode" allowClear placeholder="输入产品编码" />
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="8" :sm="24">
                    <a-form-model-item label="产品名称">
                      <a-input id="salesReturnGrabEdit-productName" v-model.trim="productForm.productName" allowClear placeholder="输入产品名称" />
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="8" :sm="24">
                    <a-form-model-item>
                      <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesReturn-refresh">查询</a-button>
                      <a-button style="margin-left: 5px" @click="resetForm" id="salesReturn-reset">重置</a-button>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-form-model>
            </a-col>
            <a-col :span="6">
              <div style="float:right;overflow: hidden;">
                <a-button
                  style="padding: 0 25px;"
                  type="primary"
                  :disabled="spinning"
                  class="button-primary"
                  @click="handleSubmit()"
                  id="salesReturnGrabEdit-handleSubmit">提交</a-button>
                <a-button
                  type="primary"
                  ghost
                  :disabled="chooseLoadData.length==0"
                  @click="salesReturnDelAll"
                  :loading="delLoading"
                  style="margin-left: 10px"
                  id="salesReturnGrabEdit-del-all">清空列表</a-button>
                <hideCellMenus placeholder="显示" @change="showCellChange" :defHiddenKes="colsArr" v-model="showCell"></hideCellMenus>
              </div>
            </a-col>
          </a-row>
        </div>
        <!-- 已选配件列表 -->
        <s-table
          class="sTable"
          ref="table"
          size="small"
          :rowKey="(record) => record.id"
          :columns="columns"
          :data="loadData"
          :defaultLoadData="false"
          :pageSize="10"
          :scroll="{ y: 300 }"
          bordered>
          <!-- 本次退货数量 -->
          <template slot="qty" slot-scope="text, record">
            <a-input-number
              :id="'salesReturnGrabEdit-qty-'+record.id"
              size="small"
              v-model="record.qty"
              :precision="0"
              :min="0"
              :max="999999"
              placeholder="请输入"
              @blur="e => onCellBlur(e.target.value, record, 'qty')"
              style="width: 100%;" />
          </template>
          <!-- 废品数量 -->
          <template slot="celQty" slot-scope="text, record">
            <a-input-number
              size="small"
              v-model="record.celQty"
              :id="'salesReturnGrabEdit-celQty-'+record.id"
              :precision="0"
              :min="0"
              :max="999999"
              placeholder="请输入"
              @blur="e => onCellBlur(e.target.value, record, 'celQty')"
              style="width: 100%;" />
          </template>
          <!-- 退货金额小计 -->
          <template slot="returnAmount" slot-scope="text, record">{{ toThousands(record.price * record.qty) }}</template>
          <!-- 仓库仓位 -->
          <template slot="warehouse" slot-scope="text, record, index">
            <a-cascader
              size="small"
              @change="e => changeWarehouseCascade(e, record, index)"
              v-model="record.warehouseCascade"
              expand-trigger="hover"
              :options="warehouseCascadeData"
              :allowClear="false"
              :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
              :id="'salesReturnGrabEdit-warehouseCascade-'+record.id"
              placeholder="请选择仓库仓位"
              style="width: 100%;" />
          </template>
          <!-- 操作 -->
          <template slot="action" slot-scope="text, record">
            <a-button
              size="small"
              type="link"
              :loading="delLoading"
              class="button-error"
              @click="handleDel(record)"
              :id="'salesReturnGrabEdit-del-'+record.id">删除</a-button>
          </template>
        </s-table>
      </a-card>
    </a-spin>
    <!-- 选择客户弹框 -->
    <choose-custom-modal ref="editCustomModal" :show="openModal" @ok="chooseCustomOk" @cancel="openModal=false"></choose-custom-modal>
  </div>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
import { STable, VSelect } from '@/components'
import queryPart from './queryPart.vue'
import chooseCustomModal from './chooseCustomModal.vue'
import { warehouseCascadeList } from '@/api/warehouse'
import { getCurrentDealer } from '@/api/product'
import hideCellMenus from '@/views/common/hideCellMenus'
import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDiscount, salesReturnDelAll, salesReturnDetailDel, salesReturnSaveProduct, salesReturnSubmit, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
import Print from '@/views/common/print.vue'
import { hdPrint } from '@/libs/JGPrint'
export default {
  name: 'SalesReturnGrabEdit',
  components: {
    STable,
    VSelect,
    queryPart,
    chooseCustomModal,
    Print,
    hideCellMenus
  },
  mixins: [commonMixin],
  data () {
    const _this = this
    return {
      spinning: false,
      disabled: false,
      orderId: null, // 单据id
      orderSn: null, // 单据sn
      buyerSn: null, // 客户sn
      openModal: false, // 选择客户弹框
      isInster: false, // 是否正在添加产品
      ordeDetail: { discountAmount: 0 }, // 详情信息
      delLoading: false, // 按钮loading
      warehouseCascadeData: [], //  仓库仓位
      // 已选产品
      dataSource: [],
      productForm: {
        productCode: '', // 产品编码
        productName: '', // 产品名称
        orderBy: 'sales_return_bill_detail.CREATE_DATE desc' // 排序
      },
      countData: null,
      chooseLoadData: [], // 已添加数据
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.disabled = true
        // 查询总计
        this.productForm.salesReturnBillSn = this.$route.params.sn
        this.getQueryCount(Object.assign(parameter, this.productForm))
        return salesReturnDetailList(Object.assign(parameter, this.productForm)).then(res => {
          let data
          if (res.status == 200) {
            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
              data.list[i].qtyBackups = data.list[i].qty
              data.list[i].celQtyBackups = data.list[i].celQty
              // 仓库仓位默认值
              const warehouseSn = data.list[i].warehouseSn || undefined
              const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
              if (warehouseSn || warehouseLocationSn) {
                data.list[i].warehouseSnBackups = warehouseSn
                data.list[i].warehouseLocationSnBackups = warehouseLocationSn
                data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
              } else {
                data.list[i].warehouseCascade = undefined
              }
            }
            this.disabled = false
            this.chooseLoadData = data.list
          }
          return data
        })
      },
      printerType: 'NEEDLE', //  打印机类型
      isShowBisiceInfo: false, // 是否显示详情信息
      showCell: [], // 已选要显示的列
      currentDealerInfo: null
    }
  },
  computed: {
    colsArr () {
      const _this = this
      // 省级且有市级价权限
      if (_this.currentDealerInfo && _this.currentDealerInfo.dealerLevel == 'PROVINCE' && _this.$hasPermissions('M_ShowAllCityPrice')) {
        return [
          {
            title: '批发价',
            key: 'wholesalePrice',
            disabled: false,
            checked: false
          },
          {
            title: '终端价',
            key: 'terminalPrice',
            disabled: false,
            checked: false
          }
        ]
      } else {
        return [
          {
            title: '终端价',
            key: 'terminalPrice',
            disabled: false,
            checked: false
          }
        ]
      }
    },
    // 表头
    columns () {
      const _this = this
      const arr = [
        { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
        { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', align: 'center', width: '10%', customRender: function (text) { return text || '--' } },
        { title: '销售单号', dataIndex: 'salesBillNo', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
        { title: '售价', dataIndex: 'price', align: 'right', width: '4%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
        // { title: '批发价', dataIndex: 'wholesalePrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
        // { title: '终端价', dataIndex: 'terminalPrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
        { title: '单位', dataIndex: 'dealerProductEntity.unit', align: 'center', width: '4%', customRender: function (text) { return text || '--' } },
        { title: '销售数量', dataIndex: 'salesQty', align: 'center', width: '5%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '本次退货数量', dataIndex: 'qty', align: 'center', width: '7%', scopedSlots: { customRender: 'qty' } },
        { title: '废品数量', dataIndex: 'celQty', align: 'center', width: '6%', scopedSlots: { customRender: 'celQty' } },
        { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '10%', align: 'center' },
        { title: '退货金额小计', align: 'right', scopedSlots: { customRender: 'returnAmount' }, width: '7%' },
        { title: '折后金额小计', dataIndex: 'discountedAmount', align: 'right', width: '7%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
        { title: '操作', scopedSlots: { customRender: 'action' }, width: '5%', align: 'center' }
      ]
      // 省级且有市级价权限
      if (_this.currentDealerInfo && _this.currentDealerInfo.dealerLevel == 'PROVINCE' && _this.$hasPermissions('M_ShowAllCityPrice')) {
        arr.splice(5, 0, { title: '批发价', dataIndex: 'wholesalePrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
        arr.splice(6, 0, { title: '终端价', dataIndex: 'terminalPrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
      } else {
        arr.splice(5, 0, { title: '终端价', dataIndex: 'terminalPrice', align: 'right', width: '5%', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
      }
      return arr.filter(item => !_this.showCell.includes(item.dataIndex))
    }
  },
  methods: {
    //  返回
    handleBack () {
      this.$router.push({ name: 'salesReturnList' })
    },
    showCellChange (val) {
      this.$refs.queryPart.showCell = val
    },
    // 获取省级经销商、市级经销商和特约经销商信息
    getCurrentDealerInfo () {
      getCurrentDealer().then(res => {
        if (res.status == 200) {
          this.currentDealerInfo = res.data
          this.$refs.queryPart.setCell(this.currentDealerInfo)
        }
      })
    },
    // 选择客户成功
    chooseCustomOk (data) {
      this.openModal = false
      this.getOrderDetail()
    },
    // 打开编辑客户弹框
    handleEditCustom () {
      this.openModal = true
      this.$refs.editCustomModal.editCust(this.ordeDetail)
    },
    // 已选产品，数量，价格、废品数量修改
    onCellBlur (val, record, type) {
      let valBackups
      if (type == 'qty') {
        valBackups = record.qtyBackups
      } else if (type == 'celQty') {
        valBackups = record.celQtyBackups
      }
      //  光标移出，值发生改变再调用编辑接口
      if (val && val != valBackups) {
        if (Number(record.celQty) > Number(record.qty)) {
          this.$message.info('废品数量不可大于本次退货数量')
          this.reductionVal(record, type, valBackups)
        } else {
          this.saveProduct(record, 'edit')
        }
      } else {
        this.reductionVal(record, type, valBackups)
      }
    },
    // 恢复默认值
    reductionVal (record, type, valBackups) {
      if (type == 'qty') {
        record.qty = valBackups
      } else if (type == 'celQty') {
        record.celQty = valBackups
      }
    },
    //  仓库仓位  级联  列表
    getWarehouseCascade () {
      warehouseCascadeList({}).then(res => {
        if (res.status == 200) {
          res.data.map(item => {
            item.sn = item.warehouseSn
            if (item.warehouseLocationList) {
              item.warehouseLocationList.map(subItem => {
                subItem.sn = subItem.warehouseLocationSn
              })
            }
          })
          this.warehouseCascadeData = res.data
        } else {
          this.warehouseCascadeData = []
        }
      })
    },
    // 修改仓库仓位
    changeWarehouseCascade (val, opt, ind) {
      console.log(val, opt, ind)
      let loadData = this.chooseLoadData[ind]
      if (val.length < 2) {
        this.$message.warning('当前仓库无仓位，请选择其他仓库')
        const warehouseSnBackups = loadData.warehouseSnBackups || undefined
        const warehouseLocationSnBackups = loadData.warehouseLocationSnBackups || undefined
        loadData.warehouseSn = warehouseSnBackups
        loadData.warehouseLocationSn = warehouseLocationSnBackups
        if (warehouseSnBackups || warehouseLocationSnBackups) {
          loadData.warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
        } else {
          loadData.warehouseCascade = undefined
        }
      } else {
        loadData.warehouseSn = val[0] ? val[0] : ''
        loadData.warehouseLocationSn = val[1] ? val[1] : ''
        loadData.warehouseSnBackups = val[0] ? val[0] : ''
        loadData.warehouseLocationSnBackups = val[1] ? val[1] : ''
        loadData = this.chooseLoadData[ind]
        console.log(loadData)
        this.saveProduct(loadData, 'edit')
      }
    },
    // 重置列表
    resetForm () {
      this.productForm = {
        productName: '',
        productCode: '',
        orderBy: 'sales_return_bill_detail.CREATE_DATE desc'
      }
      this.$refs.table.refresh(true)
    },
    // 明细统计
    getQueryCount (params) {
      salesReturnQueryCount(params).then(res => {
        this.countData = res.data || null
      })
    },
    // 获取单据详细
    getOrderDetail (flag) {
      salesReturnDetail({ sn: this.orderSn }).then(res => {
        this.ordeDetail = res.data || null
        if (!flag) {
          this.$refs.queryPart.pageInit(this.buyerSn, this.ordeDetail && this.ordeDetail.priceType || '')
        }
      })
    },
    // 打折
    salesReturnDiscount () {
      this.spinning = true
      salesReturnDiscount({
        discountAmount: this.ordeDetail.discountAmount || 0,
        salesReturnSn: this.ordeDetail.salesReturnSn,
        id: this.ordeDetail.id
      }).then(res => {
        if (res.status == 200) {
          this.getOrderDetail(true)
          this.$refs.table.refresh(true)
          this.spinning = false
        } else {
          this.spinning = false
        }
      })
    },
    // 清空列表
    salesReturnDelAll () {
      const _this = this
      this.$confirm({
        title: '提示',
        content: '确认要清空已选产品列表吗？',
        centered: true,
        closable: true,
        onOk () {
          _this.delLoading = true
          _this.spinning = true
          salesReturnDelAll({ sn: _this.ordeDetail.salesReturnSn }).then(res => {
            if (res.status == 200) {
              _this.resetSearchForm(true)
              _this.$refs.queryPart.resetSearchForm()
            }
            _this.$message.info(res.message)
            _this.delLoading = false
            _this.spinning = false
          })
        }
      })
    },
    // 删除产品
    handleDel (row) {
      const _this = this
      this.$confirm({
        title: '提示',
        content: '确认要删除吗？',
        centered: true,
        closable: true,
        onOk () {
          _this.delLoading = true
          _this.spinning = true
          salesReturnDetailDel({ id: row.id }).then(res => {
            if (res.status == 200) {
              _this.resetSearchForm(true)
            }
            _this.$message.info(res.message)
            _this.delLoading = false
            _this.spinning = false
          })
        }
      })
    },
    //  重置
    resetSearchForm (flag) {
      this.$refs.table.refresh(flag)
      if (flag) {
        this.getOrderDetail()
      }
    },
    // 添加或修改产品
    saveProduct (row, type) {
      // 防止多次添加产品
      if (this.isInster) {
        return
      }
      this.isInster = true
      const params = {
        'salesReturnBillSn': this.orderSn,
        'salesReturnBillNo': this.ordeDetail.salesReturnNo,
        'salesBillSn': row.salesBillSn,
        'salesBillNo': row.salesBillNo,
        'salesBillDetailSn': row.salesBillDetailSn,
        'price': row.price,
        'cost': row.cost,
        'productSn': row.productSn,
        'celQty': row.celQty,
        'qty': row.returnQty,
        'hasReturnQty': row.hasReturnQty,
        'warehouseLocationSn': row.warehouseLocationSn,
        'warehouseSn': row.warehouseSn
      }
      // 编辑
      if (type == 'edit') {
        params.id = row.id
        params.qty = row.qty
      } else {
        params.salesQty = row.qty
      }
      this.spinning = true
      salesReturnSaveProduct(params).then(res => {
        this.resetSearchForm(type == 'edit')
        if (type == 'new') {
          this.getOrderDetail()
        }
        this.isInster = false
        this.spinning = false
      })
    },
    // 提交销售单
    handleSubmit () {
      this.spinning = true
      salesReturnSubmit({ sn: this.orderSn }).then(res => {
        if (res.status == 200) {
          this.handleBack()
          this.$message.success(res.message)
          this.spinning = false
        } else {
          this.spinning = false
        }
      })
    },
    // 打印预览/快捷打印
    handlePrint (type, printerType) {
      const _this = this
      _this.spinning = true
      let url = salesReturnDetailPrint
      const params = { sn: this.$route.params.sn }
      if (type == 'export') { //  导出
        url = salesDetailExport
      }
      // 打印或导出
      hdPrint(printerType, type, url, params, '销售退货', function () {
        _this.spinning = false
      })
    },
    // 初始化页面
    pageInit () {
      this.orderId = this.$route.params.id
      this.orderSn = this.$route.params.sn
      this.buyerSn = this.$route.params.buyerSn
      this.getOrderDetail()
      this.getWarehouseCascade()
      this.resetForm()
      this.getCurrentDealerInfo()
    }
  },
  mounted () {
    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
      this.pageInit()
    }
  },
  activated () {
    // 如果是新页签打开或者进入新的子页（例：存在列表第2条数据编辑页页签时再打开第4条数据的编辑页），则重置当前页面
    if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
      this.pageInit()
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {})
  }
}
</script>

<style lang="less">
  .salesReturnEdit-wrap{
    position: relative;
    height: 100%;
    box-sizing: border-box;
    >.ant-spin-nested-loading{
      overflow-y: auto;
      height: 100%;
    }
    .pages-wrap{
      margin-top: 6px;
      .total-bar{
        display: flex;
        align-items: center;
        justify-content: space-between;
        > div{
          &:last-child{
            display: flex;
            align-items: center;
            justify-content: space-between;
            > div{
              padding: 0 10px;
            }
          }
        }
      }
    }
  }
</style>
