newStudentProjectApply.vue 14 KB

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