<template>
  <box title="基金涉及费用" :isErrorBtn="isErrorBtn()" @errorResolution="errorResolution">
    <div class="cost-box">
      <div :class="`li isDomActive ${isClass(item)}`" v-for="item in data.completions" :key="item.id">
        <img
          src="https://webapp-pub.ezijing.com/x-training-new/cost-i2.png"
          class="icon"
          v-if="item.tag === 'management_expense_completion'"
        />
        <img src="https://webapp-pub.ezijing.com/x-training-new/cost-i1.png" class="icon" v-else />
        <div class="right-con">
          <div class="num">
            <input v-model="item.commit_answer" type="text" placeholder="请输入" :id="item.id" />
            <span>%</span>
          </div>
          <div class="name">{{ item.subject }}</div>
        </div>
      </div>
    </div>
  </box>
</template>

<script>
import Box from './Box.vue'
export default {
  components: { Box },
  props: {
    data: { type: Object }
  },
  data() {
    return {}
  },
  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>
.cost-box {
  display: flex;
  justify-content: center;
  padding-top: 30px;
  .li + .li {
    margin-left: 20px;
  }
  .li {
    width: 225px;
    height: 97px;
    background: #ffffff;
    box-shadow: 0px 9px 9px 0px rgba(175, 175, 175, 0.27);
    border-radius: 10px;
    display: flex;
    align-items: center;
    &.active{
      border: 1px solid #C11818;
    }
    .icon {
      width: 53px;
      height: 53px;
      display: block;
      margin-left: 24px;
    }
    .right-con {
      margin-left: 24px;
      &.col-blue {
        .num {
          input {
            color: #47bcde;
          }
          span {
            color: #47bcde;
          }
        }
      }
      .num {
        display: flex;
        input {
          outline: none;
          background: none;
          width: 80px;
          font-size: 26px;
          font-weight: bold;
          color: #4eb198;
          line-height: 100%;
          font-weight: bold;
          height: 28px;
          width: 65px;
          text-align: right;
          &::-webkit-input-placeholder {
            font-size: 16px;
          }
        }
        span {
          font-size: 14px;
          color: #4eb198;
          line-height: 100%;
          margin-top: 12px;
          margin-left: 3px;
        }
      }
      .name {
        font-size: 16px;
        color: #666666;
        line-height: 100%;
        margin-top: 10px;
      }
    }
  }
}
</style>
