var ComplaintId = ""; function viewModel() { this.init = function () { $("#ComplaintList").datagrid({ toolbar: "#tb", fit: true, fitcolumns: true, striped: true, pagination: true, singleSelect: true, remoteSort: false, border: false, rownumbers: true, frozenColumns: [[ { field: '投诉事件', title: '投诉标题', width: 130, align: 'center' }, { field: '用户姓名', title: '投诉人', width: 50, align: 'left' } ]], columns: [[ { field: '名称', title: '机构', width: 100, align: 'center' }, { field: '登记时间', title: '登记时间', width: 150, align: 'center', sortable: true, sorter: function (a, b) { a = a.split('/'); b = b.split('/'); if (a[2] == b[2]) { if (a[0] == b[0]) { return (a[1] > b[1] ? 1 : -1); } else { return (a[0] > b[0] ? 1 : -1); } } else { return (a[2] > b[2] ? 1 : -1); } } }, { field: '当前处理人', title: '当前处理人', width: 80, align: 'center' }, { field: '状态', title: '状态', width: 50, align: 'center', formatter: function (value, row, index) { if (value == "0") { return "未处理"; } else if (value == "1") { return "处理中"; } else { return "已处理"; } } }, { field: '是否分配渠道', title: '是否分配渠道', width: 100, align: 'center', formatter: function (value, row, index) { if (value == "0") { return ""; } else if (value == "1") { return ""; } } }, { field: '显示名', title: '投诉种类', width: 100, align: 'left', halign: 'center' }, { field: '科室名', title: '科室名', width: 100, align: 'center', halign: 'center' }, { field: '总耗时', title: '已耗时(小时)', width: 100, align: 'center', halign: 'center' }, { field: '投诉描述', hidden: true } ]], onSelect: function (rowIndex, rowData) { GetImage(rowData["ID"]); GetComplaintPerson(rowData["登记人ID"]); DealProcess(rowData["ID"]); $("#ComplaintDetail").html(rowData["投诉描述"]); GetCommunicate(rowData["ID"]); } }); ///初始化投诉人详细列表 $("#ComplaintPerson").datagrid({ columns: [[ { field: '姓名', title: '投诉人', width: 100, align: 'center', halign: 'center' }, { field: '名称', title: '机构', width: 200, align: 'center', halign: 'center' }, { field: '部门名', title: '科室', width: 150, align: 'center' }, { field: '联系电话', title: '联系电话', width: 200, align: 'center', halign: 'center' }, { field: '电子邮箱', title: '电子邮箱', width: 200, align: 'center', halign: 'center' }, { field: '说明', title: '说明', width: 200, align: 'center', halign: 'center' } ]], fit: true, method: "get", fitcolumns: true, striped: true, singleSelect: true, onSelect: function (rowIndex, rowData) { } }); ///初始化投诉种类Combobox $("#ComplaintType").combobox({ url: '/BaseCode/GetCodeCombobox?ClassificationID=B0BF0EDD-37D7-47D4-9ED9-9D0F2DDCA6A0', valueField: 'ID', textField: '显示名', editable: false, multiple: true, onLoadSuccess: function (data) { }, onChange: function () { Refresh("0"); } }); $.ajax({ url: '/ComplaintManage/GetChannelComboTree', method: 'get', success: function (data) { if (data != null) { var all = { "id": "0", "text": "全部" } data.splice(0, 0, all); $("#Channel").combotree('loadData', data); } } }) //初始化渠道信息Combobox $("#Channel").combotree({ valueField: 'ID', textField: '名称', editable: false, onChange: function (newValue, oldValue) { Refresh("0"); }, onLoadSuccess: function (data) { $("#Channel").combotree('setValue',0); } }); $("#Status").combobox({ onChange: function () { Refresh("0"); } }); //提交沟通过程 $('#SubmitCmt').textbox({ icons: [{ iconCls: 'fa fa-pencil', handler: function (e) { var v = $(e.data.target).textbox('getValue'); if (v == "" || v == null) { mui.toast('请输入内容', { duration: 'long', type: 'div' }); return; } var Node = $('#ComplaintList').datagrid("getSelected"); if (Node == null) { mui.toast('请选择一条投诉记录', { duration: 'long', type: 'div' }); return; } var url = "/ComplaintManage/SubmitCmt/" + Node["ID"]; $.post(url, { "Content": v }, function (data) { if (data.code == 200) { top.ZLPMS.Msg(data.msg); $('#SubmitCmt').textbox('clear'); GetCommunicate(Node["ID"]); } else { ZLPMS.Msg(data.msg, 2); } }); } }] }); //处理 $('#btn-Deal').click(function () { var Node = $('#ComplaintList').datagrid("getSelected"); if (Node["状态"] == 2) { top.ZLPMS.Msg("该投诉处理已完结", 0); return; } if (Node == null) { top.ZLPMS.Msg("请选择一行投诉后执行操作", 0); return; } ComplaintId = Node["ID"]; top.ZLPMS.OpenWindow({ title: '投诉过程受理', url: '/ComplaintManage/ComplaintDeal/' + Node["ID"] + '?Event=' + Node["投诉事件"], area: ['630px', '500px'], yes: function (index, layero) { Forms.Submit(index, layero); }, }); }); //分配 $('#btn-Distribution').click(function () { var Node = $('#ComplaintList').datagrid("getSelected"); if (Node == null) { top.ZLPMS.Msg("请选择一行投诉后执行操作", 0); return; } if (Node["状态"] == 2) { top.ZLPMS.Msg("该投诉处理已完结", 0); return; } ComplaintId = Node["ID"]; top.ZLPMS.OpenWindow({ title: '投诉过程分配', url: '/ComplaintManage/ComplaintDistribute/' + Node["ID"] + '?Event=' + Node["投诉事件"], area: ['630px', '500px'], yes: function (index, layero) { Forms.SubmitDe(index, layero); }, }); }); //重置 $('#btn-default').click(function () { RefreshDeaf(); }); //状态选择事件 $("#myprob").checkbox({ checked: true, onChange: function (checked) { Refresh("0"); } }); }, this.loadmenus = function () { ///初始化日期 var curr_time = new Date(); var str = curr_time.getFullYear() + "-"; str += curr_time.getMonth() + 1 + "-"; str += curr_time.getDate() + " "; str += curr_time.getHours()+":"; str += curr_time.getMinutes(); $('#DealTime').datetimebox('setValue', str); $('#DealPersonID').combobox({ url: '/ComplaintManage/GetPerson/', valueField: 'ID', textField: '姓名', editable: true, onSelect: function (record) { $('#DealPerson').val(record.名称); }, onLoadSuccess: function (data) { if (data) { $('#DealPersonID').combobox('setValue', CurrentUser); } } }); }, this.loadmenusDis = function () { var curr_time = new Date(); var str = curr_time.getFullYear() + "-"; str += curr_time.getMonth() + 1 + "-"; str += curr_time.getDate() + " "; str += curr_time.getHours() + ":"; str += curr_time.getMinutes(); $('#DealTime').datetimebox('setValue', str); $('#DealPersonID').combobox({ valueField: 'ID', textField: '姓名', onLoadSuccess: function (data) { if (data) { $('#DealPersonID').combobox('setValue', data[0].ID); } } , onSelect: function (record) { $('#DealPerson').val(record.姓名); } }); ///读取渠道 $('#Channel').combotree({ url: '/ComplaintManage/GetChannelComboTree', valueField: 'ID', textField: '名称', editable: false, onLoadSuccess: function () { }, onChange: function (newValue, oldValue) { ///读取人员 $('#DealPersonID').combobox({ url: '/ComplaintManage/GetPersonByChannel/' + newValue }); } }); } } function Refresh(_mode) { if (_mode == "0") { var my = '2'; var t = $('#myprob').checkbox('options'); if ($('#myprob').checkbox('options').checked) { my = '1'; } var search = $('#searchs').searchbox('getValue'); var complaintType = $('#ComplaintType').combobox('getValues'); var channel = $('#Channel').combobox('getValue'); var status = $('#Status').combobox('getValues'); var startTime = $('#StartTime').datetimebox('getValue'); var endTime = $('#EndTime').datetimebox('getValue'); var ctype = ''; var sta = ''; $(complaintType).each(function (idx, text) { ctype += text + ','; }); $(status).each(function (idx, text) { sta += text + ','; }); var Params = { Search: search, ComplaintType: ctype, Channel: channel, Status: sta, StartTime: startTime, EndTime: endTime, My: my } $("#ComplaintList").datagrid({ url: '/ComplaintManage/GetComplaintDatagrid', method: 'GET', queryParams: Params, onLoadSuccess: function (data) { if (data.rows.length > 0) { var index = $('#ComplaintList').datagrid('getRowIndex', ComplaintId); if (index >= 0) { $('#ComplaintList').datagrid('selectRow', index); } else { $('#ComplaintList').datagrid('selectRow', 0); } } } }); } } //初始化 function RefreshDeaf() { $('#ComplaintType').combobox('clear'); $('#Channel').combotree('setValue',0); $('#Status').combobox('clear'); $('#EndTime').datebox('setValue', '') $('#StartTime').datebox('setValue', '') $('#searchs').searchbox('setValue', ''); Refresh("0"); } ///搜索框事件 function doSearch(value) { Refresh("0"); } ///获取附件 function GetImage(id) { var url = "/ComplaintManage/GetComplaintFileFromFTP/" + id; $.post(url, { "id": id }, function (data) { $("#ImgBox").empty(); $.each(data, function (idx, json) { $("#ImgBox").append("") }); }) } ///投诉人信息 function GetComplaintPerson(PID) { $("#ComplaintPerson").datagrid({ url: "/ComplaintManage/GetComplaintPerson?PID=" + PID, }); } ///获取投诉过程 function DealProcess(ID) { $("#timeLine").empty(); var url = "/ComplaintManage/GetDealProcess/" + ID; $.post(url, {}, function (data) { $.each(data, function (idx, json) { var icon = FindIcon(json.变更状态); $("#timeLine").append("
  • " + icon + json.变更状态 + "

    " + json.职务 + "-" + json.记录人 + "
    " + json.记录时间 + "

  • "); }); }); } ///获取过程沟通 function GetCommunicate(ID) { $("#Communication").empty(); var url = "/ComplaintManage/GetCommunicate/" + ID; $.post(url, {}, function (data) { $.each(data, function (idx, json) { $("#Communication").append("
    " + json.沟通人职务 + "-" + json.沟通人 + "
    " + json.沟通内容 + "

    " + json.沟通时间 + "

    ") }); }) } ///获取流程图标 function FindIcon(title) { if (title == "已登记") { return ""; } else if (title == "服务分配") { return ""; } else if (title == "服务受理中") { return ""; } else if (title == "处理完成") { return ""; } else if (title == "服务提交") { return ""; } else { return ''; } } //表单操作(投诉受理) var Forms = { //表单提交 Submit: function (index, layero) { var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法: var param = iframeWin.Forms.PostData();//调用子页面的方法,得到子页面返回的ids if (param != null) { var url = '/ComplaintManage/ComplaintAccept'; $.post(url, param, function (data) { if (data.code == 200) { top.ZLPMS.CloseWindow(index); top.ZLPMS.Msg(data.msg); //刷新 Refresh("0"); } else { ZLPMS.Msg(data.msg, 2); } }); } }, SubmitDe: function (index, layero) { var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法: var param = iframeWin.Forms.PostData();//调用子页面的方法,得到子页面返回的ids if (param != null) { var url = '/ComplaintManage/ComplaintDistributeSub'; $.post(url, param, function (data) { if (data.code == 200) { top.ZLPMS.CloseWindow(index); top.ZLPMS.Msg(data.msg); //刷新 Refresh("0"); } else { ZLPMS.Msg(data.msg, 2); } }); } }, //加载数据 Load: function (data) { $('#ff').form('load', data); }, //读取数据 PostData: function () { //执行提交验证 var r = $('#ff').form('validate'); if (r) {//post到后台 var param = ZLPMS.FormToObject('ff'); return param; } return null; } };