Sentence.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-sentence">
  4. <div
  5. class="Big-Book-Single-content"
  6. style="margin-left: 50px; margin-top: 20px"
  7. >
  8. <div class="Big-Book-con">
  9. <span>标题</span>
  10. <el-input
  11. style="width: 300px"
  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. <SentenceModule
  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 SentenceModule from "../common/SentenceModule.vue";
  41. export default {
  42. name: "Single",
  43. props: ["curQue", "fn_data", "changeCurQue", "type"],
  44. components: {
  45. SentenceModule,
  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: "recordHZ_inputPY_chs",
  63. name: "读汉字写拼音",
  64. title: "",
  65. option: [
  66. {
  67. number: "",
  68. con: "",
  69. answer: "",
  70. IsRecord: false,
  71. },
  72. ],
  73. },
  74. data_structure2: {
  75. type: "inputItem_chs",
  76. name: "输入选项",
  77. title: "",
  78. option: [
  79. {
  80. number: "",
  81. con: "",
  82. answer: "",
  83. },
  84. ],
  85. },
  86. };
  87. },
  88. computed: {},
  89. watch: {},
  90. //方法集合
  91. methods: {
  92. onBlur(item, field) {
  93. item[field] = item[field] ? item[field].trim() : "";
  94. },
  95. // 修改正确选项中得某一个为正确答案
  96. changAnswer(index) {
  97. this.curQue.option.forEach((item, i) => {
  98. if (index == i) {
  99. this.curQue.correct[0].input[index] = item.Answer;
  100. }
  101. });
  102. },
  103. // 删除其中一个选项
  104. deleteOptionOne(index) {
  105. if (this.curQue.option.length <= 1) {
  106. this.$message.warning("至少要保留1个选项");
  107. return;
  108. }
  109. this.curQue.option.splice(index, 1);
  110. },
  111. // 新增选项
  112. addOption() {
  113. let obj;
  114. if (this.type == "recordHZ_inputPY_chs") {
  115. obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
  116. } else if (this.type == "inputItem_chs") {
  117. obj = JSON.parse(JSON.stringify(this.data_structure2.option[0]));
  118. }
  119. this.curQue.option.push(obj);
  120. },
  121. // 更多配置选择
  122. handleCheckedFnChange(value) {
  123. // let fn_list = JSON.parse(JSON.stringify(this.curQue.fn_list));
  124. // this.curQue.fn_list = fn_list.map((item) => {
  125. // if (value.indexOf(item.name) > -1) {
  126. // this.checkList.push(item.name);
  127. // item.isFn = true;
  128. // } else {
  129. // item.isFn = false;
  130. // this.curQue.con.forEach((it) => {
  131. // it.annotation = "";
  132. // });
  133. // }
  134. // return item;
  135. // });
  136. },
  137. initcurQue() {
  138. let data = null;
  139. if (this.type == "recordHZ_inputPY_chs") {
  140. data = JSON.parse(JSON.stringify(this.data_structure));
  141. } else if (this.type == "inputItem_chs") {
  142. data = JSON.parse(JSON.stringify(this.data_structure2));
  143. }
  144. this.changeCurQue(data);
  145. },
  146. },
  147. //生命周期 - 创建完成(可以访问当前this实例)
  148. created() {
  149. if (!this.curQue) {
  150. this.initcurQue();
  151. }
  152. },
  153. //生命周期 - 挂载完成(可以访问DOM元素)
  154. mounted() {},
  155. beforeCreate() {}, //生命周期 - 创建之前
  156. beforeMount() {}, //生命周期 - 挂载之前
  157. beforeUpdate() {}, //生命周期 - 更新之前
  158. updated() {}, //生命周期 - 更新之后
  159. beforeDestroy() {}, //生命周期 - 销毁之前
  160. destroyed() {}, //生命周期 - 销毁完成
  161. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  162. };
  163. </script>
  164. <style lang='scss' scope>
  165. //@import url(); 引入公共css类
  166. .Big-Book-sentence {
  167. &-content {
  168. &.m {
  169. display: flex;
  170. justify-content: flex-start;
  171. align-items: flex-start;
  172. }
  173. .Big-Book-title {
  174. font-size: 16px;
  175. line-height: 40px;
  176. color: #000;
  177. margin-right: 15px;
  178. }
  179. .Big-Book-main {
  180. > div {
  181. margin-bottom: 10px;
  182. &.Big-Book-pinyin {
  183. display: flex;
  184. justify-content: flex-start;
  185. align-items: center;
  186. }
  187. }
  188. }
  189. }
  190. .Big-Book-addrole {
  191. > div {
  192. width: 300px;
  193. height: 40px;
  194. background: #f3f3f3;
  195. border: 1px dashed rgba(0, 0, 0, 0.15);
  196. box-sizing: border-box;
  197. border-radius: 4px;
  198. text-align: center;
  199. line-height: 40px;
  200. cursor: pointer;
  201. }
  202. }
  203. .Big-Book-more {
  204. .Big-Book-more-text {
  205. position: relative;
  206. text-align: center;
  207. }
  208. .Big-Book-more-text:before,
  209. .Big-Book-more-text:after {
  210. position: absolute;
  211. background: #ccc;
  212. content: "";
  213. height: 1px;
  214. top: 50%;
  215. width: 45%;
  216. }
  217. .Big-Book-more-text:before {
  218. left: 10px;
  219. }
  220. .Big-Book-more-text:after {
  221. right: 10px;
  222. }
  223. .Big-Book-more-main {
  224. display: flex;
  225. > :not(:nth-child(1)) {
  226. margin-left: 30px;
  227. }
  228. }
  229. }
  230. .Big-Book-con {
  231. display: flex;
  232. align-items: center;
  233. > span {
  234. width: 50px;
  235. }
  236. }
  237. }
  238. </style>
  239. <style lang="scss">
  240. </style>