Neword.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. pinyin_site: "first", //拼音位置
  93. },
  94. ],
  95. ],
  96. },
  97. };
  98. },
  99. computed: {},
  100. watch: {},
  101. //方法集合
  102. methods: {
  103. onBlur(item, field) {
  104. item[field] = item[field] ? item[field].trim() : "";
  105. },
  106. addoption() {
  107. let leg = this.curQue.option.length;
  108. let last = this.curQue.option[leg - 1];
  109. let res_data = JSON.parse(JSON.stringify(this.data_structure));
  110. let obj = res_data.option[0];
  111. this.curQue.option.push(obj);
  112. },
  113. deleteGroup(index, sIndex) {
  114. if (this.curQue.option[0].length == 1) {
  115. this.$message.warning("至少剩余1个,不能全部删除");
  116. return;
  117. }
  118. this.curQue.option[index].splice(sIndex, 1);
  119. },
  120. saddoption(item) {
  121. let con = {
  122. new_word: "",
  123. cixing: "", //词性
  124. definition_list: [""], //需要增加词性
  125. pinyin: "",
  126. img_list: [],
  127. mp3_list: [],
  128. };
  129. item.push(con);
  130. },
  131. delsItem(index) {
  132. this.curQue.option.splice(index, 1);
  133. },
  134. },
  135. //生命周期 - 创建完成(可以访问当前this实例)
  136. created() {},
  137. //生命周期 - 挂载完成(可以访问DOM元素)
  138. mounted() {
  139. if (!this.curQue) {
  140. let res_data = JSON.parse(JSON.stringify(this.data_structure));
  141. this.changeCurQue(res_data);
  142. } else {
  143. if (!this.curQue.hasOwnProperty("isInfor")) {
  144. this.$set(this.curQue, "isInfor", true);
  145. }
  146. if (!this.curQue.hasOwnProperty("titleBg")) {
  147. this.$set(this.curQue, "titleBg", "themeColor");
  148. }
  149. // let data = JSON.parse(JSON.stringify(this.curQue));
  150. this.curQue.option.forEach((item) => {
  151. if (!item[0].pinyin_site) {
  152. item[0].pinyin_site = "first"; //拼音位置
  153. }
  154. });
  155. // this.curQue = JSON.parse(JSON.stringify(data));
  156. }
  157. },
  158. beforeCreate() {}, //生命周期 - 创建之前
  159. beforeMount() {}, //生命周期 - 挂载之前
  160. beforeUpdate() {}, //生命周期 - 更新之前
  161. updated() {}, //生命周期 - 更新之后
  162. beforeDestroy() {}, //生命周期 - 销毁之前
  163. destroyed() {}, //生命周期 - 销毁完成
  164. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  165. };
  166. </script>
  167. <style lang='scss' scope>
  168. //@import url(); 引入公共css类
  169. .Big-Book-Single {
  170. &-content {
  171. &.m {
  172. display: flex;
  173. justify-content: flex-start;
  174. align-items: flex-start;
  175. }
  176. .Big-Book-title {
  177. font-size: 16px;
  178. line-height: 40px;
  179. color: #000;
  180. margin-right: 15px;
  181. }
  182. .Big-Book-main {
  183. background: rgba(230, 229, 229, 0.3);
  184. border: 1px #999 solid;
  185. border-radius: 8px;
  186. padding: 20px;
  187. > div {
  188. margin-bottom: 10px;
  189. &.Big-Book-pinyin {
  190. display: flex;
  191. justify-content: flex-start;
  192. align-items: center;
  193. }
  194. }
  195. .Big-Book-main-inner {
  196. }
  197. }
  198. }
  199. .addoption {
  200. width: 565px;
  201. height: 40px;
  202. left: 40px;
  203. top: 304px;
  204. background: #f3f3f3;
  205. border: 1px dashed rgba(0, 0, 0, 0.15);
  206. box-sizing: border-box;
  207. border-radius: 4px;
  208. text-align: center;
  209. line-height: 40px;
  210. cursor: pointer;
  211. &.addoption2 {
  212. width: 200px;
  213. }
  214. }
  215. .Big-Book-con {
  216. padding-bottom: 6px;
  217. border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
  218. }
  219. }
  220. </style>
  221. <style lang="scss">
  222. </style>