<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="企业名称">
              <a-input placeholder="请输入企业名称" v-model="queryParam.companyName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="服务商">
              <a-input placeholder="请输入服务商" v-model="queryParam.subcontractorName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('收支记录')">导出</a-button>
    </div>

    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        bordered
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">

      </a-table>
    </div>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { Arithmetic } from '@/mixins/Arithmetic'
  export default {
    name: "HlgAccountList",
    mixins:[JeecgListMixin,Arithmetic],
    components: {

    },
    data () {
      return {
        description: '账户信息表管理页面',
        // 表头
        columns: [
          {
            title:'企业名称',
            align:"left",
            dataIndex: 'companyName'
          },
          {
            title:'服务商',
            align:"left",
            dataIndex: 'subcontractorName'
          },
          {
            title:'平台',
            align:"left",
            dataIndex: 'platformName'
          },
          {
            title:'收支方向',
            align:"left",
            dataIndex: 'type_dictText'
          },
          {
            title:'金额',
            align:"left",
            dataIndex: 'amount'
          },
          {
            title:'服务费',
            align:"left",
            dataIndex: 'serviceFee'
          },
          {
            title:'备注',
            align:"left",
            dataIndex: 'type',
            customRender: (value, row, index) => {
              if(row.type === 0){
                if(row.payment_id){
                  return '付款失败：'+row.paymentCode;
                }
                return '充值'+ row.totalAmount +'元，扣除服务费'+ row.serviceFee +'元，实际到账'+ row.amount +'元';
              }else{
                if(row.payment_id){
                  return '付款：'+row.paymentCode;
                }
                return '退款'+ this.numAdd(row.serviceFee,row.amount) +'元，包含服务费'+ row.serviceFee +'元，实际扣除可用金额'+ row.amount +'元';
              }
            },
          },
          {
            title:'业务时间',
            align:"left",
            dataIndex: 'generateTime'
          },
          {
            title: '操作人',
            align: 'left',
            dataIndex: 'generateBy',
          }
        ],
        url: {
          list: "/hlgaccount/hlgAccountDetail/allList",
          exportXlsUrl: "/hlgaccount/hlgAccountDetail/exportXls",
        },
        dictOptions:{
        }
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      handleDetail(record){
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = record.companyName
        this.$refs.modalForm.disableSubmit = false
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>