<!--
  @description: 保证金收款明细管理
  @Modifier: 肖文龙
  @routerPath: /fee/bailfeeRefundAudit-list
  @date: 2020/03/30-17:40
-->
<template>
  <div>
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />保证金收款明细管理
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
        <span class="fr pointer" @click="handleToggleSearch">
          <el-link :underline="false" :class="toggleSearchStatus?'arrow-is-active':''" type="primary" class="toggleSearchStatus icon el-icon-arrow-down" />
          {{ toggleSearchStatus?'收起高级查询' :'展开高级查询' }}
        </span>
      </div>
      <section :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="120px"
            label-position="left"
          >
            <!-- 项目名称 -->
            <el-form-item
              label="项目名称"
            >
              <el-input
                v-model.trim="searchForm.tenderName"
                style="width:220px"
                placeholder="项目名称"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!-- 项目编号 -->
            <el-form-item
              label="项目编号"
              prop="refundStatus"
            >
              <el-input
                v-model.trim="searchForm.tenderNo"
                style="width:220px"
                placeholder="项目编号"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!-- 标段（包）名称 -->
            <el-form-item
              label="标段（包）名称"
              prop="packName"
            >
              <el-input
                v-model.trim="searchForm.packName"
                style="width:220px"
                placeholder="标段（包）名称"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!-- 标段（包）编号 -->
            <el-form-item
              label="标段（包）编号"
              prop="packNo"
            >
              <el-input
                v-model.trim="searchForm.packNo"
                style="width:220px"
                placeholder="标段（包）编号"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!-- 提交时间 -->
            <el-form-item v-if="bailShowShielding" label="提交时间">
              <el-date-picker
                v-model="createTime"
                :default-time="defaultTimerange"
                value-format="momentSaveFormat"
                style="width:220px"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              />
            </el-form-item>
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </section>
      <el-tabs />
      <div class="mb10">
        <el-button type="primary" @click="exportBillDetailList">
          导出报表
        </el-button>
      </div>
      <section>
        <el-table
          ref="multipleTable"
          :data="tableData"
          :row-key="getRowKeys"
          @selection-change="onSelect"
        >
          <el-table-column
            type="selection"
            width="55"
            align="center"
          />
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <!-- 项目名称  -->
          <el-table-column
            header-align="center"
            prop="tenderName"
            label="项目名称"
            min-width="250"
          />
          <!-- 账户名称  -->
          <el-table-column
            header-align="center"
            prop="accountName"
            label="账户名称"
            min-width="250"
          />
          <!-- 来款金额(元) -->
          <el-table-column
            header-align="center"
            prop="amount"
            label="来款金额(元)"
            align="center"
            min-width="160"
          />
          <!-- 标段（包）编号 -->
          <el-table-column
            header-align="center"
            prop="packNo"
            label="标段（包）编号"
            min-width="250"
          />
          <!-- 标段（包）名称 -->
          <el-table-column
            header-align="center"
            label="标段（包）名称"
            prop="packName"
            min-width="160px"
          />
          <!-- 项目经理 -->
          <el-table-column
            label="项目经理"
            prop="tenderManager"
            align="center"
            min-width="130"
          />
          <!-- 子账号 -->
          <el-table-column
            label="子账号"
            prop="accountNo"
            align="center"
            min-width="180"
          />
          <!-- 业务日期 -->
          <el-table-column
            label="业务日期"
            prop="inDate"
            align="center"
            min-width="180"
          />
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </section>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { queryBillDetailList, exportBillDetailList } from '@api/fee/bailfee'
/* 公用方法*/
import { restoreInitialValue, filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { cashDepositGroupMixin } from '../mixins/cashDepositGroupMixin'
import { depositSystemConfig } from '../mixins/depositSystemConfig'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import { download } from '@assets/js/utils'// 常用方法

export default {
  name: 'BailfeeRefundAuditList',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin, cashDepositGroupMixin, depositSystemConfig],
  data() {
    return {
      confirmLoading: true,
      activeName: '00', // 是否非错误来源 00 非错误来原 01错误来源
      // 搜索
      createTime: [], // 提交时间
      searchForm: {
        errorStatus: '', // 是否错误来账 00正常 01错误
        packName: '', // 标段名称
        packNo: '', // 标段编号
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        submitEndTime: '', // 提交结束时间
        submitStartTime: '' // 提交开始时间
      },
      tableData: [], // 列表
      tableDataSelect: [] // 选择的信息
    }
  },
  watch: {
    // 提交时间
    createTime(val) {
      this.searchForm.submitStartTime = val && val[0]
      this.searchForm.submitEndTime = val && val[1]
    },
    // 是否非错误来源
    activeName() {
      this.onSearch()
    }
  },
  created() {
    // 根据是否简单功能tab页文案显示不同
    this.bailShowShielding ? this.isShieldingActiveName = '非错误来款' : this.isShieldingActiveName = '保证金退款审批'
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 选择退款记录
    onSelect(val) {
      this.tableDataSelect = val
    },
    // table记住分页多选框选中的数据
    getRowKeys(row) {
      return row.refundDetailId
    },
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      params.packId = this.$route.params.packId // 包组id
      queryBillDetailList(params).then(response => {
        this.confirmLoading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.confirmLoading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.errorStatus = this.activeName// 是否为错误来源
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 搜索
    onSearch() {
      // 清除选项
      this.tableDataSelect = []
      this.$refs.multipleTable.clearSelection()
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm() {
      restoreInitialValue(this.searchForm)
      // 获取列表信息
      this.onSearch()
    },
    // 导出
    exportBillDetailList() {
      const data = {
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      exportBillDetailList(data).then(res => {
        download(res, '保证金收款明细.xls')
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
