userForm.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view class="form-container-box">
  3. <!-- 待用活动表单 -->
  4. <active-form
  5. :formDate="formDate"
  6. @choose-image-btn="chooseImage"
  7. @delete-img-btn="deleteImg"
  8. @sure-btn="sure" @input-val="inputVal">
  9. </active-form>
  10. <!-- (对必填项input框为空是提示的和错误两种不同提示) -->
  11. <view class="buttonBox" @click="submit1">
  12. 提交
  13. </view>
  14. <!-- (对必填项input框为为空和错误是一种提示) -->
  15. <!-- <view class="buttonBox" @click="submit2">
  16. 提交2
  17. </view> -->
  18. <cover-view class="submit-data">
  19. {{submitData}}
  20. </cover-view>
  21. <view style="margin: 100rpx; color: red;">
  22. 温馨提示: 请准确填写相关信息帮助系统对您或您的孩子生成精准学习分析报告和推荐的学习路径
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import activeForm from '@/components/userInfo/active_form.vue'
  28. import { mapGetters } from 'vuex'
  29. export default {
  30. data() {
  31. return {
  32. submitData: "",
  33. formDate: [
  34. {
  35. placeholder: "请输入姓名",
  36. label: "姓名",
  37. type: "text",
  38. rules: {
  39. name: "name",
  40. value: "",
  41. verify: "req",
  42. errMess: "请输入姓名"
  43. }
  44. },
  45. {
  46. placeholder: "请输入就读学校",
  47. label: "就读学校",
  48. type: "text",
  49. rules: {
  50. name: "from_school_name",
  51. value: "",
  52. verify: "req",
  53. errMess: "请输入就读学校"
  54. }
  55. },
  56. {
  57. placeholder: "请填写联系方式",
  58. label: "手机号",
  59. type: "number",
  60. rules: {
  61. name: "mobile",
  62. value: "",
  63. verify: "req|phone",
  64. errMess: "手机号填写不正确"
  65. }
  66. },
  67. /*{
  68. placeholder: "请填写家长姓名",
  69. label: "家长姓名",
  70. type: "text",
  71. rules: {
  72. name: "father_name",
  73. value: "",
  74. verify: "req",
  75. errMess: "请填写家长姓名"
  76. }
  77. },
  78. {
  79. placeholder: "请填写联系方式",
  80. label: "手机号",
  81. type: "number",
  82. rules: {
  83. name: "mobile",
  84. value: "",
  85. verify: "req|phone",
  86. errMess: "手机号填写不正确"
  87. }
  88. },
  89. {
  90. placeholder: "请填写学习科目",
  91. label: "科目",
  92. type: "text",
  93. rules: {
  94. name: "subject_name",
  95. value: "",
  96. verify: "req",
  97. errMess: "请填写学习科目"
  98. }
  99. },
  100. {
  101. placeholder: "请填写学期",
  102. label: "学期",
  103. type: "text",
  104. rules: {
  105. name: "term",
  106. value: "",
  107. verify: "req",
  108. errMess: "请填写学期"
  109. }
  110. }*/
  111. ]
  112. }
  113. },
  114. components:{
  115. activeForm
  116. },
  117. computed: {
  118. ...mapGetters({
  119. fromSchoolId: 'paper/getFromSchoolId',
  120. examParams: 'paper/getExamParams'
  121. })
  122. },
  123. methods: {
  124. submit1: function() {
  125. // 表单验证 可选项 otherPra:otherPra
  126. var otherPra = {
  127. reqEmptyVal: true,
  128. }
  129. if (this.$vervify({
  130. formDate: this.formDate,
  131. otherPra: otherPra
  132. })
  133. ) {
  134. let formArray = []
  135. this.formDate.forEach(item => {
  136. let itemValue = item.rules
  137. if (itemValue.name === 'sex') {
  138. if (itemValue.value === '男') {
  139. itemValue.value = 1
  140. } else if (itemValue.value === '女') {
  141. itemValue.value = 0
  142. }
  143. }
  144. formArray.push({
  145. name: itemValue.name,
  146. value: itemValue.value,
  147. })
  148. })
  149. uni.showLoading({
  150. title: '正在生成测试报告, 请稍后...'
  151. })
  152. this.$httpApi.post('/front/potentialStudentInfo', {formList: formArray, fromSchoolId: parseInt(this.fromSchoolId)})
  153. .then(response => {
  154. if (response.code === 1) {
  155. let studentId = response.data
  156. this.$store.commit('paper/updateStudentId', response.data)
  157. this.sendCommitQuestionHttp(studentId)
  158. } else {
  159. uni.hideLoading()
  160. setTimeout(() => {
  161. uni.showToast({
  162. title: response.message
  163. })
  164. }, 100)
  165. }
  166. })
  167. }
  168. },
  169. sendCommitQuestionHttp (studentId) {
  170. let form = this.examParams
  171. form.potentialStudentInfoId = studentId
  172. this.$httpApi.post('/front/aiCt/commitAiPaperQuestion', form)
  173. .then(response => {
  174. uni.hideLoading()
  175. if (response.code === 1) {
  176. uni.showToast({
  177. icon: 'none',
  178. title: '报告生成成功'
  179. })
  180. setTimeout(() => {
  181. // 跳转测评报告结果页
  182. uni.redirectTo({
  183. url: 'ctReport'
  184. })
  185. }, 100)
  186. } else {
  187. uni.showToast({
  188. icon: 'none',
  189. title: '报告生成失败'
  190. })
  191. }
  192. })
  193. },
  194. // 上传图片
  195. chooseImage: function(data) {
  196. var data=JSON.parse(data)
  197. this.formDate[data.index].rules.value=data.value;
  198. this.formDate[data.index].updateImg=true;
  199. },
  200. // 删除图片
  201. deleteImg:function(index){
  202. this.formDate[index].rules.value="";
  203. this.formDate[index].updateImg=false;
  204. },
  205. // 确定
  206. sure: function(data) {
  207. var data=JSON.parse(data);
  208. if (String(data.currentSelectIndex) != "" && String(data.currentSelectValue) != "") {
  209. this.formDate[data.currentSelectIndex].rules.value = data.currentSelectValue;
  210. }
  211. },
  212. // inputVal
  213. inputVal:function(data){
  214. var data=JSON.parse(data);
  215. if (String(data.val) != "" && String(data.index) != "") {
  216. this.formDate[data.index].rules.value = data.val;
  217. }
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss">
  223. .form-container-box{
  224. width: 100vw;
  225. font-size: 28upx;
  226. min-height: 100vh;
  227. position: relative;
  228. padding-bottom: 100upx;
  229. }
  230. .bgfff {
  231. }
  232. .buttonBox {
  233. width: 100%;
  234. height: 84upx;
  235. color: white;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. background-color: #ff5b01;
  240. position: fixed;
  241. bottom: 0;
  242. left: 0;
  243. right: 0;
  244. z-index: 999;
  245. }
  246. .submit-data {
  247. padding: 20upx;
  248. margin-top: 20upx;
  249. word-break: break-word;
  250. }
  251. </style>