<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-news__group}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('news:group:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('news:group:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="主键" header-align="center" align="center"></el-table-column>
        <el-table-column prop="groupName" label="社群名称" header-align="center" align="center"></el-table-column>
        <el-table-column prop="groupAvatar" label="社群头像" header-align="center" align="center"></el-table-column>
        <el-table-column prop="groupIntroduction" label="社群介绍" header-align="center" align="center"></el-table-column>
        <el-table-column prop="groupCategory" label="社群类别 0：党员群，1：自建群" header-align="center" align="center"></el-table-column>
        <el-table-column prop="area" label="区" header-align="center" align="center"></el-table-column>
        <el-table-column prop="areaId" label="区ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="street" label="街道" header-align="center" align="center"></el-table-column>
        <el-table-column prop="streetId" label="街道ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="community" label="社区" header-align="center" align="center"></el-table-column>
        <el-table-column prop="communityId" label="社区ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="grid" label="网格" header-align="center" align="center"></el-table-column>
        <el-table-column prop="gridId" label="网格ID" header-align="center" align="center"></el-table-column>
        <el-table-column prop="state" label="状态 0：待审核，5：审核不通过，10：审核通过，15：禁言，20：已解散" header-align="center" align="center"></el-table-column>
        <el-table-column prop="processingOpinions" label="处理意见" header-align="center" align="center"></el-table-column>
        <el-table-column prop="delFlag" label="删除标记 0：未删除，1：已删除" header-align="center" align="center"></el-table-column>
        <el-table-column prop="revision" label="乐观锁" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createdBy" label="创建人" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createdTime" label="创建时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updatedBy" label="更新人" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updatedTime" label="更新时间" header-align="center" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('news:group:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('news:group:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './group-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/news/group/page',
        getDataListIsPage: true,
        deleteURL: '/news/group',
        deleteIsBatch: true
      },
      dataForm: {
        id: ''
      }
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
