<template>
  <div class="widget-projectPanoramic">
    <!--项目概况-->
    <ProjectOverview :dataInfo="dataInfo" />
    <!--参建单位-->
    <ParticipationUnits />
    <!--项目图册-->
    <ProjectPhotos />
    <!--项目进展-->
    <ProjectProgressNew :dataInfo="dataInfo" />
    <!--项目统计-->
    <ProjectIndexStatistic :dataInfo="dataInfo" />
  </div>
</template>

<script lang="ts">
import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
import ProjectOverview from './ProjectOverview.vue'
import ParticipationUnits from './ParticipationUnits.vue'
import ProjectPhotos from './ProjectPhotos.vue'
import ProjectProgressNew from './ProjectProgressNew.vue'
import ProjectIndexStatistic from './ProjectIndexStatistic.vue'
import { getEpcProjectInfo } from '../../apis'
//
import pbsTree from '../../districtPageModules/customTools/pbsTree.vue'
//工程全景模块
@Component({
  name: 'projectPanoramic',
  components: { ProjectOverview, ParticipationUnits, ProjectPhotos, ProjectProgressNew, ProjectIndexStatistic }
})
export default class projectPanoramic extends Vue {
  pbsTreeInfo = null

  dataInfo = null

  mounted() {
    this.initModulesContentShow()
    this.getPageData()
  }
  get projectCode() {
    return this.$store.state.bigScreen.currentProjectCode
  }
  get isInitViewer() {
    return this.$store.state.bigScreen.isInitViewer
  }
  @Watch('isInitViewer')
  onChangeMethod(val) {
    if (val) this.initModulesContentShow()
  }
  //初始化显示模块内容
  initModulesContentShow() {
    if (!this.isInitViewer) return
    const pbsTreeConstructor = Vue.extend(pbsTree)
    this.pbsTreeInfo = new pbsTreeConstructor({
      store: this.$store
    }).$mount()
    ;(this.pbsTreeInfo as any).externalInit()
  }
  async getPageData() {
    const res = await getEpcProjectInfo({ code: this.projectCode })
    if (!res.result) return
    Object.keys(res.result).forEach((val) => (res.result[val] = res.result[val] || 0))
    this.dataInfo = res.result
  }
  beforeDestroy() {
    if (this.pbsTreeInfo) {
      ;(this.pbsTreeInfo as any).externalClear()
      this.pbsTreeInfo = null
    }
  }
}
</script>

<style></style>