sfy_config.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. //@ sourceURL=sfy_config.js
  2. var LODOP; //声明为全局变量
  3. var printSucess = false;
  4. var deptNoSucess = false;
  5. $(function () {
  6. $(".selectpicker").selectpicker({
  7. dropuAuto: false
  8. });
  9. //延迟触发列表加载,因为一开始打印程序还没有加载成功
  10. setTimeout('createPrinterList()', 500);
  11. $.ajax({
  12. type: "GET",
  13. contentType: "application/json;charset=UTF-8",
  14. url: "/thmz/getMzZdDeptNos",
  15. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  16. dataType: 'json',
  17. success: function (result) {
  18. if (result == '401' || result == 401) {
  19. window.location.href = '/thmz/login/view'
  20. return;
  21. }
  22. if (result.code == 0) {
  23. var arr = result.data;
  24. if (arr != null && arr.length > 0) {
  25. var html = "";
  26. for (var i = 0; i < arr.length; i++) {
  27. html += "<option value='" + arr[i].code + "'>" + arr[i].name + "</option>";
  28. }
  29. $('#deptNoSelect').html(html);
  30. $('#deptNoSelect').selectpicker('refresh');
  31. deptNoSucess = true;
  32. }
  33. } else {
  34. errorMesage(result);
  35. }
  36. }
  37. });
  38. delay(getLastWindowsByCurrentUser);
  39. /**
  40. * 提交按钮点击事件
  41. */
  42. $("#send").on("click", function (t) {
  43. $.ajax({
  44. type: "POST",
  45. contentType: "application/json;charset=UTF-8",
  46. url: "/thmz/saveWindows",
  47. dataType: 'json',
  48. data: JSON.stringify({
  49. "deptNo": $("#deptNoSelect").val(),
  50. "windowsNo": $("#winNo").val(),
  51. "printIndex": $("#printSelect").val(),
  52. "cgPrintIndex": $("#printSelect_cg").val(),
  53. "zyPrintIndex": $("#printSelect_zy").val(),
  54. "clientIpAddress": $("#client_ip_address").val(),
  55. "misPosRouterCode": $("#mis_pos_router_code").val()
  56. }),
  57. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  58. success: function (result) {
  59. if (result == '401' || result == 401) {
  60. window.location.href = '/thmz/login/view'
  61. return;
  62. }
  63. if (result.code == 0) {
  64. successMesage(result);
  65. } else {
  66. errorMesage(result);
  67. }
  68. }
  69. });
  70. });
  71. /**
  72. * 智能POS终端管理按钮点击事件
  73. */
  74. $("#posClientManager").on("click", function (t) {
  75. window.open("http://172.16.32.201:8080/ccbmis/#");
  76. // const iframeEle = document.getElementById("posClientManagerDiv");
  77. // const loadingEle = document.getElementById("posClientManagerLoading");
  78. // //设置ififrame透明
  79. // iframeEle.style.opacity = 0;
  80. // loadingEle.style.display = 'block';
  81. // $("#posClientManagerDiv").attr("src", "http://172.16.32.201:8080/ccbmis/#");
  82. // iframeEle.addEventListener('load', function () {
  83. // // Hide the loading indicator
  84. // loadingEle.style.display = 'none';
  85. // // Bring the iframe back
  86. // iframeEle.style.opacity = 1;
  87. // });
  88. // setTimeout(function () {
  89. // // iframe 重复加载不会触发上述事件
  90. // loadingEle.style.display = 'none';
  91. // iframeEle.style.opacity = 1;
  92. // }, 1000);
  93. // $("#posClientManagerModal").modal();
  94. });
  95. });
  96. /**
  97. * 查询当前用户的基础设置
  98. */
  99. function getLastWindowsByCurrentUser() {
  100. /**
  101. * 查询收费员参数信息
  102. */
  103. $.ajax({
  104. type: "GET",
  105. contentType: "application/json;charset=UTF-8",
  106. url: "/thmz/getLastWindowsByCurrentUser",
  107. dataType: 'json',
  108. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  109. success: function (result) {
  110. if (result == '401' || result == 401) {
  111. window.location.href = '/thmz/login/view'
  112. return;
  113. }
  114. if (result.code == 0) {
  115. $("#winNo").val(result.data.windowsNo);
  116. if (result.data.printIndex != null) {
  117. $('#printSelect').selectpicker('val', result.data.printIndex);
  118. $('#printSelect').selectpicker('refresh');
  119. }
  120. if (result.data.zyPrintIndex != null) {
  121. $('#printSelect_zy').selectpicker('val', result.data.zyPrintIndex);
  122. $('#printSelect_zy').selectpicker('refresh');
  123. }
  124. if (result.data.cgPrintIndex != null) {
  125. $('#printSelect_cg').selectpicker('val', result.data.cgPrintIndex);
  126. $('#printSelect_cg').selectpicker('refresh');
  127. }
  128. if (result.data.deptNo != null) {
  129. $('#deptNoSelect').selectpicker('val', result.data.deptNo);
  130. $('#deptNoSelect').selectpicker('refresh');
  131. }
  132. $("#client_ip_address").val(result.data.clientIpAddress);
  133. $("#mis_pos_router_code").val(result.data.misPosRouterCode);
  134. } else {
  135. errorMesage(result);
  136. }
  137. }
  138. });
  139. }
  140. //延迟加载方法
  141. function delay(callback) {
  142. if (deptNoSucess && printSucess) {
  143. callback();
  144. return;
  145. } else {
  146. setTimeout(function () {
  147. delay(callback)
  148. }, 100)
  149. }
  150. }
  151. /**
  152. * 加载打印机列表
  153. * @constructor
  154. */
  155. function createPrinterList() {
  156. LODOP = getLodop();
  157. LODOP.PRINT_INITA(6, 0, "92mm", "120mm", "泰和门诊发票打印");
  158. //获取打印机设备数,用于进行遍历
  159. var count = LODOP.GET_PRINTER_COUNT();
  160. var html = "";
  161. for (var i = 0; i < count; i++) {
  162. //根据设备序号获取设备名
  163. var msg = LODOP.GET_PRINTER_NAME(i);
  164. html += "<option value='" + i + "'>" + msg + "</option>";
  165. }
  166. $('#printSelect').html(html);
  167. $('#printSelect').selectpicker('refresh');
  168. $('#printSelect_zy').html(html);
  169. $('#printSelect_zy').selectpicker('refresh');
  170. $('#printSelect_cg').html(html);
  171. $('#printSelect_cg').selectpicker('refresh');
  172. printSucess = true;
  173. }