Nenhuma Descrição

honorNew.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_honor");
  10. var form = fb.build(root.find(".newForm"));
  11. var saveBtn = root.find(".opt-save"),
  12. save = function () {
  13. if (form.val().name) {
  14. var name = trim(form.val().name);
  15. if (name.length > 50) {
  16. util.alert("奖项名称不得超过50个字");
  17. return;
  18. }
  19. } else {
  20. util.alert("请填写奖项名称");
  21. return;
  22. }
  23. if (form.val().descp) {
  24. var descp = trim(form.val().descp);
  25. if (descp.length > 200) {
  26. util.alert("项目描述不得超过200个字");
  27. return;
  28. }
  29. }
  30. form.val({professorId: data.data});
  31. form.doPost("../ajax/honor", function () {
  32. spa.closeModal();
  33. if (data.hand) {
  34. data.hand();
  35. }
  36. })
  37. };
  38. root.find(".modal-ctrl .icon-times").on("click", function () {
  39. spa.closeModal();
  40. });
  41. saveBtn.on("click", save);
  42. function trim(str) { //删除左右两端的空格   
  43. return str.replace(/(^\s*)|(\s*$)/g, "");
  44. }
  45. }
  46. }
  47. });
  48. });