newStudentProjectApply.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <!-- 测试上传组件 -->
  3. <div v-loading="loading">
  4. <div class="pAHeader">
  5. <div class="pAHeader1">创客项目申请</div>
  6. </div>
  7. <hr>
  8. <!-- 学生项目立项 -->
  9. <studentProjectWord :wordData="wordData" :reversedMessage="reversedMessage"/>
  10. <div style="position: fixed;bottom: 5%;margin-left: -1%;">
  11. <el-button @click="test" type="primary">提交项目</el-button>
  12. </div>
  13. <el-dialog
  14. title="提示"
  15. :visible.sync="submitHint"
  16. width="600px"
  17. class="pageSubmitData">
  18. <div class="deleteContent">确定提交“{{wordData['projectName']}}”项目立项?</div>
  19. <span slot="footer" class="dialog-footer">
  20. <el-button type="primary" @click="submitWord" class="AllDialogBtn">确认提交</el-button>
  21. <el-button @click="submitHint=false" class="AllDialogBtn">取消</el-button>
  22. </span>
  23. </el-dialog>
  24. </div>
  25. </template>
  26. <script>
  27. // import MakerSpaceWord from '../components/MakerSpaceWord.vue'
  28. import getProjectNo from '@/components/tool/getProjectNo';
  29. import {getNowDate} from '@/components/tool/Date.js'
  30. import studentProjectWord from './components/studentProjectWord.vue'
  31. // import markerFundWord from '@/components/markerFundWord.vue';
  32. // import markeractivityWord from '@/components/markeractivityWord.vue';
  33. export default {
  34. components: {
  35. studentProjectWord,
  36. // markerFundWord,
  37. // markeractivityWord
  38. },
  39. data() {
  40. return {
  41. accept: "*",
  42. loading:false,
  43. submitHint:false,
  44. wordData:{
  45. applicationDate:getNowDate(1),//申请日期
  46. projectName:'',
  47. radio: '',
  48. checkList:[],
  49. schoolRadio:'',
  50. applyParsonRadio:'',
  51. applyParsonName:'',
  52. college:'',
  53. tel:'',
  54. beginTime:'',
  55. endTime:'',
  56. studentS:[
  57. {name:'',collage:'',work:''},
  58. {name:'',collage:'',work:''},
  59. {name:'',collage:'',work:''},
  60. {name:'',collage:'',work:''},
  61. {name:'',collage:'',work:''},
  62. {name:'',collage:'',work:''},
  63. ],
  64. teacherS:[
  65. {name:'',collage:'',work:''},
  66. {name:'',collage:'',work:''},
  67. ],
  68. brief:'',
  69. introduce:{
  70. back:'',
  71. innovate:'',
  72. path:'',
  73. scene:'',
  74. worth:'',
  75. team:'',
  76. cost:'',
  77. expectResults:'',
  78. expectResultsTeacher:'',
  79. expectConversion:'',
  80. plan:''
  81. },
  82. total:'',
  83. fund:{
  84. facility:'',
  85. materials:'',
  86. process:'',
  87. assist:'',
  88. authenticate:'',
  89. match:'',
  90. activity:'',
  91. affair:''
  92. }
  93. }
  94. };
  95. },
  96. computed:{
  97. reversedMessage: function () {
  98. return (this.wordData.fund.facility*1 + this.wordData.fund.materials*1+this.wordData.fund.process*1+ this.wordData.fund.assist*1+this.wordData.fund.authenticate*1+ this.wordData.fund.match*1+this.wordData.fund.activity*1+this.wordData.fund.affair*1)
  99. }
  100. },
  101. methods:{
  102. test(){ //验证
  103. const cEmpty = /^\s*$/g;
  104. for (let i in this.wordData){
  105. // console.log(this.wordData[i],i);
  106. switch(i){
  107. case 'projectName':
  108. if (cEmpty.test(this.wordData[i])) {
  109. this.$message.error('请输入项目名称')
  110. // this.$refs.projectName.style.background='rgb(236, 141, 141)'
  111. // setTimeout(() => {
  112. // this.$refs.projectName.style.background='#ffffff'
  113. // }, 2000);
  114. document.querySelector('#projectName').scrollIntoView({ behavior: "smooth" });
  115. return false
  116. }
  117. break;
  118. case 'radio':
  119. if (cEmpty.test(this.wordData[i])) {
  120. this.$message.error('请选择项目分组')
  121. document.querySelector('#radio').scrollIntoView({ behavior: "smooth" });
  122. return false
  123. }
  124. break;
  125. case 'checkList':
  126. if (this.wordData[i].length==0) {
  127. this.$message.error('优先支持项目')
  128. document.querySelector('#checkList').scrollIntoView({ behavior: "smooth" });
  129. return false
  130. }
  131. break;
  132. case 'schoolRadio':
  133. if (cEmpty.test(this.wordData[i])) {
  134. this.$message.error('请选择美丽校园改造项目')
  135. document.querySelector('#schoolRadio').scrollIntoView({ behavior: "smooth" });
  136. return false
  137. }
  138. break;
  139. case 'applyParsonRadio':
  140. if (cEmpty.test(this.wordData[i])) {
  141. this.$message.error('请选择项目申请人')
  142. document.querySelector('#applyParsonRadio').scrollIntoView({ behavior: "smooth" });
  143. return false
  144. }
  145. break;
  146. case 'applyParsonName':
  147. if (cEmpty.test(this.wordData[i])) {
  148. this.$message.error('请填写申请人姓名')
  149. document.querySelector('#applyParsonName').scrollIntoView({ behavior: "smooth" });
  150. return false
  151. }
  152. break;
  153. case 'college':
  154. if (cEmpty.test(this.wordData[i])) {
  155. this.$message.error('请选择所在学院')
  156. document.querySelector('#applyParsonName').scrollIntoView({ behavior: "smooth" });
  157. return false
  158. }
  159. break;
  160. case 'tel':
  161. if (cEmpty.test(this.wordData[i])) {
  162. this.$message.error('请填写联系方式')
  163. document.querySelector('#applyParsonName').scrollIntoView({ behavior: "smooth" });
  164. return false
  165. }
  166. break;
  167. case 'beginTime':
  168. if (cEmpty.test(this.wordData[i])) {
  169. this.$message.error('请选择项目起始时间')
  170. document.querySelector('#beginTime').scrollIntoView({ behavior: "smooth" });
  171. return false
  172. }
  173. break;
  174. case 'endTime':
  175. if (cEmpty.test(this.wordData[i])) {
  176. this.$message.error('请选择计划完成时间')
  177. document.querySelector('#beginTime').scrollIntoView({ behavior: "smooth" });
  178. return false
  179. }
  180. break;
  181. case 'studentS':
  182. let snum = 0;
  183. this.wordData[i].forEach(item=>{
  184. if(cEmpty.test(item['name']))snum++;
  185. // for(let j in item){
  186. // if(cEmpty.test(item[j])){
  187. // snum++;
  188. // }
  189. // }
  190. })
  191. if(snum>0){
  192. this.$message.error("学生姓名请不要留空");
  193. document.querySelector('#studentS').scrollIntoView({ behavior: "smooth" });
  194. return false;
  195. }
  196. // }
  197. break;
  198. case 'teacherS':
  199. let num = 0;
  200. this.wordData[i].forEach(item=>{
  201. if(cEmpty.test(item['name']))num++;
  202. // for(let j in item){
  203. // if(cEmpty.test(item[j])){
  204. // num++;
  205. // }
  206. // }
  207. })
  208. if(num>0){
  209. this.$message.error("老师姓名请不要留空");
  210. document.querySelector('#teacherS').scrollIntoView({ behavior: "smooth" });
  211. return false;
  212. }
  213. break;
  214. // case 'brief':
  215. // if (cEmpty.test(this.wordData[i])) {
  216. // this.$message.error('请填写项目简介')
  217. // // this.$refs.brief.style.background='rgb(236, 141, 141)'
  218. // // setTimeout(() => {
  219. // // this.$refs.brief.style.background='#ffffff'
  220. // // }, 2000);
  221. // document.querySelector('#brief').scrollIntoView({ behavior: "smooth" });
  222. // return false
  223. // }
  224. // break;
  225. case 'fund':
  226. let mon=this.wordData.fund.facility*1 + this.wordData.fund.materials*1+this.wordData.fund.process*1+ this.wordData.fund.assist*1+this.wordData.fund.authenticate*1+ this.wordData.fund.match*1+this.wordData.fund.activity*1+this.wordData.fund.affair*1
  227. if(mon==0){
  228. document.querySelector('#fund').scrollIntoView({ behavior: "smooth" });
  229. return this.$message.error('请输入经费')
  230. }
  231. break;
  232. }
  233. }
  234. this.wordData['total']=this.wordData.fund.facility*1 + this.wordData.fund.materials*1+this.wordData.fund.process*1+ this.wordData.fund.assist*1+this.wordData.fund.authenticate*1+ this.wordData.fund.match*1+this.wordData.fund.activity*1+this.wordData.fund.affair*1
  235. this.submitHint=true;
  236. },
  237. submitWord(){ //提交
  238. getProjectNo("XM").then((result)=>{
  239. let pram = {
  240. uid:this.$store.state.userInfo.userid,//用户ID
  241. pNo:result,//项目编号
  242. tid:"5e21b204-c206-11ed-a4cd-509a4c5b67cf",//特色创客空间建设项目分类ID
  243. tit:this.wordData['projectName'],//项目名称
  244. radio:this.wordData['radio'],//项目分组
  245. checkList:JSON.stringify(this.wordData['checkList']),//优先支持项目
  246. schoolRadio:this.wordData['schoolRadio'],//美丽校园改造项目
  247. applyParsonRadio:this.wordData['applyParsonRadio'],//项 目 申 请 人
  248. applyParsonName:this.wordData['applyParsonName'],//申请人姓名
  249. cid:this.wordData['college'],//学院ID,
  250. tel:this.wordData['tel'],//联系电话
  251. beh:this.wordData['beginTime'],//项目开始时间,
  252. planEnd:this.wordData['endTime'],//计划完成时间,
  253. cs:JSON.stringify(this.wordData['studentS']),//学生组,
  254. ct:JSON.stringify(this.wordData['teacherS']),//教师组,
  255. bf:this.wordData['brief'],//项目简介
  256. introduce:JSON.stringify(this.wordData['introduce']),//项目详细
  257. mon:JSON.stringify(this.wordData['fund']),//预算经费
  258. f:this.wordData['total'],//总经费
  259. apply:this.wordData['applicationDate'],//申请日期
  260. }
  261. this.ajax
  262. .post(this.$store.state.api+'/studentProjectWordApply',pram)
  263. .then(result=>{
  264. console.log(result);
  265. if(result['data']==1){
  266. this.$message.success("项目提交成功");
  267. //提交项目成功,查看sessionStore是否有数据,有则删
  268. if(sessionStorage.getItem("StudentProjectApplyData"))sessionStorage.removeItem('StudentProjectApplyData');
  269. this.$router.push('/projectApplication')
  270. }else{
  271. this.$message.error("项目提交失败");
  272. }
  273. },err=>{
  274. console.log(err);
  275. }).catch(err=>{
  276. console.log(err);
  277. })
  278. })
  279. }
  280. },
  281. mounted(){
  282. if(sessionStorage.getItem('StudentProjectApplyData'))this.wordData = JSON.parse(sessionStorage.getItem('StudentProjectApplyData'))
  283. },
  284. beforeRouteLeave (to, from, next) {
  285. //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
  286. if(!this.submitHint)sessionStorage.setItem('StudentProjectApplyData',JSON.stringify(this.wordData));
  287. next();
  288. }
  289. };
  290. </script>
  291. <style lang="less" scoped>
  292. </style>