Neword.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. style="width: 300px"
  9. placeholder="请输入标题"
  10. v-model="curQue.title"
  11. @blur="onBlur(curQue, 'title')"
  12. class="adult-book-input"
  13. :autosize="{ minRows: 2 }"
  14. ></el-input>
  15. </div>
  16. <div class="adult-book-input-item">
  17. <span class="adult-book-lable">标题颜色:</span>  
  18. <div class="adult-book-main">
  19. <el-radio-group v-model="curQue.titleBg">
  20. <el-radio label="white">白色</el-radio>
  21. <el-radio label="themeColor">书的主题色</el-radio> </el-radio-group
  22. >  
  23. </div>
  24. </div>
  25. <div class="adult-book-input-item">
  26. <span class="adult-book-lable">详细信息:</span>  
  27. <div class="adult-book-main">
  28. <el-radio-group v-model="curQue.isInfor">
  29. <el-radio :label="true">有</el-radio>
  30. <el-radio :label="false">没有</el-radio> </el-radio-group
  31. >  
  32. </div>
  33.       
  34. </div>
  35. <div
  36. class="Big-Book-main"
  37. v-for="(item, index) in curQue.option"
  38. :key="'newWord' + index"
  39. style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
  40. >
  41. <div
  42. class="Big-Book-main-inner"
  43. v-for="(sItem, sIndex) in item"
  44. :key="'newWord_' + sIndex"
  45. >
  46. <NewordPhraseModule
  47. :curQueItem="sItem"
  48. :index="index"
  49. :sIndex="sIndex"
  50. :type="curQue.type"
  51. :deleteGroup="deleteGroup"
  52. />
  53. </div>
  54. <div class="addoption addoption2" @click="saddoption(item)">
  55. 添加字词
  56. </div>
  57. <el-button size="mini" type="danger" @click="delsItem(index)">
  58. 删除本组
  59. </el-button>
  60. </div>
  61. <div class="addoption" @click="addoption">添加一组</div>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import Inputmodule from "../common/Inputmodule.vue";
  67. import NewordPhraseModule from "../common/NewordPhraseModule.vue";
  68. export default {
  69. name: "Single",
  70. props: ["curQue", "changeCurQue"],
  71. components: {
  72. Inputmodule,
  73. NewordPhraseModule,
  74. },
  75. data() {
  76. return {
  77. data_structure: {
  78. type: "NewWord_chs",
  79. name: "生词",
  80. title: "",
  81. isInfor: true,
  82. titleBg: "themeColor", //标题背景颜色
  83. option: [
  84. [
  85. {
  86. new_word: "",
  87. cixing: "", //词性
  88. definition_list: [""], //需要增加词性
  89. pinyin: "",
  90. img_list: [],
  91. mp3_list: [],
  92. },
  93. ],
  94. ],
  95. },
  96. };
  97. },
  98. computed: {},
  99. watch: {},
  100. //方法集合
  101. methods: {
  102. onBlur(item, field) {
  103. item[field] = item[field] ? item[field].trim() : "";
  104. },
  105. addoption() {
  106. let leg = this.curQue.option.length;
  107. let last = this.curQue.option[leg - 1];
  108. let res_data = JSON.parse(JSON.stringify(this.data_structure));
  109. let obj = res_data.option[0];
  110. this.curQue.option.push(obj);
  111. },
  112. deleteGroup(index, sIndex) {
  113. if (this.curQue.option[0].length == 1) {
  114. this.$message.warning("至少剩余1个,不能全部删除");
  115. return;
  116. }
  117. this.curQue.option[index].splice(sIndex, 1);
  118. },
  119. saddoption(item) {
  120. let con = {
  121. new_word: "",
  122. cixing: "", //词性
  123. definition_list: [""], //需要增加词性
  124. pinyin: "",
  125. img_list: [],
  126. mp3_list: [],
  127. };
  128. item.push(con);
  129. },
  130. delsItem(index) {
  131. this.curQue.option.splice(index, 1);
  132. },
  133. },
  134. //生命周期 - 创建完成(可以访问当前this实例)
  135. created() {},
  136. //生命周期 - 挂载完成(可以访问DOM元素)
  137. mounted() {
  138. if (!this.curQue) {
  139. let res_data = JSON.parse(JSON.stringify(this.data_structure));
  140. this.changeCurQue(res_data);
  141. } else {
  142. if (!this.curQue.hasOwnProperty("isInfor")) {
  143. this.$set(this.curQue, "isInfor", true);
  144. }
  145. if (!this.curQue.hasOwnProperty("titleBg")) {
  146. this.$set(this.curQue, "titleBg", "themeColor");
  147. }
  148. }
  149. },
  150. beforeCreate() {}, //生命周期 - 创建之前
  151. beforeMount() {}, //生命周期 - 挂载之前
  152. beforeUpdate() {}, //生命周期 - 更新之前
  153. updated() {}, //生命周期 - 更新之后
  154. beforeDestroy() {}, //生命周期 - 销毁之前
  155. destroyed() {}, //生命周期 - 销毁完成
  156. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  157. };
  158. </script>
  159. <style lang='scss' scope>
  160. //@import url(); 引入公共css类
  161. .Big-Book-Single {
  162. &-content {
  163. &.m {
  164. display: flex;
  165. justify-content: flex-start;
  166. align-items: flex-start;
  167. }
  168. .Big-Book-title {
  169. font-size: 16px;
  170. line-height: 40px;
  171. color: #000;
  172. margin-right: 15px;
  173. }
  174. .Big-Book-main {
  175. background: rgba(230, 229, 229, 0.3);
  176. border: 1px #999 solid;
  177. border-radius: 8px;
  178. padding: 20px;
  179. > div {
  180. margin-bottom: 10px;
  181. &.Big-Book-pinyin {
  182. display: flex;
  183. justify-content: flex-start;
  184. align-items: center;
  185. }
  186. }
  187. .Big-Book-main-inner {
  188. }
  189. }
  190. }
  191. .addoption {
  192. width: 565px;
  193. height: 40px;
  194. left: 40px;
  195. top: 304px;
  196. background: #f3f3f3;
  197. border: 1px dashed rgba(0, 0, 0, 0.15);
  198. box-sizing: border-box;
  199. border-radius: 4px;
  200. text-align: center;
  201. line-height: 40px;
  202. cursor: pointer;
  203. &.addoption2 {
  204. width: 200px;
  205. }
  206. }
  207. .Big-Book-con {
  208. padding-bottom: 6px;
  209. border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
  210. }
  211. }
  212. </style>
  213. <style lang="scss">
  214. </style>