Power.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * 展开/关闭
  3. */
  4. $('.tree-list i').on('click', function()
  5. {
  6. if($(this).hasClass('am-icon-plus'))
  7. {
  8. $(this).removeClass('am-icon-plus');
  9. $(this).addClass('am-icon-minus-square');
  10. } else {
  11. $(this).removeClass('am-icon-minus-square');
  12. $(this).addClass('am-icon-plus');
  13. }
  14. $(this).parent().next('.list-find').toggle(100);
  15. });
  16. /**
  17. * 全选/取消
  18. */
  19. $('.node-choice').on('click', function()
  20. {
  21. var state = $(this).is(':checked');
  22. $(this).parents('li').next('.list-find').find('input[type="checkbox"]').each(function()
  23. {
  24. this.checked = state;
  25. });
  26. });
  27. /**
  28. * 子元素选择/取消操作
  29. */
  30. $('.list-find input[type="checkbox"]').on('click', function()
  31. {
  32. var state = ($(this).parents('.list-find').find('input[type="checkbox"]:checked').length > 0);
  33. $(this).parents('ul').prev().find('label input').each(function()
  34. {
  35. this.checked = state;
  36. });
  37. });
  38. /**
  39. * 添加
  40. */
  41. $('.submit-add').on('click', function()
  42. {
  43. // 更改窗口名称
  44. $title = $('#power-save-win').find('.am-popup-title');
  45. $title.text($title.data('add-title'));
  46. // 清空表单
  47. FormDataFill({"id":"", "pid":0, "name":"", "control":"", "action":"", "icon":"", "sort":0, "is_show":1});
  48. // 移除菜单禁止状态
  49. $('form select[name="pid"]').removeAttr('disabled');
  50. // 校验成功状态增加失去焦点
  51. $('form').find('.am-field-valid').each(function()
  52. {
  53. $(this).blur();
  54. });
  55. });
  56. /**
  57. * 编辑
  58. */
  59. $('.submit-edit').on('click', function()
  60. {
  61. // 更改窗口名称
  62. $title = $('#power-save-win').find('.am-popup-title');
  63. $title.text($title.data('edit-title'));
  64. // 父级禁用菜单列表选择
  65. if($(this).data('item') == 'ok')
  66. {
  67. $('form select[name="pid"]').attr('disabled', 'disabled');
  68. } else {
  69. $('form select[name="pid"]').removeAttr('disabled');
  70. }
  71. });