<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="小区名称">
              <j-input placeholder="请输入小区名称" v-model="queryParam.communityName"></j-input>
            </a-form-item>
          </a-col>

          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
            <a-col :md="6" :sm="24">
              <a-button type="primary" @click="searchQuery">查询</a-button>
              <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
            </a-col>
          </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('t_property_settled')">导出</a-button> -->
      <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>已选择&nbsp;<a style="font-weight: 600">{{
          selectedRowKeys.length
        }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" v-if="selectedRowKeys.length > 0" @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"
      >
        <span slot="empowerDate" slot-scope="text, record">
          <span>{{ record.empowerBeginDate }}至{{ record.empowerEndDate }}</span>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="showDeleteConfirm(record)">删除关联</a>


        </span>
        <!-- 字符串超长截取省略号显示 -->
        <span slot="url" slot-scope="text">
          <j-ellipsis :value="text" :length="25"/>
        </span>
        <!-- 字符串超长截取省略号显示-->
        <span slot="component" slot-scope="text">
          <j-ellipsis :value="text"/>
        </span>
      </a-table>

    </div>
    <!-- table区域-end -->

    <notice-modal ref="modalForm" @ok="modalFormOk"></notice-modal>
    <!-- 删除关联 -->

  </a-card>
</template>

<script>
// import { getPropertyListApi, getSystemSubmenu, getSystemSubmenuBatch } from '@/api/api'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import NoticeModal from './modules/NoticeModal'
import {filterDictTextByCache} from '@/components/dict/JDictSelectUtil'

const columns = [
  {
    title: '小区名称',
    dataIndex: 'communityName',
    key: 'communityName',
    align: 'center'
  },
  {
    title: '所属区域',
    dataIndex: 'communityArea',
    key: 'communityArea',
    align: 'center'
  },
  {
    title: '占地面积（㎡）',
    dataIndex: 'coverArea',
    key: 'coverArea',
    align: 'center'
  },
  {
    title: '总栋数',
    dataIndex: 'buildingNum',
    key: 'buildingNum',
    align: 'center'
  },
  {
    title: '房屋数量',
    dataIndex: 'houseNum',
    key: 'houseNum',
    align: 'center'
  },
  {
    title: '联系人',
    dataIndex: 'adminName',
    key: 'adminName',
    align: 'center'
  },
  {
    title: '联系方式',
    dataIndex: 'adminPhone',
    key: 'adminPhone',
    align: 'center'
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    key: 'createTime',
    align: 'center'
  },
  {
    title: '操作',
    dataIndex: 'action',
    scopedSlots: {customRender: 'action'},
    align: 'center',
    width: 150
  }
]

export default {
  name: 'PermissionListAsync',
  mixins: [JeecgListMixin],
  components: {
    NoticeModal
  },
  data() {
    return {
      // 表头
      columns: columns,
      deteleId: '',
      dataSource: [
        {
          accessAddress: "hanjiangzhixing",
          addressInfo: "十堰市电饭锅",
          adminAvatar:"scott/pic/img01_1687743526373.png",
          adminName: "扫地僧",
          adminPassword:"123456",
          adminPhone:"15586468632",
          buildingNum:123,
          chargingStation: 23423,
          communityArea:"郧阳区",
          communityCode:"P00082",
          communityImage:"scott/pic/8b9eaa6e92ad56895430be936cc03896_1687746009641.jpg",
          communityIntro:"",
          communityName:"汉江之星小区",
          completedDate:"2021-06-16",
          councilsCode:null,
          councilsName:null,
          coverArea:23412,
          createBy:"13177461177",
          createTime:"2023-06-26 09:38:48",
          delFlag:0,
          houseNum:4532242,
          id:"1673143741424750593",
          lastPermissionIds:null,
          parkingSpace:2334,
          permissionIds:null,
          platformCode:"P00081",
          platformName:"汉江之星物业公司",
          platformType:"company",
          roleId:"1673143741215137794",
          updateBy:"汉江之星物业公司管理员",
          updateTime:"2023-07-20 14:35:35",
          useTo:1,
          userId:"1673143740938313730",
        }
      ],
      url: {
        // list: "/property-company/community/companyCommunity/list",
        // delete: '/property-company/community/companyCommunity/delete',
        // deleteBatch: '/property-company/community/companyCommunity/deleteBatch'
      },

    }
  },
  methods: {
    handlePerssion(roleId) {
      this.$refs.modalUserRole.show(roleId);
    },
    showDeleteConfirm(record) {
      this.deteleId = record.id;
      this.$confirm({
        title: '确定是否删除关联小区?',
        okText: '删除',
        okType: 'danger',
        cancelText: '否',
        onOk() {
          console.log(record);
        },
        onCancel() {
          console.log('Cancel');
        },
      });
    },

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