SelectInpue.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-PurePreview" v-if="curQue">
  4. <div
  5. class="Big-Book-Single-content"
  6. style="margin-left: 20px; margin-top: 20px"
  7. >
  8. <div class="adult-book-input-item">
  9. <span class="adult-book-lable">标题:</span>
  10. <el-input
  11. class="adult-book-input"
  12. type="textarea"
  13. :autosize="{ minRows: 2 }"
  14. placeholder="请输入标题"
  15. v-model="curQue.title"
  16. @blur="onBlur(curQue, 'title')"
  17. ></el-input>
  18. </div>
  19. <div v-for="(item, Cindex) in curQue.con" :key="'con' + Cindex">
  20. <div class="adult-book-input-item">
  21. <span class="adult-book-lable">内容标题:</span>
  22. <el-input
  23. class="adult-book-input"
  24. type="textarea"
  25. :autosize="{ minRows: 2 }"
  26. placeholder="请输入内容标题"
  27. v-model="item.title"
  28. @blur="onBlur(item, 'title')"
  29. ></el-input>
  30. <img
  31. @click="deleteCon(Cindex)"
  32. class="close"
  33. src="../../../assets/adult/del-close.png"
  34. alt=""
  35. />
  36. </div>
  37. <div class="adult-book-input-item">
  38. <span class="adult-book-lable">内容文本:</span>
  39. <el-input
  40. class="adult-book-input"
  41. type="textarea"
  42. :autosize="{ minRows: 2 }"
  43. placeholder="请输入内容"
  44. v-model="item.con"
  45. @blur="onBlur(item, 'con')"
  46. ></el-input>
  47. </div>
  48. </div>
  49. <div class="addoption" @click="addCon">添加一个内容</div>
  50. <div v-for="(item, Oindex) in curQue.option" :key="'op' + Oindex">
  51. <div class="adult-book-input-item">
  52. <span class="adult-book-lable">选项:</span>
  53. <el-input
  54. class="adult-book-input"
  55. type="textarea"
  56. :autosize="{ minRows: 2 }"
  57. placeholder="请输入选项内容"
  58. v-model="item.con"
  59. @blur="onBlur(item, 'con')"
  60. ></el-input>
  61. <img
  62. @click="deleteOptionOne(Oindex)"
  63. class="close"
  64. src="../../../assets/adult/del-close.png"
  65. alt=""
  66. />
  67. </div>
  68. </div>
  69. <div class="addoption" @click="addOption">添加一个选项</div>
  70. <div v-for="(item, awindex) in curQue.answer" :key="'aw' + awindex">
  71. <div class="adult-book-input-item">
  72. <span class="adult-book-lable">答案:</span>
  73. <el-input
  74. class="adult-book-input"
  75. type="textarea"
  76. :autosize="{ minRows: 2 }"
  77. placeholder="请输入答案"
  78. v-model="item.con"
  79. @blur="onBlur(item, 'con')"
  80. ></el-input>
  81. <img
  82. @click="deleteAnswer(awindex)"
  83. class="close"
  84. src="../../../assets/adult/del-close.png"
  85. alt=""
  86. />
  87. </div>
  88. </div>
  89. <div class="addoption" @click="addAnswer">添加一个答案</div>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import Upload from "../common/Upload";
  95. import SentenceSegwordChs from "../common/SentenceSegwordChs/index.vue";
  96. export default {
  97. name: "PurePreview",
  98. props: ["curQue", "fn_data", "changeCurQue", "type"],
  99. components: {
  100. SentenceSegwordChs,
  101. Upload,
  102. },
  103. data() {
  104. return {
  105. checkList: [],
  106. mp3Number: 1,
  107. form: {
  108. stem: {
  109. con: "",
  110. pinyin: "",
  111. english: "",
  112. highlight: "",
  113. underline: "",
  114. img_url: [],
  115. mp3_url: [],
  116. },
  117. },
  118. data_structure: {
  119. type: "选择填空控件",
  120. name: "select_input_chs",
  121. title: "",
  122. option: [
  123. {
  124. con: "",
  125. },
  126. ],
  127. con: [
  128. {
  129. title: "",
  130. con: "",
  131. },
  132. ],
  133. answer: [
  134. {
  135. con: "",
  136. },
  137. ],
  138. },
  139. };
  140. },
  141. computed: {},
  142. watch: {},
  143. //方法集合
  144. methods: {
  145. onBlur(item, field) {
  146. item[field] = item[field] ? item[field].trim() : "";
  147. },
  148. deleteCon(index) {
  149. this.$confirm("确定要删除吗?", "提示", {
  150. confirmButtonText: "确定",
  151. cancelButtonText: "取消",
  152. type: "warning",
  153. })
  154. .then(() => {
  155. if (this.curQue.con.length <= 1) {
  156. this.$message.warning("至少要保留1个内容");
  157. return;
  158. }
  159. this.curQue.con.splice(index, 1);
  160. })
  161. },
  162. addCon() {
  163. let obj = JSON.parse(JSON.stringify(this.data_structure.con[0]));
  164. this.curQue.con.push(obj);
  165. },
  166. // 删除其中一个选项
  167. deleteOptionOne(index) {
  168. this.$confirm("确定要删除吗?", "提示", {
  169. confirmButtonText: "确定",
  170. cancelButtonText: "取消",
  171. type: "warning",
  172. })
  173. .then(() => {
  174. if (this.curQue.option.length <= 1) {
  175. this.$message.warning("至少要保留1个选项");
  176. return;
  177. }
  178. this.curQue.option.splice(index, 1);
  179. })
  180. },
  181. // 新增选项
  182. addOption() {
  183. let obj = JSON.parse(JSON.stringify(this.data_structure.option[0]));
  184. this.curQue.option.push(obj);
  185. },
  186. // 添加答案
  187. addAnswer() {
  188. let obj = JSON.parse(JSON.stringify(this.data_structure.answer[0]));
  189. this.curQue.answer.push(obj);
  190. },
  191. // 删除其中一个答案
  192. deleteAnswer(index) {
  193. this.$confirm("确定要删除吗?", "提示", {
  194. confirmButtonText: "确定",
  195. cancelButtonText: "取消",
  196. type: "warning",
  197. })
  198. .then(() => {
  199. if (this.curQue.answer.length <= 1) {
  200. this.$message.warning("至少要保留1个答案");
  201. return;
  202. }
  203. this.curQue.answer.splice(index, 1);
  204. })
  205. },
  206. initcurQue() {
  207. let data = JSON.parse(JSON.stringify(this.data_structure));
  208. this.changeCurQue(data);
  209. },
  210. },
  211. //生命周期 - 创建完成(可以访问当前this实例)
  212. created() {
  213. if (!this.curQue) {
  214. this.initcurQue();
  215. }
  216. },
  217. //生命周期 - 挂载完成(可以访问DOM元素)
  218. mounted() {},
  219. beforeCreate() {}, //生命周期 - 创建之前
  220. beforeMount() {}, //生命周期 - 挂载之前
  221. beforeUpdate() {}, //生命周期 - 更新之前
  222. updated() {}, //生命周期 - 更新之后
  223. beforeDestroy() {}, //生命周期 - 销毁之前
  224. destroyed() {}, //生命周期 - 销毁完成
  225. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  226. };
  227. </script>
  228. <style lang='scss' scope>
  229. //@import url(); 引入公共css类
  230. .Big-Book-PurePreview {
  231. &-content {
  232. &.m {
  233. display: flex;
  234. justify-content: flex-start;
  235. align-items: flex-start;
  236. }
  237. .Big-Book-title {
  238. font-size: 16px;
  239. line-height: 40px;
  240. color: #000;
  241. margin-right: 15px;
  242. }
  243. .Big-Book-main {
  244. > div {
  245. margin-bottom: 10px;
  246. &.Big-Book-pinyin {
  247. display: flex;
  248. justify-content: flex-start;
  249. align-items: center;
  250. }
  251. }
  252. }
  253. }
  254. .addoption {
  255. width: 200px;
  256. height: 40px;
  257. left: 40px;
  258. top: 304px;
  259. background: #f3f3f3;
  260. border: 1px dashed rgba(0, 0, 0, 0.15);
  261. box-sizing: border-box;
  262. border-radius: 4px;
  263. text-align: center;
  264. line-height: 40px;
  265. cursor: pointer;
  266. }
  267. .Big-Book-addrole {
  268. > div {
  269. width: 300px;
  270. height: 40px;
  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. }
  280. .Big-Book-more {
  281. .Big-Book-more-text {
  282. position: relative;
  283. text-align: center;
  284. }
  285. .Big-Book-more-text:before,
  286. .Big-Book-more-text:after {
  287. position: absolute;
  288. background: #ccc;
  289. content: "";
  290. height: 1px;
  291. top: 50%;
  292. width: 45%;
  293. }
  294. .Big-Book-more-text:before {
  295. left: 10px;
  296. }
  297. .Big-Book-more-text:after {
  298. right: 10px;
  299. }
  300. .Big-Book-more-main {
  301. display: flex;
  302. > :not(:nth-child(1)) {
  303. margin-left: 30px;
  304. }
  305. }
  306. }
  307. .Big-Book-con {
  308. display: flex;
  309. align-items: center;
  310. }
  311. .close {
  312. width: 24px;
  313. cursor: pointer;
  314. }
  315. }
  316. </style>
  317. <style lang="scss">
  318. </style>