MultiRowInput.vue 5.3 KB

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