<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.companyName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="企业合同">
              <j-dict-select-tag v-model="queryParam.contractQuery" placeholder="请选择合同方式" dictCode="contractQuery"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :md="8" :sm="8">
              <a-form-item label="服务商">
                <a-input placeholder="请输入服务商名称" v-model="queryParam.subcontractorName"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="10">
              <a-form-item label="合同到期时间">
                <a-range-picker
                  style="width: 100%"
                  v-model="queryParam.serviceContractExpiryDateRange"
                  format="YYYY-MM-DD"
                  :placeholder="['开始时间', '结束时间']"
                  @change="onDateChange"
                  @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"
        @change="handleTableChange">


        <span slot="action" slot-scope="text, record">
            <a @click="editInfo(record)" v-has="'company:infoEdit'">编辑</a>
        </span>

      </a-table>
    </div>

  <hw-platform-company-infodeply-modal ref="modelAuthForm" @ok="modalFormOk"></hw-platform-company-infodeply-modal>
  </a-card>
  </div>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   import HwPlatformCompanyInfodeplyModal from './modules/HwPlatformCompanyInfodeplyModal'
  import { getAction, deleteAction, putAction, postAction } from '@/api/manage'
  import { filterObj } from '@/utils/util';




  export default {
    name: 'HwPlatformCompanyInfoDeplyList',
    mixins: [JeecgListMixin],
    components: {
      HwPlatformCompanyInfodeplyModal
    },
    data() {
      return {
        allowClear:false,
        description: '企业信息管理页面',
        // 查询条件
        queryParam: {
          serviceContractExpiryDateRange:[],
        },
        // 表头
        columns: [
          {
            title: '企业名称',
            align: 'center',
            dataIndex: 'companyName'
          },
          {
            title: '服务费率',
            align: 'center',
            dataIndex: 'serviceFeeRate',
            customRender: function(text) {
              return text ? text+'%' : '--'
            }
          },
          {
            title: '付款类型',
            align: 'center',
            dataIndex: 'paymentType_dictText',
            customRender: function(text) {
              return text ? text : '--'
            }
          },
          {
            title: '合同类型',
            align: 'center',
            dataIndex: 'serviceContractType_dictText',
            customRender: function(text) {
              return text ? text : '--'
            }
          },
          {
            title: '合同',
            align: 'center',
            dataIndex: 'serviceContract',
            customRender: function(text,record) {
              if(record.serviceContractType==1 || record.serviceContractType==null){
                return '--'
              }else{
                if(text){
                  return '已上传'
                }else{
                  return '未上传'
                }
              }
            }
          },
          {
            title: '合同到期时间',
            align: 'center',
            dataIndex: 'serviceContractExpiryDate',
            customRender: function(text) {
              return !text ? '--' : text.substring(0,10)
            }
          },
          {
            title: '服务商',
            align: 'center',
            dataIndex: 'subcontractorName',
            customRender: function(text) {
              return text ? text : '--'
            }
          },
          {
            title: '外包费率',
            align: 'center',
            dataIndex: 'subcontractorFeeRate',
            customRender: function(text) {
              return text ? text+'%' : '--'
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: { customRender: 'action' }
          }
        ],
        isorter: {
          column: 'updateTime',
          order: 'desc'
        },
        url: {
          list: '/saasmanager/hwPlatformCompany/infoDeplyList',
          delete: '/saasmanager/hwPlatformCompany/delete',
          deleteBatch: '/saasmanager/hwPlatformCompany/deleteBatch',
          exportXlsUrl: '/saasmanager/hwPlatformCompany/exportXls',
          importExcelUrl: 'saasmanager/hwPlatformCompany/importExcel'
        },
        dictOptions: {},
        options: [{
          value: '',
          label: '',
          isLeaf: false
        }],
      }
    },
    created() {

    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    methods: {
      getQueryParams(){
        console.log(this.queryParam.serviceContractExpiryDateRange)
        var param = Object.assign({}, this.queryParam,this.isorter);
        param.field = this.getQueryField();
        param.pageNo = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        delete param.serviceContractExpiryDateRange; // 时间参数不传递后台
        return filterObj(param);
      },
      initDictConfig() {
      },
      onDateChange: function (value, dateString) {
        console.log(dateString[0],dateString[1]);
        this.queryParam.serviceContractExpiryDate_begin=dateString[0]+" 00:00:00";
        this.queryParam.serviceContractExpiryDate_end=dateString[1] +" 23:59:59";
      },
      onDateOk(value) {
        console.log(value);
      },

      //编辑
     editInfo(record) {
        this.$refs.modelAuthForm.edit(record);
        this.$refs.modelAuthForm.title = '编辑'
        this.$refs.modelAuthForm.disableSubmit = false
      },

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