Dialogue.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-Single">
  4. <div
  5. class="Big-Book-Single-content"
  6. style="margin-left: 50px; margin-top: 20px"
  7. >
  8.         
  9. <div class="adult-book-input-item">
  10.           <span class="adult-book-lable">标题:</span>
  11.           <el-input
  12. class="adult-book-input"
  13. :autosize="{ minRows: 2 }"
  14. type="textarea"
  15. placeholder="请输入标题"
  16. v-model="curQue.title"
  17. @blur="curQue.title = curQue.title.trim()"
  18. ></el-input>
  19.         
  20. </div>
  21. <div
  22. class="Big-Book-main"
  23. v-for="(item, index) in curQue.option"
  24. :key="item + index"
  25. style="border-bottom: 1px #ccc solid; margin-bottom: 20px"
  26. >
  27. <DialogueModule
  28. :checkList="checkList"
  29. :curQueItem="item"
  30. :index="index"
  31. :changAnswer="changAnswer"
  32. :deleteOptionOne="deleteOptionOne"
  33. :type="curQue.type"
  34. />
  35. </div>
  36. <div class="Big-Book-addrole">
  37. <div class="addoption" @click="addOption">添加角色</div>
  38. <!-- <div class="addoption" @click="addOption">添加一个选项</div> -->
  39. </div>
  40. <div class="Big-Book-divide">
  41. <el-divider content-position="center">功能设置</el-divider>
  42. </div>
  43. <div>
  44. <el-checkbox-group v-model="checkList" @change="handleCheckedFnChange">
  45. <el-checkbox
  46. v-for="(fnItem, fnIndex) in curQue.fn_list"
  47. :key="'fn_list' + fnItem.type + fnIndex"
  48. :label="fnItem.name"
  49. ></el-checkbox>
  50. </el-checkbox-group>
  51. </div>
  52. <!-- <div class="Big-Book-more">
  53. <p class="Big-Book-more-text">功能配置</p>
  54. <div class="Big-Book-more-main">
  55. <div v-for="(item, index) in curQue.fn_list" :key="index + item.name">
  56. <el-checkbox
  57. style="margin-left: 7px"
  58. v-model="item.isFn"
  59. :label="index"
  60. >{{ item.name }}</el-checkbox
  61. >
  62. </div>
  63. </div>
  64. </div> -->
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import DialogueModule from "../common/DialogueModule.vue";
  70. export default {
  71. name: "Single",
  72. props: ["curQue", "fn_data"],
  73. components: {
  74. DialogueModule,
  75. },
  76. data() {
  77. return {
  78. checkList: [],
  79. form: {
  80. stem: {
  81. con: "",
  82. pinyin: "",
  83. english: "",
  84. highlight: "",
  85. underline: "",
  86. img_url: [],
  87. mp3_url: [],
  88. },
  89. },
  90. };
  91. },
  92. computed: {},
  93. watch: {},
  94. //方法集合
  95. methods: {
  96. // 修改正确选项中得某一个为正确答案
  97. changAnswer(index) {
  98. this.curQue.option.forEach((item, i) => {
  99. if (index == i) {
  100. this.curQue.correct[0].input[index] = item.Answer;
  101. }
  102. });
  103. },
  104. // 删除其中一个选项
  105. deleteOptionOne(index) {
  106. if (this.curQue.option.length <= 2) {
  107. this.$message.warning("至少要保留两个角色");
  108. return;
  109. }
  110. this.curQue.option.splice(index, 1);
  111. this.curQue.correct[0].input.splice(index, 1);
  112. },
  113. // 新增选项
  114. addOption() {
  115. let type = this.curQue.type;
  116. let cur_fn_data_arr = this.fn_data.filter((item) => item.type == type);
  117. let cur_fn_data = JSON.parse(JSON.stringify(cur_fn_data_arr[0]));
  118. let obj = cur_fn_data.data_structure.option[0];
  119. this.curQue.option.push(obj);
  120. },
  121. // 更多配置选择
  122. handleCheckedFnChange(value) {
  123. let fn_list = JSON.parse(JSON.stringify(this.curQue.fn_list));
  124. this.curQue.fn_list = fn_list.map((item) => {
  125. if (value.indexOf(item.name) > -1) {
  126. item.isFn = true;
  127. } else {
  128. item.isFn = false;
  129. this.curQue.option.forEach((it) => {
  130. it.Answer = "";
  131. });
  132. }
  133. return item;
  134. });
  135. },
  136. },
  137. //生命周期 - 创建完成(可以访问当前this实例)
  138. created() {
  139. // 如果保存过需要将选中的功能设置选中
  140. this.curQue.fn_list.forEach((item) => {
  141. if (item.isFn) {
  142. this.checkList.push(item.name);
  143. }
  144. });
  145. },
  146. //生命周期 - 挂载完成(可以访问DOM元素)
  147. mounted() {},
  148. beforeCreate() {}, //生命周期 - 创建之前
  149. beforeMount() {}, //生命周期 - 挂载之前
  150. beforeUpdate() {}, //生命周期 - 更新之前
  151. updated() {}, //生命周期 - 更新之后
  152. beforeDestroy() {}, //生命周期 - 销毁之前
  153. destroyed() {}, //生命周期 - 销毁完成
  154. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  155. };
  156. </script>
  157. <style lang='scss' scope>
  158. //@import url(); 引入公共css类
  159. .Big-Book-Single {
  160. &-content {
  161. &.m {
  162. display: flex;
  163. justify-content: flex-start;
  164. align-items: flex-start;
  165. }
  166. .Big-Book-title {
  167. font-size: 16px;
  168. line-height: 40px;
  169. color: #000;
  170. margin-right: 15px;
  171. }
  172. .Big-Book-main {
  173. > div {
  174. margin-bottom: 10px;
  175. &.Big-Book-pinyin {
  176. display: flex;
  177. justify-content: flex-start;
  178. align-items: center;
  179. }
  180. }
  181. }
  182. }
  183. .Big-Book-addrole {
  184. > div {
  185. width: 152px;
  186. height: 40px;
  187. background: #f3f3f3;
  188. border: 1px dashed rgba(0, 0, 0, 0.15);
  189. box-sizing: border-box;
  190. border-radius: 4px;
  191. }
  192. }
  193. .Big-Book-more {
  194. .Big-Book-more-text {
  195. position: relative;
  196. text-align: center;
  197. }
  198. .Big-Book-more-text:before,
  199. .Big-Book-more-text:after {
  200. position: absolute;
  201. background: #ccc;
  202. content: "";
  203. height: 1px;
  204. top: 50%;
  205. width: 45%;
  206. }
  207. .Big-Book-more-text:before {
  208. left: 10px;
  209. }
  210. .Big-Book-more-text:after {
  211. right: 10px;
  212. }
  213. .Big-Book-more-main {
  214. display: flex;
  215. > :not(:nth-child(1)) {
  216. margin-left: 30px;
  217. }
  218. }
  219. }
  220. .Big-Book-con {
  221. display: flex;
  222. align-items: center;
  223. margin: 10px 0;
  224. }
  225. }
  226. </style>
  227. <style lang="scss">
  228. </style>