makerActvityApplyMain.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <!-- 创客创新-活动申请 -->
  3. <div class="core_dialogue">
  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. this.makerActvityApplyData.project = res.data[0];
  86. }).catch(err=>{
  87. this.$message.error(err.message)
  88. })
  89. },
  90. check(){
  91. let checkData = {...this.makerActvityApplyData.select,...this.makerActvityApply2Data}
  92. const cEmpty = /^\s*$/g;
  93. for(let i in checkData){
  94. switch(i){
  95. // case "0":
  96. // if(cEmpty.test(checkData[i]))return this.$message.error("活动计划不能为空");
  97. // break;
  98. // case "1":
  99. // if(cEmpty.test(checkData[i]))return this.$message.error("预期目标不能为空");
  100. // break;
  101. // case "2":
  102. // if(cEmpty.test(checkData[i]))return this.$message.error("活动受面不能为空");
  103. // break;
  104. // case "3":
  105. // if(cEmpty.test(checkData[i]))return this.$message.error("经费支出计划不能为空");
  106. // break;
  107. case "activityName":
  108. if(cEmpty.test(checkData[i]))return this.$message.error("活动名称不能为空");
  109. break;
  110. case "teacher":
  111. if(checkData[i].length==0)return this.$message.error("请添加至少一名指导老师")
  112. break;
  113. case "fund":
  114. break;
  115. case "people":
  116. break;
  117. case "leader":
  118. if(cEmpty.test(checkData[i]))return this.$message.error("负责人不能为空");
  119. break;
  120. case "pid":
  121. if(cEmpty.test(checkData[i]))return this.$message.error("请选择所属项目");
  122. break;
  123. case "tel":
  124. if(cEmpty.test(checkData[i]))return this.$message.error("电话号码不能为空");
  125. if(!this.checkPhone(checkData[i]))return;
  126. break;
  127. case "time":
  128. if(checkData[i].length<2)return this.$message.error("请选择项目开始时间");
  129. break;
  130. case "value":
  131. if(cEmpty.test(checkData[i]))return this.$message.error("请选择所在部门");
  132. break;
  133. // case "introduce":
  134. // if(cEmpty.test(checkData[i]))return this.$message.error("活动介绍不能为空");
  135. // break;
  136. }
  137. }
  138. return 1;
  139. },
  140. checkPhone(val){
  141. if(/^\s*$/g.test(val))return;
  142. 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}$/
  143. if(!cPhone.test(val)){
  144. this.$message.error("电话号码格式不正确");
  145. return false;
  146. }
  147. return true;
  148. },
  149. checkProjectMoney(pid,aMoney){
  150. console.log(1111)
  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. let PMoney = res.data[0][0]['PMoney'];
  162. let AMoney = res.data[1][0]["AMoney"];
  163. if(PMoney<(AMoney+aMoney)){
  164. this.makerActvityApplyData.select.fund = PMoney-AMoney;
  165. return this.$message.warning(`项目预算不足,项目预算只剩:${PMoney-AMoney}`);
  166. }else{
  167. return 1;
  168. }
  169. }).catch(err=>{
  170. console.log(err)
  171. })
  172. }
  173. }
  174. },
  175. mounted() {
  176. //获取部门
  177. this.getAllClass();
  178. //获取项目
  179. this.getProject();
  180. },
  181. }
  182. </script>
  183. <style lang="less">
  184. .back{ //返回按钮
  185. padding-top: 15px;
  186. color: #000;
  187. cursor: pointer;
  188. }
  189. .pAmid{
  190. position: absolute;
  191. top: 20px;
  192. width: 100%;
  193. display: flex;
  194. justify-content: center;
  195. background: #e6eaf0;
  196. box-sizing: border-box;
  197. padding-bottom: 30px;
  198. .left{
  199. width: 10%;
  200. min-width: 130px;
  201. height: 800px;
  202. background: #32455b;
  203. display: flex;
  204. border-radius: 5px;
  205. justify-content: center;
  206. margin-right: 2%;
  207. .leftTits{
  208. display: flex;
  209. flex-direction: column;
  210. margin: 47px 0 0 15px;
  211. span{
  212. cursor: pointer;
  213. color: #fff;
  214. margin-bottom: 30px;
  215. }
  216. span:hover{
  217. color: #ccc;
  218. }
  219. }
  220. .sx{
  221. margin-top: 50px;
  222. width: 1px;
  223. height: 400px;
  224. background: #84888d;
  225. .qiu{
  226. width: 10px;
  227. height: 10px;
  228. background: #fff;
  229. border-radius: 50px;
  230. margin-left: -4.5px;
  231. }
  232. }
  233. }
  234. .right{
  235. width: 83%;
  236. background: #fff;
  237. box-sizing: border-box;
  238. padding: 20px 20px;
  239. margin-bottom: 30px;
  240. border-radius: 5px;
  241. .pAHeader{
  242. width: 85%;
  243. display: flex;
  244. justify-content:space-between;
  245. .pAHeader1{
  246. width: 200px;
  247. font-weight: 600;
  248. font-size: 22px;
  249. flex-shrink: 0;
  250. }
  251. .pAHeader2{
  252. padding-top: 15px;
  253. color: #000;
  254. cursor: pointer;
  255. }
  256. }
  257. }
  258. }
  259. </style>