<template>
  <box title="投资目标" :isErrorBtn="isErrorBtn()" @errorResolution="errorResolution">
    <textarea :disabled="$route.path !== '/product-analysis/result' ? false : true" :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;
  position: relative;
  z-index: 999;
  &.active{
    background: #FFFFFF;
    border: 1px solid #C11818;
  }
}
</style>
