<template>
  <div class="content-1180">
    <div class="d-flex mt-4">
      <LeftNav :code="code" :list="list" class="mr-4" @chanegCode="chanegCode" />
      <div class="flex-1 flex-column">
        <Location />
        <div class="content-detail p-4" :style="{ 'min-height': list.children.length * 56 + 'px' }">
          <RichText :rich-obj="content" />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapActions } from 'vuex';
import LeftNav from '@/components/LeftNav/LeftNav.vue';
import RichText from '@/components/RichText/RichText.vue';
import Location from '@/components/Location/Location.vue';

export default {
  components: { LeftNav, RichText, Location },
  data() {
    return {
      code: '0901',
      list: {
        title: '部门首页',
        url: '/department',
        children: [
          {
            title: '总经理工作部',
            code: '0901',
          },
          {
            title: '计划营销部',
            code: '0902',
          },
          {
            title: '财务管理部',
            code: '0903',
          },
          {
            title: '人力资源部',
            code: '0904',
          },
          {
            title: '党群工作部',
            code: '0905',
          },
          {
            title: '纪委办公室（审计部）',
            code: '0906',
          },
          {
            title: '燃料采购部',
            code: '0907',
          },
          {
            title: '物资管理部',
            code: '0908',
          },
          {
            title: '项目开发部',
            code: '0909',
          },
          {
            title: '燃料质量验收部',
            code: '0910',
          },
          {
            title: '安全监督部',
            code: '0911',
          },
          {
            title: '设备部',
            code: '0912',
          },
          {
            title: '发电部',
            code: '0913',
          },
          {
            title: '维护部',
            code: '0914',
          },
          {
            title: '热工专业',
            code: '0915',
          },
          {
            title: '电气专业',
            code: '0916',
          },
        ],
      },
      content: {},
    };
  },
  watch: {
    '$route.query.code'(val) {
      if (this.$route.path === this.list.url) {
        this.code = val;
        this.getData(this.code);
      }
    },
  },
  created() {
    this.code = this.$route.query.code;
    this.getData(this.code);
  },
  methods: {
    ...mapActions('home', ['getDetail']),
    async getData(showPage) {
      try {
        const param = {
          showPage,
          introId: '',
        };
        const data = await this.getDetail(param);
        this.content = data;
      } catch (error) {}
    },
    chanegCode(code) {
      this.code = code;
    },
  },
};
</script>
<style scoped>
.content-detail {
  background: #fff;
}
</style>
