/// //系统按钮管理 var viewModel = function () { this.id = ""; //初始化表格 this.init = function () { $('#dgbuttons').datagrid({ url: '/SysManager/ButtonList', method: 'get', singleSelect: true, fit: true, striped: true, border: false, rownumbers: true, toolbar: '#toolbar', columns: [[ { field: '图标', title: '图标', width: 40, align: 'center', formatter: function (value, row, index) { return ZLPMS.SetIcons(row.图标, row.颜色) } }, { field: '名称', title: '名称', width: 150 }, { field: '标识', title: '标识', width: 100 }, { field: '启用', title: '启用', width: 100, align: 'center', formatter: function (value, row, index) { return ZLPMS.SetIsActiveIcon(row.启用); } }, { field: '序号', title: '序号', align: 'center', width: 60 }, { field: '颜色', title: '颜色', align: 'center', width: 80 }, { field: '备注', title: '备注', width: 250 } ]], }); //增加 $('#btn-add').click(function () { top.ZLPMS.OpenWindow({ url: '/SysManager/ButtonInfo', title: '增加按钮信息', btn: ['确定', '取消'], area: ['600px', '490px'], yes: function (index, layero) { Forms.Submit(index, layero); }, }); }); //编辑 $('#btn-edit').click(function () { var row = $('#dgbuttons').treegrid('getSelected'); if (row != null) { //打开编辑窗口 top.ZLPMS.OpenWindow({ url: '/SysManager/ButtonInfo/' + row.ID, title: '编辑按钮信息', btn: ['确定', '取消'], area: ['600px', '490px'], yes: function (index, layero) { Forms.Submit(index, layero); }, }); } else { top.ZLPMS.Msg("请选择一行记录后执行操作", 0); } }); //刷新 $('#btn-ref').click(function () { $('#dgbuttons').datagrid('reload'); }); } //绑定数据 this.bindData = function (id) { this.id = id; //加载修改内容 $.ajax({ url: '/SysManager/GetButtonInfo/' + id, method: 'GET', success: function (data) { if (data.code == 200) { var json = JSON.parse(data.obj); $('#ff').form('load', json); //设置值layer设置表单 ZLPMS.SetFormVal('ff', { "isactive": json.Active == 1 ? true : false }); } else { //弹出错误消息 ZLPMS.Alert(data.msg, 1); } } }); } } var Forms = { //表单提交 Submit: function (index, layero) { var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法: var param = iframeWin.Forms.PostData();//调用子页面的方法,得到子页面返回的ids if (param != null) { var url = '/SysManager/PostButtonInfo'; $.post(url, param, function (data) { if (data.code == 200) { top.ZLPMS.CloseWindow(index); top.ZLPMS.Msg(data.msg); //刷新 List.Reload(); } else { ZLPMS.Msg(data.msg, 2); } }); } }, //读取数据 PostData: function () { //执行提交验证 var r = $('#ff').form('validate'); if (r) {//post到后台 var param = ZLPMS.FormToObject('ff'); return param; } return null; } } //列表操作 var List = { //重新加载 Reload: function () { $('#dgbuttons').datagrid('reload'); }, //删除指定的模块菜单 Del: function (id) { } }