<template>
  <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.hwSubcontractorName"></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>
              <!--<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">
      <a-button @click="handleAdd" type="primary" icon="plus" v-has="'require:taxAdd'">新增</a-button>
      <!--<a-button type="primary" icon="download" @click="handleExportXls('hw_tax')">导出</a-button>-->
      <!--<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
        <!--<a-button type="primary" icon="import">导入</a-button>-->
      <!--</a-upload>-->
      <!--<a-dropdown v-if="selectedRowKeys.length > 0">-->
        <!--<a-menu slot="overlay">-->
          <!--<a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
        <!--</a-menu>-->
        <!--<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
      <!--</a-dropdown>-->
    </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="action1" slot-scope="text, record">
           <a @click="handleDetail(record)">{{record.hwSubcontractor.name}}</a>
        </span>




        <span slot="action" slot-scope="text, record">
           <a @click="handleEdit(record)" v-has="'require:editdetail'">编辑</a>
            <a-divider type="vertical"/>
            <a @click="viewRecord(record)" v-has="'require:record'">修改记录</a>
        </span>


      </a-table>
    </div>

    <hwTax-modal ref="modalForm" @ok="modalFormOk"></hwTax-modal>
    <hw-tax-record-modal ref="recordForm" @ok="modalFormOk"></hw-tax-record-modal>
  </a-card>
  </div>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HwTaxModal from './modules/HwTaxModal'
  import HwTaxRecordModal from './modules/HwTaxRecordModal'
  export default {
    name: "HwTaxList",
    mixins:[JeecgListMixin],
    components: {
      HwTaxRecordModal,
      HwTaxModal
    },
    data () {
      return {
        description: 'hw_tax管理页面',
        // 表头
        columns: [
          {
            title:'服务商',
            align:"center",
            dataIndex: 'subcontractorId',
            scopedSlots: { customRender: 'action1' },
          },
          {
            title:'有效期',
            align:"center",
            dataIndex: 'startDate',
            customRender:function (text,record) {
              return record.startDate+"~"+record.endDate
            }
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/taxmanager/hwTax/list",
          delete: "/taxmanager/hwTax/delete",
          deleteBatch: "/taxmanager/hwTax/deleteBatch",
          exportXlsUrl: "/taxmanager/hwTax/exportXls",
          importExcelUrl: "taxmanager/hwTax/importExcel",
        },
        dictOptions:{
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      //刷新路由
      routeReload(){
        this.reloadFlag = false
        let ToggleMultipage = "ToggleMultipage"
        this.$store.dispatch(ToggleMultipage,false)
        this.$nextTick(()=>{
          this.$store.dispatch(ToggleMultipage,true)
          this.reloadFlag = true
        })
      },
      modalFormOk(){
        this.routeReload()
      },
      viewRecord(record){
        this.$refs.recordForm.edit(record);
        this.$refs.recordForm.title = '修改记录'
        this.$refs.recordForm.disableSubmit = false
      }
       
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>