<style>
.investigationDetail .item{
  padding: 20px 0 10px 20px;
}
</style>
<template>
  <el-form class="investigationDetail">
    <div v-for="(item, index) in details" :key="index" >
      <p>{{index+1}}、{{item.Title}}</p>
      <div class="item">
        <el-rate
          disabled="disabled"
          v-if="item.SurveyType === 1"
          v-model="item.ScoreNum"
          :texts="texts"
          show-text>
        </el-rate>
        <template v-else-if="item.SurveyType === 2"> 
          <template v-for="(r, i) in item.SurveyOptionsList" v-if="r.IsCheck!=='0'">
            <span>{{r.OptionsName}}</span>
          </template> 
        </template>
        <template v-else-if="item.SurveyType === 3">
          <template v-for="(r, i) in item.SurveyOptionsList" v-if="r.IsCheck!=='0'">
            <span>{{r.OptionsName}}</span>
          </template>
        </template>
        <template v-else-if="item.SurveyType === 4"> 
          <span>{{item.TextContent}}</span> 
        </template>
      </div>
    </div>
  </el-form>
</template>
<script>
export default {
  props:['ID'],
  data(){
    return{
      details: [],
      texts: ['非常不满意', '不满意', '感觉一般', '满意', '非常满意']
    }
  },watch: {
    ID: {
      handler: function(val, oldVal) {
        if (val !== oldVal){
          this.getDetails()
        }
      },
      deep: true
    }
  },mounted() {
    this.getDetails()
  },methods: {
    getDetails: function () {
      this.apipost('survey_post_GetGuestSurvey', {SurveyID: this.ID}, res=>{
        if (res.data.resultCode === 1) {
          let data = res.data.data
          data.map(x=>{
            if (x.SurveyType === 2) {
              x.SurveyOptionsList.map(y=>{
                if (y.IsCheck === '1') {
                  x.lable = y.ID
                }
              })
            }
            if (x.SurveyType === 3) {
              let ckeckList = []
              x.SurveyOptionsList.map(y=>{
                if (y.IsCheck === '1') {
                  ckeckList.push(y.ID)
                }
              })
              x.ckeckList = ckeckList
            }
          })
          this.details = data
        }
      }, null)
    }
  }
}
</script>
