SingleModule.vue 6.9 KB

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