sysmanager.buttons.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /// <reference path="E:\ZLSoft\109-中联开发管理系统\ZLPMS\PMS.WebUI\Content/Scripts/zlpms.js" />
  2. //系统按钮管理
  3. var viewModel = function () {
  4. this.id = "";
  5. //初始化表格
  6. this.init = function () {
  7. $('#dgbuttons').datagrid({
  8. url: '/SysManager/ButtonList',
  9. method: 'get',
  10. singleSelect: true,
  11. fit: true,
  12. striped: true,
  13. border: false,
  14. rownumbers: true,
  15. toolbar: '#toolbar',
  16. columns: [[
  17. { field: '图标', title: '图标', width: 40, align: 'center', formatter: function (value, row, index) { return ZLPMS.SetIcons(row.图标, row.颜色) } },
  18. { field: '名称', title: '名称', width: 150 },
  19. { field: '标识', title: '标识', width: 100 },
  20. { field: '启用', title: '启用', width: 100, align: 'center', formatter: function (value, row, index) { return ZLPMS.SetIsActiveIcon(row.启用); } },
  21. { field: '序号', title: '序号', align: 'center', width: 60 },
  22. { field: '颜色', title: '颜色', align: 'center', width: 80 },
  23. { field: '备注', title: '备注', width: 250 }
  24. ]],
  25. });
  26. //增加
  27. $('#btn-add').click(function () {
  28. top.ZLPMS.OpenWindow({
  29. url: '/SysManager/ButtonInfo',
  30. title: '增加按钮信息',
  31. btn: ['确定', '取消'],
  32. area: ['600px', '490px'],
  33. yes: function (index, layero) {
  34. Forms.Submit(index, layero);
  35. },
  36. });
  37. });
  38. //编辑
  39. $('#btn-edit').click(function () {
  40. var row = $('#dgbuttons').treegrid('getSelected');
  41. if (row != null) {
  42. //打开编辑窗口
  43. top.ZLPMS.OpenWindow({
  44. url: '/SysManager/ButtonInfo/' + row.ID,
  45. title: '编辑按钮信息',
  46. btn: ['确定', '取消'],
  47. area: ['600px', '490px'],
  48. yes: function (index, layero) {
  49. Forms.Submit(index, layero);
  50. },
  51. });
  52. } else {
  53. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  54. }
  55. });
  56. //刷新
  57. $('#btn-ref').click(function () {
  58. $('#dgbuttons').datagrid('reload');
  59. });
  60. }
  61. //绑定数据
  62. this.bindData = function (id) {
  63. this.id = id;
  64. //加载修改内容
  65. $.ajax({
  66. url: '/SysManager/GetButtonInfo/' + id,
  67. method: 'GET',
  68. success: function (data) {
  69. if (data.code == 200) {
  70. var json = JSON.parse(data.obj);
  71. $('#ff').form('load', json);
  72. //设置值layer设置表单
  73. ZLPMS.SetFormVal('ff', { "isactive": json.Active == 1 ? true : false });
  74. } else {
  75. //弹出错误消息
  76. ZLPMS.Alert(data.msg, 1);
  77. }
  78. }
  79. });
  80. }
  81. }
  82. var Forms = {
  83. //表单提交
  84. Submit: function (index, layero) {
  85. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  86. var param = iframeWin.Forms.PostData();//调用子页面的方法,得到子页面返回的ids
  87. if (param != null) {
  88. var url = '/SysManager/PostButtonInfo';
  89. $.post(url, param, function (data) {
  90. if (data.code == 200) {
  91. top.ZLPMS.CloseWindow(index);
  92. top.ZLPMS.Msg(data.msg);
  93. //刷新
  94. List.Reload();
  95. } else {
  96. ZLPMS.Msg(data.msg, 2);
  97. }
  98. });
  99. }
  100. },
  101. //读取数据
  102. PostData: function () {
  103. //执行提交验证
  104. var r = $('#ff').form('validate');
  105. if (r) {//post到后台
  106. var param = ZLPMS.FormToObject('ff');
  107. return param;
  108. }
  109. return null;
  110. }
  111. }
  112. //列表操作
  113. var List = {
  114. //重新加载
  115. Reload: function () {
  116. $('#dgbuttons').datagrid('reload');
  117. },
  118. //删除指定的模块菜单
  119. Del: function (id) {
  120. }
  121. }