householdGender.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div class="modelBlock">
  3. <div class="model-title">
  4. <div class="model-title-text">住户性别占比</div>
  5. <el-select v-model="mixins_query.communityId" placeholder="所有社区" clearable class="saveColumn-select" @change="getData">
  6. <el-option v-for="(item, index) in communityList" :label="item.communityName" :value="item.id" :key="index"></el-option>
  7. </el-select>
  8. </div>
  9. <div class="model-content">
  10. <zz-echart :option="clientOptions" class="chart"></zz-echart>
  11. <div class="totals">
  12. <span>{{ total }}</span>
  13. <span class="numbers">总人数</span>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import { ringType } from './indexOptionChart';
  20. export default {
  21. data() {
  22. return {
  23. mixins_query: {
  24. communityId: ''
  25. },
  26. total: 0,
  27. clientOptions: ringType(
  28. [],
  29. [
  30. { value: 0, name: '男' },
  31. { value: 0, name: '女' }
  32. ],
  33. {},
  34. { type: '%', total: 0 }
  35. )
  36. };
  37. },
  38. computed: {
  39. communityList() {
  40. return this.$store.getters['getAreaSelect'];
  41. }
  42. },
  43. methods: {
  44. getData() {
  45. this.$http.get('/sc-community/statisticUserGender', this.mixins_query).then(({ data, msg, status }) => {
  46. if (status == 0 && !!data.datas) {
  47. this.clientOptions = ringType([], this.eachartObj(data), {}, { type: '%', total: data.total });
  48. } else {
  49. this.clientOptions = ringType(
  50. [],
  51. [
  52. { value: 0, name: '男' },
  53. { value: 0, name: '女' }
  54. ],
  55. {},
  56. { type: '%', total: 0 }
  57. );
  58. }
  59. });
  60. },
  61. eachartObj(data) {
  62. this.total = data.total;
  63. let typeName = {
  64. 0: '其他',
  65. 1: '男',
  66. 2: '女'
  67. };
  68. let newData = [];
  69. for (let a in data.datas) {
  70. newData.push({
  71. value: data.datas[a],
  72. name: typeName[a]
  73. });
  74. }
  75. return newData;
  76. }
  77. },
  78. created() {
  79. this.getData();
  80. }
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. @import './style.scss';
  85. </style>