<template>
  <el-card shadow="never"
           class="aui-card--fill">
    <div class="mod-__metausergridopining}">
      <el-form :inline="true"
               :model="dataForm"
               @keyup.enter.native="getDataList()">
        <el-form-item label="所属机构">
          <el-cascader v-model="deptIdList"
                       :options="options"
                       :props="{ checkStrictly: true }"
                       clearable></el-cascader>
        </el-form-item>
        <el-form-item label="截止日期">
          <el-date-picker v-model="dataForm.createdTime"
                          type="date"
                          placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary"
                     @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item>
        <!-- <el-form-item>
            <el-button v-if="$hasPermission(':metausergridopining:save')"
                       type="primary"
                       @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
          </el-form-item>
          <el-form-item>
            <el-button v-if="$hasPermission(':metausergridopining: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="gridId"
                         label="网格id"
                         header-align="center"
                         align="center"></el-table-column> -->
        <el-table-column prop="allDeptName"
                         label="网格名称"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="gridLeader"
                         label="网格党建指导员姓名"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="registerCount"
                         label="用户总数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="partyCount"
                         label="党员数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="residentCount"
                         label="已注册居民"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="unAuthorizedCount"
                         label="未注册居民"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="newsCount"
                         label="新闻发布数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="communityCount"
                         label="社群数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="communityMemberCount"
                         label="群成员数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="communityTopicCount"
                         label="群话题数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="eventCount"
                         label="议题总数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="itemCount"
                         label="项目数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="itemCloseCount"
                         label="项目已解决数"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="itemPraiseCount"
                         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(':metausergridopining:update')"
                       type="text"
                       size="small"
                       @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission(':metausergridopining: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 './metausergridopining-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/analysis/metausergridopining/page',
        getDataListIsPage: true,
        deleteURL: '/analysis/metausergridopining',
        deleteIsBatch: true,
        exportURL: '/analysis/metausergridopining/export'
      },
      dataForm: {
        id: '',
        createdTime: ''
      },
      options: [],
      deptIdList: []
    }
  },
  components: {
    AddOrUpdate
  },
  created () {
    this.$http
      .get(`/sys/user/deptOptions/getByLoginUser`)
      .then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        this.options = res.data.options
      })
      .catch(() => { })
  },
  watch: {
    'deptIdList': function (val) {
      console.log(this.deptIdList)
      if (val.length !== 0) {
        this.dataForm.gridId = val[val.length - 1]
      } else {
        this.dataForm.gridId = ''
      }
    }
  }
}
</script>
