Sin Descripción

eduNew.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_userinfo_edu");
  10. var form = fb.build(root.find(".newForm"));
  11. var saveBtn = root.find(".opt-save"),
  12. save = function () {
  13. if (form.val().eduSchool) {
  14. var eduSchool = trim(form.val().eduSchool);
  15. if (eduSchool.length > 50) {
  16. util.alert("学校名称不得超过50个字");
  17. return;
  18. }
  19. } else {
  20. util.alert("请填写学校名称");
  21. return;
  22. }
  23. if (form.val().eduCollege) {
  24. var eduCollege = trim(form.val().eduCollege);
  25. if (eduCollege.length > 20) {
  26. util.alert("院系名称不得超过20个字");
  27. return;
  28. }
  29. }
  30. if (form.val().eduMajor) {
  31. var eduMajor = trim(form.val().eduMajor);
  32. if (eduMajor.length > 20) {
  33. util.alert("专业名称不得超过20个字");
  34. return;
  35. }
  36. }
  37. if (form.val().eduYear) {
  38. form.val({eduYear: form.val().eduYear.substring(0, 4)});
  39. }
  40. var item = form.val();
  41. item.no = data.data.length;
  42. data.data.push(item);
  43. data.hand();
  44. spa.closeModal();
  45. };
  46. root.find(".modal-ctrl .icon-times").on("click", function () {
  47. spa.closeModal();
  48. });
  49. saveBtn.on("click", save);
  50. function trim(str) { //删除左右两端的空格   
  51. return str.replace(/(^\s*)|(\s*$)/g, "");
  52. }
  53. }
  54. }
  55. });
  56. });