makerActvityApplyMain.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <!-- 创客创新-活动申请 -->
  3. <div>
  4. <makerActvityApply :data="makerActvityApplyData" :checkProjectMoney="checkProjectMoney" :checkPhone="checkPhone" :next="next" v-if="status==0" />
  5. <makerActvityApply2 :data="makerActvityApply2Data" :activityName="makerActvityApplyData.select.activityName" :check="check" :submit="submit" :back="back" v-if="status==1" />
  6. </div>
  7. </template>
  8. <script>
  9. import makerActvityApply from './makerActvityApply.vue';
  10. import makerActvityApply2 from './makerActvityApply2.vue';
  11. export default {
  12. components:{makerActvityApply,makerActvityApply2},
  13. data() {
  14. return {
  15. status:0,
  16. makerActvityApplyData:{
  17. select:{
  18. activityName:'',
  19. pid:"",
  20. leader:'',
  21. tel:'',
  22. time:'',
  23. fund:0,
  24. people:0,
  25. value:'',
  26. teacher:[],
  27. introduce:'',
  28. },
  29. class:[],
  30. project:[],
  31. },
  32. makerActvityApply2Data:["","","","",]
  33. }
  34. },
  35. methods:{
  36. next(){
  37. if(this.status>=1) return
  38. this.status++
  39. },
  40. back(){
  41. if(this.status==0) return
  42. this.status--
  43. },
  44. submit(){
  45. let data1 = this.makerActvityApplyData.select;
  46. let param = {
  47. uid:this.$store.state.userInfo.userid,
  48. tit:data1['activityName'],
  49. con:data1['introduce'],
  50. leader:data1['leader'],
  51. money:data1['fund'],
  52. students:data1['people'],
  53. teacher:JSON.stringify(data1['teacher']),
  54. chapters:JSON.stringify(this.makerActvityApply2Data),
  55. pid:data1['pid'],
  56. cid:data1['value'],
  57. phone:data1['tel'],
  58. beginTime:JSON.stringify(data1['time']),
  59. }
  60. this.ajax.post(this.$store.state.api+"/CreateActivity",param).then(res=>{
  61. if(res.data==1){
  62. this.$message({message:"创建创客活动成功!",type:"success"})
  63. this.$router.push("/makerActvity")
  64. }else{
  65. this.$message.error(`创建创客活动失败:${res.data}`);
  66. }
  67. console.log(res)
  68. }).catch(err=>{
  69. this.$message.error(err.message);
  70. })
  71. },
  72. getAllClass(){
  73. this.ajax.get(this.$store.state.api+"/SelectAllDepartment",{
  74. uid:this.$store.state.userInfo.userid,
  75. }).then(res=>{
  76. this.makerActvityApplyData.class = res.data[0];
  77. }).catch(err=>{
  78. this.$message.error(err.message)
  79. })
  80. },
  81. getProject(){
  82. this.ajax.get(this.$store.state.api+"/GetAllProjectName",{
  83. uid:this.$store.state.userInfo.userid,
  84. }).then(res=>{
  85. console.log(res.data[0])
  86. this.makerActvityApplyData.project = res.data[0].filter(item=>item.endProject==0);
  87. }).catch(err=>{
  88. this.$message.error(err.message)
  89. })
  90. },
  91. check(){
  92. let checkData = {...this.makerActvityApplyData.select,...this.makerActvityApply2Data}
  93. const cEmpty = /^\s*$/g;
  94. for(let i in checkData){
  95. switch(i){
  96. // case "0":
  97. // if(cEmpty.test(checkData[i]))return this.$message.error("活动计划不能为空");
  98. // break;
  99. // case "1":
  100. // if(cEmpty.test(checkData[i]))return this.$message.error("预期目标不能为空");
  101. // break;
  102. // case "2":
  103. // if(cEmpty.test(checkData[i]))return this.$message.error("活动受面不能为空");
  104. // break;
  105. // case "3":
  106. // if(cEmpty.test(checkData[i]))return this.$message.error("经费支出计划不能为空");
  107. // break;
  108. case "activityName":
  109. if(cEmpty.test(checkData[i]))return this.$message.error("活动名称不能为空");
  110. break;
  111. case "teacher":
  112. if(checkData[i].length==0)return this.$message.error("请添加至少一名指导老师")
  113. break;
  114. case "fund":
  115. break;
  116. case "people":
  117. break;
  118. case "leader":
  119. if(cEmpty.test(checkData[i]))return this.$message.error("负责人不能为空");
  120. break;
  121. case "pid":
  122. if(cEmpty.test(checkData[i]))return this.$message.error("请选择所属项目");
  123. break;
  124. case "tel":
  125. if(cEmpty.test(checkData[i]))return this.$message.error("电话号码不能为空");
  126. if(!this.checkPhone(checkData[i]))return;
  127. break;
  128. case "time":
  129. if(checkData[i].length<2)return this.$message.error("请选择项目开始时间");
  130. break;
  131. case "value":
  132. if(cEmpty.test(checkData[i]))return this.$message.error("请选择所在部门");
  133. break;
  134. // case "introduce":
  135. // if(cEmpty.test(checkData[i]))return this.$message.error("活动介绍不能为空");
  136. // break;
  137. }
  138. }
  139. return 1;
  140. },
  141. checkPhone(val){
  142. if(/^\s*$/g.test(val))return;
  143. const cPhone = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/
  144. if(!cPhone.test(val)){
  145. this.$message.error("电话号码格式不正确");
  146. return false;
  147. }
  148. return true;
  149. },
  150. checkProjectMoney(pid,aMoney){
  151. if(aMoney==0){
  152. return 1;
  153. }else if(/^\s*$/g.test(pid) && aMoney!=0){
  154. this.makerActvityApplyData.select.fund = 0;
  155. return this.$message.info("请先选择所属项目");
  156. } else if(!/^\s*$/g.test(pid) && aMoney!=0){
  157. this.ajax.get(this.$store.state.api+"/GetAllActivityMoneyByProjectId",{
  158. uid:this.$store.state.userInfo.userid,
  159. projectid:pid
  160. }).then(res=>{
  161. console.log(res.data)
  162. let PMoney = res.data[0][0]['PMoney'];
  163. let AMoney = res.data[1][0]["AMoney"];
  164. if(PMoney<(AMoney+aMoney)){
  165. this.makerActvityApplyData.select.fund = PMoney-AMoney;
  166. return this.$message.warning(`项目预算不足,项目预算只剩:${PMoney-AMoney}`);
  167. }else{
  168. return 1;
  169. }
  170. }).catch(err=>{
  171. console.log(err)
  172. })
  173. }
  174. }
  175. },
  176. mounted() {
  177. //获取部门
  178. this.getAllClass();
  179. //获取项目
  180. this.getProject();
  181. },
  182. }
  183. </script>
  184. <style lang="less">
  185. .back{ //返回按钮
  186. padding-top: 15px;
  187. color: #000;
  188. cursor: pointer;
  189. }
  190. .pAmid{
  191. position: absolute;
  192. top: 20px;
  193. width: 100%;
  194. display: flex;
  195. justify-content: center;
  196. background: #e6eaf0;
  197. box-sizing: border-box;
  198. // padding-bottom: 30px;
  199. .left{
  200. width: 10%;
  201. min-width: 130px;
  202. height: 800px;
  203. background: #32455b;
  204. display: flex;
  205. border-radius: 5px;
  206. justify-content: center;
  207. margin-right: 2%;
  208. .leftTits{
  209. display: flex;
  210. flex-direction: column;
  211. margin: 47px 0 0 15px;
  212. span{
  213. cursor: pointer;
  214. color: #fff;
  215. margin-bottom: 30px;
  216. }
  217. span:hover{
  218. color: #ccc;
  219. }
  220. }
  221. .sx{
  222. margin-top: 50px;
  223. width: 1px;
  224. height: 400px;
  225. background: #84888d;
  226. .qiu{
  227. width: 10px;
  228. height: 10px;
  229. background: #fff;
  230. border-radius: 50px;
  231. margin-left: -4.5px;
  232. }
  233. }
  234. }
  235. .right{
  236. width: 83%;
  237. background: #fff;
  238. box-sizing: border-box;
  239. padding: 20px 20px;
  240. margin-bottom: 30px;
  241. border-radius: 5px;
  242. .pAHeader{
  243. width: 85%;
  244. display: flex;
  245. justify-content:space-between;
  246. .pAHeader1{
  247. width: 200px;
  248. font-weight: 600;
  249. font-size: 22px;
  250. flex-shrink: 0;
  251. }
  252. .pAHeader2{
  253. padding-top: 15px;
  254. color: #000;
  255. cursor: pointer;
  256. }
  257. }
  258. }
  259. }
  260. </style>