<!--  -->
<template>
  <div class="Big-Book-Record">
    <!-- <img
      src="../../../assets/adult/maikefeng-red.png"
      class="Big-Book-Record-icon"
    /> -->
    <div
      class="Big-Book-hanzi-option"
      v-for="(item, index) in curQue.option"
      :key="'singleHz' + index"
    >
      <AudioControlModule
        :curQue="curQue"
        :curQueItem="item"
        :type="curQue.type"
        :index="index"
        :deleteOptionOne="deleteOptionOne"
      />
    </div>
    <div
      v-if="curQue.type == 'audio_control_easy'"
      class="addoption"
      @click="addOption"
    >
      添加
    </div>
  </div>
</template>

<script>
import AudioControlModule from "../common/AudioControlModule.vue";

export default {
  components: { AudioControlModule },
  props: ["curQue", "fn_data"],
  data() {
    return {};
  },
  computed: {},
  watch: {},
  //方法集合
  methods: {
    //添加一个选项
    addOption() {
      let type = this.curQue.type;
      let cur_fn_data_arr = this.fn_data.filter((item) => item.type == type);
      let cur_fn_data = JSON.parse(JSON.stringify(cur_fn_data_arr[0]));
      let obj = cur_fn_data.data_structure.option[0];
      this.curQue.option.push(obj);
    },
    deleteOptionOne(index) {
      this.$confirm("确定要删除吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
            if (this.curQue.option.length <= 1) {
                this.$message.warning("至少要保留一个");
                return;
            }
            this.curQue.option.splice(index, 1);
        })
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
.Big-Book-Record {
  &-icon {
    width: 48px;
    height: 48px;
  }
  .Big-Book-hanzi-option {
    margin-top: 20px;
  }
  .addoption {
    width: 148px;
    height: 40px;
    background: #f3f3f3;
    border: 1px dashed rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    border-radius: 4px;
    text-align: center;
    line-height: 40px;
    cursor: pointer;
    font-size: 14px;
    color: #000000;
  }
}
</style>