Ei kuvausta

projectNew.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Created by TT on 2017/8/15.
  3. */
  4. ;
  5. spa_define(function () {
  6. return $.use(["spa", "util", "form"], function (spa, util, fb) {
  7. return {
  8. modal: function (data) {
  9. var root = spa.findInModal(".sys_professornew_project");
  10. var form = fb.build(root.find(".newForm"));
  11. var date = new Date(),
  12. month = date.getMonth() + 1,
  13. myDate = "" + date.getFullYear() + (month > 9 ? month : ("0" + month));
  14. var saveBtn = root.find(".opt-save"),
  15. save = function () {
  16. if (form.val().name) {
  17. var name = trim(form.val().name);
  18. if (name.length > 50) {
  19. util.alert("项目名称不得超过50个字");
  20. return;
  21. }
  22. } else {
  23. util.alert("请填写项目名称");
  24. return;
  25. }
  26. if (form.val().descp) {
  27. var descp = trim(form.val().descp);
  28. if (descp.length > 200) {
  29. util.alert("项目描述不得超过200个字");
  30. return;
  31. }
  32. }
  33. if (!form.val().startMonth && form.val().stopMonth) {
  34. util.alert("没有选择开始时间");
  35. return;
  36. }
  37. if(form.val().stopMonth == "至今"){
  38. form.val().stopMonth = "";
  39. }
  40. form.val({professorId:data.data})
  41. form.doPost("../ajax/project",function () {
  42. spa.closeModal();
  43. if (data.hand){
  44. data.hand();
  45. }
  46. })
  47. };
  48. root.find(".modal-ctrl .icon-times").on("click", function () {
  49. spa.closeModal();
  50. });
  51. saveBtn.on("click", save);
  52. function trim(str) { //删除左右两端的空格   
  53. return str.replace(/(^\s*)|(\s*$)/g, "");
  54. }
  55. }
  56. }
  57. });
  58. });