<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.receiptNumber"></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>
          <template v-if="toggleSearchStatus">
            <a-col :md="6" :sm="8">
              <a-form-item label="完税时间">
                <a-range-picker
                  style="width: 100%"
                  v-model="queryParam.uploadTimeRange"
                  format="YYYY-MM-DD"
                  :placeholder="['开始时间', '结束时间']"
                  @change="onUpDateChange"
                  @ok="onDateOk"
                  :allowClear="allowClear"
                />
              </a-form-item>
            </a-col>
          </template>
          <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"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleView(record)">查看证明</a>
          <a-divider type="vertical" />
          <a @click="handleDetail(record)">完税明细</a>
        </span>

      </a-table>
    </div>

    <hlwDutyPaid-modal ref="modalForm" @ok="modalFormOk"></hlwDutyPaid-modal>
    <HlwPictureModal ref="modalSelectRequireForm"></HlwPictureModal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HlwDutyPaidModal from './modules/HlwDutyPaidModal'
  import { filterObj } from '@/utils/util';
  import HlwPictureModal from './modules/HlwPictureModal'

  export default {
    name: "HlwDutyPaidList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      HlwDutyPaidModal,
      HlwPictureModal
    },
    data () {
      return {
        description: 'hlw_duty_paid管理页面',
        // 查询条件
        queryParam: {
          uploadTimeRange:[]
        },
        // 表头
        columns: [

          {
            title:'发票号',
            align:"left",
            dataIndex: 'receiptNumber'
          },
          {
            title:'服务商',
            align:"left",
            dataIndex: 'subcontractorName'
          },
          {
            title:'完税金额',
            align:"left",
            dataIndex: 'totalAmount'
          },
          {
            title:'完税时间',
            align:"left",
            dataIndex: 'uploadTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"left",
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/wisdom/hlwDutyPaid/list",
          delete: "/wisdom/hlwDutyPaid/delete",
          deleteBatch: "/wisdom/hlwDutyPaid/deleteBatch",
          exportXlsUrl: "/wisdom/hlwDutyPaid/exportXls",
          importExcelUrl: "wisdom/hlwDutyPaid/importExcel",
          imgerver: window._CONFIG['imgDomainOssURL']
        },
        dictOptions:{},
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      getQueryParams(){
        var param = Object.assign({}, this.queryParam,this.isorter);
        param.field = this.getQueryField();
        param.pageNo = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        delete param.uploadTimeRange;// 时间参数不传递后台
        return filterObj(param);
      },
      initDictConfig(){
      },
      onUpDateChange: function (value, dateString) {
        console.log(dateString[0],dateString[1]);
        this.queryParam.uploadTime_begin=dateString[0]+" 00:00:00";
        this.queryParam.uploadTime_end=dateString[1] +" 23:59:59";
      },
      onDateOk(value) {
        console.log(value);
      },
      handleView(record){
        var idcard = [];
        if(record.taxPaymentReceipt){
          var invoiceArr=record.taxPaymentReceipt.split(",")
          for (let i = 0; i <invoiceArr.length ; i++) {
            if( invoiceArr[i].indexOf("http")!=-1){
              idcard.push(invoiceArr[i])
            }else{
              idcard.push(this.url.imgerver  +invoiceArr[i])
            }
          }
          this.$refs.modalSelectRequireForm.edit(idcard);
          this.$refs.modalSelectRequireForm.title = '完税证明'
          this.$refs.modalSelectRequireForm.disableSubmit = false
        }else{
          this.$message.warning('未上传')
        }
      },
      handleDetail(record){
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = '完税明细'
        this.$refs.modalForm.disableSubmit = false
      }

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