<template>
  <j-modal
    :title="title"
    :width="modelStyle.width"
    :visible="visible"
    :bodyStyle="bodyStyle"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    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
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange">

            <span slot="action" slot-scope="text, record">
              <a @click="handleEdit(record)">人员明细</a>
            </span>

          </a-table>
        </div>
        <HlwDutyApplyModal ref="modalForm" @ok="modalFormOk"></HlwDutyApplyModal>
      </a-card>
    </a-spin>
  </j-modal>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { httpAction ,getAction} from '@/api/manage'
  import pick from 'lodash.pick'
  import { validateDuplicateValue } from '@/utils/util'
  import JDate from '@/components/jeecg/JDate'
  import HlwDutyApplyModal from '../modules/HlwDutyApplyModal'


  export default {
    name: "HlwDutyPaidModal",
    mixins: [JeecgListMixin],
    components: { 
      JDate,
      HlwDutyApplyModal
    },
    data () {
      return {
        form: this.$form.createForm(this),
        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 },
        },
        confirmLoading: false,
        // 表头
        columns: [
          {
            title:'付款平台',
            align:"left",
            dataIndex: 'applicationName'
          },
          {
            title:'付款单号',
            align:"left",
            dataIndex: 'paymentCode'
          },
          {
            title:'付款企业',
            align:"left",
            dataIndex: 'companyName'
          },
          {
            title:'通过平台',
            align:"left",
            dataIndex: 'isThroughPlatform_dictText'
          },
          {
            title:'完税金额',
            align:"left",
            dataIndex: 'amount'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"left",
            // fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/wisdom/hlwDutyApply/dutyList",
        }
      }
    },
    created () {
    },
    methods: {
      resetData() {
        this.model = {};
      },
      add () {
        this.edit({});
      },
      edit (record) {
        this.resetData();
        this.model = Object.assign({}, record)
        this.visible = true;
        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.dutyPaidId = this.model.id
        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.$emit('close');
        this.visible = false;
      },
      handleOk () {
        this.close()
      },
      handleCancel () {
        this.close()
      },
      handleEdit(record){
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = '人员明细'
        this.$refs.modalForm.disableSubmit = false
      },
      
    }
  }
</script>