<template>
  <div>
    <a-card size="small" :bordered="false" class="searchBox">
      <!-- 搜索条件 -->
      <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
        <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="审核时间">
                <rangeDate ref="rangeAuditDate" :value="auditDate" @change="dateAuditChange" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="收款单号">
                <a-input id="collectionDetail-bookNo" v-model.trim="queryParam.bookNo" allowClear placeholder="请输入收款单号"/>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="收款打印状态">
                <v-select
                  v-model="queryParam.printStatus"
                  code="PRINT_STATUS"
                  placeholder="请选择收款打印状态"
                  allowClear
                ></v-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="开票状态">
                <v-select
                  v-model="queryParam.invoiceStatus"
                  code="FINANCE_BOOK_INVOICE_STATUS"
                  placeholder="请选择开票状态"
                  allowClear
                ></v-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="收款日期">
                <rangeDate ref="receiptDate" :value="receiptDate" @change="receiptDateChange" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="申请人">
                <employee style="width: 100%;" id="collectionDetail-Employee" placeholder="请选择申请人" v-model="queryParam.applyPersonSn"></employee>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="付款方类型">
                <v-select
                  v-model="queryParam.payerType"
                  code="PAYER_TYPE"
                  placeholder="请选择付款方类型"
                ></v-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-item label="付款方">
                <a-input id="financialCollectionList-payerName" v-model.trim="queryParam.payerName" allowClear placeholder="请输入付款方"/>
              </a-form-item>
            </a-col>
            <template v-if="advanced">
              <a-col :md="6" :sm="24">
                <a-form-item label="开票日期">
                  <rangeDate ref="invoiceDate" :value="invoiceDate" @change="invoiceDateChange" />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="财务编码">
                  <a-input id="collectionDetail-kdMidCustomerFnumber" placeholder="请输入财务编码" v-model="queryParam.kdMidCustomerFnumber"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="付款账户">
                  <a-input id="collectionDetail-payerAccountInfo" placeholder="请输入付款账户" v-model="queryParam.payerAccountInfo"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="户名">
                  <a-select placeholder="请选择户名" allowClear v-model="queryParam.bankAccount" style="width: 100%" @change="handleChange">
                    <a-select-option v-for="item in bankList" :value="item.bankAccount">
                      {{ item.bankAccount }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="所属区域">
                  <subarea id="collectionDetail-subarea" ref="subarea" @change="subareaChange"></subarea>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="所属省份">
                  <Area id="collectionDetail-provinceSn" v-model="queryParam.provinceSn" placeholder="请选择省"></Area>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="汇入银行">
                  <a-select placeholder="请选择汇入银行" allowClear v-model="queryParam.bankName" style="width: 100%">
                    <a-select-option v-for="item in bankNameList" :value="item">
                      {{ item }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="是否足额打款">
                  <v-select
                    v-model="queryParam.fullPaymentFlag"
                    ref="fullPaymentFlag"
                    id="collectionDetail-fullPaymentFlag"
                    code="FLAG"
                    placeholder="请选择是否足额打款"
                    allowClear></v-select>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="仓库">
                  <chooseWarehouse ref="warehouse" v-model="queryParam.warehouseSn"></chooseWarehouse>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
                <a-form-item label="客服">
                  <customerService ref="customerName" v-model="queryParam.bizUserSn"></customerService>
                </a-form-item>
              </a-col>
            </template>
            <a-col :md="isShowCustomerSearch&&advanced?6:24" :sm="24" :style="{textAlign:(isShowCustomerSearch&&advanced)?'':'center'}">
              <a-button type="primary" @click="searchForm" :disabled="disabled" id="collectionDetail-refresh">查询</a-button>
              <a-button style="margin-left: 10px" @click="resetSearchForm" :disabled="disabled" id="collectionDetail-reset">重置</a-button>
              <a-button
                style="margin-left: 10px"
                type="primary"
                class="button-warning"
                @click="handleExport"
                :disabled="disabled"
                :loading="exportLoading"
                v-if="$hasPermissions('M_FC_Details_Export')"
                id="sendOut-export">导出</a-button>
              <a @click="advanced=!advanced" style="margin-left: 5px;">
                {{ advanced ? '收起' : '展开' }}
                <a-icon :type="advanced ? 'up' : 'down'"/>
              </a>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card size="small" :bordered="false" class="collectionDetail-wrap" style="margin-top:5px;">
      <div class="flex-center" style="margin-bottom: 10px;">
        <div class="flex-center">
          <a-dropdown>
            <a-menu slot="overlay" @click="handleMenuClick">
              <a-menu-item key="1"> <a-icon type="printer" />批量允许打印 </a-menu-item>
              <a-menu-item key="2"> <a-icon type="block" />批量设置开票 </a-menu-item>
            </a-menu>
            <a-button type="primary" ghost> 批量处理 <a-icon type="down" /></a-button>
          </a-dropdown>
          <span v-if="selNums" style="margin-left:10px;">已选{{ selNums }}项</span>
        </div>
        <div class="flex-center" style="margin-left:10px;">
          订单总金额：<strong> {{ toThousands(countData&&countData.orderAmount||0) }}</strong>；
          收款总金额：<strong>{{ toThousands(countData&&countData.receiptAmount||0) }}</strong>；
          使用授信总金额：<strong>{{ toThousands(countData&&countData.useCreditAmount||0) }}</strong>；
          授信还款总金额：<strong>{{ toThousands(countData&&countData.payCreditAmount||0) }}</strong>；
          余款抵扣总金额：<strong>{{ toThousands(countData&&countData.balanceAmount||0) }}</strong>；
          跨月打款总金额：<strong>{{ toThousands(countData&&countData.nextMonthAmount||0) }}</strong>；
          特殊申请发货总金额：<strong>{{ toThousands(countData&&countData.specialSendAmount||0) }}</strong>；
        </div>
      </div>
      <a-spin :spinning="spinning" tip="Loading...">
        <!-- 列表 -->
        <s-table
          class="sTable fixPagination"
          ref="table"
          :style="{ height: tableHeight+60+'px' }"
          size="small"
          :rowKey="(record) => record.id"
          :columns="columns"
          :data="loadData"
          :row-selection="{ columnWidth: 40 }"
          @rowSelection="rowSelectionFun"
          :scroll="{ y: tableHeight-45}"
          :defaultLoadData="false"
          bordered>
          <!-- 开票日期 -->
          <template slot="draftDate" slot-scope="text, record">
            <div @click="handleInvoice(record)">
              <span v-if="record.invoiceDate" class="link-bule">{{ record.invoiceDate }}</span>
              <span class="link-bule" v-else>--</span>
            </div>
          </template>
          <!-- 收款打印状态 -->
          <template slot="printStatus" slot-scope="text, record">
            <span v-if="record.printStatus=='NO_PRINT' || record.printStatus=='PRINT'">{{ record.printStatusDictValue }}</span>
            <span @click="handlePrint(record)" class="link-bule" v-else>{{ record.printStatusDictValue }}</span>
          </template>
          <!-- 备注 -->
          <template slot="note" slot-scope="text, record">
            <div @click="handleNote(record)">
              <span :title="record.remarks" class="link-bule" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;width:100%;display:block;">{{ record.remarks || '--' }}</span>
            </div>
          </template>
        </s-table>
      </a-spin>
      <!-- 开票日期弹窗 -->
      <invoiceModal v-drag :show="invoiceIsShow" :info="invoiceInfo" @cancel="cancel"></invoiceModal>
      <plInvoiceModal v-drag :show="plinvoiceIsShow" @ok="plinvoiceOk" @cancel="cancel"></plInvoiceModal>
      <!-- 备注弹窗 -->
      <noteModal ref="remarksModal" v-drag :show="noteIsShow" @cancel="cancel"></noteModal>
      <!-- 收款打印状态 -->
      <printModal v-drag :show="printIsShow" :info="printInfo" @cancel="cancel"></printModal>
    </a-card>
  </div>
</template>

<script>
import { commonMixin } from '@/utils/mixin'
import moment from 'moment'
import { STable, VSelect } from '@/components'
import getDate from '@/libs/getDate.js'
import rangeDate from '@/views/common/rangeDate.vue'
import subarea from '@/views/common/subarea.js'
import Area from '@/views/common/area.js'
import { hdExportExcel } from '@/libs/exportExcel'
import employee from '../../expenseManagement/expenseReimbursement/employee.js'
import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
import invoiceModal from './invoiceModal.vue'
import plInvoiceModal from './plInvoiceModal.vue'
import noteModal from './noteModal.vue'
import printModal from './printModal.vue'
import chooseWarehouse from '@/views/common/chooseWarehouse'
import customerService from '@/views/common/customerService'
import { financeBookDetailQueryPage, financeBookDetailExport, financeBookReportDetailCount, financeBookDetailUpdateBatch } from '@/api/financeBook.js'
export default {
  name: 'CollectionDetailStaticList',
  mixins: [commonMixin],
  components: { STable, VSelect, rangeDate, employee, dealerSubareaScopeList, subarea, Area, invoiceModal, plInvoiceModal, noteModal, printModal, chooseWarehouse, customerService },
  data () {
    return {
      spinning: false,
      exportLoading: false,
      plinvoiceIsShow: false,
      tableHeight: 0,
      queryParam: { //  查询条件
        bookNo: '',
        auditBeginDate: getDate.getCurrMonthDays().starttime,
        auditEndDate: getDate.getCurrMonthDays().endtime,
        receiptBeginDate: '',
        receiptEndDate: '',
        applyPersonSn: undefined,
        payerName: undefined,
        kdMidCustomerFnumber: '',
        payerAccountInfo: '',
        fullPaymentFlag: undefined,
        bankAccount: undefined,
        bankName: undefined,
        subareaArea: {
          subareaSn: undefined,
          subareaAreaSn: undefined
        },
        provinceSn: undefined,
        printStatus: undefined,
        invoiceStatus: undefined,
        invoiceDateType: undefined,
        invoiceBeginDate: '',
        invoiceEndDate: '',
        payerType: undefined,
        warehouseSn: undefined, // 仓库
        bizUserSn: undefined
      },
      invoiceIsShow: false,
      noteIsShow: false,
      printIsShow: false,
      disabled: false, //  查询、重置按钮是否可操作
      receiptDate: [], //  收款时间
      invoiceDate: [], // 开票日期
      plinvoiceInfo: null,
      auditDate: [
        getDate.getCurrMonthDays().starttime,
        getDate.getCurrMonthDays().endtime
      ], // 审核时间
      advanced: false,
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.disabled = true
        this.spinning = true
        const params = Object.assign(parameter, this.queryParam)
        params.invoiceDate = params.invoiceDate ? moment(params.invoiceDate).format('YYYY-MM-DD') : ''
        return financeBookDetailQueryPage(params).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
            }
            this.total = data.count || 0
            this.disabled = false
          }
          this.spinning = false
          this.getCount(params)
          return data
        })
      },
      total: 0, // 合计
      countData: null,
      bankList: [
        {
          bankAccount: '张丽友',
          bankName: ['建设银行', '微信收款']
        },
        {
          bankAccount: '张丽添',
          bankName: ['农业银行']
        },
        {
          bankAccount: '东莞箭冠',
          bankName: ['东莞银行']
        },
        {
          bankAccount: '江西箭冠',
          bankName: ['九江银行']
        }
      ],
      bankNameList: [],
      invoiceInfo: null,
      printInfo: null,
      rowSelectionInfo: null
    }
  },
  // 根据权限显示列表字段
  computed: {
    selNums () {
      return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
    },
    columns () {
      const arr = [
        { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
        { title: '审核时间', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '收款单号', dataIndex: 'bookNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '申请人', dataIndex: 'applyPersonName', align: 'center', width: '5%', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '仓库', dataIndex: 'warehouseName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '收款事由', dataIndex: 'bookReason', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '收款日期', dataIndex: 'receiptDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '区域', dataIndex: 'subareaArea.subareaName', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
        { title: '分区', dataIndex: 'subareaArea.subareaAreaName', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
        { title: '付款方类型', dataIndex: 'payerTypeDictValue', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
        { title: '付款方', dataIndex: 'payerName', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
        { title: '财务编码', dataIndex: 'kdMidCustomerFnumber', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
        { title: '付款账户（营业执照）', dataIndex: 'payerAccountInfo', align: 'center', width: '8%', customRender: function (text) { return text || '--' } },
        { title: '订单金额', dataIndex: 'orderAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
        { title: '收款金额', dataIndex: 'receiptAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
        { title: '使用授信', dataIndex: 'useCreditAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
        { title: '授信还款', dataIndex: 'payCreditAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
        { title: '余款抵扣', dataIndex: 'balanceAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
        { title: '跨月打款', dataIndex: 'nextMonthAmount', align: 'right', width: '5%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
        { title: '特殊申请发货', dataIndex: 'specialSendAmount', width: '5%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
        { title: '户名', dataIndex: 'bankAccount', align: 'center', width: '5%', customRender: function (text) { return text || '--' } },
        { title: '汇入银行', dataIndex: 'bankName', align: 'center', width: '5%', customRender: function (text) { return text || '--' } },
        { title: '足额打款', dataIndex: 'fullPaymentFlagDictValue', align: 'center', width: '5%', customRender: function (text) { return (text == 0 || text) ? text : '--' } },
        { title: '说明', dataIndex: 'explainInfo', align: 'center', width: '8%', customRender: function (text) { return text || '--' }, ellipsis: true },
        { title: '开票日期', scopedSlots: { customRender: 'draftDate' }, align: 'center', width: '8%' },
        { title: '收款打印状态', scopedSlots: { customRender: 'printStatus' }, align: 'center', width: '8%' },
        { title: '备注', scopedSlots: { customRender: 'note' }, align: 'center', width: '8%' }
      ]
      return arr
    }
  },
  methods: {
    // 关闭弹窗刷新表格
    cancel (flag) {
      console.log(flag)
      this.invoiceIsShow = false
      this.noteIsShow = false
      this.printIsShow = false
      this.plinvoiceIsShow = false
      if (flag === 1) {
        this.searchForm()
      }
    },
    getCount (params) {
      financeBookReportDetailCount(params).then(res => {
        this.countData = res.data
      })
    },
    handleMenuClick (e) {
      console.log('click', e)
      const _this = this
      const rows = _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows || []
      const slen = rows.length
      if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
        _this.$message.warning('请在列表勾选后再进行批量操作！')
        return false
      }

      if (e.key == 1) { // 批量允许打印
        const dataList = rows.filter(item => !(item.printStatus == 'NO_PRINT' || item.printStatus == 'PRINT'))
        if (dataList.length) {
          this.$confirm({
            title: '批量允许打印',
            content: `已选有效数据 ${dataList.length} 条，确认将收款打印状态变更为允许打印吗?`,
            okText: '确定',
            centered: true,
            cancelText: '取消',
            onOk () {
              // 批量允许打印接口
              const data = []
              dataList.map(item => {
                data.push({ id: item.id, printStatus: 'NO_PRINT' })
              })
              _this.plUpdateStatus(data, 1)
            }
          })
        } else {
          _this.$message.warning('没有可操作的有效数据！')
        }
      }

      if (e.key == 2) { // 批量开票
        const data = []
        rows.map(item => {
          data.push({ id: item.id, invoiceDate: '', remarks: '' })
        })
        _this.plinvoiceInfo = data
        _this.plinvoiceIsShow = true
      }
    },
    // 批量操作
    plUpdateStatus (data, type) {
      this.spinning = true
      financeBookDetailUpdateBatch(data, type).then(res => {
        if (res.status == 200) {
          this.searchForm()
        }
        this.spinning = false
      })
    },
    // 确定批量开票
    plinvoiceOk (data) {
      this.plinvoiceInfo.map(item => {
        item.invoiceDate = data.invoiceDate
        item.remarks = data.remarks
      })
      this.plUpdateStatus(this.plinvoiceInfo, 0)
    },
    // 表格选中项
    rowSelectionFun (obj) {
      this.rowSelectionInfo = obj || null
    },
    handleChange (v) {
      if (v) {
        const row = this.bankList.find(item => item.bankAccount == v)
        this.bankNameList = row.bankName
        this.queryParam.bankName = undefined
      } else {
        this.queryParam.bankAccount = undefined
        this.queryParam.bankName = undefined
      }
    },
    //  收款日期  change
    receiptDateChange (date) {
      this.queryParam.receiptBeginDate = date[0] ? date[0] : ''
      this.queryParam.receiptEndDate = date[1] ? date[1] : ''
    },
    //  开票时间  change
    invoiceDateChange (date) {
      this.queryParam.invoiceBeginDate = date[0] ? date[0] : ''
      this.queryParam.invoiceEndDate = date[1] ? date[1] : ''
    },
    //  审核时间  change
    dateAuditChange (date) {
      this.queryParam.auditBeginDate = date[0] ? date[0] : ''
      this.queryParam.auditEndDate = date[1] ? date[1] : ''
    },
    searchForm () {
      this.$refs.table.refresh(true)
      this.$refs.table.clearSelected()
    },
    subareaChange (val) {
      this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
      this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
    },
    //  重置
    resetSearchForm () {
      // 审核日期
      this.auditDate = [
        getDate.getCurrMonthDays().starttime,
        getDate.getCurrMonthDays().endtime
      ]
      this.$refs.rangeAuditDate.resetDate(this.auditDate)
      this.queryParam.auditBeginDate = getDate.getCurrMonthDays().starttime
      this.queryParam.auditEndDate = getDate.getCurrMonthDays().endtime
      // 收款日期
      this.receiptDate = []
      this.queryParam.receiptBeginDate = ''
      this.queryParam.receiptEndDate = ''
      this.$refs.receiptDate.resetDate(this.receiptDate)

      // 开票日期
      this.invoiceDate = []
      this.queryParam.invoiceBeginDate = ''
      this.queryParam.invoiceEndDate = ''
      if (this.advanced) {
        this.$refs.invoiceDate.resetDate(this.invoiceDate)
      }

      this.queryParam.bookNo = ''
      this.queryParam.dispatchBillNo = ''
      this.queryParam.applyPersonSn = undefined
      this.queryParam.kdMidCustomerFnumber = ''
      this.queryParam.payerName = undefined
      this.queryParam.payerAccountInfo = ''
      this.queryParam.fullPaymentFlag = undefined
      this.queryParam.bankName = undefined
      this.queryParam.bankAccount = undefined
      this.queryParam.subareaArea.subareaSn = undefined
      this.queryParam.subareaArea.subareaAreaSn = undefined
      this.queryParam.provinceSn = undefined
      this.queryParam.invoiceDateType = undefined
      this.queryParam.invoiceDate = ''
      this.queryParam.printStatus = undefined
      this.queryParam.invoiceStatus = undefined
      this.queryParam.payerType = undefined
      this.queryParam.warehouseSn = undefined
      this.queryParam.bizUserSn = undefined
      if (this.advanced) {
        this.$refs.subarea.clearData()
      }
      this.searchForm()
    },
    //  导出
    handleExport () {
      const _this = this
      _this.exportLoading = true
      _this.spinning = true
      _this.$store.state.app.curActionPermission = 'M_FC_Details_Export'
      hdExportExcel(financeBookDetailExport, _this.queryParam, '财务收款明细统计', function () {
        _this.exportLoading = false
        _this.spinning = false
        _this.$store.state.app.curActionPermission = ''
      })
    },
    pageInit () {
      const _this = this
      this.$nextTick(() => { // 页面渲染完成后的回调
        _this.setTableH()
      })
    },
    setTableH () {
      const tableSearchH = this.$refs.tableSearch.offsetHeight
      this.tableHeight = window.innerHeight - tableSearchH - 245
    },
    // 开票操作
    handleInvoice (con) {
      const obj = {
        no: con.bookNo,
        payerName: con.payerName,
        bookDetailSn: con.bookDetailSn,
        invoiceDate: con.invoiceDate,
        remarks: con.remarks ? con.remarks : ''
      }
      this.invoiceInfo = obj
      this.$nextTick(() => {
        this.invoiceIsShow = true
      })
    },
    // 修改备注
    handleNote (info) {
      const obj = {
        no: info.bookNo,
        payerName: info.payerName,
        bookDetailSn: info.bookDetailSn,
        remarks: info.remarks ? info.remarks : '',
        invoiceDate: info.invoiceDate
      }
      this.noteIsShow = true
      const _this = this
      _this.$nextTick(() => {
        _this.$refs.remarksModal.setData(JSON.stringify(obj))
      })
    },
    // 允许打印
    handlePrint (item) {
      const obj = {
        no: item.bookNo,
        payerName: item.payerName,
        id: item.id,
        printStatus: item.printStatus
      }
      this.printInfo = obj
      this.$nextTick(() => {
        this.printIsShow = true
      })
    }
  },
  watch: {
    advanced (newValue, oldValue) {
      const _this = this
      this.$nextTick(() => { // 页面渲染完成后的回调
        _this.setTableH()
      })
    },
    '$store.state.app.winHeight' (newValue, oldValue) { //  窗口变更时，需同时更改表格高度
      this.setTableH()
    }
  },
  mounted () {
    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
      this.pageInit()
      this.resetSearchForm()
    }
  },
  activated () {
    // 如果是新页签打开，则重置当前页面
    if (this.$store.state.app.isNewTab) {
      this.pageInit()
      this.resetSearchForm()
    }
    // 仅刷新列表，不重置页面
    if (this.$store.state.app.updateList) {
      this.pageInit()
      this.$refs.table.refresh()
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {})
  }
}
</script>
