Ligature.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-ligature" v-if="curQue">
  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. maxlength="500"
  14. show-word-limit
  15. ></el-input>
  16. </div>
  17. <div
  18. class="Big-Book-main"
  19. style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
  20. >
  21. <div>
  22. <p>问题</p>
  23. <div class="adult-book-input-item">
  24.   <span class="adult-book-lable">问题标题:</span>   <el-input
  25. class="adult-book-input"
  26. type="textarea"
  27. autosize
  28. placeholder="请输入问题标题"
  29. v-model="curQue.conTitle"
  30. @blur="curQue.conTitle = curQue.conTitle.trim()"
  31. maxlength="200"
  32. show-word-limit
  33. ></el-input>
  34. </div>
  35. <div v-for="(item, index) in curQue.con" :key="index">
  36. <LigatureModule
  37. :curQueItem="item"
  38. :index="index"
  39. :deleteOptionOne="deleteOptionOne"
  40. :type="'con'"
  41. />
  42. </div>
  43. <div class="addoption" @click="addOption('con')">添加问题</div>
  44. </div>
  45. <div>
  46. <p>答案</p>
  47. <div class="adult-book-input-item">
  48.   <span class="adult-book-lable">答案标题:</span>   <el-input
  49. class="adult-book-input"
  50. type="textarea"
  51. autosize
  52. placeholder="请输入答案标题"
  53. v-model="curQue.optionTitle"
  54. @blur="curQue.optionTitle = curQue.optionTitle.trim()"
  55. maxlength="200"
  56. show-word-limit
  57. ></el-input>
  58. </div>
  59. <div v-for="(item, index) in curQue.option" :key="index">
  60. <LigatureModule
  61. :curQueItem="item"
  62. :index="index"
  63. :deleteOptionOne="deleteOptionOne"
  64. :type="'option'"
  65. />
  66. </div>
  67. <div class="addoption" @click="addOption('option')">添加选项</div>
  68. </div>
  69. </div>
  70. <div class="Big-Book-divide">
  71. <el-divider content-position="center">答案配置</el-divider>
  72. <div class="answerList">
  73. <div v-for="(item, index) in curQue.con" :key="index">
  74. <span v-if="item.detail.sentence"
  75. >{{ item.detail.sentence }}:</span
  76. >
  77. <el-radio-group
  78. @change="changeAnswer(index)"
  79. v-model="item.AnswerList"
  80. class="checkbox-group"
  81. >
  82. <span v-for="(op, OPindex) in curQue.option" :key="OPindex">
  83. <el-radio
  84. v-if="item.detail.sentence && op.detail.sentence"
  85. :label="OPindex"
  86. >{{ op.detail.sentence }}</el-radio
  87. >
  88. </span>
  89. </el-radio-group>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </template>
  96. <script>
  97. import LigatureModule from "../common/LigatureModule.vue";
  98. export default {
  99. name: "Single",
  100. props: ["curQue", "fn_data", "changeCurQue"],
  101. components: {
  102. LigatureModule,
  103. },
  104. data() {
  105. return {
  106. form: {
  107. stem: {
  108. con: "",
  109. pinyin: "",
  110. english: "",
  111. highlight: "",
  112. underline: "",
  113. img_url: [],
  114. mp3_url: [],
  115. },
  116. },
  117. data_structure: {
  118. type: "ligature_chs",
  119. name: "连线",
  120. title: "",
  121. conTitle: "",
  122. optionTitle: "",
  123. con: [
  124. {
  125. mp3_list: [],
  126. img_list: [],
  127. AnswerList: [],
  128. detail: {
  129. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  130. sentence: "", //句子
  131. segList: [], //分词结果
  132. seg_words: "",
  133. wordsList: [],
  134. },
  135. number: "",
  136. },
  137. {
  138. mp3_list: [],
  139. img_list: [],
  140. AnswerList: [],
  141. number: "",
  142. detail: {
  143. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  144. sentence: "", //句子
  145. segList: [], //分词结果
  146. seg_words: "",
  147. wordsList: [],
  148. },
  149. },
  150. ],
  151. option: [
  152. {
  153. con: "",
  154. mp3_list: [],
  155. img_list: [],
  156. number: "",
  157. AnswerList: [],
  158. detail: {
  159. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  160. sentence: "", //句子
  161. segList: [], //分词结果
  162. seg_words: "",
  163. wordsList: [],
  164. },
  165. },
  166. {
  167. con: "",
  168. mp3_list: [],
  169. img_list: [],
  170. number: "",
  171. AnswerList: [],
  172. detail: {
  173. pyPosition: "top", //top 拼音在上面;bottom 拼音在下面
  174. sentence: "", //句子
  175. segList: [], //分词结果
  176. seg_words: "",
  177. wordsList: [],
  178. },
  179. },
  180. ],
  181. correct: [
  182. {
  183. input: ["", ""],
  184. },
  185. ],
  186. },
  187. };
  188. },
  189. computed: {},
  190. watch: {},
  191. //方法集合
  192. methods: {
  193. // 修改正确选项中得某一个为正确答案
  194. changeAnswer(index, value) {
  195. this.curQue.correct[index] = this.curQue.con[index].AnswerList;
  196. },
  197. // 删除其中一个选项
  198. deleteOptionOne(index, type) {
  199. if (type == "option") {
  200. if (this.curQue.option.length <= 2) {
  201. this.$message.warning("至少要保留两个选项");
  202. return;
  203. }
  204. // // 多选删除选项
  205. // this.curQue.con.forEach((item) => {
  206. // item.AnswerList.forEach((it, i) => {
  207. // if (it == index) {
  208. // item.AnswerList.splice(i, 1);
  209. // }
  210. // });
  211. // });
  212. // this.curQue.correct.forEach((item) => {
  213. // item.forEach((it, i) => {
  214. // if (it == index) {
  215. // item.AnswerList.splice(i, 1);
  216. // }
  217. // });
  218. // });
  219. this.curQue.option.splice(index, 1);
  220. } else if (type == "con") {
  221. if (this.curQue.con.length <= 1) {
  222. this.$message.warning("至少要保留一个问题");
  223. return;
  224. }
  225. this.curQue.con.splice(index, 1);
  226. }
  227. console.log(this.curQue);
  228. },
  229. //添加一个选项
  230. addOption(CorO) {
  231. if (CorO == "con") {
  232. let obj = JSON.parse(JSON.stringify(this.data_structure.con[0]));
  233. this.curQue.con.push(obj);
  234. } else {
  235. let obj = JSON.parse(JSON.stringify(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>