SingleModule.vue 6.4 KB

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