AudioControl.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-Record">
  4. <!-- <img
  5. src="../../../assets/adult/maikefeng-red.png"
  6. class="Big-Book-Record-icon"
  7. /> -->
  8. <div
  9. class="Big-Book-hanzi-option"
  10. v-for="(item, index) in curQue.option"
  11. :key="'singleHz' + index"
  12. >
  13. <AudioControlModule
  14. :curQue="curQue"
  15. :curQueItem="item"
  16. :type="curQue.type"
  17. :index="index"
  18. :deleteOptionOne="deleteOptionOne"
  19. />
  20. </div>
  21. <div
  22. v-if="curQue.type == 'audio_control_easy'"
  23. class="addoption"
  24. @click="addOption"
  25. >
  26. 添加
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import AudioControlModule from "../common/AudioControlModule.vue";
  32. export default {
  33. components: { AudioControlModule },
  34. props: ["curQue", "fn_data"],
  35. data() {
  36. return {};
  37. },
  38. computed: {},
  39. watch: {},
  40. //方法集合
  41. methods: {
  42. //添加一个选项
  43. addOption() {
  44. let type = this.curQue.type;
  45. let cur_fn_data_arr = this.fn_data.filter((item) => item.type == type);
  46. let cur_fn_data = JSON.parse(JSON.stringify(cur_fn_data_arr[0]));
  47. let obj = cur_fn_data.data_structure.option[0];
  48. this.curQue.option.push(obj);
  49. },
  50. deleteOptionOne(index) {
  51. this.$confirm("确定要删除吗?", "提示", {
  52. confirmButtonText: "确定",
  53. cancelButtonText: "取消",
  54. type: "warning",
  55. })
  56. .then(() => {
  57. if (this.curQue.option.length <= 1) {
  58. this.$message.warning("至少要保留一个");
  59. return;
  60. }
  61. this.curQue.option.splice(index, 1);
  62. })
  63. },
  64. },
  65. //生命周期 - 创建完成(可以访问当前this实例)
  66. created() {},
  67. //生命周期 - 挂载完成(可以访问DOM元素)
  68. mounted() {},
  69. beforeCreate() {}, //生命周期 - 创建之前
  70. beforeMount() {}, //生命周期 - 挂载之前
  71. beforeUpdate() {}, //生命周期 - 更新之前
  72. updated() {}, //生命周期 - 更新之后
  73. beforeDestroy() {}, //生命周期 - 销毁之前
  74. destroyed() {}, //生命周期 - 销毁完成
  75. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  76. };
  77. </script>
  78. <style lang='scss' scoped>
  79. //@import url(); 引入公共css类
  80. .Big-Book-Record {
  81. &-icon {
  82. width: 48px;
  83. height: 48px;
  84. }
  85. .Big-Book-hanzi-option {
  86. margin-top: 20px;
  87. }
  88. .addoption {
  89. width: 148px;
  90. height: 40px;
  91. background: #f3f3f3;
  92. border: 1px dashed rgba(0, 0, 0, 0.15);
  93. box-sizing: border-box;
  94. border-radius: 4px;
  95. text-align: center;
  96. line-height: 40px;
  97. cursor: pointer;
  98. font-size: 14px;
  99. color: #000000;
  100. }
  101. }
  102. </style>