Brak opisu

jobEdit.js 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * Created by TT on 2017/8/14.
  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. if (form.val().startMonth && form.val().stopMonth) {
  48. form.val().startMonth = form.val().startMonth.substring(0, 6);
  49. form.val().stopMonth = form.val().stopMonth.substring(0, 6);
  50. }
  51. form.doPut("../ajax/job",function () {
  52. spa.closeModal();
  53. if (data.hand){
  54. data.hand();
  55. }
  56. },function (data) {
  57. util.alert(data.msg);
  58. })
  59. };
  60. root.find(".modal-ctrl .icon-times").on("click", function () {
  61. spa.closeModal();
  62. });
  63. saveBtn.on("click", save);
  64. form.val(data.data);
  65. if (data.data.stopMonth) {
  66. if (trim(data.data.stopMonth) == "至今") {
  67. form.val({stopMonth: ""});
  68. }
  69. }
  70. function trim(str) {
  71. return str.replace(/(^\s*)|(\s*$)/g, "");
  72. }
  73. }
  74. }
  75. });
  76. });