SelfAssessment.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-Single" v-if="curQue">
  4. <div
  5. class="Big-Book-Single-content"
  6. style="margin-left: 20px; margin-top: 20px"
  7. >
  8. <div class="adult-book-input-item">
  9. <span class="adult-book-lable">标题:</span>
  10. <el-input
  11. class="adult-book-input"
  12. :autosize="{ minRows: 2 }"
  13. type="textarea"
  14. placeholder="请输入标题"
  15. v-model="curQue.title"
  16. @blur="curQue.title = curQue.title.trim()"
  17. ></el-input>
  18. </div>
  19. <div
  20. class="Big-Book-main"
  21. v-for="(item, index) in curQue.option"
  22. :key="item + index"
  23. style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
  24. >
  25. <SelfAssessmentModule
  26. :curQueItem="item"
  27. :index="index"
  28. :changAnswer="changAnswer"
  29. :deleteOptionOne="deleteOptionOne"
  30. :type="type"
  31. />
  32. </div>
  33. <div class="addoption" @click="addOption">添加一个选项</div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import SelfAssessmentModule from "../common/SelfAssessmentModule.vue";
  39. import Upload from "../common/Upload.vue";
  40. export default {
  41. name: "Single",
  42. props: ["curQue", "fn_data", "changeCurQue", "type"],
  43. components: {
  44. SelfAssessmentModule,
  45. Upload,
  46. },
  47. data() {
  48. return {
  49. form: {
  50. stem: {
  51. con: "",
  52. pinyin: "",
  53. english: "",
  54. highlight: "",
  55. underline: "",
  56. img_url: [],
  57. mp3_url: [],
  58. },
  59. },
  60. imgNumber: 1,
  61. mp3Number: 1,
  62. data_structure: {
  63. type: "checkbox_self_assessment_chs",
  64. name: "自我评估",
  65. title: "",
  66. option: [
  67. {
  68. con: "",
  69. isAnswer: "",
  70. },
  71. {
  72. con: "",
  73. isAnswer: "",
  74. },
  75. ],
  76. correct: [],
  77. },
  78. };
  79. },
  80. computed: {},
  81. watch: {},
  82. //方法集合
  83. methods: {
  84. // 修改正确选项中得某一个为正确答案
  85. changAnswer(index) {
  86. let arr = [];
  87. this.curQue.option.forEach((item, i) => {
  88. if (index == i && item.isAnswer != "") {
  89. this.curQue.correct.push(i);
  90. } else if (index == i && item.isAnswer == "") {
  91. this.curQue.correct.splice(i, 1);
  92. }
  93. });
  94. },
  95. // 删除其中一个选项
  96. deleteOptionOne(index) {
  97. if (this.curQue.option.length <= 2) {
  98. this.$message.warning("至少要保留两个选项");
  99. return;
  100. }
  101. this.curQue.option.splice(index, 1);
  102. },
  103. //添加一个选项
  104. addOption(index) {
  105. let obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
  106. this.curQue.option.push(obj);
  107. },
  108. },
  109. //生命周期 - 创建完成(可以访问当前this实例)
  110. created() {
  111. if (!this.curQue) {
  112. this.changeCurQue(this.data_structure);
  113. }
  114. },
  115. //生命周期 - 挂载完成(可以访问DOM元素)
  116. mounted() {},
  117. beforeCreate() {}, //生命周期 - 创建之前
  118. beforeMount() {}, //生命周期 - 挂载之前
  119. beforeUpdate() {}, //生命周期 - 更新之前
  120. updated() {}, //生命周期 - 更新之后
  121. beforeDestroy() {}, //生命周期 - 销毁之前
  122. destroyed() {}, //生命周期 - 销毁完成
  123. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  124. };
  125. </script>
  126. <style lang='scss' scope>
  127. //@import url(); 引入公共css类
  128. .Big-Book-Single {
  129. &-content {
  130. &.m {
  131. display: flex;
  132. justify-content: flex-start;
  133. align-items: flex-start;
  134. }
  135. .Big-Book-title {
  136. font-size: 16px;
  137. line-height: 40px;
  138. color: #000;
  139. margin-right: 15px;
  140. }
  141. .Big-Book-main {
  142. > div {
  143. margin-bottom: 10px;
  144. &.Big-Book-pinyin {
  145. display: flex;
  146. justify-content: flex-start;
  147. align-items: center;
  148. }
  149. }
  150. }
  151. }
  152. .addoption {
  153. width: 565px;
  154. height: 40px;
  155. left: 40px;
  156. top: 304px;
  157. background: #f3f3f3;
  158. border: 1px dashed rgba(0, 0, 0, 0.15);
  159. box-sizing: border-box;
  160. border-radius: 4px;
  161. text-align: center;
  162. line-height: 40px;
  163. cursor: pointer;
  164. }
  165. .close {
  166. width: 24px;
  167. cursor: pointer;
  168. }
  169. }
  170. </style>
  171. <style lang="scss">
  172. </style>