newStudentProjectApply.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <!-- 测试上传组件 -->
  3. <div v-loading="loading">
  4. <div class="pAHeader">
  5. <div class="pAHeader1">创客项目申请</div>
  6. </div>
  7. <hr>
  8. <!-- 学生项目立项 -->
  9. <studentProjectWord ref="pdf" :wordData="wordData" :reversedMessage="reversedMessage"/>
  10. <div style="position: fixed;bottom: 5%;right: 2%;">
  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. ],
  63. teacherS:[
  64. {name:'',collage:'',work:''},
  65. {name:'',collage:'',work:''},
  66. ],
  67. brief:'',
  68. introduce:{
  69. back:'',
  70. innovate:'',
  71. path:'',
  72. scene:'',
  73. worth:'',
  74. team:'',
  75. cost:'',
  76. expectResults:'',
  77. expectResultsTeacher:'',
  78. expectConversion:'',
  79. plan:''
  80. },
  81. total:'',
  82. fund:{
  83. facility:'',
  84. materials:'',
  85. process:'',
  86. assist:'',
  87. authenticate:'',
  88. match:'',
  89. activity:'',
  90. affair:''
  91. }
  92. }
  93. };
  94. },
  95. computed:{
  96. reversedMessage: function () {
  97. 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)
  98. }
  99. },
  100. methods:{
  101. test(){ //验证
  102. const cEmpty = /^\s*$/g;
  103. for (let i in this.wordData){
  104. // console.log(this.wordData[i],i);
  105. switch(i){
  106. case 'projectName':
  107. if (cEmpty.test(this.wordData[i])) {
  108. this.$message.error('请输入项目名称')
  109. // this.$refs.projectName.style.background='rgb(236, 141, 141)'
  110. // setTimeout(() => {
  111. // this.$refs.projectName.style.background='#ffffff'
  112. // }, 2000);
  113. document.querySelector('#projectName').scrollIntoView({ behavior: "smooth" });
  114. return false
  115. }
  116. break;
  117. case 'radio':
  118. if (cEmpty.test(this.wordData[i])) {
  119. this.$message.error('请选择项目分组')
  120. document.querySelector('#radio').scrollIntoView({ behavior: "smooth" });
  121. return false
  122. }
  123. break;
  124. case 'checkList':
  125. if (this.wordData[i].length==0) {
  126. this.$message.error('优先支持项目')
  127. document.querySelector('#checkList').scrollIntoView({ behavior: "smooth" });
  128. return false
  129. }
  130. break;
  131. case 'schoolRadio':
  132. if (cEmpty.test(this.wordData[i])) {
  133. this.$message.error('请选择美丽校园改造项目')
  134. document.querySelector('#schoolRadio').scrollIntoView({ behavior: "smooth" });
  135. return false
  136. }
  137. break;
  138. case 'applyParsonRadio':
  139. if (cEmpty.test(this.wordData[i])) {
  140. this.$message.error('请选择项目申请人')
  141. document.querySelector('#applyParsonRadio').scrollIntoView({ behavior: "smooth" });
  142. return false
  143. }
  144. break;
  145. case 'applyParsonName':
  146. if (cEmpty.test(this.wordData[i])) {
  147. this.$message.error('请填写申请人姓名')
  148. document.querySelector('#applyParsonName').scrollIntoView({ behavior: "smooth" });
  149. return false
  150. }
  151. break;
  152. case 'college':
  153. if (cEmpty.test(this.wordData[i])) {
  154. this.$message.error('请选择所在学院')
  155. document.querySelector('#applyParsonName').scrollIntoView({ behavior: "smooth" });
  156. return false
  157. }
  158. break;
  159. case 'tel':
  160. if (cEmpty.test(this.wordData[i])) {
  161. this.$message.error('请填写联系方式')
  162. document.querySelector('#applyParsonName').scrollIntoView({ behavior: "smooth" });
  163. return false
  164. }
  165. break;
  166. case 'beginTime':
  167. if (cEmpty.test(this.wordData[i])) {
  168. this.$message.error('请选择项目起始时间')
  169. document.querySelector('#beginTime').scrollIntoView({ behavior: "smooth" });
  170. return false
  171. }
  172. break;
  173. case 'endTime':
  174. if (cEmpty.test(this.wordData[i])) {
  175. this.$message.error('请选择计划完成时间')
  176. document.querySelector('#beginTime').scrollIntoView({ behavior: "smooth" });
  177. return false
  178. }
  179. break;
  180. case 'studentS':
  181. let snum = 0;
  182. this.wordData[i].forEach(item=>{
  183. if(cEmpty.test(item['name']))snum++;
  184. // for(let j in item){
  185. // if(cEmpty.test(item[j])){
  186. // snum++;
  187. // }
  188. // }
  189. })
  190. if(snum>0){
  191. this.$message.error("学生姓名请不要留空");
  192. document.querySelector('#studentS').scrollIntoView({ behavior: "smooth" });
  193. return false;
  194. }
  195. // }
  196. break;
  197. case 'teacherS':
  198. let num = 0;
  199. this.wordData[i].forEach(item=>{
  200. if(cEmpty.test(item['name']))num++;
  201. // for(let j in item){
  202. // if(cEmpty.test(item[j])){
  203. // num++;
  204. // }
  205. // }
  206. })
  207. if(num>0){
  208. this.$message.error("老师姓名请不要留空");
  209. document.querySelector('#teacherS').scrollIntoView({ behavior: "smooth" });
  210. return false;
  211. }
  212. break;
  213. // case 'brief':
  214. // if (cEmpty.test(this.wordData[i])) {
  215. // this.$message.error('请填写项目简介')
  216. // // this.$refs.brief.style.background='rgb(236, 141, 141)'
  217. // // setTimeout(() => {
  218. // // this.$refs.brief.style.background='#ffffff'
  219. // // }, 2000);
  220. // document.querySelector('#brief').scrollIntoView({ behavior: "smooth" });
  221. // return false
  222. // }
  223. // break;
  224. case 'fund':
  225. 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
  226. if(mon==0){
  227. document.querySelector('#fund').scrollIntoView({ behavior: "smooth" });
  228. return this.$message.error('请输入经费')
  229. }
  230. break;
  231. }
  232. }
  233. 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
  234. this.submitHint=true;
  235. },
  236. submitWord(){ //提交
  237. getProjectNo("XM").then((result)=>{
  238. let pram = {
  239. uid:this.$store.state.userInfo.userid,//用户ID
  240. pNo:result,//项目编号
  241. tid:"5e21b204-c206-11ed-a4cd-509a4c5b67cf",//特色创客空间建设项目分类ID
  242. tit:this.wordData['projectName'],//项目名称
  243. radio:this.wordData['radio'],//项目分组
  244. checkList:JSON.stringify(this.wordData['checkList']),//优先支持项目
  245. schoolRadio:this.wordData['schoolRadio'],//美丽校园改造项目
  246. applyParsonRadio:this.wordData['applyParsonRadio'],//项 目 申 请 人
  247. applyParsonName:this.wordData['applyParsonName'],//申请人姓名
  248. cid:this.wordData['college'],//学院ID,
  249. tel:this.wordData['tel'],//联系电话
  250. beh:this.wordData['beginTime'],//项目开始时间,
  251. planEnd:this.wordData['endTime'],//计划完成时间,
  252. cs:JSON.stringify(this.wordData['studentS']),//学生组,
  253. ct:JSON.stringify(this.wordData['teacherS']),//教师组,
  254. bf:this.wordData['brief'],//项目简介
  255. introduce:JSON.stringify(this.wordData['introduce']),//项目详细
  256. mon:JSON.stringify(this.wordData['fund']),//预算经费
  257. f:this.wordData['total'],//总经费
  258. apply:this.wordData['applicationDate'],//申请日期
  259. mem:this.wordData['studentS'].length+this.wordData['teacherS'].length,//项目组人数
  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>