MakerSpaceApply.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <!-- 项目立项申请 -->
  3. <div id="MakerSpaceApply" v-loading="loading">
  4. <div class="pAHeader">
  5. <div class="pAHeader1">创客空间申请</div>
  6. </div>
  7. <hr />
  8. <MakerSpaceWord :wordData="wordData" :reversedMessage="reversedMessage" />
  9. <div style="position: fixed; bottom: 5%; right: 2%">
  10. <el-button @click="saveDraft" type="primary">保存草稿</el-button>
  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. >
  19. <div class="deleteContent">
  20. 确定提交“{{ wordData["projectName"] }}”项目吗?
  21. </div>
  22. <span slot="footer" class="dialog-footer">
  23. <el-button type="primary" @click="applyProject" class="AllDialogBtn"
  24. >确认提交</el-button
  25. >
  26. <el-button @click="submitHint = false" class="AllDialogBtn"
  27. >取消</el-button
  28. >
  29. </span>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. import { getNowDate } from "@/components/tool/Date.js";
  35. import getProjectNo from "@/components/tool/getProjectNo";
  36. import MakerSpaceWord from "./components/MakerSpaceWord.vue";
  37. export default {
  38. components: { MakerSpaceWord },
  39. data() {
  40. return {
  41. wordData: {
  42. applicationDate: getNowDate(1), //申请日期
  43. projectName: "", //项目名称
  44. college: "", //所在学院
  45. begin_at: "", //项目开始时间
  46. state: "", //项目状态
  47. plannedEnd_at: "", //计划完成时间
  48. pro_leader: "", //项目负责人
  49. lead_leader: "", //学院牵头领导
  50. teacher: [
  51. {
  52. name: "",
  53. speciality: "",
  54. title: "",
  55. education: "",
  56. section: "",
  57. work: "",
  58. },
  59. ], //教师组//name:姓名 speciality:专业 title:职称 education:学历 section:所在教研室 work:项目组角色分工
  60. student: [{ name: "", class: "", age: "", work: "" }], //学生组//name:姓名 class:班级 age:年龄 work:项目组任务分工
  61. brief: "", //项目简介
  62. Construction: "", //建设内容
  63. ProjectBasis: "", //立项依据
  64. development: "", //创客空间物理环境、制度建设及软件设施建设情况
  65. studio: "", //学生创客工作室建设情况
  66. studentTeam: "", //学生创客团队(人才)培养预期成果、数量
  67. studentActivities: "", //学生创客活动组织实施情况
  68. Transforming: "", //学生创客团队孵化、转化创业项目情况
  69. condition: "", //立 项基 础及条 件
  70. total: "",
  71. fund: {
  72. device: "",
  73. Material: "",
  74. processing: "",
  75. Collaboration: "",
  76. APPRAISAL: "",
  77. entery: "",
  78. activities: "",
  79. Transaction: "",
  80. }, //预算经费
  81. //total:总经费
  82. //小型仪器设备费:device deviceRemarks
  83. //材料费:Material MaterialRemarks
  84. //测试化验加工费:processing processingRemarks
  85. //项目协作费:Collaboration CollaborationRemarks
  86. //项目成果鉴定费:APPRAISAL APPRAISALRemarks
  87. //参展参赛费:entery enteryRemarks
  88. //创客交流活动费:activities activitiesRemarks
  89. //知识产权事务费:Transaction TransactionRemarks
  90. },
  91. loading: false,
  92. submitHint: false,
  93. };
  94. },
  95. methods: {
  96. test() {
  97. //项目提交
  98. //检查各个字段
  99. const cEmpty = /^\s*$/g;
  100. for (let i in this.wordData) {
  101. switch (i) {
  102. case "projectName":
  103. if (cEmpty.test(this.wordData[i])) {
  104. this.$message.error("请输入项目名称");
  105. document
  106. .querySelector("#one")
  107. .scrollIntoView({ behavior: "smooth" });
  108. return false;
  109. }
  110. break;
  111. case "college":
  112. if (cEmpty.test(this.wordData[i])) {
  113. this.$message.error("请选择所在学院");
  114. document
  115. .querySelector("#one")
  116. .scrollIntoView({ behavior: "smooth" });
  117. return false;
  118. }
  119. break;
  120. case "state":
  121. if (cEmpty.test(this.wordData[i])) {
  122. this.$message.error("请选择项目状态");
  123. document
  124. .querySelector("#two")
  125. .scrollIntoView({ behavior: "smooth" });
  126. return false;
  127. }
  128. break;
  129. case "begin_at":
  130. if (cEmpty.test(this.wordData[i])) {
  131. this.$message.error("请选择项目开始时间");
  132. document
  133. .querySelector("#three")
  134. .scrollIntoView({ behavior: "smooth" });
  135. return false;
  136. }
  137. break;
  138. case "plannedEnd_at":
  139. if (cEmpty.test(this.wordData[i])) {
  140. this.$message.error("请选择计划完成时间");
  141. document
  142. .querySelector("#three")
  143. .scrollIntoView({ behavior: "smooth" });
  144. return false;
  145. }
  146. break;
  147. case "pro_leader":
  148. if (cEmpty.test(this.wordData[i])) {
  149. this.$message.error("请输入项目负责人");
  150. document
  151. .querySelector("#four")
  152. .scrollIntoView({ behavior: "smooth" });
  153. return false;
  154. }
  155. break;
  156. case "lead_leader":
  157. if (cEmpty.test(this.wordData[i])) {
  158. this.$message.error("请输入学院牵头领导");
  159. document
  160. .querySelector("#four")
  161. .scrollIntoView({ behavior: "smooth" });
  162. return false;
  163. }
  164. break;
  165. // case "teacher":
  166. // if (this.wordData[i].length < 3) {
  167. // this.$message.error("教师团队应3人以上");
  168. // document
  169. // .querySelector("#five")
  170. // .scrollIntoView({ behavior: "smooth" });
  171. // return false;
  172. // } else {
  173. // let num = 0;
  174. // this.wordData[i].forEach((item) => {
  175. // if (cEmpty.test(item["name"])) num++;
  176. // });
  177. // if (num > 0) {
  178. // this.$message.error("教师姓名请不要留空");
  179. // document
  180. // .querySelector("#five")
  181. // .scrollIntoView({ behavior: "smooth" });
  182. // return false;
  183. // }
  184. // // }
  185. // break;
  186. // case "student":
  187. // if (this.wordData[i].length < 5) {
  188. // this.$message.error("学生团队应5人以上");
  189. // document
  190. // .querySelector("#six")
  191. // .scrollIntoView({ behavior: "smooth" });
  192. // return false;
  193. // } else {
  194. // let num1 = 0;
  195. // this.wordData[i].forEach((item) => {
  196. // if (cEmpty.test(item["name"])) num1++;
  197. // });
  198. // if (num1 > 0) {
  199. // this.$message.error("学生姓名请不要留空");
  200. // document
  201. // .querySelector("#six")
  202. // .scrollIntoView({ behavior: "smooth" });
  203. // return false;
  204. // }
  205. // // }
  206. // break;
  207. case "fund":
  208. let sum = 0;
  209. for (let i in this.wordData["fund"]) {
  210. sum += this.wordData["fund"][i] * 1;
  211. }
  212. if (sum <= 0) {
  213. document
  214. .querySelector("#fund")
  215. .scrollIntoView({ behavior: "smooth" });
  216. return this.$message.error("请输入预算经费");
  217. }
  218. break;
  219. case "brief":
  220. if (this.wordData[i].length > 300 || this.wordData[i].length == 0) {
  221. this.$message.error("请填写项目简介,字数在300字以内");
  222. document
  223. .querySelector("#brief")
  224. .scrollIntoView({ behavior: "smooth" });
  225. return false;
  226. }
  227. break;
  228. //#region
  229. // case "brief":
  230. // if(cEmpty.test(this.wordData[i])){
  231. // this.$message.error("请填写项目简介");
  232. // document.querySelector('#seven').scrollIntoView({ behavior: "smooth" });
  233. // return false;
  234. // }else{
  235. // if(this.wordData[i].length<200||this.wordData>300){
  236. // this.$message.error("项目简介需要200-300字")
  237. // document.querySelector('#seven').scrollIntoView({ behavior: "smooth" });
  238. // return false;
  239. // }
  240. // }
  241. // break;
  242. // case "Construction":
  243. // if(cEmpty.test(this.wordData[i])){
  244. // this.$message.error("请填写建设内容");
  245. // document.querySelector('#eight').scrollIntoView({ behavior: "smooth" });
  246. // return false;
  247. // }
  248. // break;
  249. // case "ProjectBasis":
  250. // if(cEmpty.test(this.wordData[i])){
  251. // this.$message.error("请填写立项依据");
  252. // document.querySelector('#nine').scrollIntoView({ behavior: "smooth" });
  253. // return false;
  254. // }
  255. // break;
  256. // case "development":
  257. // if(cEmpty.test(this.wordData[i])){
  258. // this.$message.error("请填写创客空间物理环境、制度建设及软件设施建设情况");
  259. // document.querySelector('#ten').scrollIntoView({ behavior: "smooth" });
  260. // return false;
  261. // }
  262. // break;
  263. // case "studio":
  264. // if(cEmpty.test(this.wordData[i])){
  265. // this.$message.error("请填写学生创客工作室建设情况");
  266. // document.querySelector('#eleven').scrollIntoView({ behavior: "smooth" });
  267. // return false;
  268. // }
  269. // break;
  270. // case "studentTeam":
  271. // if(cEmpty.test(this.wordData[i])){
  272. // this.$message.error("请填写学生创客团队(人才)培养预期成果、数量");
  273. // document.querySelector('#twelve').scrollIntoView({ behavior: "smooth" });
  274. // return false;
  275. // }
  276. // break;
  277. // case "studentActivities":
  278. // if(cEmpty.test(this.wordData[i])){
  279. // this.$message.error("请填写学生创客活动组织实施情况");
  280. // document.querySelector('#thirteen').scrollIntoView({ behavior: "smooth" });
  281. // return false;
  282. // }
  283. // break;
  284. // case "Transforming":
  285. // if(cEmpty.test(this.wordData[i])){
  286. // this.$message.error("请填写学生创客团队孵化、转化创业项目情况");
  287. // document.querySelector('#fourteen').scrollIntoView({ behavior: "smooth" });
  288. // return false;
  289. // }
  290. // break;
  291. // case "condition":
  292. // if(cEmpty.test(this.wordData[i])){
  293. // this.$message.error("请填写基础条件");
  294. // document.querySelector('#fifteen').scrollIntoView({ behavior: "smooth" });
  295. // return false;
  296. // }
  297. // break
  298. //#endregion
  299. }
  300. }
  301. this.wordData["total"] =
  302. this.wordData.fund.device * 1 +
  303. this.wordData.fund.Material * 1 +
  304. this.wordData.fund.processing * 1 +
  305. this.wordData.fund.Collaboration * 1 +
  306. this.wordData.fund.APPRAISAL * 1 +
  307. this.wordData.fund.entery * 1 +
  308. this.wordData.fund.activities * 1 +
  309. this.wordData.fund.Transaction * 1;
  310. console.log(this.wordData["total"]);
  311. this.submitHint = true;
  312. },
  313. applyProject() {
  314. //先获取编号
  315. getProjectNo("XM").then((result) => {
  316. let pram = {
  317. uid: this.$store.state.userInfo.userid, //用户ID
  318. pNo: result, //项目编号
  319. tit: this.wordData["projectName"], //项目名称
  320. bf: this.wordData["brief"], //项目简介
  321. pLeader: this.wordData["pro_leader"], //项目负责人
  322. lLeader: this.wordData["lead_leader"], //学院牵头领导,
  323. cid: this.wordData["college"], //学院ID,
  324. ct: JSON.stringify(this.wordData["teacher"]), //教师组,
  325. cs: JSON.stringify(this.wordData["student"]), //学生组,
  326. f: this.wordData["total"], //总经费
  327. chp: JSON.stringify({
  328. Construction: this.wordData["Construction"], //建设内容
  329. ProjectBasis: this.wordData["ProjectBasis"], //立项依据
  330. development: this.wordData["development"], //创客空间物理环境、制度建设及软件设施建设情况
  331. studio: this.wordData["studio"], //学生创客工作室建设情况
  332. studentTeam: this.wordData["studentTeam"], //学生创客团队(人才)培养预期成果、数量
  333. studentActivities: this.wordData["studentActivities"], //学生创客活动组织实施情况
  334. Transforming: this.wordData["Transforming"], //学生创客团队孵化、转化创业项目情况
  335. condition: this.wordData["condition"], //立 项基 础及条 件
  336. }).replaceAll(/%/g, "%25"), //项目详细
  337. tid: "5f7a66d5-c206-11ed-a4cd-509a4c5b67cf", //特色创客空间建设项目分类ID
  338. tName: this.wordData["state"], //项目状态
  339. mon: JSON.stringify(this.wordData["fund"]), //预算经费
  340. planEnd: this.wordData["plannedEnd_at"], //计划完成时间,
  341. beh: this.wordData["begin_at"], //项目开始时间,
  342. apply: this.wordData["applicationDate"], //申请日期
  343. members:
  344. this.wordData["student"].length + this.wordData["teacher"].length,
  345. };
  346. // return console.log(pram);
  347. this.ajax
  348. .post(this.$store.state.api + "/MakerSpaceWordApply", pram)
  349. .then(async (result) => {
  350. console.log(result);
  351. if (result["data"] == 1) {
  352. this.$message.success("项目提交成功");
  353. //提交项目成功,查看sessionStore是否有数据,有则删
  354. if (localStorage.getItem(`MakerSpaceApplyData${this.$store.state.userInfo.userid}`))localStorage.removeItem(`MakerSpaceApplyData${this.$store.state.userInfo.userid}`);
  355. await this.ajax.post(this.$store.state.api+"/delDraft",{userid:this.$store.state.userInfo.userid,type:1})
  356. this.$router.push("/projectApplication");
  357. } else {
  358. this.$message.error("项目提交失败");
  359. }
  360. })
  361. .catch((err) => {
  362. console.log(err);
  363. });
  364. });
  365. },
  366. saveData() {
  367. localStorage.setItem(
  368. `MakerSpaceApplyData${this.$store.state.userInfo.userid}`,
  369. JSON.stringify(this.wordData)
  370. );
  371. },
  372. // 保存草稿
  373. saveDraft(){
  374. if(this.loading)return this.$message.info('请稍等...');
  375. this.loading = true;
  376. let params = {
  377. userid:this.$store.state.userInfo.userid,
  378. type:1,
  379. jsonData:encodeURIComponent(JSON.stringify(this.wordData))
  380. }
  381. this.ajax.post(this.$store.state.api + "/saveDraft",params).then(res=>{
  382. if(res.data==1){
  383. this.$message.success("保存成功")
  384. }else{
  385. this.$message.error("保存失败")
  386. }
  387. this.loading = false;
  388. })
  389. },
  390. //获取草稿
  391. getDraft(){
  392. if(this.loading)return this.$message.info('请稍等...');
  393. this.loading = true;
  394. let params = {
  395. userid:this.$store.state.userInfo.userid,
  396. type:1,
  397. }
  398. this.ajax.get(this.$store.state.api + "/getDraft",params).then(res=>{
  399. if(res.data[0].length){
  400. this.wordData = JSON.parse(res.data[0][0].json)
  401. }else{
  402. if (localStorage.getItem(`MakerSpaceApplyData${this.$store.state.userInfo.userid}`))
  403. this.wordData = JSON.parse(
  404. localStorage.getItem(`MakerSpaceApplyData${this.$store.state.userInfo.userid}`)
  405. );
  406. }
  407. this.loading = false;
  408. })
  409. }
  410. },
  411. computed: {
  412. reversedMessage: function () {
  413. return (
  414. this.wordData.fund.device * 1 +
  415. this.wordData.fund.Material * 1 +
  416. this.wordData.fund.processing * 1 +
  417. this.wordData.fund.Collaboration * 1 +
  418. this.wordData.fund.APPRAISAL * 1 +
  419. this.wordData.fund.entery * 1 +
  420. this.wordData.fund.activities * 1 +
  421. this.wordData.fund.Transaction * 1
  422. );
  423. },
  424. },
  425. mounted() {
  426. //跳转到此页面立刻获取数据
  427. // this.getData(); //获取表格数据
  428. // this.applyProject();
  429. //判断,如果sessionStore里有MakerSpaceApplyData这个字段,则存到this.wordData里
  430. // if (localStorage.getItem("MakerSpaceApplyData")) {
  431. // this.wordData = JSON.parse(localStorage.getItem("MakerSpaceApplyData"));
  432. // }
  433. this.getDraft();
  434. window.addEventListener("beforeunload", () => this.saveData());
  435. },
  436. beforeRouteLeave(to, from, next) {
  437. //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
  438. if (!this.submitHint)this.saveData()
  439. next();
  440. },
  441. };
  442. </script>
  443. <style lang="less">
  444. #MakerSpaceApply {
  445. display: flex;
  446. flex-direction: column;
  447. // align-items: flex-end;
  448. // justify-content: flex-end;
  449. position: relative;
  450. }
  451. </style>