//@ sourceURL=sfy_config.js
var LODOP; //声明为全局变量
var printSucess = false;
var deptNoSucess = false;
$(function () {
$(".selectpicker").selectpicker({
dropuAuto: false
});
//延迟触发列表加载,因为一开始打印程序还没有加载成功
setTimeout('createPrinterList()', 500);
$.ajax({
type: "GET",
contentType: "application/json;charset=UTF-8",
url: "/thmz/getMzZdDeptNos",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
dataType: 'json',
success: function (result) {
if (result == '401' || result == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (result.code == 0) {
var arr = result.data;
if (arr != null && arr.length > 0) {
var html = "";
for (var i = 0; i < arr.length; i++) {
html += "";
}
$('#deptNoSelect').html(html);
$('#deptNoSelect').selectpicker('refresh');
deptNoSucess = true;
}
} else {
errorMesage(result);
}
}
});
delay(getLastWindowsByCurrentUser);
/**
* 提交按钮点击事件
*/
$("#send").on("click", function (t) {
$.ajax({
type: "POST",
contentType: "application/json;charset=UTF-8",
url: "/thmz/saveWindows",
dataType: 'json',
data: JSON.stringify({
"deptNo": $("#deptNoSelect").val(),
"windowsNo": $("#winNo").val(),
"printIndex": $("#printSelect").val(),
"cgPrintIndex": $("#printSelect_cg").val(),
"zyPrintIndex": $("#printSelect_zy").val(),
"clientIpAddress": $("#client_ip_address").val(),
"misPosRouterCode": $("#mis_pos_router_code").val()
}),
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (result) {
if (result == '401' || result == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (result.code == 0) {
successMesage(result);
} else {
errorMesage(result);
}
}
});
});
/**
* 智能POS终端管理按钮点击事件
*/
$("#posClientManager").on("click", function (t) {
window.open("http://172.16.32.201:8080/ccbmis/#");
// const iframeEle = document.getElementById("posClientManagerDiv");
// const loadingEle = document.getElementById("posClientManagerLoading");
// //设置ififrame透明
// iframeEle.style.opacity = 0;
// loadingEle.style.display = 'block';
// $("#posClientManagerDiv").attr("src", "http://172.16.32.201:8080/ccbmis/#");
// iframeEle.addEventListener('load', function () {
// // Hide the loading indicator
// loadingEle.style.display = 'none';
// // Bring the iframe back
// iframeEle.style.opacity = 1;
// });
// setTimeout(function () {
// // iframe 重复加载不会触发上述事件
// loadingEle.style.display = 'none';
// iframeEle.style.opacity = 1;
// }, 1000);
// $("#posClientManagerModal").modal();
});
});
/**
* 查询当前用户的基础设置
*/
function getLastWindowsByCurrentUser() {
/**
* 查询收费员参数信息
*/
$.ajax({
type: "GET",
contentType: "application/json;charset=UTF-8",
url: "/thmz/getLastWindowsByCurrentUser",
dataType: 'json',
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (result) {
if (result == '401' || result == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (result.code == 0) {
$("#winNo").val(result.data.windowsNo);
if (result.data.printIndex != null) {
$('#printSelect').selectpicker('val', result.data.printIndex);
$('#printSelect').selectpicker('refresh');
}
if (result.data.zyPrintIndex != null) {
$('#printSelect_zy').selectpicker('val', result.data.zyPrintIndex);
$('#printSelect_zy').selectpicker('refresh');
}
if (result.data.cgPrintIndex != null) {
$('#printSelect_cg').selectpicker('val', result.data.cgPrintIndex);
$('#printSelect_cg').selectpicker('refresh');
}
if (result.data.deptNo != null) {
$('#deptNoSelect').selectpicker('val', result.data.deptNo);
$('#deptNoSelect').selectpicker('refresh');
}
$("#client_ip_address").val(result.data.clientIpAddress);
$("#mis_pos_router_code").val(result.data.misPosRouterCode);
} else {
errorMesage(result);
}
}
});
}
//延迟加载方法
function delay(callback) {
if (deptNoSucess && printSucess) {
callback();
return;
} else {
setTimeout(function () {
delay(callback)
}, 100)
}
}
/**
* 加载打印机列表
* @constructor
*/
function createPrinterList() {
LODOP = getLodop();
LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊发票打印");
//获取打印机设备数,用于进行遍历
var count = LODOP.GET_PRINTER_COUNT();
var html = "";
for (var i = 0; i < count; i++) {
//根据设备序号获取设备名
var msg = LODOP.GET_PRINTER_NAME(i);
html += "";
}
$('#printSelect').html(html);
$('#printSelect').selectpicker('refresh');
$('#printSelect_zy').html(html);
$('#printSelect_zy').selectpicker('refresh');
$('#printSelect_cg').html(html);
$('#printSelect_cg').selectpicker('refresh');
printSucess = true;
}