SentenceModule.vue 8.3 KB

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