Nav apraksta

eduNew.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Created by TT on 2017/7/11.
  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_edu");
  10. var form = fb.build(root.find(".newForm"));
  11. var saveBtn = root.find(".opt-save"),
  12. save = function () {
  13. if (form.val().school) {
  14. var school = trim(form.val().school);
  15. if (school.length > 50) {
  16. util.alert("学校名称不得超过50个字");
  17. return;
  18. }
  19. } else {
  20. util.alert("请填写学校名称");
  21. return;
  22. }
  23. if (form.val().college) {
  24. var college = trim(form.val().college);
  25. if (college.length > 20) {
  26. util.alert("院系名称不得超过20个字");
  27. return;
  28. }
  29. }
  30. if (form.val().major) {
  31. var major = trim(form.val().major);
  32. if (major.length > 20) {
  33. util.alert("专业名称不得超过20个字");
  34. return;
  35. }
  36. }
  37. if (form.val().year) {
  38. form.val({year: form.val().year.substring(0, 4)});
  39. }
  40. form.val({professorId: data.data});
  41. form.doPost("../ajax/edu", 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. });