<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.ownerName"></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>

    <!-- table区域-begin -->
    <div>
      <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns"
        :dataSource="dataSource" :pagination="ipagination" :loading="loading"  class="j-table-force-nowrap"
        @change="handleTableChange">
        <!-- <span slot="noticeTitle" slot-scope="text, record"
          style=" width: 200px;display: block;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
          <a-tooltip placement="topLeft" :title="record.noticeTitle">{{record.noticeTitle}}</a-tooltip>
        </span> -->
        <span slot="labelImg" slot-scope="text, record">
          <img :src="getAvatar(record.labelImg)" style="width:100px;height:100px;" alt="">
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="onCommunityAdd(record.id, 'detail')">详情</a>
          <template v-if="record.auditStatus === 'waitAudit'">
            <a-divider type="vertical" />
            <a @click="onCommunityAdd(record.id, 'audit')">审核</a>
          </template>
        </span>
      </a-table>

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

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

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import NoticeModal from './modules/NoticeModal'
import { deleteCommunityApi } from '@/api/api'
  import { getFileAccessHttpUrl } from "@/api/manage"
import { filterDictTextByCache } from '@/components/dict/JDictSelectUtil'

const columns = [
  {
    title: '业主名称',
    dataIndex: 'ownerName',
    key: 'ownerName',
    align: 'center',
    // customRender: function (text) {
    //   return filterDictTextByStatic(URGENT_DEGREE, text)
    // },
  },
  {
    title: '所属小区',
    dataIndex: 'communityName',
    // scopedSlots: { customRender: 'communityName' },
    key: 'communityName',
    align: 'center'
  },
  {
    title: '贫困类型',
    dataIndex: 'labelDesc',
    key: 'labelDesc',
    align: 'center',
    // customRender: function (text) {
    //   return filterDictTextByStatic(SCHEDULED_RELEASE, text)
    // },
  },
  {
    title: '证件照',
    dataIndex: 'labelImg',
    scopedSlots: { customRender: 'labelImg' },
    key: 'labelImg',
    align: 'center'
  },
  {
    title: '申请人',
    dataIndex: 'createBy',
    key: 'createBy',
    align: 'center',
  },
  {
    title: '申请时间',
    dataIndex: 'createTime',
    key: 'createTime',
    align: 'center',
  },
  // {
  //   title: '住户数量',
  //   dataIndex: 'noticeStatus',
  //   key: 'noticeStatus',
  //   align: 'center',
  //   customRender: function (text) {
  //     return filterDictTextByStatic(NOTICE_STATUS, text)
  //   },
  // },
  {
    title: '状态',
    dataIndex: 'auditStatus',
    key: 'auditStatus',
    align: 'center',
    customRender: function (text) {
      return filterDictTextByCache('auditStatus', text)
    }
  },
  {
    title: '操作',
    dataIndex: 'action',
    scopedSlots: { customRender: 'action' },
    align: 'center',
    fixed: 'right',
    width: 150,
  },
]

export default {
  name: 'PermissionListAsync',
  mixins: [JeecgListMixin],
  components: { NoticeModal },
  data() {
    return {
      // 表头
      columns: columns,
      url: {
        list: '/property-community/ownerlabel/ownerLabel/list'
      },
    }
  },
  methods: {
    getAvatar(url){
      return getFileAccessHttpUrl(url)
    },
    async onHandleDelete(ids) {
      let res = await deleteCommunityApi({
        action: 'delete',
        ids
      })
      this.$message.success('解绑成功')
      this.loadData()
    },
    onBatchDelele() {
      let _this = this
      this.$confirm({
        title: '提示',
        content: '确认要批量解绑选中的小区吗?',
        onOk() {
          _this.onHandleDelete(_this.selectedRowKeys.join(','))
        },
        onCancel() {
        },
      });
    },
    onCommunityAdd(id, type) {
      this.$router.push({
        path: `/poor/PoorDetail?id=${id}&type=${type}`
      });
    }
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>