<template>
  <div class="bool">
    <div class="left">
      <h3>判断题 第{{Data.id}}题</h3>
      <div
        class="header"
        v-html="Data.content"
      >
      </div>
      <div class="body">
        <el-radio-group
          @change="Success"
          v-model="value"
        >
          <el-radio :label="1">正确</el-radio>
          <el-radio :label="0">错误</el-radio>
        </el-radio-group>
      </div>
    </div>
    <div
      v-if="State"
      class="right"
    >
      <div class="header">共错误3次，最后一次出错：2021-04-26 15:23，XXXXXX模拟考试</div>
      <div class="body">解析：
        XXXXXX</div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    //状态  答题 查看答案
    State: {
      type: Boolean,
      default: false
    },
    // 题
    //  {
    //     id: 3,
    //     type: "bool",
    //     content: "<p>结合xxx特征<p>",
    //     result: {
    //       yes: ["正确答案", "正确答案"],
    //       no: ["错误答案", "错误答案"],
    //     }
    //   }
    Data: {
      type: Object,
      default: {}
    }
  },
  data () {
    return {
      value: ''
    }
  },
  created () {
    this.ValueFunc();
  },
  methods: {
    ValueFunc () {
      this.Data.value.forEach(item => {
        if (item.state) {
          this.value = item.id;
          this.Success(item.id)
        }
      })
    },
    // 获取选择的值
    Success (e) {
      let data = [e];
      this.$emit("Func", data);
    }
  },
  watch: {
    Data (val, oldval) {
      this.value = '';
      this.ValueFunc();
    }
  }
}
</script>
<style lang="less" scoped>
.bool {
  display: flex;
  .left {
    width: 100%;
    h3 {
      margin-top: 0;
    }
    .body {
      margin: 5px 0;
    }
  }
  .right {
    width: 400px;
    background-color: #f4f7ed;
  }
}
</style>