liuxiaolong
2019-05-06 acc45d2ece02563964d7b8a22ff0c40bd8358889
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<template>
  <div class="row">
    <div class="col-sm-6 col-xl-4 mb5">
      <b-card no-body class="mb-1 pl20 pr20 pt15 pb10">
        <div class="d-flex align-items-center">
          <div class="ion d-block ion-ios-school display-4 text-success"></div>
          <div class="ml-3">
            <div class="text-muted small">下属学校</div>
            <div class="text-large">{{this.schoolList.length}}</div>
          </div>
        </div>
      </b-card>
      <b-card no-body class="mb-2">
        <b-card-header header-tag="h5" class="with-elements pr-0 pb-0">
          <div class="card-header-title">日常上报统计:
            <small class="text-muted">(当日0点—24点)</small>
          </div>
          <!-- <div class="card-header-elements ml-auto">
              <b-dd variant="default icon-btn borderless btn-round md-btn-flat" size="sm" text="Primary" class="dropdown-toggle-hide-arrow mr-3" :right="!isRTL">
                <template slot="button-content"><i class="ion ion-ios-more"></i></template>
                <b-dd-item>Action 1</b-dd-item>
                <b-dd-item>Action 2</b-dd-item>
              </b-dd>
            </div> -->
        </b-card-header>
        <div class="py-2 px-3">
          <div class="cui-example cui-example-vertical-spacing">
            <vue-echart :options="pieOptions" :theme="polarTheme" :auto-resize="true"></vue-echart>
          </div>
        </div>
      </b-card>
      <b-card no-body>
        <b-card-header header-tag="h5" class="with-elements pr-0 pb-0">
          <div class="card-header-title">应急上报事件</div>
        </b-card-header>
        <div class="pl10 pr10 pt10 overflow-y" style="height:30vh">
          <b-list-group :flush="true" v-if="tableData.length !== 0">
            <b-list-group-item class="py-3" v-for="(iteam,index) in tableData" :key="index">
              <div class="badge badge-danger float-right">紧急</div>
              <div class="font-weight-semibold f18">【{{userInfo.sysOrgs.length&&userInfo.sysOrgs[0]?userInfo.sysOrgs[0].name:''}}】{{iteam.orgName}}</div>
              <p class="text-truncate my-1">{{iteam.name}}</p>
              <small class="text-muted">{{iteam.submitDate}}</small>
            </b-list-group-item>
          </b-list-group>
          <div class="py-5 text-center" v-else>
            <small class="text-muted">暂无数据</small>
          </div>
        </div>
        <div class="pb20 pl10 pr10" v-if="total">
          <hr class="border-light mt-0">
          <b-pagination class="justify-content-center justify-content-sm-end m-0" v-model="activePage" :total-rows="total" :per-page="pageSize" />
        </div>
      </b-card>
    </div>
    <div class="col-sm-6 col-xl-8">
      <b-card no-body class="pr" style="height: 84vh;">
        <div class="clearfix mapSearch">
          <b-input
              placeholder=" 搜学校..."
              style="max-width: 20rem;"
              class="mr5 fl"
              v-model="searchName"
              @keyup.enter.native="handleSearch"
            />
            <b-btn variant="primary" class="mr10 fl" @click.native="handleSearch"><span class="fs fas-search"></span>搜索</b-btn>
        </div>
        <commonMapModel :searchArr="searchRESList" @mapDailyfn="toDailyReporting" @mapEmergencyfn="toDailyEmergencyReporting"/>
      </b-card>
    </div>
  </div>
</template>
 
<!-- Custom template animation -->
<style>
.echarts {
  height: 300px !important;
  width: 100% !important;
}
</style>
<script>
import {
  getDailySubmitCount,
  getEmergencyList
  // getSchoolInfo
} from '@/server/home.js'
import { getDistrictAllSchoolById } from '@/server/common.js'
import commonMapModel from '@/components/map/commonMapModel'
import ECharts from 'vue-echarts/components/ECharts.vue'
import 'echarts/lib/chart/pie'
import 'echarts/theme/shine'
let pieOption = {
  tooltip: {
    trigger: 'item',
    formatter: '{a} <br/>{b} : {d}% ({c})'
  },
  legend: {
    // orient: 'vertical',
    // x: 'left',
    // y: 'center',
    type: 'scroll',
    data: ['未上报', '已上报']
  },
  series: [
    {
      name: '签到统计',
      type: 'pie',
      // radius: ['40%', '60%'],
      radius: '80%', // 50%
      center: ['50%', '55%'],
      avoidLabelOverlap: true,
      selectedMode: 'single',
      position: 'top',
      label: {
        // show:false
        position: 'inside',
        formatter: params => {
          // '{b}({c})'
          let labelStr = ''
          if (
            params.data &&
            params.data.name &&
            (params.data.value || params.data.value === 0) &&
            (params.data.countNum || params.data.countNum === 0)
          ) {
            labelStr =
              params.data.name +
              '(' +
              params.data.value +
              '/' +
              params.data.countNum +
              ')'
          }
          return labelStr !== '' ? labelStr : params.name
        }
      },
      data: []
    }
  ]
}
export default {
  name: 'home',
  metaInfo: {
    title: 'Home'
  },
  data() {
    return {
      userInfo: this.$store.getters.basicUserInfo,
      /* 列表 */
      tableData: [],
      total: 0,
      pageSize: 3,
      activePage: 1,
      /* 图表 */
      pieOptions: pieOption,
      polarTheme: 'shine',
 
      schoolList: [],
      searchName: '',
      searchRESList: []
    }
  },
  computed: {},
  methods: {
    /* 查询图表数据 */
    async getDailySubmitCountData() {
      let res = await getDailySubmitCount({ orgId: this.userInfo.orgId })
      if (
        res &&
        !isNaN(parseInt(res.notSubmitedSchools)) &&
        !isNaN(parseInt(res.submitedSchools))
      ) {
        const countNum =
          parseInt(res.notSubmitedSchools) + parseInt(res.submitedSchools)
        // this.pieOptions.series[0].data.splice(0,1,{ value: res.notSubmitedSchools, name: '未上报', countNum })
        // this.pieOptions.series[0].data.splice(1,1,{ value: res.submitedSchools, name: '已上报', countNum })
        this.pieOptions.series[0].data = [
          { value: res.notSubmitedSchools, name: '未上报', countNum },
          { value: res.submitedSchools, name: '已上报', countNum }
        ]
      }
    },
    /* 查询应急事件列表 */
    async getETableList() {
      let result = await getEmergencyList({
        orgId: this.userInfo.orgId,
        start: (this.activePage - 1) * this.pageSize,
        length: this.pageSize,
        startTime: this.$moment().format('YYYY-MM-DD 00:00:00'),
        endTime: this.$moment().format('YYYY-MM-DD 23:59:59'),
        isSubmit: '1'
      })
      if (result && result.data && (result.total || result.total === 0)) {
        this.tableData = result.data
        this.total = result.total
      } else {
        this.$toast({
          message: result.message && result.message + '(' + result.code + ')',
          type: 'error'
        })
      }
    },
    /* 查询地图数据 */
    async getMapSchoolList() {
      let res = await getDistrictAllSchoolById({
        currentId: this.userInfo.orgId,
        searchName: this.searchName
      })
      if (res && res.data) {
        if (this.schoolList.length === 0 && this.searchName === '') {
          this.schoolList = res.data
        } else {
          this.searchRESList = res.data
        }
      }
    },
    // 搜索
    handleSearch() {
      this.getMapSchoolList()
    },
 
    /* 地图跳转 */
    toDailyReporting(row) {
      this.$router.push({
        path: '/reportingRecord',
        query: { tabType: 'daily', searchName: row.data.name }
      })
    },
    toDailyEmergencyReporting(row) {
      this.$router.push({
        path: '/reportingRecord',
        query: { tabType: 'emergent', searchName: row.data.name }
      })
    }
  },
  created() {
    console.log(this.$store.getters, '获取基础信息', this.$store.state.userInfo.orgId)
    this.getDailySubmitCountData()
    this.getETableList()
    /* 查询地图 */
    this.getMapSchoolList()
  },
  watch: {
    activePage(val, oldVal) {
      if (val !== oldVal) {
        this.activePage = val
        this.getETableList()
      }
    }
  },
  components: {
    'vue-echart': ECharts,
    commonMapModel
  }
}
</script>
<style>
.mapSearch {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 9;
  padding: 10px;
  width: 100%;
  max-width: 30rem;
}
</style>