<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 :xl="8" :lg="7" :md="8" :sm="24">
            <a-form-item label="海事机构">
              <j-tree-select
                v-model="queryParam.departId"
                placeholder="请选择机构"
                dict="view_depart,depart_nam,depart_no"
                pidField="updepart_no"
                pidValue="384"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用电船舶">
              <j-input placeholder="请输入用电船舶" v-model="queryParam.shipName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="作业单位">
              <j-input placeholder="请输入作业单位" v-model="queryParam.companySimpleName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="7" :md="8" :sm="24">
            <a-form-item label="申报时间">
              <a-range-picker
                style="width: 230px"
                v-model="createTimeRange"
                format="YYYY-MM-DD"
                :placeholder="['开始时间', '结束时间']"
                @change="onDateChange"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <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-button type="primary" icon="download" @click="handleExportXls('替代措施')" style="margin-left: 8px">导出</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 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">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

        <span slot="detail" slot-scope="text">
          <j-ellipsis :value="text" :length="15" />
        </span>

      </a-table>
    </div>

    <adAlternativeMeasure-modal ref="modalForm" @ok="modalFormOk"></adAlternativeMeasure-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import AdAlternativeMeasureModal from './modules/AdAlternativeMeasureModal'
  import JDate from '@/components/jeecg/JDate.vue'
  import JInput from '@/components/jeecg/JInput'
  import JTreeSelect from '@/components/jeecg/JTreeSelect'
  import JEllipsis from "@/components/jeecg/JEllipsis"

  export default {
    name: "AdAlternativeMeasureList",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      JEllipsis,
      JDate,
      JInput,
      JTreeSelect,
      AdAlternativeMeasureModal
    },
    data () {
      return {
        description: '替代措施管理页面',
        createTimeRange: [],
        // 表头
        columns: [
          {
            title:'用电船舶',
            align:"center",
            dataIndex: 'shipName'
          },
          {
            title:'联系方式',
            align:"center",
            dataIndex: 'contactWay'
          },
          {
            title:'作业单位',
            align:"center",
            dataIndex: 'companySimpleName'
          },
          {
            title:'管辖海事机构',
            align:"center",
            dataIndex: 'departNam'
          },
          {
            title:'申报时间',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title:'替代措施',
            align:"center",
            dataIndex: 'type_dictText'
          },
          {
            title:'具体描述',
            align:"center",
            dataIndex: 'detail',
            scopedSlots: {customRender: 'detail'},
          },
          // {
          //   title: '操作',
          //   dataIndex: 'action',
          //   align:"center",
          //   // fixed:"right",
          //   width:147,
          //   scopedSlots: { customRender: 'action' }
          // }
        ],
        url: {
          list: "/ad/adAlternativeMeasure/list",
          exportXlsUrl: "/ad/adAlternativeMeasure/exportXls",
        },
        dictOptions:{},
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      onDateChange: function(value, dateString) {
        this.queryParam.createTime_begin = dateString[0]
        this.queryParam.createTime_end = dateString[1]
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>