DialogueModule.vue 8.6 KB

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