//@ sourceURL=registration_list.js var $dataTableHot; //病人下拉选当前页记录 var pageIndex = 0; //判断病人列表是否在加载中,防止重复加载 var msg_list_loading = false; //挂号卡片列表页面下标 var pageIndex = 0; //判断表格列表是否已经初始化 var isTableListInit = false; var LODOP; //声明为全局变量pageIndex //默认打印机下标 var printIndex = -1; var TableInit = function () { var oTableInit = new Object(); //初始化Table oTableInit.Init = function () { $dataTableHot = $('#tb_fee_info').bootstrapTable({ url: '', //请求后台的URL(*) method: 'post', //请求方式(*) toolbar: '#toolbar', //工具按钮用哪个容器 striped: true, //是否显示行间隔色 cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*) pagination: false, //是否显示分页(*) sortable: true, //是否启用排序 sortOrder: "asc", //排序方式 //queryParams: oTableInit.queryParams,//传递参数(*) sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*) pageNumber: 1, //初始化加载第一页,默认第一页 pageSize: 10, //每页的记录行数(*) pageList: [10, 25, 50, 100], //可供选择的每页的行数(*) search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大 strictSearch: true, showColumns: false, //是否显示所有的列 showRefresh: false, //是否显示刷新按钮 minimumCountColumns: 2, //最少允许的列数 clickToSelect: true, //是否启用点击选中行 uniqueId: "ID", //每一行的唯一标识,一般为主键列 showToggle: false, //是否显示详细视图和列表视图的切换按钮 cardView: false, //是否显示详细视图 detailView: false, ajaxOptions: { headers: { 'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token") } }, columns: [ // { // checkbox: true // }, { field: 'name', title: '名称', align: "center", valign: 'middle', //sortable: true }, { field: 'money', title: '金额(元)', align: "center", valign: 'middle', //sortable: true }, { field: 'moneyReceived', title: '实收金额(元)', align: "center", valign: 'middle', // sortable: true }], responseHandler: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } var ress = eval(res); if (ress.code == -1) { new PNotify({ title: '错误提示', text: ress.message, type: 'error', hide: true, styling: 'bootstrap3' }); return { "total": 0,//总页数 "rows": {} //数据 }; } return { "total": ress.pageViewVO.total,//总页数 "rows": ress.pageViewVO.data //数据 }; }, }); }; return oTableInit; }; $(function () { initGenderSelect(); initResponceTypeSelect(); //设置挂号窗口的高度 var width = $('#confirmFee').css("width"); var widthNum = parseInt(width); widthNum -= 24; $("#confirmFee").css("width", widthNum + "px"); init_daterangepicker(); //1.初始化Table var oTable = new TableInit(); oTable.Init(); formatCheck(); //默认光标在卡号输入框 $("#cardNo").focus(); //根据病人姓名输入框内容动态加载病人列表 initUserList(); //卡号输入改变事件 cardNoChange(); //卡号输入改变事件 userNameChange(); //数据校验 init_validator(); //时间区间 initMzWorkTime(); //初始门诊收银方式下拉选 initChequeType("payType"); //初始修改收费方式 收银方式下拉选 initChequeType("payTypeEditPayMode"); /** * 清空 */ $("#clearRegistration").on("click", function (t) { clearRegistration(); }); /** * 增加收款方式按钮事件 */ $("#addPayType").on("click", function (t) { var payTypeIndex = $("#payTypeIndex").val(); var payTypeId = "payType_" + payTypeIndex; var html = '
'; $("#changeAmountParent").before(html); initChequeType(payTypeId) payTypeIndex = payTypeIndex + 1; $("#payTypeIndex").val(payTypeIndex); }); // //当ic卡号输入框失去光标后,重置光标到卡号输入框 // $("#cardNo").blur(function () { // var focus = !($("#userName").is(":focus") || $("#age").is(":focus") || $("#birthDay").is(":focus") || $("#phoneNum").is(":focus") || $("#idCard").is(":focus") || $("#address").is(":focus")); // if (focus && $("#cardNo").val() == null || $("#cardNo").val() == "") { // //默认光标在卡号输入框 // $("#cardNo").focus(); // } // }); // /** // * 设置窗口号 // */ // $("#editWindows").on("click", function (t) { // $.ajax({ // type: "GET", // url: '/thmz/getLastWindowsByCurrentUser', // contentType: "application/json;charset=UTF-8", // dataType: "json", // headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, // success: function (res) { // if (res == '401' || res == 401) { // window.location.href = '/thmz/login/view' // return; // } // if (res.code == 0) { // $("#windowsNum").val(res.data.windowsNo) // } else { // new PNotify({ // title: '错误提示', // text: res.message, // type: 'error', // hide: true, // styling: 'bootstrap3' // }); // } // } // }); // $("#editWindowsModal").modal(); // }); /** * 退费重收事件 */ $("#saveConfirmFee").on("click", function (t) { var serialNo = $("#serialNo").val(); if (!confirm("确定要将流水号【" + serialNo + "】的挂号记录退费重收吗?")) { return; } $.ajax({ type: "GET", url: '/thmz/chargeFeeForByjz?serialNo=' + serialNo + "&paymode=" + $("#payType").val(), contentType: "application/json;charset=UTF-8", dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } if (res.code == 0) { $('#confirmFeeModal').modal('hide'); $("#serialNo").val(null); prn1Print(res.data.patientId, res.data.times); } else { new PNotify({ title: '错误提示', text: res.message, type: 'error', hide: true, styling: 'bootstrap3' }); } } }); }); /** * 患者信息修改 */ $("#saveEditUser").on("click", function (t) { modifyPatient(); }); /** * 挂号列表中的科室和医生列表初始化 */ initListSelect(); $("#queryListButton").on("click", function (t) { loadTableCount(); loadRegistrationList(true); }); loadTableCount(); loadRegistrationList(true); // $("#editPrint").on("click", function (t) { // CreatePrinterList(); // $("#editPrintModal").modal(); // }); //初始化页面上面的按钮事件 $("#btn_excel").click(function (t) { exportExcel(); }); }); // function CreatePageList() { // LODOP = getLodop(); // LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊发票打印"); // //获取纸张大小数,用于进行遍历 // var strPageSizeList = LODOP.GET_PAGESIZES_LIST($('#printSelect').val(), "\n"); // var html = ""; // var arr = strPageSizeList.split("\n"); // for (var i = 0; i < arr.length; i++) { // html += ""; // } // $('#pageSelect').html(html); // $('#pageSelect').selectpicker('refresh'); // } /** * 初始化性别下拉选 */ function initGenderSelect() { $(".selectpicker").selectpicker({ dropuAuto: false }); var gender = ''; $('#gender').html(gender); $('#gender').selectpicker('refresh'); $('#editUserGender').html(gender); $('#editUserGender').selectpicker('refresh'); } /** * 初始化病人身份类别下拉选 */ function initResponceTypeSelect() { $(".selectpicker").selectpicker({ dropuAuto: false }); $.ajax({ type: "GET", url: '/thmz/getMzResponceType', contentType: "application/json;charset=UTF-8", dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } if (res.code == 0) { res.data.forEach(function (item, index) { var html = ''; $('#patientsNature').append(html); $('#editUserPatientsNature').append(html); }); $('#patientsNature').selectpicker('refresh'); $('#editUserPatientsNature').selectpicker('refresh'); } else { new PNotify({ title: '错误提示', text: res.message, type: 'error', hide: true, styling: 'bootstrap3' }); } } }); } /** * 初始科室下拉选 * @param ampm 时间段区间 */ function initDeptPlus() { //科室列表 $.ajax({ type: "GET", url: '/thmz/getUnitCodeByRequestDay?ampm=' + $("#ampm").val(), dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (data) { if (data == '401' || data == 401) { window.location.href = '/thmz/login/view' return; } var html = ''; $.each(data.data, function (commentIndex, comment) { html += ''; }); $('#deptNo').empty(); $('#deptNo').html(html); $('#deptNo').selectpicker('refresh'); $('#chargeType').empty(); $('#chargeType').selectpicker('refresh'); emptyInput(); } }); } /** * 初始医生下拉选 * @param ampm 时间段区间 */ function initEmployee() { //医生列表 $.ajax({ type: "GET", url: '/thmz/getDoctorCodeByRequestDay?unitCode=' + $('#deptNo').val() + "&m=" + $("#ampm").val() + "&chargeType=" + $("#chargeType").val(), dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } var html = ''; var defaultCode = null; $.each(res.data, function (commentIndex, comment) { html += ''; if (res.data.length == 1) { //如果只有一个号别,默认选中 defaultCode = comment.employee.employeeCode; } }); $('#doctor').empty(); $('#doctor').html(html); $('#doctor').selectpicker('refresh'); validator.checkAll($("#regi_form")); if (defaultCode != null) { //如果有无需选择医生的选项,默认选择 $('#doctor').selectpicker('val', defaultCode); $('#doctor').selectpicker('refresh'); fitFee(); } } }); } /** * 初始门诊时间区间下拉选 */ function initMzWorkTime() { $.ajax({ type: "GET", url: '/thmz/getMzWorkTime', dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } var html = ''; var ampm = null; $.each(res.data, function (commentIndex, comment) { html += ''; if (ampm == null || (ampm != "a" && ampm != "p")) { var startTime = paseToFullTime(comment.startTime); var endTime = paseToFullTime(comment.endTime); if (range(startTime, endTime)) { ampm = comment.code; } } }); $('#ampm').empty(); //清空resText里面的所有内容 $('#ampm').html(html); $('#ampm').selectpicker('refresh'); $("#ampm").selectpicker('val', ampm); $('#ampm').selectpicker('refresh'); initDeptPlus(); } }); } /** * 初始门诊号别下拉选 */ function initChargeType() { $.ajax({ type: "GET", url: '/thmz/getChargeTypeByRequestDay?unitCode=' + $('#deptNo').val() + "&m=" + $("#ampm").val(), dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } var html = ''; var defaultCode = null; $.each(res.data, function (commentIndex, comment) { if (res.data.length == 1) { //如果只有一个号别,默认选中 defaultCode = comment.code; } html += ''; }); $('#chargeType').empty(); //清空resText里面的所有内容 $('#chargeType').html(html); $('#chargeType').selectpicker('refresh'); if (defaultCode != null) { //如果有默认选项,默认选择 $('#chargeType').selectpicker('val', defaultCode); $('#chargeType').selectpicker('refresh'); initEmployee(); } validator.checkAll($("#regi_form")); emptyInput(); } }); } /** * 设置挂号费等费用 */ function fitFee() { var chargeType = $('#doctor').find("option:selected").attr('data-chargeType'); var checkFee = $('#doctor').find("option:selected").attr('data-checkFee'); $("#checkFee").val(checkFee); $("#amountMoney").text(checkFee); $("#amountMoneyConfirm").text(checkFee); $("#realMoney").val(checkFee); $("#cash").val(checkFee); $("#changeAmount").val(0); $.ajax({ type: "GET", url: '/thmz/getMzChargeTypeByCode?code=' + chargeType, dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } $("#registrationFee").val(res.data.reqFee); $("#hospitalFee").val(res.data.clinicFee); checkFee = parseFloat(checkFee) + parseFloat(res.data.reqFee) + parseFloat(res.data.clinicFee); $("#amountMoney").text(checkFee); $("#amountMoneyConfirm").text(checkFee); $("#realMoney").val(checkFee); $("#cash").val(checkFee); validator.checkAll($("#regi_form")); } }); } /** * 初始门诊收银方式下拉选 */ function initChequeType(payType) { $.ajax({ type: "GET", url: '/thmz/getAllZdChequeTypeForMz', dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } var html = ''; $.each(res.data, function (commentIndex, comment) { html += ''; }); $('#' + payType).empty(); $('#' + payType).html(html); $('#' + payType).selectpicker('refresh'); } }); } /** * 日期值改变修改年龄字段 * @param ev */ function changeDate(ev) { } /** * 列表类型按钮切换事件 * @param object */ function titleButtonChange(object) { $("#regi_List_btn_group").find("button").each(function (index, element) { if ($(element).hasClass("btn-primary")) { $(element).removeClass("btn-primary").addClass("btn-default"); } }); $(object).removeClass("btn-default").addClass("btn-primary"); loadRegistrationList(true); } /** * 表格类型切换事件 卡片展示或者列表形式 */ function listTypeChange(object) { //var indexNum = 0; $("#regi_List_type").find("button").each(function (index, element) { if ($(element).hasClass("btn-primary")) { $(element).removeClass("btn-primary").addClass("btn-default"); } // if (object == element) { // indexNum = index; // } }); $(object).removeClass("btn-default").addClass("btn-primary"); loadRegistrationList(true); } /** * 打开编辑用户信息窗口 * @param data */ function editUserModal(data) { $("#editUserModal").modal(); if (data == null) { data = $("#patientId").val(); } $.ajax({ type: "GET", url: '/thmz/getByPatientId?patientId=' + data, contentType: "application/json;charset=UTF-8", dataType: "json", headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } if (res.code == 0) { if (res.data != null) { //延时调用,因为当前弹框还没有加载出来,校验规则无法获取光标与模拟光标丢失事件,延时可以等弹框加载出来后模拟事件 setTimeout(function () { fillPlusPatinet(res.data); }, 400); } } else { new PNotify({ title: '错误提示', text: res.message, type: 'error', hide: true, styling: 'bootstrap3' }); } } }); } /** * 打开退费信息窗口 * @param patientId * @param times */ function backNoModal(patientId, times) { $.ajax({ type: "POST", url: '/thmz/getMzyReqrecByPatientIdAndTimes', contentType: "application/json;charset=UTF-8", dataType: "json", data: JSON.stringify({"patientId": patientId, "times": times}), headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")}, success: function (res) { if (res == '401' || res == 401) { window.location.href = '/thmz/login/view' return; } if (res.code == 0) { if (res.data != null) { $("#backNoPatientId").val(patientId); $("#backNoTimes").val(times); $("#backNoSickName").text(res.data.mzyReqrec.name); $("#backNoPayType").text(res.data.mzyReqrec.paymode); $("#backNoPhone").text(res.data.mzPatientMi.phoneNo); $("#backNoAmpm").text(res.data.mzyReqrec.ampm); $("#backNoDeptName").text(res.data.mzyReqrec.unitCode); $("#backNoChargeType").text(res.data.mzyReqrec.chargeType); $("#backNoDoctorName").text(res.data.mzyReqrec.doctorCode); $("#backNoRegiDate").text(format(res.data.mzyReqrec.requestDay, "yyyy-MM-dd HH:mm:ss")); var index = 0; var trHtml = ''; if (res.data.mzyReqrec.reqFee != null && res.data.mzyReqrec.reqFee != "" && res.data.mzyReqrec.reqFee > 0) { trHtml = '