<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="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="所属区域">
              <j-search-select-tag placeholder="请选择所属区域" v-model="queryParam.iconClass" dict="common_icon_image,title,id"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="分类标识">
              <j-search-select-tag placeholder="请选择分类标识" v-model="queryParam.classId" dict="common_class,title,id"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="审核状态">
                <j-dict-select-tag placeholder="请选择审核状态" v-model="queryParam.status" dictCode="home_status"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="用户">
                <j-search-select-tag placeholder="请选择用户" v-model="queryParam.userId" dict="han_hai_member,nick_name,id"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="地区标识">
                <j-search-select-tag placeholder="请选择地区标识" v-model="queryParam.areaId" dict="comm_city,title,id"/>
              </a-form-item>
            </a-col>
          </template>
          <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 @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">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('房源信息表')">导出</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>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <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>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        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,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" 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="downloadFile(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 @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

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

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import CommonHomeModal from './modules/CommonHomeModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'CommonHomeList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      CommonHomeModal
    },
    data () {
      return {
        description: '房源信息表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'创建日期',
            align:"center",
            sorter: true,
            dataIndex: 'createTime'
          },
          {
            title:'所属区域',
            align:"center",
            dataIndex: 'iconClass_dictText'
          },
          {
            title:'图片',
            align:"center",
            dataIndex: 'image',
            scopedSlots: {customRender: 'imgSlot'}
          },
          {
            title:'标题',
            align:"center",
            dataIndex: 'title'
          },
          {
            title:'分类标识',
            align:"center",
            dataIndex: 'classId_dictText'
          },
          {
            title:'标签',
            align:"center",
            dataIndex: 'iconTitle'
          },
          {
            title:'价格',
            align:"center",
            dataIndex: 'price'
          },
          {
            title:'单位',
            align:"center",
            dataIndex: 'unit'
          },
          {
            title:'地址',
            align:"center",
            dataIndex: 'address'
          },
          {
            title:'浏览量',
            align:"center",
            dataIndex: 'num'
          },
          {
            title:'年限',
            align:"center",
            dataIndex: 'timeGo'
          },
          {
            title:'热点名称',
            align:"center",
            dataIndex: 'iconName'
          },
          {
            title:'视频',
            align:"center",
            dataIndex: 'homeMp4',
            scopedSlots: {customRender: 'fileSlot'}
          },
          {
            title:'户型',
            align:"center",
            dataIndex: 'homeType'
          },
          {
            title:'面积',
            align:"center",
            dataIndex: 'homeMi'
          },
          {
            title:'房屋结构',
            align:"center",
            dataIndex: 'homeJg'
          },
          {
            title:'房屋编号',
            align:"center",
            dataIndex: 'homeNo'
          },
          {
            title:'房屋周边',
            align:"center",
            dataIndex: 'homeBian'
          },
          {
            title:'房间数量',
            align:"center",
            dataIndex: 'homeNum'
          },
          {
            title:'菜地',
            align:"center",
            dataIndex: 'homeCai'
          },
          {
            title:'距离场镇距离',
            align:"center",
            dataIndex: 'homeJl'
          },
          {
            title:'距离成都西三环',
            align:"center",
            dataIndex: 'homeShjl'
          },
          {
            title:'房屋主体是否改造',
            align:"center",
            dataIndex: 'homeGz'
          },
          {
            title:'房屋面积',
            align:"center",
            dataIndex: 'homeMj'
          },
          {
            title:'院子总面积',
            align:"center",
            dataIndex: 'homeYzmj'
          },
          {
            title:'房屋朝向及海拔',
            align:"center",
            dataIndex: 'homeHb'
          },
          {
            title:'是否经过安置',
            align:"center",
            dataIndex: 'homeAz'
          },
          {
            title:'交通',
            align:"center",
            dataIndex: 'homeJt'
          },
          {
            title:'坟包及电塔 工厂噪音',
            align:"center",
            dataIndex: 'homeZy'
          },
          {
            title:'水电气网',
            align:"center",
            dataIndex: 'homeSd'
          },
          {
            title:'停车',
            align:"center",
            dataIndex: 'homeCat'
          },
          {
            title:'付款方式及押金',
            align:"center",
            dataIndex: 'homePay'
          },
          {
            title:'租期',
            align:"center",
            dataIndex: 'homeTime'
          },
          {
            title:'非正常死亡',
            align:"center",
            dataIndex: 'homeSw'
          },
          {
            title:'邻居对房东评价',
            align:"center",
            dataIndex: 'homePj'
          },
          {
            title:'佣金',
            align:"center",
            dataIndex: 'homeMoney'
          },
          {
            title:'钥匙',
            align:"center",
            dataIndex: 'homeYs'
          },
          {
            title:'户主家庭职业',
            align:"center",
            dataIndex: 'homeJtzy'
          },
          {
            title:'报建手续',
            align:"center",
            dataIndex: 'homeBjsx'
          },
          {
            title:'府市民云房屋信息档案查询',
            align:"center",
            dataIndex: 'homeTf',
            scopedSlots: {customRender: 'imgSlot'}
          },
          {
            title:'审核状态',
            align:"center",
            dataIndex: 'status_dictText'
          },
          {
            title:'户主年龄',
            align:"center",
            dataIndex: 'homeAge'
          },
          {
            title:'产权证照片',
            align:"center",
            dataIndex: 'homeImage',
            scopedSlots: {customRender: 'imgSlot'}
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'homeBz'
          },
          {
            title:'用户',
            align:"center",
            dataIndex: 'userId_dictText'
          },
          {
            title:'经度',
            align:"center",
            dataIndex: 'longitude'
          },
          {
            title:'纬度',
            align:"center",
            dataIndex: 'latitude'
          },
          {
            title:'地区标识',
            align:"center",
            dataIndex: 'areaId_dictText'
          },
          {
            title:'视频',
            align:"center",
            dataIndex: 'mpVio',
            scopedSlots: {customRender: 'fileSlot'}
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/commonHome/commonHome/list",
          delete: "/commonHome/commonHome/delete",
          deleteBatch: "/commonHome/commonHome/deleteBatch",
          exportXlsUrl: "/commonHome/commonHome/exportXls",
          importExcelUrl: "commonHome/commonHome/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'datetime',value:'createTime',text:'创建日期'})
        fieldList.push({type:'sel_search',value:'iconClass',text:'所属区域',dictTable:"common_icon_image", dictText:'title', dictCode:'id'})
        fieldList.push({type:'Text',value:'image',text:'图片',dictCode:''})
        fieldList.push({type:'string',value:'title',text:'标题',dictCode:''})
        fieldList.push({type:'sel_search',value:'classId',text:'分类标识',dictTable:"common_class", dictText:'title', dictCode:'id'})
        fieldList.push({type:'string',value:'iconTitle',text:'标签',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'price',text:'价格',dictCode:''})
        fieldList.push({type:'string',value:'unit',text:'单位',dictCode:''})
        fieldList.push({type:'string',value:'address',text:'地址',dictCode:''})
        fieldList.push({type:'int',value:'num',text:'浏览量',dictCode:''})
        fieldList.push({type:'int',value:'timeGo',text:'年限',dictCode:''})
        fieldList.push({type:'string',value:'iconName',text:'热点名称',dictCode:''})
        fieldList.push({type:'Text',value:'homeMp4',text:'视频',dictCode:''})
        fieldList.push({type:'string',value:'homeType',text:'户型',dictCode:''})
        fieldList.push({type:'string',value:'homeMi',text:'面积',dictCode:''})
        fieldList.push({type:'string',value:'homeJg',text:'房屋结构',dictCode:''})
        fieldList.push({type:'string',value:'homeNo',text:'房屋编号',dictCode:''})
        fieldList.push({type:'string',value:'homeBian',text:'房屋周边',dictCode:''})
        fieldList.push({type:'string',value:'homeNum',text:'房间数量',dictCode:''})
        fieldList.push({type:'string',value:'homeCai',text:'菜地',dictCode:''})
        fieldList.push({type:'string',value:'homeJl',text:'距离场镇距离',dictCode:''})
        fieldList.push({type:'string',value:'homeShjl',text:'距离成都西三环',dictCode:''})
        fieldList.push({type:'string',value:'homeGz',text:'房屋主体是否改造',dictCode:''})
        fieldList.push({type:'string',value:'homeMj',text:'房屋面积',dictCode:''})
        fieldList.push({type:'string',value:'homeYzmj',text:'院子总面积',dictCode:''})
        fieldList.push({type:'string',value:'homeHb',text:'房屋朝向及海拔',dictCode:''})
        fieldList.push({type:'string',value:'homeAz',text:'是否经过安置',dictCode:''})
        fieldList.push({type:'string',value:'homeJt',text:'交通',dictCode:''})
        fieldList.push({type:'string',value:'homeZy',text:'坟包及电塔 工厂噪音',dictCode:''})
        fieldList.push({type:'string',value:'homeSd',text:'水电气网',dictCode:''})
        fieldList.push({type:'string',value:'homeCat',text:'停车',dictCode:''})
        fieldList.push({type:'string',value:'homePay',text:'付款方式及押金',dictCode:''})
        fieldList.push({type:'string',value:'homeTime',text:'租期',dictCode:''})
        fieldList.push({type:'string',value:'homeSw',text:'非正常死亡',dictCode:''})
        fieldList.push({type:'string',value:'homePj',text:'邻居对房东评价',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'homeMoney',text:'佣金',dictCode:''})
        fieldList.push({type:'int',value:'homeYs',text:'钥匙',dictCode:''})
        fieldList.push({type:'string',value:'homeJtzy',text:'户主家庭职业',dictCode:''})
        fieldList.push({type:'string',value:'homeBjsx',text:'报建手续',dictCode:''})
        fieldList.push({type:'Text',value:'homeTf',text:'府市民云房屋信息档案查询',dictCode:''})
        fieldList.push({type:'int',value:'status',text:'审核状态',dictCode:'home_status'})
        fieldList.push({type:'string',value:'homeAge',text:'户主年龄',dictCode:''})
        fieldList.push({type:'Text',value:'homeImage',text:'产权证照片',dictCode:''})
        fieldList.push({type:'Text',value:'homeBz',text:'备注',dictCode:''})
        fieldList.push({type:'sel_search',value:'userId',text:'用户',dictTable:"han_hai_member", dictText:'nick_name', dictCode:'id'})
        fieldList.push({type:'string',value:'longitude',text:'经度',dictCode:''})
        fieldList.push({type:'string',value:'latitude',text:'纬度',dictCode:''})
        fieldList.push({type:'sel_search',value:'areaId',text:'地区标识',dictTable:"comm_city", dictText:'title', dictCode:'id'})
        fieldList.push({type:'Text',value:'mpVio',text:'视频',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>