function viewModel() { this.ID = ""; this.loadmenus = function () { //上级目录 $('#parentid').combotree({ url: '/SysManager/GetModuleTree', method: 'GET' }); //清空事件 $('#clear').click(function () { $('#parentid').combotree('clear'); }); $("#nature").combobox({ url: '/Channel/GetChannelnature', valueField: "ID", textField: "名称" }); }, //初始化树形表格 this.init = function () { $("#treegrid").treegrid({ pageSize: 10, url: '/Channel/SearchModuleInfos?search=' +"" , idField: 'ID', treeField: '名称', method: 'GET', fit: true, pageSize:20, toolbar: '#Channeltb', rownumbers: true, //底部显示分页工具栏 pagination: true, //列名称 columns: [[ { field: '状态', title: '状态', width: 60, align: 'center', styler: function (value, row, index) { if (value == '正常') { return 'color:green;font-weight:bold'; } if (value == '终止') { return 'color:red;font-weight:bold'; } } }, { field: '编码', title: '编码', width:40, align: 'center' }, { field: '名称', title: '名称', width: 180 }, { field: '显示名', title: '渠道性质', width: 100, align: 'center' }, //{ field: '简码', title: '简码', width: 80 }, { field: '商务联系人', title: '商务联系人', width: 120 }, { field: '技术联系人', title: '技术联系人', width: 120 }, { field: '电话', title: '电话', width: 100 }, { field: '开始日期', title: '开始日期', width: 100, align: 'center' }, //{ field: '终止日期', title: '终止日期', width: 100 }, { field: '地址', title: '地址', width: 240 }, { field: '备注', title: '备注', width: 160, align: 'center' } ]] }); //新增渠道信息 $('#Channeltbbtn-add').click(function () { top.ZLPMS.OpenWindow({ title: '新增渠道信息', url: '/Channel/ModulePopWindows', area: ['750px', '600px'], yes: function (index, layero) { //提交表单 Forms.Submit(index, layero); } }); }); //修改渠道信息 $('#Channeltbbtn-edit').click(function () { var row = $('#treegrid').treegrid('getSelected'); if (row != null) { top.ZLPMS.OpenWindow({ title: '修改渠道信息', url: '/Channel/ModulePopWindows?id=' + row.ID, area: ['750px', '600px'], yes: function (index, layero) { //提交表单 Forms.Submit(index, layero); } }); } else { top.ZLPMS.Msg("请选择一行记录后执行操作", 0); } }); //删除渠道信息 $('#Channeltbbtn-del').click(function () { var row = $('#treegrid').treegrid('getSelected'); if (row != null) { var data = { 'id': row.ID, 'type': 0 }; //确认删除对话框 top.ZLPMS.Confirm('您确定要删除选中的记录吗?', 3, function () { //执行删除 Doajax(data,1); }); } else { top.ZLPMS.Msg("请选择一行记录后执行操作!") } }); //终止合同 $('#Channeltbbtn-stop').click(function () { var row = $('#treegrid').treegrid('getSelected'); if (row != null) { var data = { 'id': row.ID, 'type': 1 }; Doajax(data,2); } else { top.ZLPMS.Msg("请选择一行记录后执行操作!") } }); //启用 $('#Channeltbbtn-cancel').click(function () { var row = $('#treegrid').treegrid('getSelected'); if (row != null) { var data = { 'id': row.ID, 'type': 2 }; Doajax(data,3); } else { top.ZLPMS.Msg("请选择一行记录后执行操作!") } }); //刷新 $('#Channeltbbtn-ref').click(function () { $("#treegrid").treegrid("reload"); }); //查询 $('#Channeltbbtn-select').click(function () { var search = $('#userAccount').val(); $("#treegrid").treegrid({ pageSize: 10, url: '/Channel/SearchModuleInfos?search=' + search, idField: 'ID', treeField: '名称', method: 'GET', fit: true, pageSize: 20, toolbar: '#Channeltb', rownumbers: true, //底部显示分页工具栏 pagination: true, //列名称 columns: [[ { field: '状态', title: '状态', width: 60, align: 'center', styler: function (value, row, index) { if (value == '正常') { return 'color:green;font-weight:bold'; } if (value == '终止') { return 'color:red;font-weight:bold'; } } }, { field: '编码', title: '编码', width: 40, align: 'center' }, { field: '名称', title: '名称', width: 180 }, { field: '显示名', title: '渠道性质', width: 100, align: 'center' }, { field: '商务联系人', title: '商务联系人', width: 120 }, { field: '技术联系人', title: '技术联系人', width: 120 }, { field: '电话', title: '电话', width: 100 }, { field: '开始日期', title: '开始日期', width: 100, align: 'center' }, { field: '地址', title: '地址', width: 240 }, { field: '备注', title: '备注', width: 160, align: 'center' } ]] }); }) }, this.bindData = function (ID) { this.ID = ID; $.ajax({ url: '/Channel/GetChannelInfo?id=' + ID, method: 'Get', success: function (data) { // 1-直营;2-技术服务中心;3-分公司;4-二级渠道; if (data.code == 200) { $('#ID').val(ID); $('#code').textbox('setValue', data.obj[0].编码); $('#name').textbox('setValue', data.obj[0].名称); $('#brevitycode').textbox('setValue', data.obj[0].简码); $("#startdate").datebox('setValue', data.obj[0].开始日期);//赋值 // $('#endtime').datebox('setValue', data.obj[0].终止日期); $('#phonenumber').textbox('setValue', data.obj[0].电话); $('#business').textbox('setValue', data.obj[0].商务联系人); $('#technology').textbox('setValue', data.obj[0].技术联系人); $('#address').textbox('setValue', data.obj[0].地址); $('#note').textbox('setValue', data.obj[0].备注); //处理云监控通知JSON $('#businessMail').textbox('setValue', data.obj[0].商务联系人邮箱); $('#businessWxin').textbox('setValue', data.obj[0].商务联系人微信); $('#technologyMail').textbox('setValue', data.obj[0].技术联系人邮箱); $('#technologyWxin').textbox('setValue', data.obj[0].技术联系人微信); //设置值 ZLPMS.SetFormVal('ff', { "state": data.obj[0].状态 == 1 ? true : false }); $('#nature').combobox('setValue', data.obj[0].性质); } else { //弹出错误消息 ZLPMS.Alert(data.msg, 1); } } }) }, //新增绑定编码 this.bindCode=function() { $.ajax({ url: '/Channel/ChannelCode', method:'Post', success: function (data) { $('#code').textbox('setValue', data); } }) }, this.Channelbusiness = function () { $.ajax({ url: '/Channel/Channelbusiness', method: 'Post', success: function (data) { $('#code').textbox('setValue', data); } }) } }; //提交表单信息 var Forms = { Submit: function (index, layero) { var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法: //调用子页面的方法,得到子页面返回的ids var param = iframeWin.Forms.PostData(); if (param != null) { if (param["state"] == 'on') { param["state"] = 1; } else { param["state"] = 0; } //6提交表单信息到具体得页面 var url = '/Channel/SaveModulePopWindows'; $.post(url, param, function (data) { if (data.code==200) { top.ZLPMS.CloseWindow(index); top.ZLPMS.Msg("保存成功"); //刷新页面 List.Reload(); } else { ZLPMS.Msg(data.msg, 2); } }); } }, //读取数据 PostData: function () { //执行提交验证 var r = $("#ff").form('validate'); if (r) { var param = ZLPMS.FormToObject('ff'); return param; } return null; } }; //重新刷新页面 7 var List = { //重新加载页面所有信息 Reload: function () { $('#treegrid').treegrid('reload'); } }; //删除,撤销,终止 var Doajax = function (data,s) { $.ajax({ //TextSearchDetail.aspx?searchType=" + searchType + "&Content=" + searchContent url: '/Channel/DelChannelInfo', method: 'GET', data: data, success: function (t) { if (t.code == 200) { if (s == 1) { top.ZLPMS.Msg("删除成功"); //刷新页面 List.Reload(); } if (s == 2) { top.ZLPMS.Msg("终止成功") List.Reload(); } if (s == 3) { top.ZLPMS.Msg("启用成功"); List.Reload(); } } else { if (s == 1) { top.ZLPMS.Msg("删除失败"); alert("请先删除渠道下的项目等信息"); List.Reload(); } if(s==2) { top.ZLPMS.Msg("终止失败"); } if (s == 3) { top.ZLPMS.Msg("启用失败"); } } } }); } //回车提交查询 function Enter_Submit() { var search = $('#userAccount').val(); $("#treegrid").treegrid({ pageSize: 10, url: '/Channel/SearchModuleInfos?search=' + search, idField: 'ID', treeField: '名称', method: 'GET', fit: true, pageSize: 20, toolbar: '#Channeltb', rownumbers: true, //底部显示分页工具栏 pagination: true, //列名称 columns: [[ { field: '状态', title: '状态', width: 60, align: 'center', styler: function (value, row, index) { if (value == '正常') { return 'color:green;font-weight:bold'; } if (value == '终止') { return 'color:red;font-weight:bold'; } } }, { field: '编码', title: '编码', width: 40, align: 'center' }, { field: '名称', title: '名称', width: 180 }, { field: '显示名', title: '渠道性质', width: 100, align: 'center' }, { field: '商务联系人', title: '商务联系人', width: 120 }, { field: '技术联系人', title: '技术联系人', width: 120 }, { field: '电话', title: '电话', width: 100 }, { field: '开始日期', title: '开始日期', width: 100, align: 'center' }, { field: '地址', title: '地址', width: 240 }, { field: '备注', title: '备注', width: 160, align: 'center' } ]] }); }