ImageQuestionModule.vue 6.8 KB

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