// 检索内容 邓岚
<template>
  <div class="retrievalBox">
      <dialog-edit
        :visible.sync="detailsData.dialogVisible"
        :editModel="editModel"
        :title="$t('retrievalContentIndex.retrievalContent')"
        :form={}
        width="800px"
        :footerBtnShow="false">
      <template>
        <div class="detailsBox"><span class="iconfont iconwentidian"></span>{{listData.problemPoint}}，{{$t('retrievalContentIndex.howToDo')}}？</div>
        <div class="titleLine">
          <span class="iconfont iconbiaoji"></span>
          {{$t('feedbackMaterialIndex.solutionNo')}}: {{listData.solutionCode}}
          <span class="line"></span>
          <span class="whiteLine"></span>
        </div>
        <ul>
          <li><span>{{$t('feedbackMaterialIndex.problemType')}}：</span><label>{{listData.problemType}}</label></li>
          <li><span>{{$t('feedbackMaterialIndex.problemPoint')}}：</span><label>{{listData.problemPoint}}</label></li>
          <li><span>{{$t('feedbackMaterialIndex.solution')}}：</span><label>{{listData.solution}}</label></li>
          <li><span>{{$t('knowledgeBaseIndex.production')}}：</span><label>{{listData.applicableProject ? listData.applicableProject : '/' }}</label></li>
          <li><span>{{$t('retrievalContentIndex.correspondingLawFirms')}}：</span><label>{{listData.correspondingLawFirms ? listData.correspondingLawFirms : '/' }}</label></li>
        </ul>
        <!-- 通过素材编号（materialNo）判断是否显示最新相关案例 -->
        <div v-if="listData.materialNo || listData.reviewNo" class="caseList">
          <div class="titleLine">
            <span class="iconfont iconbiaoji"></span>
            {{$t('retrievalContentIndex.newCase')}}（{{$t('feedbackMaterialIndex.materialNo')}}：{{listData.materialSourceType !== '04' ? listData.materialNo : listData.reviewNo}}）
            <span class="line"></span>
            <span class="whiteLine"></span>
          </div>
        <!-- s素材来源为1/2/3 展示这一个 -->
          <ul v-if="listData.materialSourceType !== '04'">
            <li><span>{{$t('retrievalContentIndex.resource')}}：</span><label>{{listData.materialSourceName}}</label></li>
            <li><span>{{$t('common.payCode')}}：</span><label>{{listData.payCode}}</label></li>
            <li><span>{{$t('feedbackMaterialIndex.institutionOpinions')}}：</span><label>{{listData.institutionOpinions}}</label></li>
            <li><span>{{$t('feedbackMaterialIndex.hgOpinions')}}：</span><label>{{listData.hgOpinions}}</label></li>
            <li>
              <span>{{$t('retrievalContentIndex.enclosure')}}：</span>
              <btn-batch-download v-if="listData.fileIds !== '' && listData.fileIds.length !== 0" :fileID="listData.fileIds" type="primary" size="mini" downloadButtonMsg="下载" :classType="true"></btn-batch-download>
            </li>
          </ul>
          <!-- s素材来源为4 展示这一个 -->
          <ul v-if="listData.materialSourceType === '04'">
            <li><span>{{$t('retrievalContentIndex.resource')}}：</span><label>{{listData.materialSourceName}}</label></li>
            <li><span>{{$t('common.payCode')}}：</span><label>{{listData.payCode}}</label></li>
            <li><span>{{$t('reviewMaterialIndex.problemSummary')}}：</span><label>{{listData.problemSummary}}</label></li>
            <li><span>{{$t('reviewMaterialIndex.problemDesc')}}：</span><label>{{listData.problemDesc}}</label></li>
            <li><span>{{$t('reviewMaterialIndex.reviewConclusion')}}：</span><label>{{listData.reviewConclusion}}</label></li>
            <li><span>{{$t('reviewMaterialIndex.remark')}}：</span><label>{{listData.remark}}</label></li>
            <li>
              <span>{{$t('retrievalContentIndex.enclosure')}}：</span>
              <btn-batch-download v-if="listData.fileIds !== '' && listData.fileIds.length !== 0" :fileID="listData.fileIds" type="primary" size="mini" downloadButtonMsg="下载" :classType="true"></btn-batch-download>
            </li>
          </ul>
        </div>
      </template>
      <template slot="footer">
        <el-button type="primary" size="medium" @click="fFKYJ">{{$t('knowledgeBaseIndex.feedback')}}</el-button>
        <el-button size="medium" @click="dialogClose">{{$t('common.close')}}</el-button>
      </template>
    </dialog-edit>
    <createFeedback
      v-if="createFeedbackVisible"
      :visible.sync="createFeedbackVisible"
      :editModel="editModel"
      :form="feedbackForm"
      :feedbackKeyId="detailsData.keyId"
      @dialogClose="dialogClose"></createFeedback>
  </div>
</template>

<script>
import { DialogEdit, authButton, btnBatchDownload } from 'newepoch-components'
import retrievalApi from '@/api/assetaudit/knowledgeBase/retrievalApi'
import createFeedback from '@/pages/assetaudit/reviewMaterial/createFeedback'
import * as format from '@/filters/index'
export default {
  props: {
    detailsData: {
      type: Object,
      default () {
        return {
          dialogVisible: false,
          keyId: ''
        }
      }
    }
  },
  components: {
    DialogEdit,
    authButton,
    btnBatchDownload,
    createFeedback
  },
  data () {
    return {
      createFeedbackVisible: false,
      feedbackForm: {},
      listData: {
        solutionCode: '',
        problemType: '',
        problemPoint: '',
        applicableProject: '',
        correspondingLawFirms: '',
        reviewNo: '',
        materialSourceType: '',
        payCode: '',
        problemSummary: '',
        problemDesc: '',
        reviewConclusion: '',
        remark: '',
        institutionOpinions: '',
        hgOpinions: '',
        fileIds: '',
        relatedSources: '01'
      },
      editModel: 'A'
    }
  },
  created () {
    retrievalApi.detail.get(this.detailsData.keyId).then(res => {
      if (res.code && res.code === '0') {
        res.data.materialSourceName = format.formatDict(res.data.materialSourceType, 'MATERIAL_SOURCE')
        Object.assign(this.listData, res.data)
      }
    })
  },
  methods: {
    // ...format,
    shwoFeedbackOptions () {
      this.createFeedbackVisible = true
    },
    dialogClose () {
      this.listData = {
        solutionCode: '',
        problemType: '',
        problemPoint: '',
        applicableProject: '',
        correspondingLawFirms: '',
        reviewNo: '',
        materialSourceType: '',
        payCode: '',
        problemSummary: '',
        problemDesc: '',
        reviewConclusion: '',
        remark: '',
        institutionOpinions: '',
        hgOpinions: '',
        fileIds: '',
        relatedSources: '01'
      }
      this.detailsData.dialogVisible = false
    },
    fFKYJ () {
      this.createFeedbackVisible = true
    }
  }
}
</script>
