<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">
            <a-form-item label="发票号">
              <a-input placeholder="请输入发票号" v-model="queryParam.invoiceNumber"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item  label="开票状态">
              <j-dict-select-tag v-model="queryParam.invoiceStatus" placeholder="请选择开票状态" dictCode="invoiceStatus"/>
            </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">
    </div>

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


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



        <span slot="action" slot-scope="text, record">
            <a v-has="'hcwinvoice:invoiceDetail'" @click="invoiceDetail(record)" >开票明细</a>

          <template v-if="record.invoiceNumber">
           <a-divider v-has="'hcwinvoice:viewInvoice'" type="vertical"  />


            <a v-has="'hcwinvoice:viewInvoice'" style="color: limegreen" @click="viewInvoice(record)" >发票查看</a>
          </template>

        </span>

      </a-table>
    </div>
      <HwPictureModal ref="hwViewPictureForm" @ok="modalFormOk"></HwPictureModal>
  </a-card>

</template>
<script>

  import { httpAction ,getAction,putAction} from '@/api/manage'
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HwPictureModal from '../tools/HwPictureModal'

  export default {
    name: "HlwInvoiceManageList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      HwPictureModal

    },
    data () {
      return {
        queryParam: {},
        selectedRowKeys: [],
        selectedRows: [],
        description: '开票申请',
        // 表头
        columns: [
          {
            title:'企业名称',
            align:"center",
            dataIndex: 'companyName',
            customRender:function (text) {
              return text
            }
          },
          {
            title:'通过平台',
            align:"center",
            dataIndex: 'isThroughPlatform_dictText'
          },
          {
            title:'平台名称',
            align:"center",
            dataIndex: 'cpName'
          },
          {
            title:'服务商',
            align:"center",
            dataIndex: 'subcontractorName'
          },
          {
            title:'发票明细',
            align:"center",
            dataIndex: 'invoiceDetailNum',
          },
          {
            title:'平台发票号',
            align:"center",
            dataIndex: 'serviceInvoiceNumber'
          },
          {
            title:'平台开票金额',
            align:"center",
            dataIndex: 'serviceAmount'
          },
          {
            title:'服务商发票号',
            align:"center",
            dataIndex: 'invoiceNumber'
          },
          {
            title:'发票类型',
            align:"center",
            dataIndex: 'invoiceType_dictText'
          },
          {
            title:'服务商发票金额',
            align:"center",
            dataIndex: 'amount'
          },
          {
            title:'开票状态',
            align:"center",
            dataIndex: 'invoiceStatus',
            customRender:function (text,record) {
              return record.invoiceNumber?"已开票":"待处理"
            }
          },
          {
            title:'申请人',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title:'申请时间',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title:'开票人',
            align:"center",
            dataIndex: 'uploadBy'
          },
          {
            title:'开票时间',
            align:"center",
            dataIndex: 'uploadTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/wisdom/hlwInvoice/alreadyInvoiceList",
          imgerver: window._CONFIG['imgDomainOssURL']
        },
        dictOptions:{},
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      viewInvoice(record){
        if(!record.invoice || record.invoice==''){
          this.$message.error('暂未上传发票!')
          return
        }
        var idcard = [];
        var arr=record.invoice.split(",")
        for (let i = 0; i <arr.length ; i++) {
          if( arr[i].indexOf("http")!=-1){
            idcard.push(arr[i])
          }else{
            idcard.push(this.url.imgerver  +arr[i])
          }
        }
        this.$refs.hwViewPictureForm.edit(idcard);
        this.$refs.hwViewPictureForm.title = '发票照片'
        this.$refs.hwViewPictureForm.disableSubmit = false
      },
      invoiceDetail(record){
        this.$router.push({ path: '/wisdom/hlwInvoice/queryById',query:{id:record.id }})
      },


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