ImageQuestion.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-sentence" 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. type="textarea"
  13. autosize
  14. placeholder="请输入标题"
  15. v-model="curQue.title"
  16. @blur="onBlur(curQue, 'title')"
  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="margin-bottom: 20px"
  24. >
  25. <ImageQuestionModule
  26. :curQueItem="item"
  27. :curQue="curQue"
  28. :deleteOptionOne="deleteOptionOne"
  29. :index="index"
  30. :type="type"
  31. />
  32. </div>
  33. <div class="Big-Book-addrole">
  34. <div class="addoption" @click="addOption">添加一个</div>
  35. </div>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import ImageQuestionModule from "../common/ImageQuestionModule.vue";
  41. export default {
  42. name: "Single",
  43. props: ["curQue", "fn_data", "changeCurQue", "type"],
  44. components: {
  45. ImageQuestionModule,
  46. },
  47. data() {
  48. return {
  49. checkList: [],
  50. form: {
  51. stem: {
  52. con: "",
  53. pinyin: "",
  54. english: "",
  55. highlight: "",
  56. underline: "",
  57. img_url: [],
  58. mp3_url: [],
  59. },
  60. },
  61. data_structure: {
  62. type: "image_question_input_record",
  63. name: "看图填空+录入",
  64. title: "",
  65. option: [
  66. {
  67. number: "",
  68. con: "",
  69. answer: "",
  70. IsRecord: false,
  71. mp3_url: [],
  72. },
  73. ],
  74. },
  75. data_structure_sentence: {
  76. type: "image_question",
  77. name: "看图模板",
  78. title: "",
  79. option: [
  80. {
  81. img_list: [],
  82. number: "",
  83. detail: {
  84. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  85. sentence: "", //句子
  86. segList: [], //分词结果
  87. seg_words: "",
  88. wordsList: [],
  89. },
  90. en: "", //英文
  91. answer: [""],
  92. judge: true,
  93. },
  94. ],
  95. fn_list: [
  96. {
  97. type: "image_question_record",
  98. name: "录音",
  99. isFn: false,
  100. },
  101. {
  102. type: "image_question_input",
  103. name: "输入",
  104. isFn: false,
  105. },
  106. ],
  107. },
  108. };
  109. },
  110. computed: {},
  111. watch: {},
  112. //方法集合
  113. methods: {
  114. onBlur(item, field) {
  115. item[field] = item[field] ? item[field].trim() : "";
  116. },
  117. // 修改正确选项中得某一个为正确答案
  118. changAnswer(index) {
  119. this.curQue.option.forEach((item, i) => {
  120. if (index == i) {
  121. this.curQue.correct[0].input[index] = item.Answer;
  122. }
  123. });
  124. },
  125. // 删除其中一个选项
  126. deleteOptionOne(index) {
  127. if (this.curQue.option.length <= 1) {
  128. this.$message.warning("至少要保留1个选项");
  129. return;
  130. }
  131. this.curQue.option.splice(index, 1);
  132. },
  133. // 新增选项
  134. addOption() {
  135. let obj;
  136. if (this.type.indexOf("image_question") > -1) {
  137. obj = JSON.parse(
  138. JSON.stringify(this.data_structure_sentence.option[0])
  139. );
  140. }
  141. this.curQue.option.push(obj);
  142. },
  143. // 更多配置选择
  144. handleCheckedFnChange(value) {
  145. // let fn_list = JSON.parse(JSON.stringify(this.curQue.fn_list));
  146. // this.curQue.fn_list = fn_list.map((item) => {
  147. // if (value.indexOf(item.name) > -1) {
  148. // this.checkList.push(item.name);
  149. // item.isFn = true;
  150. // } else {
  151. // item.isFn = false;
  152. // this.curQue.con.forEach((it) => {
  153. // it.annotation = "";
  154. // });
  155. // }
  156. // return item;
  157. // });
  158. },
  159. //处理数据
  160. handleStructure(type) {
  161. let data = JSON.parse(JSON.stringify(this.data_structure_sentence));
  162. data.fn_list.map((item) => {
  163. if (type == "image_question_input_record") {
  164. if (item.type == "image_question_record" || item.type == "image_question_input") {
  165. item.isFn = true;
  166. }
  167. }
  168. return item;
  169. });
  170. return data;
  171. },
  172. initcurQue() {
  173. let data = null;
  174. if (this.type.indexOf("image_question") > -1) {
  175. data = this.handleStructure(this.type);
  176. }
  177. this.changeCurQue(data);
  178. },
  179. },
  180. //生命周期 - 创建完成(可以访问当前this实例)
  181. created() {
  182. console.log("看图控件的录入");
  183. if (!this.curQue) {
  184. this.initcurQue();
  185. }
  186. },
  187. //生命周期 - 挂载完成(可以访问DOM元素)
  188. mounted() {},
  189. beforeCreate() {}, //生命周期 - 创建之前
  190. beforeMount() {}, //生命周期 - 挂载之前
  191. beforeUpdate() {}, //生命周期 - 更新之前
  192. updated() {}, //生命周期 - 更新之后
  193. beforeDestroy() {}, //生命周期 - 销毁之前
  194. destroyed() {}, //生命周期 - 销毁完成
  195. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  196. };
  197. </script>
  198. <style lang='scss' scope>
  199. //@import url(); 引入公共css类
  200. .Big-Book-sentence {
  201. &-content {
  202. &.m {
  203. display: flex;
  204. justify-content: flex-start;
  205. align-items: flex-start;
  206. }
  207. .Big-Book-title {
  208. font-size: 16px;
  209. line-height: 40px;
  210. color: #000;
  211. margin-right: 15px;
  212. }
  213. .Big-Book-main {
  214. > div {
  215. margin-bottom: 10px;
  216. &.Big-Book-pinyin {
  217. display: flex;
  218. justify-content: flex-start;
  219. align-items: center;
  220. }
  221. }
  222. }
  223. }
  224. .Big-Book-addrole {
  225. > div {
  226. width: 300px;
  227. height: 40px;
  228. background: #f3f3f3;
  229. border: 1px dashed rgba(0, 0, 0, 0.15);
  230. box-sizing: border-box;
  231. border-radius: 4px;
  232. text-align: center;
  233. line-height: 40px;
  234. cursor: pointer;
  235. }
  236. }
  237. .Big-Book-more {
  238. .Big-Book-more-text {
  239. position: relative;
  240. text-align: center;
  241. }
  242. .Big-Book-more-text:before,
  243. .Big-Book-more-text:after {
  244. position: absolute;
  245. background: #ccc;
  246. content: "";
  247. height: 1px;
  248. top: 50%;
  249. width: 45%;
  250. }
  251. .Big-Book-more-text:before {
  252. left: 10px;
  253. }
  254. .Big-Book-more-text:after {
  255. right: 10px;
  256. }
  257. .Big-Book-more-main {
  258. display: flex;
  259. > :not(:nth-child(1)) {
  260. margin-left: 30px;
  261. }
  262. }
  263. }
  264. .Big-Book-con {
  265. display: flex;
  266. align-items: center;
  267. }
  268. }
  269. </style>
  270. <style lang="scss">
  271. </style>