Ligature.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-ligature">
  4. <div class="Big-Book-Single-content">
  5.         
  6. <div class="Big-Book-con">
  7.           <span>标题:</span>           <el-input
  8. style="width: 300px"
  9. type="textarea"
  10. autosize
  11. placeholder="请输入标题"
  12. v-model="curQue.title"
  13. @blur="curQue.title = curQue.title.trim()"
  14. ></el-input>
  15.         
  16. </div>
  17. <div
  18. class="Big-Book-main"
  19. style="
  20. border-bottom: 1px #ccc solid;
  21. margin-bottom: 20px;
  22. display: flex;
  23. "
  24. >
  25. <div>
  26. <p>问题</p>
  27. <div v-for="(item, index) in curQue.con" :key="index">
  28. <LigatureModule
  29. :curQueItem="item"
  30. :index="index"
  31. :deleteOptionOne="deleteOptionOne"
  32. :type="'con'"
  33. />
  34. </div>
  35. <div class="addoption" @click="addOption('con')">添加问题</div>
  36. </div>
  37. <div>
  38. <p>答案</p>
  39. <div v-for="(item, index) in curQue.option" :key="index">
  40. <LigatureModule
  41. :curQueItem="item"
  42. :index="index"
  43. :deleteOptionOne="deleteOptionOne"
  44. :type="'option'"
  45. />
  46. </div>
  47. <div class="addoption" @click="addOption('option')">添加选项</div>
  48. </div>
  49. </div>
  50. <div class="Big-Book-divide">
  51. <el-divider content-position="center">答案配置</el-divider>
  52. <div class="answerList">
  53. <div v-for="(item, index) in curQue.con" :key="index">
  54. <span v-if="item.con">{{ item.con }}:</span>
  55. <el-radio-group
  56. @change="changeAnswer(index)"
  57. v-model="item.AnswerList"
  58. class="checkbox-group"
  59. >
  60. <span v-for="(op, OPindex) in curQue.option" :key="OPindex">
  61. <el-radio v-if="item.con && op.con" :label="OPindex">{{
  62. op.con
  63. }}</el-radio>
  64. </span>
  65. </el-radio-group>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </template>
  72. <script>
  73. import LigatureModule from "../common/LigatureModule.vue";
  74. export default {
  75. name: "Single",
  76. props: ["curQue", "fn_data"],
  77. components: {
  78. LigatureModule,
  79. },
  80. data() {
  81. return {
  82. form: {
  83. stem: {
  84. con: "",
  85. pinyin: "",
  86. english: "",
  87. highlight: "",
  88. underline: "",
  89. img_url: [],
  90. mp3_url: [],
  91. },
  92. },
  93. data_structure: {
  94. type: "ligature",
  95. name: "连线",
  96. title: "",
  97. optionTitle: "",
  98. conTitle: "",
  99. con: [
  100. {
  101. hanzi: "",
  102. pinyin: "",
  103. Number: "",
  104. mp3_list: [],
  105. img_list: [],
  106. definition_list: [],
  107. Answer: "",
  108. isAnswer: "",
  109. isChecked: "",
  110. judge: "",
  111. correctInput: "",
  112. AnswerList: [],
  113. },
  114. {
  115. hanzi: "",
  116. pinyin: "",
  117. Number: "",
  118. mp3_list: [],
  119. img_list: [],
  120. definition_list: [],
  121. Answer: "",
  122. isAnswer: "",
  123. isChecked: "",
  124. judge: "",
  125. correctInput: "",
  126. AnswerList: [],
  127. },
  128. ],
  129. option: [
  130. {
  131. hanzi: "",
  132. pinyin: "",
  133. mp3_list: [],
  134. img_list: [],
  135. definition_list: [],
  136. Answer: "",
  137. isAnswer: "",
  138. isChecked: "",
  139. judge: "",
  140. correctInput: "",
  141. },
  142. {
  143. hanzi: "",
  144. pinyin: "",
  145. mp3_list: [],
  146. img_list: [],
  147. definition_list: [],
  148. Answer: "",
  149. isAnswer: "",
  150. isChecked: "",
  151. judge: "",
  152. correctInput: "",
  153. },
  154. ],
  155. correct: [
  156. {
  157. input: ["", ""],
  158. },
  159. ],
  160. },
  161. };
  162. },
  163. computed: {},
  164. watch: {},
  165. //方法集合
  166. methods: {
  167. // 修改正确选项中得某一个为正确答案
  168. changeAnswer(index, value) {
  169. this.curQue.correct[index] = this.curQue.con[index].AnswerList;
  170. },
  171. // 删除其中一个选项
  172. deleteOptionOne(index, type) {
  173. if (type == "option") {
  174. if (this.curQue.option.length <= 2) {
  175. this.$message.warning("至少要保留两个选项");
  176. return;
  177. }
  178. // // 多选删除选项
  179. // this.curQue.con.forEach((item) => {
  180. // item.AnswerList.forEach((it, i) => {
  181. // if (it == index) {
  182. // item.AnswerList.splice(i, 1);
  183. // }
  184. // });
  185. // });
  186. // this.curQue.correct.forEach((item) => {
  187. // item.forEach((it, i) => {
  188. // if (it == index) {
  189. // item.AnswerList.splice(i, 1);
  190. // }
  191. // });
  192. // });
  193. this.curQue.option.splice(index, 1);
  194. } else if (type == "con") {
  195. if (this.curQue.con.length <= 1) {
  196. this.$message.warning("至少要保留一个问题");
  197. return;
  198. }
  199. this.curQue.con.splice(index, 1);
  200. }
  201. console.log(this.curQue);
  202. },
  203. //添加一个选项
  204. addOption(CorO) {
  205. let leg = this.curQue.option.length;
  206. let last = this.curQue.option[leg - 1];
  207. // if (!last.hanzi && !last.pinyin) {
  208. // this.$message.warning("数据不能全是空");
  209. // return;
  210. // }
  211. let type = this.curQue.type;
  212. let cur_fn_data_arr = this.fn_data.filter((item) => item.type == type);
  213. let cur_fn_data = JSON.parse(JSON.stringify(cur_fn_data_arr[0]));
  214. if (CorO == "con") {
  215. let obj = cur_fn_data.data_structure.con[0];
  216. this.curQue.con.push(obj);
  217. } else {
  218. let obj = cur_fn_data.data_structure.option[0];
  219. this.curQue.option.push(obj);
  220. }
  221. },
  222. },
  223. //生命周期 - 创建完成(可以访问当前this实例)
  224. created() {},
  225. //生命周期 - 挂载完成(可以访问DOM元素)
  226. mounted() {},
  227. beforeCreate() {}, //生命周期 - 创建之前
  228. beforeMount() {}, //生命周期 - 挂载之前
  229. beforeUpdate() {}, //生命周期 - 更新之前
  230. updated() {}, //生命周期 - 更新之后
  231. beforeDestroy() {}, //生命周期 - 销毁之前
  232. destroyed() {}, //生命周期 - 销毁完成
  233. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  234. };
  235. </script>
  236. <style lang='scss' scope>
  237. //@import url(); 引入公共css类
  238. .Big-Book-ligature {
  239. &-content {
  240. &.m {
  241. display: flex;
  242. justify-content: flex-start;
  243. align-items: flex-start;
  244. }
  245. .Big-Book-title {
  246. font-size: 16px;
  247. line-height: 40px;
  248. color: #000;
  249. margin-right: 15px;
  250. }
  251. }
  252. .Big-Book-main {
  253. > div {
  254. margin-bottom: 10px;
  255. &.Big-Book-pinyin {
  256. display: flex;
  257. justify-content: flex-start;
  258. align-items: center;
  259. }
  260. }
  261. > :nth-child(2) {
  262. margin-left: 40px;
  263. }
  264. }
  265. .addoption {
  266. margin: 0 auto;
  267. width: 300px;
  268. height: 40px;
  269. left: 40px;
  270. top: 304px;
  271. background: #f3f3f3;
  272. border: 1px dashed rgba(0, 0, 0, 0.15);
  273. box-sizing: border-box;
  274. border-radius: 4px;
  275. text-align: center;
  276. line-height: 40px;
  277. cursor: pointer;
  278. }
  279. .Big-Book-divide {
  280. > div {
  281. width: 100%;
  282. }
  283. .answerList {
  284. > div {
  285. margin-top: 16px;
  286. display: flex;
  287. align-items: center;
  288. > :nth-child(1) {
  289. display: inline-block;
  290. width: 100px;
  291. margin-right: 10px;
  292. word-break: break-all;
  293. }
  294. .checkbox-group {
  295. > span {
  296. display: inline-block;
  297. margin-left: 29px;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. .Big-Book-con {
  304. display: flex;
  305. align-items: center;
  306. margin: 10px 0;
  307. }
  308. }
  309. </style>