newStudentProjectApply.vue 13 KB

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