<!--
  @description: 收款记录
  @Modifier: sunxinman/haofengxian
  @routerPath: /fee/collectionRecords
  @date: 2020/03/25-09:40
-->
<template>
  <div>
    <section class="title p0-16 clearfix">
      <!-- 返回 -->
      <div class="title-back pointer" @click="back()">
        <i class="iconfont icon-fanhui mr10" />收款记录
      </div>
    </section>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
      </div>
      <section :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
          >
            <!-- 投标人 -->
            <el-form-item ref="supplierName" label="投标人" prop="supplierName">
              <el-input v-model.trim="searchForm.supplierName" placeholder="投标人" />
            </el-form-item>
            <!-- 子账号 -->
            <el-form-item ref="accountNo" label="子账号" prop="accountNo">
              <el-input v-model.trim="searchForm.accountNo" placeholder="子账号" />
            </el-form-item>
            <!-- 保证金状态 -->
            <el-form-item label="保证金状态" prop="payStatus">
              <el-select v-model="searchForm.payStatus" placeholder="请选择">
                <el-option
                  v-for="(item,index) in cashDepositStatuslist"
                  :key="index"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </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>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>
      <div class="mb10">
        <el-button type="primary" @click="patchConfirm">
          批量确认
        </el-button>
      </div>
      <section>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
          @selection-change="selectionChange"
        >
          <el-table-column
            :selectable="isDisabled"
            disabled="true"
            type="selection"
            width="55"
          />
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <!-- 投标人  -->
          <el-table-column
            prop="supplierName"
            label="投标人"
            min-width="200"
          />
          <!-- 子账号 -->
          <el-table-column
            header-align="center"
            label="子账号"
            prop="accountNo"
            min-width="200"
          />
          <!-- 交易类型 -->
          <el-table-column
            header-align="center"
            prop="managerName"
            label="交易类型"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              <span>普通外部转账</span>
            </template>
          </el-table-column>
          <!-- 交易时间 -->
          <el-table-column
            header-align="center"
            prop="inDate"
            label="交易时间"
            width="140"
            align="center"
          />
          <!-- 对方账号 -->
          <el-table-column
            header-align="center"
            label="对方账号"
            prop="payerNo"
            align="left"
            min-width="150"
          />
          <!-- 对方账号名称 -->
          <el-table-column
            header-align="center"
            label="对方账号名称"
            prop="payerName"
            align="left"
            min-width="200"
          />
          <!-- 交易金额（元） -->
          <el-table-column
            label="交易金额（元）"
            prop="amount"
            align="right"
            width="110"
          />
          <!-- 状态 -->
          <el-table-column
            :formatter="formatPayStatus"
            label="状态"
            prop="payStatus"
            align="center"
            width="100"
          />
          <!-- 收款编号 -->
          <el-table-column
            label="收款编号"
            prop="seqNo"
            align="center"
            min-width="150"
          />
          <!-- 操作 -->
          <el-table-column
            header-align="center"
            label="操作"
            width="100"
          >
            <template slot-scope="scope">
              <!--未确认00 已收款01 待退款02 退款中03 已退款04-->
              <el-link
                v-if="scope.row.payStatus==='00'"
                type="primary"
                @click.stop="confirmCollectionInfo(scope.row,'00')"
              >
                [确认]
              </el-link>
              <el-link
                v-if="scope.row.payStatus!=='00'"
                type="primary"
                @click.stop="confirmCollectionInfo(scope.row,'01')"
              >
                [查看]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </section>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { queryBillList } from '@api/fee/bailfee'
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { cashDepositGroupMixin } from '../../mixins/cashDepositGroupMixin'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页

export default {
  name: 'CollectionRecordsList',
  components: {
    pagination// 分页
  },
  mixins: [ListMixin, cashDepositGroupMixin],
  data() {
    return {
      loading: true,
      // 搜索
      packId: this.$route.params.packId,
      searchForm: {
        accountId: '', // 虚拟账户Id
        accountNo: '', // 虚拟账户
        packId: '', // 包组ID
        payStatus: '', // 支付状态 未确认00 已收款01 待退款02 退款中03 已退款04
        stageId: '', // 阶段ID
        supplierId: '', // 供应商id
        supplierName: '', // 供应商名称
        tenderId: '' // 项目id
      },
      tableData: [],
      patchList: []// 批量确认数据存放
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      queryBillList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {

      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      param.packId = this.packId
      return filterObj(param)
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.loadData()
    },
    // 返回
    back() {
      this.$router.push({
        path: '/fee/cashDepositManage'
      })
    },
    // 确认来款信息/查看收款记录
    confirmCollectionInfo(row, type) {
      // type00确认 01查看
      this.$router.push({
        path: '/fee/confirmCollectionInfo',
        name: 'ConfirmCollectionInfo',
        params: {
          billId: row.billId, // 交易信息ID
          packId: this.packId,
          type
        }
      })
    },
    // 批量确认
    patchConfirm(row) {
      if (!this.patchList.length) {
        this.$message({
          type: 'warning',
          message: '请至少确认一条记录'
        })
        return
      }
    },
    // 选择
    selectionChange(val) {
      this.patchList = val
    },
    // 复选框部分禁用
    isDisabled(row, index) {
      if (row.payStatus === '00') {
        return true
      } else {
        return false
      }
    }
  }
}
</script>
<style lang="less" scoped>

</style>
