<template>
  <el-card shadow="never"
           class="aui-card--fill">
    <div class="mod-__metauserpartyrank}">
      <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(':metauserpartyrank:save')"
                     type="primary"
                     @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission(':metauserpartyrank: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 prop="streetName"
                         label="街道名称"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="partyMemberCount"
                         label="已注册党员数量（已认证）"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="oldCount"
                         label="年龄超过50岁党员数量"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="oldPercent"
                         label="老龄化比例"
                         header-align="center"
                         align="center">
          <template slot-scope="scope">
            {{(scope.row.oldPercent*100).toFixed(2)}}%
          </template>
        </el-table-column>
        <el-table-column prop="youngCount"
                         label="年龄50岁以下的党员数量"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="youngPercent"
                         label="年轻化比例"
                         header-align="center"
                         align="center">
          <template slot-scope="scope">
            {{(scope.row.youngPercent*100).toFixed(2)}}%
          </template>
        </el-table-column>
        <el-table-column prop="maleCount"
                         label="男"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="femaleCount"
                         label="女"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="unknownSexCount"
                         label="未知性别"
                         header-align="center"
                         align="center"></el-table-column>
        <el-table-column prop="partyAuthFailureCount"
                         label="党员认证失败数"
                         header-align="center"
                         align="center"></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>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/analysis/metauserpartyrank/page',
        getDataListIsPage: true,
        deleteURL: '/analysis/metauserpartyrank',
        deleteIsBatch: true,
        exportURL: '/analysis/metauserpartyrank/export'
      },
      dataForm: {
        id: '',
        createdTime: ''
      },
      options: [],
      deptIdList: []
    }
  },
  components: {
  },
  watch: {
    'deptIdList': function (val) {
      if (val.length !== 0) {
        this.dataForm.streetId = val[val.length - 1]
      } else {
        this.dataForm.streetId = ''
      }
    }
  }
}
</script>
