<template>
  <div id="lawDetail">
    <lawDetail-detail :info="info" :liebiaoList="liebiaoList" :columnTitle="columnTitle" :lawDetailInfo="lawDetailInfo"></lawDetail-detail>
  </div>
</template>

<script>
import lawDetailDetail from '@/components/policy/lawDetail.vue';
import { createNamespacedHelpers, mapGetters } from 'vuex';
import _ from 'loadsh';
const { mapActions: mapSite } = createNamespacedHelpers('site');
const { mapActions: mappolicyColumn } = createNamespacedHelpers('policyColumn');
const { mapActions: mappolicyNews } = createNamespacedHelpers('policyNews');
export default {
  name: 'lawDetail',
  props: {},
  components: {
    lawDetailDetail,
  },
  data: () => ({
    info: {},
    liebiaoList: [],
    columnTitle: '',
    lawDetailInfo: {},
  }),
  async created() {
    this.searchSite();
    await this.policyColumn();
    await this.searchInfo();
  },
  computed: {},
  methods: {
    ...mapSite(['showInfo']),
    ...mappolicyColumn({ policyColumns: 'query', policyfetch: 'fetch' }),
    ...mappolicyNews({ policyNew: 'query', newsFetch: 'fetch' }),
    // 查询站点信息
    async searchSite() {
      let res = await this.showInfo();
      let object = JSON.parse(JSON.stringify(res.data));
      if (object) {
        this.$set(this, `info`, res.data);
      } else {
        this.$message.error(res.errmsg ? res.errmsg : 'error');
      }
    },
    // 查询栏目
    async policyColumn({ ...info } = {}) {
      const res = await this.policyColumns({ ...info });
      if (this.$checkRes(res)) {
        this.$set(this, `liebiaoList`, res.data);
      }
    },
    async searchInfo() {
      let detailId = this.$route.query.id;
      const res = await this.newsFetch(detailId);
      const result = await this.policyfetch(res.data.column_id);
      this.$set(this, `columnTitle`, result.data.name);
      this.$set(this, `lawDetailInfo`, res.data);
    },
  },
};
</script>

<style lang="less" scoped></style>
