<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.invoiceCategoryName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="分类名称">
              <a-input placeholder="模糊搜索" v-model="queryParam.taxCategoryName"></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" @click="handleImportExcel()" icon="import" v-has="'hlw:invoiceCategory:import'">导入开票内容</a-button>
    </div>

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

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        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="handleDelete(record)" v-has="'hlw:invoiceCategory:delete'">删除</a>
        </span>

      </a-table>
    </div>

    <HlwInvoiceCategoryImportModal ref="modalImportForm" @ok="modalFormOk"></HlwInvoiceCategoryImportModal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { httpAction, getAction,deleteAction } from '@/api/manage'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HlwInvoiceCategoryImportModal from './modules/HlwInvoiceCategoryImportModal'

  export default {
    name: "HlwInvoiceCategoryList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      HlwInvoiceCategoryImportModal
    },
    data () {
      return {
        description: 'hlw_invoice_category管理页面',
        // 表头
        columns: [
          {
            title:'开票内容代码',
            align:"center",
            dataIndex: 'invoiceCategoryCode'
          },
          {
            title:'开票内容',
            align:"center",
            dataIndex: 'invoiceCategoryName'
          },
          {
            title:'税收分类代码',
            align:"center",
            dataIndex: 'taxCategoryCode'
          },
          {
            title:'税收分类名称',
            align:"center",
            dataIndex: 'taxCategoryName'
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createTime',
          },
          {
            title:'创建者',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title:'更新时间',
            align:"center",
            dataIndex: 'updateTime',
          },
          {
            title:'更新者',
            align:"center",
            dataIndex: 'updateBy'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/wisdom/hlwInvoiceCategory/list",
          delete: "/wisdom/hlwInvoiceCategory/delete",
          deleteBatch: "/wisdom/hlwInvoiceCategory/deleteBatch",
          exportXlsUrl: "/wisdom/hlwInvoiceCategory/exportXls",
          importExcelUrl: "wisdom/hlwInvoiceCategory/importExcel",
        },
        dictOptions:{},
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      handleImportExcel() {
        this.$refs.modalImportForm.edit({})
        this.$refs.modalImportForm.title = '导入开票内容'
        this.$refs.modalImportForm.disableSubmit = true
      },
      handleDelete(record){
        var that = this;
        const modal = that.$confirm({
          title: '删除开票内容',
          closable: true,
          keyboard: false,
          maskClosable: true,
          content: '确定要删除该开票内容吗？',
          okText: '确定删除',
          cancelText: '取消',
          onOk: function() {
            deleteAction(that.url.delete, {id: record.id}).then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.loadData();
              } else {
                that.$message.warning(res.message);
              }
            });
          },
          onCancel(e) {
            modal.destroy()
          }
        })
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>