test.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="content">
  3. <view class="title">
  4. 阶段
  5. </view>
  6. <view>
  7. <view class="title_name on"
  8. >
  9. sdsdd
  10. </view>
  11. </view>
  12. <view class="title">
  13. 年级
  14. </view>
  15. <view>
  16. <view
  17. class="title_name ">
  18. 年级
  19. </view>
  20. </view>
  21. <view class="title">
  22. 科目
  23. </view>
  24. <view>
  25. <view class="title_name">
  26. 科目
  27. </view>
  28. <view class="title_name">
  29. 科目
  30. </view>
  31. <view class="title_name">
  32. 科目
  33. </view>
  34. </view>
  35. <view class="title">
  36. 知识点
  37. </view>
  38. <view>
  39. <ly-tree
  40. :tree-data="languagePointsList"
  41. :ready="ready"
  42. :show-checkbox="true"
  43. node-key="id"
  44. @node-expand="handleNodeExpand"
  45. @node-click="handleNodeClick">
  46. </ly-tree>
  47. </view>
  48. <view class="title">
  49. 已选择知识点
  50. </view>
  51. <view>
  52. <view class="title_name">知识点1</view>
  53. <view class="title_name">知识点2</view>
  54. </view>
  55. <view class="uni-padding-wrap">
  56. <view class="uni-title">默认样式</view>
  57. <view>
  58. <label class="radio"><radio value="r1" checked="true" />选中</label>
  59. <label class="radio"><radio value="r2" />未选中</label>
  60. </view>
  61. </view>
  62. <view class="ai_btn">
  63. <button
  64. class="ai_btn_item"
  65. type="warn">取消</button>
  66. <button
  67. type="primary"
  68. @click="createCtPaper"
  69. class="ai_btn_item">确定</button>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import LyTree from '@/components/ly-tree/ly-tree.vue'
  75. import { mapGetters, mapState } from 'vuex'
  76. export default {
  77. components: {LyTree},
  78. data() {
  79. return {
  80. selectSubjectId: 0,
  81. selectSchoolTypeId: 0,
  82. selectGradeTypeId: 0,
  83. ready: false, // 这里用于自主控制loading加载状态,避免异步正在加载数据的空档显示“暂无数据”
  84. subjectList: [],
  85. languagePointsList: [],
  86. schoolTypeList: [],
  87. gradeTypeList: [],
  88. selectLanguagePointsList: [], //选中的知识点集合
  89. languagePointsList: []
  90. }
  91. },
  92. onLoad() {
  93. // this.getData()
  94. // 模拟异步请求
  95. setTimeout(() => {
  96. this.languagePointsList = [{
  97. id: 1,
  98. label: '一级 1',
  99. children: [{
  100. id: 11,
  101. label: '二级 1-1',
  102. children: [{
  103. id: 111,
  104. label: '三级 1-1-1'
  105. }]
  106. }]
  107. }, {
  108. id: 2,
  109. label: '一级 2',
  110. children: [{
  111. id: 21,
  112. label: '二级 2-1',
  113. children: [{
  114. id: 211,
  115. label: '三级 2-1-1'
  116. }]
  117. }, {
  118. id: 22,
  119. label: '二级 2-2',
  120. children: [{
  121. id: 221,
  122. label: '三级 2-2-1'
  123. }]
  124. }]
  125. }, {
  126. id: 3,
  127. label: '一级 3',
  128. children: [{
  129. id: 31,
  130. label: '二级 3-1',
  131. children: [{
  132. id: 311,
  133. label: '三级 3-1-1'
  134. }]
  135. }, {
  136. id: 32,
  137. label: '二级 3-2',
  138. children: [{
  139. id: 321,
  140. label: '三级 3-2-1'
  141. }]
  142. }]
  143. }];
  144. this.ready = true;
  145. }, 2000);
  146. },
  147. methods: {
  148. selectSchoolType (item) {
  149. },
  150. getData () {
  151. this.$httpApi.get('/front/userInfo/getStudentInfo', {})
  152. .then(res => {
  153. let result = res.data.data
  154. this.schoolTypeList = result.schoolTypeList
  155. this.gradeTypeList = result.gradeTypeList
  156. this.selectSchoolTypeId = result.selectSchoolTypeId
  157. this.selectGradeTypeId = result.selectGradeTypeId
  158. this.subjectList = result.subjectList
  159. this.selectSubjectId = result.selectSubjectId
  160. })
  161. },
  162. // 加载科目知识点
  163. loadLanguagePointsList () {
  164. this.$httpApi.get(this.$httpApi.httpUrl('/front/languagePoints'), {
  165. params: {
  166. gradeType: this.selectGradeTypeId,
  167. subjectId: this.selectSubjectId
  168. }
  169. }).then(response => {
  170. this.languagePointsList = response.data.data
  171. })
  172. },
  173. createCtPaper () {
  174. if (this.selectGradeTypeId === 0) {
  175. uni.showToast({
  176. icon: 'none',
  177. title: '请选择年级'
  178. });
  179. return false
  180. }
  181. if (this.selectSubjectId === 0) {
  182. uni.showToast({
  183. icon: 'none',
  184. title: '请选择科目'
  185. });
  186. return false
  187. }
  188. uni.navigateTo({
  189. url: 'result'
  190. })
  191. },
  192. generatePaper () {
  193. let form = {
  194. subjectId: this.selectSubjectId,
  195. schoolType: this.selectSchoolTypeId,
  196. gradeType: this.selectGradeTypeId,
  197. languagePointsList: this.selectLanguagePointsList
  198. }
  199. this.$httpApi.post(this.$httpApi.httpUrl('/front/aiCt/createAiCtPaper'), form).then(response => {
  200. if (response.data.code === 1) {
  201. let paperInfo = response.data.data
  202. paperInfo.languagePointsList = this.selectLanguagePointsList
  203. this.$store.commit('paper/updatePaperInfo', paperInfo)
  204. } else {
  205. loading.close();
  206. this.$message.error(response.data.message)
  207. }
  208. })
  209. },
  210. // uni-app中emit触发的方法只能接受一个参数,所以会回传一个对象,打印对象即可见到其中的内容
  211. handleNodeClick(obj) {
  212. console.log('handleNodeClick', JSON.stringify(obj));
  213. },
  214. handleNodeExpand(obj) {
  215. console.log('handleNodeExpand', JSON.stringify(obj));
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="scss">
  221. .content {
  222. padding: 10px;
  223. margin: 2%;
  224. width: 90%;
  225. height: 90%;
  226. display: flex;
  227. flex-direction: column;
  228. .on {
  229. background: #409eff;
  230. color: #fff;
  231. border: 1px solid #409eff;
  232. }
  233. .on:hover {
  234. background: #409eff;
  235. color: #fff;
  236. border: 1px solid #409eff;
  237. }
  238. }
  239. .title_name {
  240. cursor: pointer;
  241. color: #cacaca;
  242. margin: 10px 5px 10px 10px;
  243. padding: 0px 5px 0px 5px;
  244. display: block;
  245. min-width: 65px;
  246. line-height: 30px;
  247. float: left;
  248. text-align: center;
  249. border: 1px solid #d0d0d0;
  250. }
  251. .ai_btn {
  252. display: inline-block;
  253. float: right;
  254. line-height: 40px;
  255. position: relative;
  256. left: 10%;
  257. }
  258. .ai_btn_item {
  259. width: 100px;
  260. float: left;
  261. line-height: 50px;
  262. margin-left: 20px;
  263. margin-top: 20px;
  264. }
  265. </style>