説明なし

edit.js 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ;
  2. spa_define(function() {
  3. return $.use(["spa", "form", "code"], function(spa, fb, code) {
  4. return {
  5. modal: function(data) {
  6. var root = spa.findInModal(".sys_role_edit");
  7. var form = fb.build(root.find(".newForm"));
  8. var cr = code.parseCode(root.find(".right-ctn"));
  9. root.find(".modal-ctrl .icon-times").on("click", function() {
  10. spa.closeModal();
  11. });
  12. root.on("click", ".icon-st-check", function() {
  13. $(this).toggleClass("checked");
  14. });
  15. root.find(".opt-save").on("click", function() {
  16. var ret = [];
  17. root.find(".right-ctn i.checked").each(function() {
  18. ret.push(parseInt($(this).attr("right")));
  19. });
  20. form.val({ "auths": ret });
  21. form.doPut("../ajax/sys/role", function() {
  22. spa.closeModal();
  23. if(data.hand) {
  24. data.hand();
  25. }
  26. });
  27. });
  28. data.rights.forEach(function(item) {
  29. item.checked = (data.data.auths.indexOf(item.id) >= 0) ? "checked" : "";
  30. });
  31. cr.val(data.rights);
  32. form.val(data.data);
  33. }
  34. };
  35. });
  36. });