<!--
  @description: 保证金管理
  @Modifier: sunxinman/haofengxian
  @routerPath: /fee/cashDepositManage
  @date: 2020/03/24-11:30
-->
<template>
  <table-crud
    ref="tableCrud"
    :search-form="searchForm"
    search-label-width="110px"
    @on-load="loadData"
  >
    <template v-slot:header>
      保证金管理
    </template>
    <template v-slot:search="search">
      <!-- 招标项目编号 -->
      <el-form-item ref="tenderNo" label="招标项目编号" prop="tenderNo">
        <el-input v-model.trim="searchForm.tenderNo" placeholder="招标项目编号" style="width: 228px" @keyup.enter.native="search.onSearch" />
      </el-form-item>
      <!-- 标段（包）名称 -->
      <el-form-item ref="packName" label="标段（包）名称" prop="packName">
        <el-input v-model.trim="searchForm.packName" placeholder="标段（包）名称" style="width: 228px" @keyup.enter.native="search.onSearch" />
      </el-form-item>
      <!--            &lt;!&ndash; 退款状态 &ndash;&gt;
            <el-form-item
              label="退款状态"
              prop="refundStatus">
              <el-select
                v-model="searchForm.refundStatus"
                placeholder="请选择"
                style="width:228px">
                <el-option
                  v-for="item in refundStatusList"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"/>
              </el-select>
            </el-form-item>-->
      <!-- 退款逾期 -->
      <el-form-item
        v-if="bailShowShielding"
        label="退款逾期"
        prop="refundOverdueStatus"
      >
        <el-select
          v-model="searchForm.refundOverdueStatus"
          placeholder="请选择"
          style="width:228px"
        >
          <el-option
            v-for="item in refundExpireStatusList"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
    </template>
    <template v-slot:GXTable>
      <el-table
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <!-- 招标项目编号 -->
        <el-table-column
          prop="tenderNo"
          align="center"
          label="招标项目编号"
          width="160"
        />
        <!-- 标段（包）名称 -->
        <el-table-column
          header-align="center"
          label="标段（包）名称"
          prop="packName"
          align="left"
          min-width="200"
        />
        <!-- 保证金余额（元） -->
        <el-table-column
          header-align="center"
          prop="totalBalance"
          label="保证金余额（元）"
          align="right"
          width="120"
        />
        <!-- 可用余额（元） -->
        <el-table-column
          header-align="center"
          prop="availableBalance"
          label="可用余额（元）"
          min-width="100"
          align="right"
        />
        <!-- 待确认金额（元） -->
        <el-table-column
          v-if="bailShowShielding"
          header-align="center"
          prop="undefinedAmount"
          label="待确认金额（元）"
          align="right"
          width="120"
        />
        <!-- 退款逾期-->
        <el-table-column
          v-if="bailShowShielding"
          :formatter="formatRefundOverdueStatus"
          header-align="center"
          label="退款逾期"
          prop="refundOverdueStatus"
          align="center"
          width="100"
        />
        <!-- 退款状态 -->
        <!--          <el-table-column
                  header-align="center"
                  label="退款状态"
                  prop="refundStatus"
                  align="center"
                  width="100">
                  <template slot-scope="scope">
                    <span
                      v-for="item in refundStatusList"
                      v-if="item.typecode===scope.row.refundStatus"
                      :key="item.typecode">{{ item.typename }}
                    </span>
                  </template>
                </el-table-column>-->
        <el-table-column
          header-align="center"
          label="操作"
          align="left"
          width="300"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click="subAccountInfo(scope.row)"
            >
              [子账号信息]
            </el-link>
            <el-link
              type="primary"
              @click.stop="collectionRecord(scope.row)"
            >
              [收款记录]
            </el-link>
            <!-- <el-link
              v-if="bailShowShielding"
              type="primary"
              @click.stop="letterManage(scope.row)"
            >
              [保函管理]
            </el-link> -->
            <!--              v-if="scope.row.refundOverdueStatus!=='00'"-->
            <el-link
              type="primary"
              @click.stop="refundManage(scope.row)"
            >
              [退款管理]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { queryDepositPackinfoList } from '@api/fee/bailfee'
/* 混合开发方法-参数字段*/
import { cashDepositGroupMixin } from '../../mixins/cashDepositGroupMixin'
import { depositSystemConfig } from '../../mixins/depositSystemConfig'

export default {
  name: 'CashDepositManageList',
  mixins: [cashDepositGroupMixin, depositSystemConfig],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        packName: '', // 标段名称
        refundOverdueStatus: '', // 退款逾期状态
        refundStatus: '', // 退款状态
        tenderDepartId: '', // 业务部门ID
        tenderManagerId: '', // 项目经理ID
        tenderNo: '' // 项目编号
      },
      tableData: []
    }
  },
  methods: {
    // 获取数据
    loadData(params, callback) {
      queryDepositPackinfoList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
      })
    },
    // 子账号信息
    subAccountInfo(row) {
      this.$router.push({
        path: '/fee/subAccountInfo',
        name: 'SubAccountInfoList',
        params: {
          packId: row.packId
        }
      })
    },
    // 收款记录
    collectionRecord(row) {
      this.$router.push({
        path: '/fee/collectionRecords',
        name: 'CollectionRecordsList',
        params: {
          packId: row.packId // 包组id
        }
      })
    },
    // 保函管理
    letterManage(row) {
      this.$router.push({
        path: '/fee/letterManage',
        name: 'LetterManageList',
        params: {
          packId: row.packId
        }
      })
    },
    // 退款管理
    refundManage(row) {
      this.$router.push({
        path: '/fee/refundManage',
        name: 'RefundManageList',
        params: {
          packId: row.packId
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
