NewordPhraseModule.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-input">
  4. <div class="Big-Book-content m">
  5. <div class="Big-Book-main">
  6.         
  7. <div class="Big-Book-en">
  8. <span>汉字:</span>
  9. <el-input
  10. style="width: 300px; margin-right: 10px"
  11. placeholder="请输入汉字"
  12. v-model="curQueItem.new_word"
  13. @blur="onBlur(curQueItem, 'new_word')"
  14. ></el-input>
  15. <el-button type="danger" size="small" @click="deleteGroup"
  16. >删除</el-button
  17. >
  18. </div>
  19. <div class="Big-Book-en">
  20. <span>拼音:</span>
  21. <el-input
  22. style="width: 300px; margin-right: 10px"
  23. placeholder="请输入拼音"
  24. v-model="curQueItem.pinyin"
  25. @blur="onBlur(curQueItem, 'pinyin')"
  26. ></el-input>
  27. <el-button type="primary" size="small" @click="getPinyin(curQueItem)"
  28. >生成拼音</el-button
  29. >
  30. </div>
  31. <div class="Big-Book-en">
  32. <span>词性:</span>
  33. <el-input
  34. style="width: 300px"
  35. placeholder="请输入词性"
  36. v-model="curQueItem.cixing"
  37. @blur="onBlur(curQueItem, 'cixing')"
  38. ></el-input>
  39. </div>
  40. <div class="Book_flex_start">
  41. <span>释义:</span>
  42. <div>
  43. <div
  44. class="Big-Book-en"
  45. v-for="(item, i) in curQueItem.definition_list"
  46. :key="i"
  47. >
  48. <el-input
  49. style="width: 300px"
  50. type="textarea"
  51. :autosize="{ minRows: 2, maxRows: 4 }"
  52. placeholder="请输入释义"
  53. v-model="curQueItem.definition_list[i]"
  54. @blur="trimEvent(i)"
  55. ></el-input>
  56. <img
  57. @click="deletecn(i)"
  58. class="close"
  59. src="../../../assets/adult/del-close.png"
  60. alt=""
  61. />
  62. </div>
  63. </div>
  64. </div>
  65. <div class="addoption" @click="Addcn">添加释义</div>
  66. <div class="Big-Book-mp3">
  67. <Upload
  68. :changeFillId="changeMp3"
  69. :datafileList="fileCon.mp3_list"
  70. :filleNumber="mp3Number"
  71. :uploadType="'mp3'"
  72. />
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import Upload from "./Upload.vue";
  80. import "@/utils/pinyin_dict_withtone";
  81. import "@/utils/pinyinUtil";
  82. export default {
  83. components: {
  84. Upload,
  85. },
  86. props: ["curQueItem", "index", "type", "deleteGroup"],
  87. data() {
  88. return {
  89. mp3Number: 1,
  90. fileCon: {
  91. img_list: [],
  92. mp3_list: [],
  93. },
  94. };
  95. },
  96. computed: {},
  97. watch: {},
  98. //方法集合
  99. methods: {
  100. onBlur(item, field) {
  101. item[field] = item[field] ? item[field].trim() : "";
  102. },
  103. trimEvent(i) {
  104. let str = this.curQueItem.definition_list[i].trim();
  105. this.$set(this.curQueItem.definition_list, i, str);
  106. },
  107. // 删除释义
  108. deletecn(index) {
  109. if (this.curQueItem.definition_list.length <= 1) {
  110. this.$message.warning("至少要保留一个");
  111. return;
  112. }
  113. this.curQueItem.definition_list.splice(index, 1);
  114. },
  115. // 点击生成拼音
  116. getPinyin(item) {
  117. console.log(item);
  118. let bool = false;
  119. let value = "";
  120. if (item.new_word == "") {
  121. this.$message.info("请先输入内容,再生成拼音");
  122. bool = true;
  123. } else {
  124. value = item.new_word;
  125. }
  126. if (bool) {
  127. return;
  128. }
  129. let result = pinyinUtil.getPinyin(value);
  130. item.pinyin = result;
  131. },
  132. // 添加释义
  133. Addcn() {
  134. this.curQueItem.definition_list.push("");
  135. },
  136. changeMp3(fileList) {
  137. const articleImgList = JSON.parse(JSON.stringify(fileList));
  138. const articleImgRes = [];
  139. articleImgList.forEach((item) => {
  140. if (item.response) {
  141. const obj = {
  142. name: item.name,
  143. url: item.response.file_info_list[0].file_url,
  144. id: item.response.file_info_list[0].file_id,
  145. media_duration: item.response.file_info_list[0].media_duration,
  146. file_relative_path:
  147. item.response.file_info_list[0].file_relative_path,
  148. };
  149. articleImgRes.push(obj);
  150. }
  151. });
  152. //this.articleImgList = articleImgRes;
  153. this.curQueItem.mp3_list = JSON.parse(JSON.stringify(articleImgRes));
  154. },
  155. changeImage(fileList) {
  156. console.log(fileList);
  157. const articleImgList = JSON.parse(JSON.stringify(fileList));
  158. const articleImgRes = [];
  159. articleImgList.forEach((item) => {
  160. if (item.response) {
  161. const obj = {
  162. name: item.name,
  163. url: item.response.file_info_list[0].file_url,
  164. id: item.response.file_info_list[0].file_id,
  165. file_relative_path: file_relative_path,
  166. };
  167. articleImgRes.push(obj);
  168. }
  169. });
  170. //this.articleImgList = articleImgRes;
  171. this.curQueItem.img_list = JSON.parse(JSON.stringify(articleImgRes));
  172. },
  173. },
  174. //生命周期 - 创建完成(可以访问当前this实例)
  175. created() {},
  176. //生命周期 - 挂载完成(可以访问DOM元素)
  177. mounted() {
  178. if (this.curQueItem) {
  179. this.fileCon.img_list = this.curQueItem.img_list;
  180. this.fileCon.mp3_list = this.curQueItem.mp3_list;
  181. }
  182. },
  183. beforeCreate() {}, //生命周期 - 创建之前
  184. beforeMount() {}, //生命周期 - 挂载之前
  185. beforeUpdate() {}, //生命周期 - 更新之前
  186. updated() {}, //生命周期 - 更新之后
  187. beforeDestroy() {}, //生命周期 - 销毁之前
  188. destroyed() {}, //生命周期 - 销毁完成
  189. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  190. };
  191. </script>
  192. <style lang='scss' scoped>
  193. //@import url(); 引入公共css类
  194. .Big-Book-input {
  195. .Big-Book-content {
  196. &.m {
  197. display: flex;
  198. justify-content: flex-start;
  199. align-items: flex-start;
  200. }
  201. .Big-Book-con {
  202. display: flex;
  203. align-items: center;
  204. }
  205. .Big-Book-title {
  206. font-size: 16px;
  207. line-height: 40px;
  208. color: #000;
  209. margin-right: 15px;
  210. }
  211. .Big-Book-main {
  212. position: relative;
  213. width: 100%;
  214. > div {
  215. margin-bottom: 10px;
  216. &.Big-Book-pinyin,
  217. &.Big-Book-con,
  218. &.Big-Book-en {
  219. margin-bottom: 8px;
  220. span {
  221. width: 60px;
  222. text-align: right;
  223. }
  224. }
  225. &.Big-Book-yb {
  226. display: flex;
  227. align-items: flex-start;
  228. span {
  229. width: 60px;
  230. text-align: right;
  231. }
  232. }
  233. }
  234. .close {
  235. width: 24px;
  236. cursor: pointer;
  237. }
  238. }
  239. }
  240. .addoption {
  241. width: 148px;
  242. height: 40px;
  243. background: #f3f3f3;
  244. border: 1px dashed rgba(0, 0, 0, 0.15);
  245. box-sizing: border-box;
  246. border-radius: 4px;
  247. text-align: center;
  248. line-height: 40px;
  249. cursor: pointer;
  250. font-size: 14px;
  251. color: #000000;
  252. margin-top: 20px;
  253. }
  254. }
  255. </style>