<template>
  <ai-detail>
    <template slot="title">
      <ai-title title="课程详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
      </ai-title>
    </template>
    <template slot="content">
      <ai-card title="基本信息">
        <template #content>
          <ai-wrapper
            label-width="120px">
            <ai-info-item label="题目描述" isLine :value="info.title"></ai-info-item>
            <ai-info-item label="题目类型" isLine :value="info.title"></ai-info-item>
            <ai-info-item label="正确答案" isLine :value="info.areaName"></ai-info-item>
            <ai-info-item label="题目选项" isLine :value="info.contentType"></ai-info-item>
            <ai-info-item label="正文" isLine>
              <AiArticle :value="info.content"></AiArticle>
            </ai-info-item>
          </ai-wrapper>
        </template>
      </ai-card>
    </template>
  </ai-detail>
</template>

<script>
  export default {
    name: 'Detail',

    props: {
      instance: Function,
      dict: Object,
      params: Object,
      moduleId: String
    },

    data () {
      return {
        info: {},
        id: ''
      }
    },

    created () {
      if (this.params && this.params.id) {
        this.id = this.params.id
        this.getInfo(this.params.id)
      }
    },

    methods: {
      getInfo (id) {
        this.instance.post(`/app/appcontentinfo/queryDetailById?id=${id}`).then(res => {
          if (res.code === 0) {
            this.info = res.data
            this.info.pictureUrl = res.data.pictureUrl ? [{
              url: res.data.pictureUrl
            }] : []
          }
        })
      },

      cancel (isRefresh) {
        this.$emit('change', {
          type: 'List',
          isRefresh: !!isRefresh
        })
      }
    }
  }
</script>

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