<template>
  <m-grid
    :template="[
      'title title title',
      'box1 . box5',
      'box2 . box5',
      'box3 . box6',
      'box4 . box6',
    ]"
    columns="1fr 2.5fr 1fr"
    rows="3rem 1fr 1.5fr 1fr 2fr"
    gap="0"
    :bgImg="require('@/assets/images/stars-bg.png')"
    style="padding: 0"
  >
    <m-title area="title" color="#fff" :bgImg="require('@/assets/images/title-bg.png')">智慧物业管理微平台</m-title>
    <m-card area="box1" title="物业应急指挥体系" mode="4" :icon="require('@/assets/images/icon1.png')">
      <EmergencyCommand />
    </m-card>
    <m-card area="box2" title="运行体征" mode="4" :icon="require('@/assets/images/icon2.png')">
      <Operation @select="handleSelect" />
    </m-card>
    <m-card area="box3" title="投诉保修" mode="4" :icon="require('@/assets/images/icon3.png')">
      <Repair />
    </m-card>
    <m-card area="box4" title="智能发现" mode="4" :icon="require('@/assets/images/icon4.png')">
      <Discovery />
    </m-card>
    <m-card area="box5" title="物业督查" mode="4" :icon="require('@/assets/images/icon5.png')">
      <Supervision  @clickCommunity="clickCommunity"/>
    </m-card>
    <m-card area="box6" title="协同处置" mode="4" :icon="require('@/assets/images/icon6.png')">
      <Handle/>
    </m-card>
  </m-grid>
</template>

<script>
import EmergencyCommand from '@/views/components/emergencyCommand.vue'
import Operation from '@/views/components/operation.vue'
import Repair from '@/views/components/repair.vue'
import Discovery from '@/views/components/discovery.vue'
import Supervision from '@/views/components/supervision.vue'
import Handle from '@/views/components/handle.vue'
export default {
  name: 'Main',
  components: {
    EmergencyCommand,
    Operation,
    Repair,
    Discovery,
    Supervision,
    Handle,
  },
  data(){
    return{
      isPublish:'1',
    }
  },
  methods: {
    handleSelect(data) {
      console.log(data)
    },
    clickCommunity(data){
      console.log(data)
    },

    getCheckCommunityList(){                 // 获取检查小区的列表
      let searchParams ={}
      if (this.isPublish == 1  ) {
        searchParams = {
          isPublish: 1
        }
        this.isPublish = 0
      }
      this.$ajax.post({
        url: this.$api.POST_CHECKCOMMUNITY_LIST,
        params:Object.assign({},searchParams,{
          pageSize:100000,
          someday:'20200317',
          // taskId:''
          // pageNo:1,
        })
      }).then(res => {
        if (res.code== '200') {
          let list = this.$com.confirm(res, 'data.content', [])
          if (!!searchParams.isPublish) {
            this.$store.commit('SET_SENDCHECKED',list.length)            // 传了1   已开单小区
          } else {
            this.$store.commit('SET_CHECKCOMMUNITYLIST',list)    // 没传ispublish   已检查小区总数
            this.$store.commit('SET_ALLCHECKED',list.length)
          }
        }else{
          this.$Message.error('未获取到检查小区列表数据')
        }
      })
    },

    getCheckedPeopleList(){            // 获取检查人员的列表
      let searchParams = {}
      this.$ajax.post({
        url: this.$api.POST_CHECKPEOPLE_LIST,
        params:Object.assign({},searchParams,{
          startDate:'2020-03-17 00:00:00',
          endDate:'2020-03-18 23:19:54',
          pageSize:10000,
          // pageNumber:1,
          // taskId:'',
        })
      }).then(res => {
        if (res.code== '200') {
          let list = this.$com.confirm(res, 'data.content', [])
          this.$store.commit('SET_CHECKPEOPLELIST',list)
        }else{
          this.$Message.error('未获取到检查人员列表数据')
        }
      })
    }

  },
  created(){
    this.getCheckCommunityList()
    this.getCheckCommunityList()
    this.getCheckedPeopleList()
  }
}
</script>
