SingleModule.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-single">
  4. <div class="Big-Book-content m">
  5. <div class="Big-Book-main">
  6. <div class="adult-book-input-item">
  7. <span class="adult-book-lable">题目:</span>
  8. <el-input
  9. class="adult-book-input"
  10. :autosize="{ minRows: 2 }"
  11. type="textarea"
  12. placeholder="请输入题目"
  13. v-model="curQueItem.topic.con"
  14. @blur="curQueItem.topic.con = curQueItem.topic.con.trim()"
  15. ></el-input>
  16. <img
  17. @click="deleteOption"
  18. class="close"
  19. src="../../../assets/adult/del-close.png"
  20. alt=""
  21. />
  22. </div>
  23. <div class="adult-book-input-item">
  24. <span class="adult-book-lable">题目图片:</span>
  25. <Upload
  26. :changeFillId="timuchangeImage"
  27. :datafileList="fileCon.timu_img_list"
  28. :filleNumber="imgNumber"
  29. :uploadType="'image'"
  30. />
  31. </div>
  32. <div class="adult-book-input-item">
  33. <span class="adult-book-lable">题目音频:</span>
  34. <Upload
  35. :changeFillId="timuchangeMp3"
  36. :datafileList="fileCon.timu_mp3_list"
  37. :filleNumber="mp3Number"
  38. :uploadType="'mp3'"
  39. />
  40. </div>
  41. <div class="adult-book-input-item">
  42. <span class="adult-book-lable">选项内容:</span>
  43. <el-input
  44. class="adult-book-input"
  45. :autosize="{ minRows: 2 }"
  46. type="textarea"
  47. placeholder="请输入内容"
  48. v-model="curQueItem.con"
  49. @blur="curQueItem.con = curQueItem.con.trim()"
  50. ></el-input>
  51. <template v-if="type == 'single_chs'">
  52. <el-radio
  53. style="margin-left: 7px"
  54. @change="changeIsAnswer"
  55. v-model="curQueItem.isAnswer"
  56. :label="index"
  57. >答案</el-radio
  58. >
  59. </template>
  60. <template v-if="type == 'checkbox_chs'">
  61. <el-checkbox
  62. style="margin-left: 7px"
  63. @change="changeIsAnswer"
  64. v-model="curQueItem.isAnswer"
  65. :label="index"
  66. >答案</el-checkbox
  67. >
  68. </template>
  69. <!-- <div class=""></div> -->
  70. </div>
  71. <div class="adult-book-input-item">
  72. <span class="adult-book-lable">选项图片:</span>
  73. <Upload
  74. :changeFillId="changeImage"
  75. :datafileList="fileCon.img_list"
  76. :filleNumber="imgNumber"
  77. :uploadType="'image'"
  78. />
  79. </div>
  80. <div class="adult-book-input-item">
  81. <span class="adult-book-lable">选项音频:</span>
  82. <Upload
  83. :changeFillId="changeMp3"
  84. :datafileList="fileCon.mp3_list"
  85. :filleNumber="mp3Number"
  86. :uploadType="'mp3'"
  87. />
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import Upload from "./Upload.vue";
  95. import "@/utils/pinyin_dict_withtone";
  96. import "@/utils/pinyinUtil";
  97. export default {
  98. components: {
  99. Upload,
  100. },
  101. props: ["curQueItem", "index", "changAnswer", "deleteOptionOne", "type"],
  102. data() {
  103. return {
  104. imgNumber: 10,
  105. mp3Number: 10,
  106. fileCon: {
  107. timu_img_list: [],
  108. timu_mp3_list: [],
  109. img_list: [],
  110. mp3_list: [],
  111. },
  112. };
  113. },
  114. computed: {},
  115. watch: {},
  116. //方法集合
  117. methods: {
  118. // 删除当前选项
  119. deleteOption() {
  120. this.$confirm("确定要删除此选项吗?", "提示", {
  121. confirmButtonText: "确定",
  122. cancelButtonText: "取消",
  123. type: "warning",
  124. }).then(() => {
  125. this.deleteOptionOne(this.index);
  126. });
  127. },
  128. // 修改正确答案
  129. changeIsAnswer() {
  130. this.changAnswer(this.index);
  131. },
  132. // 点击生成拼音
  133. getPinyin(item) {
  134. let bool = false;
  135. let value = "";
  136. if (item.con == "") {
  137. this.$message.info("请先输入内容,再生成拼音");
  138. bool = true;
  139. } else {
  140. value = item.con;
  141. }
  142. if (bool) {
  143. return;
  144. }
  145. let result = pinyinUtil.getPinyin(value);
  146. item.pinyin = result;
  147. },
  148. changeMp3(fileList) {
  149. console.log(fileList);
  150. const articleImgList = JSON.parse(JSON.stringify(fileList));
  151. const articleImgRes = [];
  152. articleImgList.forEach((item) => {
  153. if (item.response) {
  154. const obj = {
  155. name: item.name,
  156. url: item.response.file_info_list[0].file_url,
  157. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  158. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  159. };
  160. articleImgRes.push(obj);
  161. }
  162. });
  163. this.curQueItem.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  164. },
  165. changeImage(fileList) {
  166. console.log(fileList);
  167. const articleImgList = JSON.parse(JSON.stringify(fileList));
  168. const articleImgRes = [];
  169. articleImgList.forEach((item) => {
  170. if (item.response) {
  171. const obj = {
  172. name: item.name,
  173. url: item.response.file_info_list[0].file_url,
  174. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  175. };
  176. articleImgRes.push(obj);
  177. }
  178. });
  179. //this.articleImgList = articleImgRes;
  180. this.curQueItem.img_list = JSON.parse(JSON.stringify(articleImgRes));
  181. },
  182. timuchangeMp3(fileList) {
  183. console.log(fileList);
  184. const articleImgList = JSON.parse(JSON.stringify(fileList));
  185. const articleImgRes = [];
  186. articleImgList.forEach((item) => {
  187. if (item.response) {
  188. const obj = {
  189. name: item.name,
  190. url: item.response.file_info_list[0].file_url,
  191. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  192. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  193. };
  194. articleImgRes.push(obj);
  195. }
  196. });
  197. this.curQueItem.topic.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  198. },
  199. timuchangeImage(fileList) {
  200. console.log(fileList);
  201. const articleImgList = JSON.parse(JSON.stringify(fileList));
  202. const articleImgRes = [];
  203. articleImgList.forEach((item) => {
  204. if (item.response) {
  205. const obj = {
  206. name: item.name,
  207. url: item.response.file_info_list[0].file_url,
  208. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  209. };
  210. articleImgRes.push(obj);
  211. }
  212. });
  213. //this.articleImgList = articleImgRes;
  214. this.curQueItem.topic.img_list = JSON.parse(JSON.stringify(articleImgRes));
  215. },
  216. },
  217. //生命周期 - 创建完成(可以访问当前this实例)
  218. created() {},
  219. //生命周期 - 挂载完成(可以访问DOM元素)
  220. mounted() {
  221. if (this.curQueItem) {
  222. this.fileCon.img_list = this.curQueItem.img_list;
  223. this.fileCon.mp3_list = this.curQueItem.mp3_list;
  224. this.fileCon.timu_img_list = this.curQueItem.topic.img_list;
  225. this.fileCon.timu_mp3_list = this.curQueItem.topic.mp3_list;
  226. }
  227. },
  228. beforeCreate() {}, //生命周期 - 创建之前
  229. beforeMount() {}, //生命周期 - 挂载之前
  230. beforeUpdate() {}, //生命周期 - 更新之前
  231. updated() {}, //生命周期 - 更新之后
  232. beforeDestroy() {}, //生命周期 - 销毁之前
  233. destroyed() {}, //生命周期 - 销毁完成
  234. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  235. };
  236. </script>
  237. <style lang='scss' scoped>
  238. //@import url(); 引入公共css类
  239. .Big-Book-single {
  240. .Big-Book-content {
  241. &.m {
  242. display: flex;
  243. justify-content: flex-start;
  244. align-items: flex-start;
  245. }
  246. .Big-Book-con {
  247. display: flex;
  248. align-items: center;
  249. }
  250. .Big-Book-title {
  251. font-size: 16px;
  252. line-height: 40px;
  253. color: #000;
  254. margin-right: 15px;
  255. }
  256. .Big-Book-main {
  257. position: relative;
  258. width: 100%;
  259. > div {
  260. margin-bottom: 10px;
  261. &.Big-Book-pinyin,
  262. &.Big-Book-con,
  263. &.Big-Book-en {
  264. display: flex;
  265. justify-content: flex-start;
  266. align-items: center;
  267. }
  268. }
  269. .close {
  270. cursor: pointer;
  271. width: 24px;
  272. height: 24px;
  273. }
  274. }
  275. }
  276. }
  277. </style>