<template>
  <page-layout>
    <div class="page-header-index-wide">
      <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.paymentCode"></a-input>
            </a-form-item>
          </a-col>
          <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">
            <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>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="import" @click="handleImport" v-has="'payment:fujian:import'">导入</a-button>
    </div>

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


      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :scroll="{ x: 1640 }"
        @change="handleTableChange">

        <span slot="paymentCode" slot-scope="text,record">
          <a @click="toDetail(record)">{{text}}</a>
        </span>

        <span slot="action" slot-scope="text, record">
              <a v-if="record.requirementName" @click="handleViewRequirementsModal(record)" v-has="'payment:fujian:viewrequirement'">查看需求</a>
              <a v-if="!record.requirementName" @click="handleRequirement(record)" v-has="'payment:fujian:requirement'">关联需求</a>
              <a-divider type="vertical" v-has="'payment:fujian:del'"/>
              <a style="color: #D9001B" @click="handleDelete(record)" v-has="'payment:fujian:del'">删除</a>
        </span>

      </a-table>
    </div>

        <HlgPaymentFujianImportModal ref="modalForm" @ok="modalFormOk"></HlgPaymentFujianImportModal>
        <HlgPaymentRequirementModal ref="requirementModal" @ok="modalFormOk"></HlgPaymentRequirementModal>
        <HlgPaymentViewRequirementsModal ref="viewRequirementsModal"></HlgPaymentViewRequirementsModal>
      </a-card>
    </div>
  </page-layout>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import PageLayout from '@/components/page/PageLayout'
  import HlgPaymentFujianImportModal from './modules/HlgPaymentFujianImportModal'
  import HlgPaymentRequirementModal from './modules/HlgPaymentFujianRequirementModal'
  import HlgPaymentViewRequirementsModal from '../hlgpayment/modules/HlgPaymentViewRequirementsModal'
  import { httpAction, getAction, deleteAction } from '@/api/manage'

  export default {
    name: "HlgPaymentFujianList",
    mixins:[JeecgListMixin],
    components: {
      PageLayout,
      HlgPaymentFujianImportModal,
      HlgPaymentRequirementModal,
      HlgPaymentViewRequirementsModal
    },
    data () {
      return {
        description: 'hlg_payment_fujian管理页面',
        // 表头
        columns: [
          {
            title: '付款单号',
            align: 'left',
            width: 200,
            dataIndex: 'paymentCode',
            scopedSlots: { customRender: 'paymentCode' }
          },
          {
            title: '付款企业',
            align: 'left',
            width: 300,
            dataIndex: 'companyName'
          },
          {
            title: '实发金额',
            align: 'left',
            width: 200,
            dataIndex: 'totalPayment'
          },
          // （0：待复核 1：付款中 2：复核未通过 3：已付款）
          {
            title: '状态',
            align: 'left',
            width: 200,
            customRender: function () {
              return '已付款';
            }
          },
          {
            title: '业务处理情况',
            align: 'left',
            width: 300,
            dataIndex: 'remark'
          },
          {
            title:'付款时间',
            align: 'left',
            width: 200,
            dataIndex: 'paymentTime',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'left',
            width: 240,
            fixed: 'right',
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/hlgpaymentfujian/hlgPaymentFujian/list",
          delete: "/hlgpaymentfujian/hlgPaymentFujian/delete",
          deleteBatch: "/hlgpaymentfujian/hlgPaymentFujian/deleteBatch",
          exportXlsUrl: "/hlgpaymentfujian/hlgPaymentFujian/exportXls",
          importExcelUrl: "hlgpaymentfujian/hlgPaymentFujian/importExcel",
        },
        dictOptions:{
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      toDetail(record) {
        this.$router.push({ path: '/hlgpaymentfujian/hlgPaymentDetailFujian/list',query:{ paymentId:record.id } })
      },
      handleDelete(record) {
        const id = record.id
        let that = this
        const modal = that.$confirm({
          title: '删除付款',
          closable: true,
          keyboard: false,
          maskClosable: true,
          content: '确定要删除该付款吗？',
          okText: '确定删除',
          cancelText: '取消',
          onOk: function() {
            deleteAction(that.url.delete, { id }).then(res => {
              if (res.success) {
                that.$message.success(res.message)
                that.loadData(1)
              } else {
                that.$error({
                  title: '删除失败',
                  content: res.message,
                  okText: '确定'
                })
              }
            })
          },
          onCancel(e) {
            modal.destroy()
          }
        })
      },
      handleImport() {
        this.$refs.modalForm.add()
        this.$refs.modalForm.title = '导入付款'
        this.$refs.modalForm.disableSubmit = false
      },
      //关联需求
      handleRequirement(record) {
        this.$refs.requirementModal.edit(record)
        this.$refs.requirementModal.title = '关联需求'
        this.$refs.requirementModal.disableSubmit = false
      },
      //查看需求
      handleViewRequirementsModal(record){
        record.description = record.requirementDescription;
        record.requirementTime = record.requirmentTime;
        this.$refs.viewRequirementsModal.edit(record)
        this.$refs.viewRequirementsModal.title = '查看需求'
        this.$refs.viewRequirementsModal.disableSubmit = false
      }
       
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>