<template>
  <div class="app-container">
    <!-- Start 列表页面 -->
    <div>
      <button-bar view-title="选择融资平仓款" ref="btnbar" :btndisabled="btndisabled" @btnhandle="btnHandle"/>
      <div class="main-content">
        <div class="">
          <el-table :key="tableKey" v-loading="listLoading" :data="list" border style="width: 100%;" @selection-change="handleSelectionChange">
            <el-table-column fixed type="selection" align="center" width="50px"/>
            <el-table-column fixed label="序号" type="index" :index="indexMethod" align="center" width="80px"/>
            <el-table-column prop="costTitleValue" label="款项名称" align="center" width="200" />
            <el-table-column prop="openDate" label="融资付款开通日期" align="center" width="160" />
            <el-table-column prop="period" label="期(台)数" align="center" width="100" />
            <el-table-column prop="receiveCompany" label="收款单位名称" align="center" width="140" />
            <el-table-column prop="bank" label="开户行" align="center" width="130" />
            <el-table-column prop="receivingAccount" label="收款银行账号" align="center" width="140" />
            <el-table-column prop="receivingAccount" label="平仓付款日期" align="center" width="140" />
            <el-table-column prop="exePayPrice" label="平仓付款金额" align="center" width="140" />
            <el-table-column prop="remarks" label="备注" align="center" min-width="200" />
          </el-table>
        </div>
        <div class="pages">
          <!-- 翻页 -->
          <pagination v-show="list.length > 0" :total="listQuery.total" :page.sync="listQuery.current" :limit.sync="listQuery.size" class="pagination" @pagination="getList"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import req from '@/api/anruifinmanagement/payment'
import Pagination from '@/components/pagination'
import ButtonBar from '@/components/ButtonBar'

export default {
  name: 'ClosingPayment',
  components: {
    Pagination,
    ButtonBar
  },
  data() {
    return {
      btndisabled: false,
      btnList: [
        {
          type: 'primary',
          size: 'small',
          icon: '',
          btnKey: 'doConfirm',
          btnLabel: '确定'
        },
        {
          type: 'info',
          size: 'small',
          icon: 'cross',
          btnKey: 'doClose',
          btnLabel: '关闭'
        }
      ],
      isSearchShow: false,
      searchxianshitit: '显示查询条件',
      // 查询条件 -----------
      tableKey: 0,
      list: [],
      multipleSelection: [],
      FormLoading: false,
      listLoading: false,
      listQuery: {
        params: {
          payCompanySid: '',
          useOrgSid: '',
          sidList: []
        },
        current: 1,
        size: 5,
        total: 0
      },
      rules: {}
    }
  },
  created() {
    // 加载列表
    this.getList()
  },
  mounted() {
    this.$refs['btnbar'].setButtonList(this.btnList)
  },
  methods: {
    // 搜索条件效果
    clicksearchShow() {
      this.isSearchShow = !this.isSearchShow
      if (this.isSearchShow) {
        this.searchxianshitit = '隐藏查询条件'
      } else {
        this.searchxianshitit = '显示查询条件'
      }
    },
    btnHandle(btnKey) {
      console.log('XXXXXXXXXXXXXXX    ' + btnKey)
      switch (btnKey) {
        case 'doConfirm':
          this.doConfirm()
          break
        case 'doClose':
          this.doClose()
          break
        default:
          break
      }
    },
    // 序号
    indexMethod(index) {
      var pagestart = (this.listQuery.current - 1) * this.listQuery.size
      var pageindex = index + 1 + pagestart
      return pageindex
    },
    handleSelectionChange(row) {
      this.multipleSelection = row
    },
    // 查询列表信息
    getList() {
      this.listLoading = true
      req.chooseEve(this.listQuery).then((response) => {
        this.listLoading = false
        if (response.success) {
          this.list = response.data.records
          this.listQuery.total = response.data.total
        } else {
          this.list = []
          this.listQuery.total = 0
        }
      })
    },
    showData(value, createOrgSid, payCompanySid) {
      this.listQuery.params.useOrgSid = createOrgSid
      this.listQuery.params.payCompanySid = payCompanySid
      const aa = []
      // if (value.length > 0) {
      //   for (var i = 0; i < value.length; i++) {
      //     for (var j = 0; j < value[i].vehRebateSids.length; j++) {
      //       aa.push(value[i].vehRebateSids[j])
      //     }
      //   }
      // }
      this.listQuery.params.sidList = aa
      this.listQuery.current = 1
      this.getList()
    },
    // 查询按钮
    handleFilter() {
      this.listQuery.current = 1
      this.getList()
    },
    handleReset() {
      this.listQuery = {
        params: {
          createBySid: '',
          createEndTime: '',
          createStartTime: ''
        },
        current: 1,
        size: 5,
        total: 0
      }
      this.getList()
    },
    doConfirm() {
      if (this.multipleSelection.length > 0) {
        this.$emit('backData', this.multipleSelection)
      } else {
        this.$notify({ title: '提示', message: '请选择至少一条记录!', type: 'error', duration: 2000 })
      }
    },
    doClose() {
      this.$emit('doback')
    }
  }
}
</script>

<style scoped>
</style>
