<template>
  <a-modal
    :title="title"
    :width="modelStyle.width"
    :visible="visible"
    :bodyStyle="bodyStyle"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :maskClosable="false"
    cancelText="关闭">
    <template slot="footer">
      <a-button type="primary" @click="handleOk">
        关闭
      </a-button>
    </template>
    <a-spin :spinning="confirmLoading">
      <a-card :bordered="false">

        <!-- 操作按钮区域 -->
        <div class="table-operator">

        </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>
    </a-spin>
  </a-modal>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { Arithmetic } from '@/mixins/Arithmetic'
  import { httpAction, getAction, putAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import JDate from '@/components/jeecg/JDate'

  export default {
    name: 'HlgAccountPaymentDetailsModal',
    mixins: [JeecgListMixin, Arithmetic],
    components: {
      JDate,
    },
    data() {
      return {
        title: '',
        bodyStyle: {
          padding: '0',
          height: (window.innerHeight * 0.62) + 'px',
          'overflow-y': 'auto'
        },
        modelStyle: {
          width: '76%',
          style: { top: '10px' },
          fullScreen: false
        },
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        // 表头
        columns: [
          {
            title: '业务时间',
            align: 'left',
            dataIndex: 'createTime'
          },
          {
            title: '业务类型',
            align: 'left',
            dataIndex: 'type_dictText',
            scopedSlots: { customRender: 'type' }
          },
          {
            title: '金额',
            align: 'left',
            dataIndex: 'amount'
          },
          {
            title: '服务费',
            align: 'left',
            dataIndex: 'serviceFee',
            customRender: (value,record) => {
              return value ? value:'--'
            }
          },
          {
            title: '备注',
            align: 'left',
            dataIndex: 'paymentCode',
            customRender: (value,record) => {
              return value ? value:'--'
            }
          },
          {
            title: '操作人',
            align: 'left',
            dataIndex: 'updateBy'
          },
          {
            title: '操作时间',
            align: 'left',
            dataIndex: 'updateTime'
          }
        ],
        confirmLoading: false,
        companyName: '',
        companyId: 0,
        url: {
          list: '/wisdom/hlwCompanyAccountDetail/list',
        }

      }
    },
    created() {
    },
    methods: {
      resetData() {
        this.model = {};
      },
      add() {
        this.edit({})
      },
      edit(record) {
        this.resetData();
        this.model = Object.assign({}, record)
        this.companyId = record.companyId
        this.visible = true
        this.companyName = record.companyName
        this.companyAccountId = record.id
        this.loadData(1)
      },
      loadData(arg) {
        if (!this.url.list) {
          this.$message.error('请设置url.list属性!')
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1
        }
        var params = this.getQueryParams()//查询条件
        params.companyAccountId = this.companyAccountId
        this.loading = true
        getAction(this.url.list, params).then((res) => {
          console.log(res)
          if (res.success) {
            this.dataSource = res.result.records
            this.ipagination.total = res.result.total
          }
          if (res.code === 510) {
            this.$message.warning(res.message)
          }
          this.loading = false
        })
      },
      close() {
        this.visible = false
      },
      handleOk() {
        this.close()
      },
      handleCancel() {
        this.close()
      },

      modalFormOk(){
        this.$emit('ok')
        this.loadData(1);
      },

    }
  }
</script>