DialogueModule.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-input">
  4. <div class="Big-Book-content m">
  5. <div class="Big-Book-main">
  6. <div>
  7. <el-input
  8. style="width: 150px"
  9. type="textarea"
  10. autosize
  11. placeholder="请输入角色名"
  12. v-model="curQueItem.roleName"
  13. @blur="curQueItem.roleName = curQueItem.roleName.trim()"
  14. ></el-input>
  15. </div>
  16. <div style="margin-left: 50px">
  17. <div class="adult-book-input-item">
  18. <span class="adult-book-input-item">内容:</span>
  19. <el-input
  20. type="textarea"
  21. class="adult-book-input"
  22. :autosize="{ minRows: 2 }"
  23. placeholder="请输入内容"
  24. v-model="curQueItem.con"
  25. @blur="curQueItem.con = curQueItem.con.trim()"
  26. ></el-input>
  27. <img
  28. @click="deleteOption"
  29. class="close"
  30. src="../../../assets/adult/del-close.png"
  31. alt=""
  32. />
  33. </div>
  34. <div class="adult-book-input-item">
  35. <span class="adult-book-input-item">内容:</span>
  36. <el-input
  37. type="textarea"
  38. class="adult-book-input"
  39. :autosize="{ minRows: 2 }"
  40. placeholder="请输入内容"
  41. v-model="curQueItem.number"
  42. @blur="curQueItem.number = curQueItem.number.trim()"
  43. ></el-input>
  44. </div>
  45. <template v-if="checkList.indexOf('输入') != -1">
  46. <div
  47. class="adult-book-input-item"
  48. v-for="(item, i) in curQueItem.AnswerList"
  49. :key="i"
  50. >
  51. <span class="adult-book-input-item">答案:</span>
  52. <el-input
  53. type="textarea"
  54. autosize
  55. placeholder="请输入答案"
  56. v-model="curQueItem.AnswerList[i]"
  57. @blur="
  58. curQueItem.AnswerList[i] = curQueItem.AnswerList[i].trim()
  59. "
  60. ></el-input>
  61. <img
  62. @click="deleteAnswer(i)"
  63. class="close"
  64. src="../../../assets/adult/del-close.png"
  65. alt=""
  66. />
  67. <!-- <img
  68. v-if="checkList.indexOf('跟读') != -1"
  69. src="../../../assets/adult/Dialogue-audio.png"
  70. alt=""
  71. /> -->
  72. </div>
  73. <div>
  74. <div class="addoption" @click="addAnswer">添加答案</div>
  75. </div>
  76. </template>
  77. <div class="adult-book-input-item">
  78. <span class="adult-book-input-item">位置:</span>
  79. <el-radio
  80. @change="changesite"
  81. v-model="curQueItem.site"
  82. label="left"
  83. >左侧</el-radio
  84. >
  85. <el-radio
  86. @change="changesite"
  87. v-model="curQueItem.site"
  88. label="right"
  89. >右侧</el-radio
  90. >
  91. </div>
  92. <div class="adult-book-input-item">
  93. <span class="adult-book-input-item">录音:</span>
  94. <el-radio v-model="curQueItem.isRecord" label="true">是</el-radio>
  95. <el-radio v-model="curQueItem.isRecord" label="false">否</el-radio>
  96. </div>
  97. <div class="adult-book-input-item">
  98. <Upload
  99. :changeFillId="changeImage"
  100. :datafileList="fileCon.img_list"
  101. :filleNumber="imgNumber"
  102. :uploadType="'image'"
  103. />
  104. </div>
  105. <div class="adult-book-input-item">
  106. <Upload
  107. :changeFillId="changeMp3"
  108. :datafileList="fileCon.mp3_list"
  109. :filleNumber="mp3Number"
  110. :uploadType="'mp3'"
  111. />
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. <script>
  119. import Upload from "./Upload.vue";
  120. import "@/utils/pinyin_dict_withtone";
  121. import "@/utils/pinyinUtil";
  122. export default {
  123. components: {
  124. Upload,
  125. },
  126. props: [
  127. "curQueItem",
  128. "index",
  129. "changAnswer",
  130. "deleteOptionOne",
  131. "type",
  132. "checkList",
  133. ],
  134. data() {
  135. return {
  136. imgNumber: 10,
  137. mp3Number: 1,
  138. fileCon: {
  139. img_list: [],
  140. mp3_list: [],
  141. },
  142. };
  143. },
  144. computed: {},
  145. watch: {},
  146. //方法集合
  147. methods: {
  148. // 删除当前选项
  149. deleteOption() {
  150. this.$confirm("确定要删除此角色吗?", "提示", {
  151. confirmButtonText: "确定",
  152. cancelButtonText: "取消",
  153. type: "warning",
  154. }).then(() => {
  155. this.deleteOptionOne(this.index);
  156. });
  157. },
  158. deleteAnswer(i) {
  159. this.$confirm("确定要删除此答案选项吗?", "提示", {
  160. confirmButtonText: "确定",
  161. cancelButtonText: "取消",
  162. type: "warning",
  163. }).then(() => {
  164. if (this.curQueItem.AnswerList.length < 1) {
  165. this.$message.warning("至少保留一个答案选项");
  166. return;
  167. } else {
  168. this.curQueItem.AnswerList.splice(i, 1);
  169. }
  170. });
  171. },
  172. addAnswer() {
  173. this.curQueItem.AnswerList.push("");
  174. },
  175. changeMp3(fileList) {
  176. const articleImgList = JSON.parse(JSON.stringify(fileList));
  177. const articleImgRes = [];
  178. articleImgList.forEach((item) => {
  179. if (item.response) {
  180. const obj = {
  181. name: item.name,
  182. url: item.response.file_info_list[0].file_url,
  183. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  184. media_duration: item.response.file_info_list[0].media_duration, //音频时长
  185. };
  186. articleImgRes.push(obj);
  187. }
  188. });
  189. //this.articleImgList = articleImgRes;
  190. this.curQueItem.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  191. },
  192. changeImage(fileList) {
  193. const articleImgList = JSON.parse(JSON.stringify(fileList));
  194. const articleImgRes = [];
  195. articleImgList.forEach((item) => {
  196. if (item.response) {
  197. const obj = {
  198. name: item.name,
  199. url: item.response.file_info_list[0].file_url,
  200. id: item.response.file_info_list[0].file_id,
  201. };
  202. articleImgRes.push(obj);
  203. }
  204. });
  205. //this.articleImgList = articleImgRes;
  206. this.curQueItem.img_list = JSON.parse(JSON.stringify(articleImgRes));
  207. },
  208. },
  209. //生命周期 - 创建完成(可以访问当前this实例)
  210. created() {},
  211. //生命周期 - 挂载完成(可以访问DOM元素)
  212. mounted() {
  213. if (this.curQueItem) {
  214. this.fileCon.img_list = this.curQueItem.img_list;
  215. this.fileCon.mp3_list = this.curQueItem.mp3_list;
  216. }
  217. },
  218. beforeCreate() {}, //生命周期 - 创建之前
  219. beforeMount() {}, //生命周期 - 挂载之前
  220. beforeUpdate() {}, //生命周期 - 更新之前
  221. updated() {}, //生命周期 - 更新之后
  222. beforeDestroy() {}, //生命周期 - 销毁之前
  223. destroyed() {}, //生命周期 - 销毁完成
  224. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  225. };
  226. </script>
  227. <style lang='scss' scoped>
  228. //@import url(); 引入公共css类
  229. .Big-Book-input {
  230. .Big-Book-content {
  231. &.m {
  232. display: flex;
  233. justify-content: flex-start;
  234. align-items: flex-start;
  235. }
  236. .Big-Book-con {
  237. display: flex;
  238. align-items: center;
  239. img {
  240. width: 24px;
  241. }
  242. }
  243. .Big-Book-title {
  244. font-size: 16px;
  245. line-height: 40px;
  246. color: #000;
  247. margin-right: 15px;
  248. }
  249. .Big-Book-main {
  250. position: relative;
  251. width: 100%;
  252. display: flex;
  253. :nth-child(2) > div {
  254. margin-bottom: 10px;
  255. &.Big-Book-pinyin,
  256. &.Big-Book-en,
  257. &.Big-Book-answer,
  258. &.Big-Book-con {
  259. display: flex;
  260. justify-content: flex-start;
  261. align-items: center;
  262. }
  263. .Big-Book-answer {
  264. margin-left: 10px;
  265. display: flex;
  266. justify-content: flex-start;
  267. align-items: center;
  268. }
  269. }
  270. .close {
  271. width: 24px;
  272. cursor: pointer;
  273. }
  274. .Big-Book-site {
  275. margin: 15px 0;
  276. }
  277. }
  278. }
  279. .addoption {
  280. width: 148px;
  281. height: 40px;
  282. background: #f3f3f3;
  283. border: 1px dashed rgba(0, 0, 0, 0.15);
  284. box-sizing: border-box;
  285. border-radius: 4px;
  286. text-align: center;
  287. line-height: 40px;
  288. cursor: pointer;
  289. font-size: 14px;
  290. color: #000000;
  291. }
  292. }
  293. </style>