SentenceModule.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-SentenceModule" v-if="curQueItem">
  4. <div class="adult-book-input-item">
  5. <span class="adult-book-lable">序号:</span>
  6. <el-input
  7. size="small"
  8. class="adult-book-input"
  9. :autosize="{ minRows: 2 }"
  10. placeholder="请输入序号"
  11. v-model="curQueItem.number"
  12. @blur="onBlur(curQueItem, 'number')"
  13. ></el-input>
  14. <div class="deleteOptionBox">
  15. <img
  16. @click="deleteOption"
  17. class="close"
  18. src="../../../assets/adult/del-close.png"
  19. alt=""
  20. />
  21. </div>
  22. </div>
  23. <div class="NPC-sentence-Segword">
  24. <SentenceSegwordChs :curQue="curQueItem.detail" />
  25. </div>
  26. <div class="adult-book-input-item">
  27. <span class="adult-book-lable">英文:</span>
  28. <el-input
  29. size="small"
  30. class="adult-book-input"
  31. placeholder="请输入句子翻译"
  32. v-model="curQueItem.en"
  33. @blur="onBlur(curQueItem, 'en')"
  34. ></el-input>
  35. </div>
  36. <template v-if="type == 'sentence_input'">
  37. <div class="adult-book-input-item">
  38. <span class="adult-book-lable">答案:</span>
  39. <div>
  40. <div
  41. class="NPC-sentence-input-box"
  42. v-for="(ansItem, ansIndex) in curQueItem.answer"
  43. :key="'answer' + ansIndex"
  44. >
  45. <el-input
  46. class="adult-book-input"
  47. type="textarea"
  48. autosize
  49. placeholder="请输入答案"
  50. v-model="curQueItem.answer[ansIndex]"
  51. @blur="onBlurIndex(ansIndex, 'answer')"
  52. ></el-input>
  53. <div class="adult-book-del-icon" @click="delAnswer(ansIndex)">
  54. <i class="el-icon-circle-close"></i>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="adult-book-input-item" style="padding-left: 80px">
  60. <el-button
  61. size="mini"
  62. type="primary"
  63. icon="el-icon-plus"
  64. @click="addAnswer"
  65. >添加答案</el-button
  66. >
  67. </div>
  68. </template>
  69. <div class="adult-book-input-item" v-if="type == 'sentence_judge'">
  70. <span class="adult-book-lable">判断:</span>
  71. <el-radio-group v-model="curQueItem.judge">
  72. <el-radio :lable="true" :label="true">正确</el-radio>
  73. <el-radio :lable="false" :label="false">错误</el-radio>
  74. </el-radio-group>
  75. </div>
  76. <div class="adult-book-input-item" v-if="type == 'sentence_record'">
  77. <span class="adult-book-lable">录音组件:</span>
  78. <img src="../../../assets/adult/mini.png" class="adult-record-min" />
  79. </div>
  80. <div class="adult-book-input-item" v-if="type == 'recordHZ_inputPY_chs'">
  81. <span>录音</span>
  82. <el-radio v-model="curQueItem.IsRecord" :label="true">需要</el-radio>
  83. <el-radio v-model="curQueItem.IsRecord" :label="false">不需要</el-radio>
  84. </div>
  85. <div
  86. class="adult-book-input-item"
  87. v-if="type == 'recordHZ_inputPY_chs' && curQueItem.IsRecord"
  88. >
  89. <img src="../../../assets/adult/pro-plus.png" alt="" />
  90. </div>
  91. <div class="adult-book-input-item">
  92. <span class="adult-book-lable">音频:</span>
  93. <Upload
  94. :changeFillId="changeMp3"
  95. :datafileList="fileCon.mp3_list"
  96. :filleNumber="mp3Number"
  97. :uploadType="'mp3'"
  98. />
  99. </div>
  100. </div>
  101. </template>
  102. <script>
  103. import SentenceSegwordChs from "./SentenceSegwordChs/index.vue";
  104. import Upload from "./Upload.vue";
  105. import "@/utils/pinyin_dict_withtone";
  106. import "@/utils/pinyinUtil";
  107. export default {
  108. components: { Upload, SentenceSegwordChs },
  109. props: [
  110. "curQue",
  111. "curQueItem",
  112. "index",
  113. "changAnswer",
  114. "deleteOptionOne",
  115. "checkList",
  116. "type",
  117. ],
  118. data() {
  119. return {
  120. //checkListRes: [],
  121. fileCon: {
  122. mp3_list: [],
  123. img_list: [],
  124. },
  125. mp3Number: 1,
  126. imgNumber: 1,
  127. };
  128. },
  129. computed: {},
  130. watch: {},
  131. //方法集合
  132. methods: {
  133. onBlur(item, field) {
  134. item[field] = item[field] ? item[field].trim() : "";
  135. },
  136. onBlurIndex(index, field) {
  137. let res = this.curQueItem[field][index].trim();
  138. this.$set(this.curQueItem[field], index, res);
  139. },
  140. onBlurCorrect(item) {
  141. item[index] = item[index].trim();
  142. },
  143. // 删除当前选项
  144. deleteOption() {
  145. this.$confirm("确定要删除此选项吗?", "提示", {
  146. confirmButtonText: "确定",
  147. cancelButtonText: "取消",
  148. type: "warning",
  149. }).then(() => {
  150. // this.deleteOptionOne(this.index);
  151. console.log(this.deleteOptionOne());
  152. });
  153. },
  154. // 修改正确答案
  155. changeIsAnswer(type) {
  156. this.changAnswer(this.index, type);
  157. },
  158. changeMp3(fileList) {
  159. const articleImgList = JSON.parse(JSON.stringify(fileList));
  160. const articleImgRes = [];
  161. articleImgList.forEach((item) => {
  162. if (item.response) {
  163. const obj = {
  164. name: item.name,
  165. url: item.response.file_info_list[0].file_url,
  166. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  167. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  168. };
  169. articleImgRes.push(obj);
  170. }
  171. });
  172. this.curQueItem.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  173. },
  174. //添加答案
  175. addAnswer() {
  176. let leg = this.curQueItem.answer.length;
  177. let last = this.curQueItem.answer[leg - 1];
  178. if (!last) {
  179. this.$message.warning("请先填写完整");
  180. return;
  181. }
  182. this.curQueItem.answer.push("");
  183. },
  184. delAnswer(ansIndex) {
  185. this.curQueItem.answer.splice(ansIndex, 1);
  186. },
  187. },
  188. //生命周期 - 创建完成(可以访问当前this实例)
  189. created() {},
  190. //生命周期 - 挂载完成(可以访问DOM元素)
  191. mounted() {
  192. console.log(this.curQueItem);
  193. if (this.curQueItem) {
  194. this.fileCon.img_list = this.curQueItem.img_list;
  195. this.fileCon.mp3_list = this.curQueItem.mp3_list;
  196. }
  197. },
  198. beforeCreate() {}, //生命周期 - 创建之前
  199. beforeMount() {}, //生命周期 - 挂载之前
  200. beforeUpdate() {}, //生命周期 - 更新之前
  201. updated() {}, //生命周期 - 更新之后
  202. beforeDestroy() {}, //生命周期 - 销毁之前
  203. destroyed() {}, //生命周期 - 销毁完成
  204. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  205. };
  206. </script>
  207. <style lang='scss' scoped>
  208. //@import url(); 引入公共css类
  209. .Big-Book {
  210. &-delDef {
  211. padding: 0;
  212. line-height: 32px;
  213. color: #f56c6c;
  214. }
  215. &-def-list {
  216. margin-bottom: 8px;
  217. }
  218. &-top {
  219. display: flex;
  220. justify-content: flex-start;
  221. align-items: center;
  222. margin-top: 10px;
  223. .deleteOptionBox {
  224. width: 40px;
  225. height: 33px;
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. .close {
  230. width: 24px;
  231. cursor: pointer;
  232. }
  233. }
  234. }
  235. &-mp3 {
  236. margin-top: 6px;
  237. span {
  238. width: 50px;
  239. }
  240. }
  241. &-img {
  242. span {
  243. width: 50px;
  244. }
  245. }
  246. }
  247. .NPC-sentence-input-box {
  248. display: flex;
  249. justify-content: flex-start;
  250. align-items: flex-start;
  251. margin-bottom: 10px;
  252. }
  253. </style>
  254. <style lang="scss">
  255. .NPC-sentence-input-box {
  256. .NPC-sentence-input {
  257. margin-right: 10px;
  258. }
  259. > i {
  260. width: 24px;
  261. height: 24px;
  262. cursor: pointer;
  263. }
  264. }
  265. </style>