<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>
            <ai-info-item label="意见详情" isLine :value="info.opinion"></ai-info-item>
            <ai-info-item label="联系人" isLine :value="info.contacts"></ai-info-item>
            <ai-info-item label="联系方式" isLine :value="info.phone"></ai-info-item>
            <ai-info-item label="反馈平台" isLine :value="info.sourceHost"></ai-info-item>
            <ai-info-item label="图片" isLine>
              <ai-uploader v-model="info.images" disabled :instance="instance" :limit="9"></ai-uploader>
            </ai-info-item>
          </ai-wrapper>
        </template>
      </ai-card>
    </template>
  </ai-detail>
</template>

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

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

    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(`/api/appfeedback/queryDetailById?id=${id}`).then(res => {
          if (res.code === 0) {
            this.info = res.data
            this.info.images = res.data.pictureUrl ? res.data.pictureUrl.split(',').map(v => {
              return {
                url: v
              }
            }) : []
          }
        })
      },

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

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