Keine Beschreibung

jobNew.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_job");
  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().company) {
  17. var company = trim(form.val().company);
  18. if (company.length > 50) {
  19. util.alert("机构名称不得超过50个字");
  20. return;
  21. }
  22. } else {
  23. util.alert("请填写机构名称");
  24. return;
  25. }
  26. if (form.val().title) {
  27. var title = trim(form.val().title);
  28. if (title.length > 50) {
  29. util.alert("职位不得超过50个字");
  30. return;
  31. }
  32. } else {
  33. util.alert("请填写职位");
  34. return;
  35. }
  36. if (form.val().department) {
  37. var department = trim(form.val().department);
  38. if (department.length > 50) {
  39. util.alert("部门名称不得超过50个字");
  40. return;
  41. }
  42. }
  43. if (!form.val().startMonth && form.val().stopMonth) {
  44. util.alert("没有选择开始时间");
  45. return;
  46. }
  47. form.val({professorId:data.data})
  48. form.doPost("../ajax/job",function () {
  49. spa.closeModal();
  50. if (data.hand){
  51. data.hand();
  52. }
  53. })
  54. };
  55. root.find(".modal-ctrl .icon-times").on("click", function () {
  56. spa.closeModal();
  57. });
  58. saveBtn.on("click", save);
  59. function trim(str) { //删除左右两端的空格   
  60. return str.replace(/(^\s*)|(\s*$)/g, "");
  61. }
  62. }
  63. }
  64. });
  65. });