Ligature.vue 9.3 KB

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