<template>
  <box title="投资目标" :isErrorBtn="isErrorBtn()" @errorResolution="errorResolution">
    <textarea :class="`isDomActive ${isClass(item)}`" v-for="(item, index) in data.completions" v-model="item.commit_answer" :key="index" :id="item.id"></textarea>
  </box>
</template>

<script>
import Box from './Box.vue'
export default {
  components: {
    Box
  },
  props: {
    data: {
      type: Object
    }
  },
  methods: {
    isErrorBtn() {
      const findErr = this.data.completions.findIndex(item => !item.is_correct)
      return findErr + 1
    },
    errorResolution() {
      this.$emit('errorResolution', this.data)
    },
    isClass(item) {
      if (this.$route.path === '/product-analysis/result') {
        return item.is_correct ? '' : 'active'
      }
      return ''
    }
  }
}
</script>

<style lang="scss" scoped>
textarea {
  width: 603px;
  height: 150px;
  background: #ececec;
  border-radius: 10px;
  outline: none;
  resize: none;
  margin: 20px auto 0;
  display: block;
  padding: 15px;
  box-sizing: border-box;
  &.active{
    background: #FFFFFF;
    border: 1px solid #C11818;
  }
}
</style>
