Ligature.vue 9.0 KB

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