Nenhuma Descrição

role.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ;
  2. spa_define(function() {
  3. return $.use(["spa", "form", "code","util"], function(spa, fb, code,util) {
  4. return {
  5. modal: function(data) {
  6. var userid = data.id;
  7. var root = spa.findInModal(".sys_user_role");
  8. var form = fb.build(root.find(".newForm"));
  9. var cr = code.parseCode(root.find(".role-ctn"));
  10. root.find(".modal-ctrl .icon-times").on("click", function() {
  11. spa.closeModal();
  12. });
  13. root.on("click", ".icon-st-check", function() {
  14. $(this).toggleClass("checked");
  15. });
  16. root.find(".opt-save").on("click", function() {
  17. var ret = [];
  18. root.find(".role-ctn i.checked").each(function() {
  19. ret.push($(this).attr("roleid"));
  20. });
  21. util.post("../ajax/sys/userRole",{userid:userid,role:ret},function(){
  22. spa.closeModal();
  23. });
  24. });
  25. data.roles.forEach(function(item){
  26. item.checked = (data.userRoles.find(function(role){return role.roleid==item.id})?"checked":"");
  27. });
  28. cr.val(data.roles);
  29. form.val({name:data.name,mobile:data.mobile,email:data.email});
  30. }
  31. };
  32. });
  33. });