Notes.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-Single" v-if="curQue">
  4. <div class="Big-Book-Single-content" style="margin-top: 20px">
  5. <div class="adult-book-input-item">
  6. <span class="adult-book-lable">标题:</span>           
  7. <el-input
  8. class="adult-book-input"
  9. :autosize="{ minRows: 2 }"
  10. placeholder="请输入标题"
  11. v-model="curQue.title"
  12. @blur="onBlur(curQue, 'title')"
  13. maxlength="500"
  14. show-word-limit
  15. ></el-input>
  16. </div>
  17. <div
  18. class="Big-Book-main"
  19. v-for="(curQueItem, index) in curQue.option"
  20. :key="'curQueItem' + index"
  21. style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
  22. >
  23. <div class="adult-book-input-item">
  24. <span class="adult-book-lable">序号:</span>
  25. <el-input
  26. class="adult-book-input"
  27. :autosize="{ minRows: 2 }"
  28. placeholder="请输入内容"
  29. v-model="curQueItem.number"
  30. @blur="onBlur(curQueItem, 'number')"
  31. maxlength="200"
  32. show-word-limit
  33. ></el-input>
  34. <el-button type="danger" size="small" @click="deleteGroup()"
  35. >删除</el-button
  36. >
  37. </div>
  38. <div class="adult-book-input-item">
  39. <span class="adult-book-lable">内容:</span>
  40. <el-input
  41. class="adult-book-input"
  42. :autosize="{ minRows: 2 }"
  43. placeholder="请输入内容"
  44. v-model="curQueItem.con"
  45. @blur="onBlur(curQueItem, 'con')"
  46. maxlength="200"
  47. show-word-limit
  48. ></el-input>
  49. </div>
  50. <div class="adult-book-input-item">
  51. <span class="adult-book-lable">翻译:</span>
  52. <el-input
  53. class="adult-book-input"
  54. :autosize="{ minRows: 2 }"
  55. placeholder="请输入内容"
  56. v-model="curQueItem.interpret"
  57. @blur="onBlur(curQueItem, 'interpret')"
  58. maxlength="200"
  59. show-word-limit
  60. ></el-input>
  61. </div>
  62. <div class="adult-book-input-item">
  63. <span class="adult-book-lable">注释:</span>
  64. <el-input
  65. type="textarea"
  66. class="adult-book-input"
  67. :autosize="{ minRows: 2 }"
  68. placeholder="请输入内容"
  69. v-model="curQueItem.note"
  70. @blur="onBlur(curQueItem, 'note')"
  71. maxlength="200"
  72. show-word-limit
  73. ></el-input>
  74. </div>
  75. <div class="adult-book-input-item">
  76. <span class="adult-book-lable"></span>
  77. <Upload
  78. :changeFillId="changeImage"
  79. :datafileList="fileCon[index] && fileCon[index].img_list"
  80. :filleNumber="imgNumber"
  81. :uploadType="'image'"
  82. :index="index"
  83. />
  84. </div>
  85. </div>
  86. <div class="addoption" @click="addoption">添加注释</div>
  87. </div>
  88. </div>
  89. </template>
  90. <script>
  91. import Upload from "../common/Upload.vue";
  92. export default {
  93. name: "Single",
  94. props: ["curQue", "changeCurQue"],
  95. components: { Upload },
  96. data() {
  97. return {
  98. imgNumber: 10000,
  99. fileCon: [
  100. {
  101. img_list: [],
  102. mp3_list: [],
  103. },
  104. ],
  105. data_structure: {
  106. type: "notes_chs",
  107. name: "注释",
  108. title: "",
  109. option: [
  110. {
  111. number: "", //序号
  112. con: "", //内容
  113. interpret: "", //翻译
  114. note: "", //注释详情
  115. img_list: [],
  116. },
  117. ],
  118. },
  119. };
  120. },
  121. computed: {},
  122. watch: {},
  123. //方法集合
  124. methods: {
  125. onBlur(item, field) {
  126. item[field] = item[field] ? item[field].trim() : "";
  127. },
  128. addoption() {
  129. let res_data = JSON.parse(JSON.stringify(this.data_structure));
  130. let obj = res_data.option[0];
  131. this.curQue.option.push(obj);
  132. },
  133. deleteGroup(index) {
  134. if (this.curQue.option.length == 1) {
  135. this.$message.warning("至少剩余1个,不能全部删除");
  136. return;
  137. }
  138. this.curQue.option.splice(index, 1);
  139. },
  140. changeImage(fileList, duration, index) {
  141. const articleImgList = JSON.parse(JSON.stringify(fileList));
  142. const articleImgRes = [];
  143. articleImgList.forEach((item) => {
  144. if (item.response) {
  145. const obj = {
  146. name: item.name,
  147. url: item.response.file_info_list[0].file_url,
  148. id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
  149. };
  150. articleImgRes.push(obj);
  151. }
  152. });
  153. this.curQue.option[index].img_list = JSON.parse(
  154. JSON.stringify(articleImgRes)
  155. );
  156. },
  157. },
  158. //生命周期 - 创建完成(可以访问当前this实例)
  159. created() {},
  160. //生命周期 - 挂载完成(可以访问DOM元素)
  161. mounted() {
  162. if (!this.curQue) {
  163. let res_data = JSON.parse(JSON.stringify(this.data_structure));
  164. this.changeCurQue(res_data);
  165. } else {
  166. let fileCon = [];
  167. this.curQue.option.forEach((item) => {
  168. let obj = { img_list: item.img_list };
  169. fileCon.push(obj);
  170. });
  171. this.fileCon = JSON.parse(JSON.stringify(fileCon));
  172. console.log(this.fileCon);
  173. }
  174. },
  175. beforeCreate() {}, //生命周期 - 创建之前
  176. beforeMount() {}, //生命周期 - 挂载之前
  177. beforeUpdate() {}, //生命周期 - 更新之前
  178. updated() {}, //生命周期 - 更新之后
  179. beforeDestroy() {}, //生命周期 - 销毁之前
  180. destroyed() {}, //生命周期 - 销毁完成
  181. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  182. };
  183. </script>
  184. <style lang='scss' scope>
  185. //@import url(); 引入公共css类
  186. .Big-Book-Single {
  187. &-content {
  188. &.m {
  189. display: flex;
  190. justify-content: flex-start;
  191. align-items: flex-start;
  192. }
  193. .Big-Book-title {
  194. font-size: 16px;
  195. line-height: 40px;
  196. color: #000;
  197. margin-right: 15px;
  198. }
  199. .Big-Book-main {
  200. > div {
  201. margin-bottom: 10px;
  202. &.Big-Book-pinyin {
  203. display: flex;
  204. justify-content: flex-start;
  205. align-items: center;
  206. }
  207. }
  208. }
  209. }
  210. .addoption {
  211. width: 565px;
  212. height: 40px;
  213. left: 40px;
  214. top: 304px;
  215. background: #f3f3f3;
  216. border: 1px dashed rgba(0, 0, 0, 0.15);
  217. box-sizing: border-box;
  218. border-radius: 4px;
  219. text-align: center;
  220. line-height: 40px;
  221. cursor: pointer;
  222. }
  223. .Big-Book-con {
  224. display: flex;
  225. padding-bottom: 6px;
  226. border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
  227. }
  228. }
  229. </style>
  230. <style lang="scss">
  231. </style>