<template>
  <index-card :title="`${type}/${title}`">
    <el-button slot="more" size="small" round @click="closeDetail">返回</el-button>
    <div v-loading="loading" class="mt20" style="padding: 0 30px" v-html="data.content" />
  </index-card>
</template>
<script>
import * as career from '@/api/webApi/career-news'
import IndexCard from '@/views/login/components/modules/shared/IndexCard'

export default {
  components: { IndexCard },
  props: {
    type: {
      type: String | Number,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    id: {
      type: String | Number,
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      data: {}
    }
  },
  watch: {
    id(newVal, oldVal) {
      this.getDetail()
    }
  },
  created() {
    this.getDetail()
  },
  methods: {
    closeDetail() {
      this.$emit('close')
    },

    getDetail() {
      if (!this.id) return
      this.loading = true
      career.info({ id: this.id }).then((res) => {
        console.log('career news info res', res)
        if (res.code == 200 || res.code == 0) {
          this.data = res.data
        } else {
          this.msgError(res.msg || 'career news info 请求异常')
        }
        this.loading = false
      })
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
