spirit_anesthetic_print.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. //@ sourceURL=spirit_anesthetic_print.js
  2. var LODOP; //声明为全局变量
  3. $(function () {
  4. initDynamicSelect("allUnitCode", "unitCodeSearch");
  5. init_daterangepickertime();
  6. setTimeout(function () {
  7. getLodop();
  8. }, 800);
  9. $("#jmtj_table").hide();
  10. $(".selectpicker").selectpicker({
  11. dropuAuto: false
  12. });
  13. //初始化页面上面的按钮事件
  14. $("#btn_search").click(function (t) {
  15. $('.sjh').remove();
  16. if ($('#drugFlagSearch').val() == 0) {
  17. getSendDrugRecordData();
  18. } else {
  19. getSpiritAnestheticPrintData();
  20. }
  21. });
  22. $('#btn_clean').click(function () {
  23. cleanParams();
  24. });
  25. $("#btn_daily").click(function (t) {
  26. print();
  27. });
  28. $("#btn_excel").click(function (t) {
  29. let id = "qbtj_table";
  30. let name = "药品发药明细统计表";
  31. if ($("#qbtj_table").is(':hidden')) {
  32. id = "jmtj_table";
  33. let drugFlag = $("#drugFlagSearch").val();
  34. if (drugFlag == 1) {
  35. name = "麻、精一及麻黄碱类药品使用登记";
  36. } else if (drugFlag == 2) {
  37. name = "终止妊娠药统计";
  38. } else if (drugFlag == 3) {
  39. name = "精二类统计";
  40. }
  41. }
  42. $("#" + id).table2excel({
  43. exclude: ".exclHide",
  44. filename: name + "(" + getRePortRangeArr()[0].substring(0, getRePortRangeArr()[0].indexOf(" ") + 1) + ").xls"
  45. })
  46. });
  47. $("#drugFlagSearch").change(function (t, d, e) {
  48. let drugFlag = $("#drugFlagSearch").val();
  49. let title = "";
  50. if (drugFlag == 1) {
  51. title = "麻、精一及麻黄碱类药品使用登记";
  52. $("#jmtj_table").show();
  53. $("#qbtj_table").hide();
  54. } else if (drugFlag == 2) {
  55. title = "终止妊娠药统计";
  56. $("#jmtj_table").show();
  57. $("#qbtj_table").hide();
  58. } else if (drugFlag == 3) {
  59. title = "精二类统计";
  60. $("#jmtj_table").show();
  61. $("#qbtj_table").hide();
  62. } else if (drugFlag == 0) {
  63. title = "药品发药明细统计表";
  64. $("#qbtj_table").show();
  65. $("#jmtj_table").hide();
  66. }
  67. $(".title").html(title);
  68. $(".dateRange").html($('#reportrange span').html());
  69. $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
  70. });
  71. //初始化药品查询弹出框
  72. initSearchList('<div id="medicinePopoverContent"><table id="tb_table_medicine"></table></div>',
  73. 'searchTextDrug', 700, 250);
  74. $('#searchTextDrug').on('input focus', function (e) {
  75. showDrugPopover({
  76. data: {
  77. searchTextDrug: $("#searchTextDrug").val() == "" ? null : $("#searchTextDrug").val()
  78. },
  79. columns: [
  80. {
  81. field: 'delFlag',
  82. title: '已作废',
  83. align: "center",
  84. valign: 'middle',
  85. formatter: function (value, row, index) {
  86. return value == 1 ? '<span style="color: red">是</span>' : '否';
  87. }
  88. }]
  89. });
  90. if ($('#searchTextDrug').val() == '') {
  91. $('#codeSearch').val("");
  92. $('#serialSearch').val("");
  93. }
  94. });
  95. });
  96. /**
  97. * 获取精麻药统计报表
  98. */
  99. function getSpiritAnestheticPrintData() {
  100. $(".dateRange").html($('#reportrange span').html());
  101. $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
  102. $.ajax({
  103. type: "GET",
  104. url: '/thmz/getSpiritAnestheticPrint',
  105. contentType: "application/json;charset=UTF-8",
  106. dataType: "json",
  107. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  108. data: queryParams(),
  109. success: function (res) {
  110. if (res == '401' || res == 401) {
  111. window.location.href = '/thmz/login/view'
  112. return;
  113. }
  114. if (res.code == 0) {
  115. let html = '';
  116. let code = '';
  117. let number = 0;
  118. let sex;
  119. let drugFlag = $("#drugFlagSearch").val();
  120. for (var i = 0; i < res.data.length; i++) {
  121. let data = res.data[i];
  122. if (code == '') {
  123. code = data.chargeItemCode;
  124. number += parseFloat(data.quantity);
  125. } else if (code == data.chargeItemCode) {
  126. number += parseFloat(data.quantity);
  127. } else {
  128. html += '<tr class="sjh">';
  129. html += '<td colspan="15" style="text-align: center;font-weight: 700;">共计:' + number + '</td>';
  130. html += '</tr>';
  131. code = data.chargeItemCode;
  132. number = parseFloat(data.quantity);
  133. }
  134. if (data.sex == 1) {
  135. sex = "男"
  136. } else if (data.sex == 2) {
  137. sex = "女"
  138. } else {
  139. sex = "未知"
  140. }
  141. html += '<tr class="sjh">';
  142. html += '<td class="xtd" style="text-align: center;mso-number-format: \'\\@\';">' + data.chargeDate.substring(5, 11) + '</td>';
  143. html += '<td class="xtd" style="text-align: center;">' + data.patientId + '</td>';
  144. html += '<td class="xtd" style="text-align: center;">' + data.name + '</td>';
  145. html += '<td class="xtd" style="text-align: center;">' + sex + '</td>';
  146. html += '<td class="xtd" style="text-align: center;">' + data.age + '</td>';
  147. html += '<td style="mso-number-format: \'\\@\';">' + data.socialNo + '</td>';
  148. html += '<td>' + data.icdText + '</td>';
  149. html += '<td class="xtd" style="text-align: center;">' + data.chargeItemCode + '</td>';
  150. html += '<td>' + data.drugname + '</td>';
  151. html += '<td>' + data.specification + '</td>';
  152. html += '<td class="xtd" style="text-align: center;">' + data.quantity + '</td>';
  153. html += '<td style="text-align: center;">' + data.chargeDate + '</td>';
  154. html += '<td class="xtd" style="text-align: left;">' + (isEmpty(data.manuNo)?"":data.manuNo) + '</td>';
  155. html += '<td class="xtd" style="text-align: center;">' + data.employeeName + '</td>';
  156. html += '<td class="xtd" style="text-align: center;">' + data.warnDeptName+'<br>'+(isEmpty(data.execName)?'':'/'+data.execName) + '</td>';
  157. html += '<td class="xtd" ></td>';
  158. html += '<td class="xtd" ></td>';
  159. html += '</tr>';
  160. }
  161. html += '<tr class="sjh">';
  162. html += '<td colspan="17" style="text-align: center;font-weight: 700;">共计:' + number + '</td>';
  163. html += '</tr>';
  164. $("#jmtj_table").append(html);
  165. } else if (res.code == -1) {
  166. new PNotify({
  167. title: '错误提示',
  168. text: res.message,
  169. type: 'error',
  170. hide: true,
  171. styling: 'bootstrap3'
  172. });
  173. }
  174. }
  175. });
  176. }
  177. /**
  178. * 获取所有药品类型统计报表
  179. */
  180. function getSendDrugRecordData() {
  181. $('#YWaitDialog').css('top', $('.xtd').offset().top);
  182. $('#YWaitDialog').show();
  183. $(".dateRange").html($('#reportrange span').html());
  184. $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
  185. $.ajax({
  186. type: "POST",
  187. url: '/thmz/getSendDrugRecord',
  188. contentType: "application/json;charset=UTF-8",
  189. dataType: "json",
  190. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  191. data: JSON.stringify({
  192. 'beginDate': getRePortRangeArr()[0],
  193. 'endDate': getRePortRangeArr()[1],
  194. 'chargeCode': $('#codeSearch').val() == '' ? null : $('#codeSearch').val(),
  195. 'serial': $('#serialSearch').val() == '' || $('#serialSearch').val() === '0' ? null : $('#serialSearch').val(),
  196. 'warnDept': $('#unitCodeSearch').val() != null ? $('#unitCodeSearch').val()[0] : null,
  197. 'queryScope': $("#queryScopeSearch").val()
  198. }),
  199. success: function (res) {
  200. $('#YWaitDialog').hide();
  201. if (res == '401' || res == 401) {
  202. window.location.href = '/thmz/login/view'
  203. return;
  204. }
  205. if (res.code == 0) {
  206. let html = '';
  207. let flag = '';//区分门诊住院 -1住院 其它门诊
  208. let number = 0;
  209. let totalNumber = 0;
  210. let sex;
  211. for (var i = 0; i < res.data.length; i++) {
  212. let data = res.data[i];
  213. if (flag == '') {
  214. flag = data.id.indexOf("-") != -1 ? '0' : '1';
  215. number += parseFloat(data.quantity);
  216. } else if (flag == (data.id.indexOf("-") != -1 ? '0' : '1')) {
  217. number += parseFloat(data.quantity);
  218. } else {
  219. html += '<tr class="sjh">';
  220. html += '<td colspan="11" style="text-align: right;font-weight: 700;">小计:' + number + '</td>';
  221. html += '<td colspan="5"></td>';
  222. html += '</tr>';
  223. flag = data.id.indexOf("-") != -1 ? '0' : '1';
  224. totalNumber += number;
  225. number = parseFloat(data.quantity);
  226. }
  227. if (data.sex == 1) {
  228. sex = "男"
  229. } else if (data.sex == 2) {
  230. sex = "女"
  231. } else {
  232. sex = "未知"
  233. }
  234. let queryScope = data.id.indexOf("-") != -1 ? '门诊' : '住院';
  235. let age = data.birthDay != null ? getBirthSlot(data.birthDay, new Date()) : '';
  236. html += '<tr class="sjh">';
  237. html += '<td class="xtd" style="text-align: center;">' + data.id + '</td>';
  238. html += '<td class="xtd" style="text-align: center;">' + data.name + '</td>';
  239. html += '<td class="xtd" style="text-align: center;">' + sex + '</td>';
  240. html += '<td class="xtd" style="text-align: center;">' + age.substring(0, age.indexOf('岁')) + '</td>';
  241. html += '<td class="xtd" style="text-align: left;">' + data.warnDeptName+'<br>'+(isEmpty(data.execName)?'':'/'+data.execName) + '</td>';
  242. html += '<td>' + data.icdText + '</td>';
  243. html += '<td class="xtd" style="text-align: center;">' + data.chargeCode + '</td>';
  244. html += '<td>' + data.drugName + '</td>';
  245. html += '<td>' + data.specification + '</td>';
  246. html += '<td>' + data.abbrName + '</td>';
  247. html += '<td class="xtd" style="text-align: center;">' + data.quantity + '</td>';
  248. html += '<td style="text-align: center;">' + data.chargeDate + '</td>';
  249. let doctorName ='';
  250. if(data.employeeName!=null){
  251. doctorName = data.employeeName.trim().substring(0, 1) + new Array(data.employeeName.trim().length).join('*');
  252. }
  253. html += '<td class="xtd" style="text-align: center;">' + doctorName + '</td>';
  254. html += '<td class="xtd" style="text-align: center;">' + data.supplyName + '</td>';
  255. html += '<td class="xtd" style="text-align: center;">' + data.frequency + '</td>';
  256. html += '<td class="xtd" style="text-align: left;">' + (isEmpty(data.manuNo)?"":data.manuNo) + '</td>';
  257. html += '<td class="xtd" style="text-align: center;">' + queryScope + '</td>';
  258. html += '</tr>';
  259. }
  260. html += '<tr class="sjh">';
  261. html += '<td colspan="11" style="text-align: right;font-weight: 700;">小计:' + number + '</td>';
  262. html += '<td colspan="6"></td>';
  263. html += '</tr>';
  264. html += '<tr class="sjh">';
  265. html += '<td colspan="11" style="text-align: right;font-weight: 700;">总计:' + parseFloat(totalNumber + number) + '</td>';
  266. html += '<td colspan="6"></td>';
  267. html += '</tr>';
  268. $("#qbtj_table").append(html);
  269. } else if (res.code == -1) {
  270. new PNotify({
  271. title: '错误提示',
  272. text: res.message,
  273. type: 'error',
  274. hide: true,
  275. styling: 'bootstrap3'
  276. });
  277. }
  278. }
  279. });
  280. }
  281. /**
  282. * 获取按钮组选择的下标
  283. * @param id
  284. * @returns {number}
  285. */
  286. function getIndex(id) {
  287. var index = 0;
  288. var item = $("#" + id).find("button");
  289. for (var i = 0; i <= item.length; i++) {
  290. if ($(item[i]).hasClass("btn-primary")) {
  291. index = i;
  292. break;
  293. }
  294. }
  295. return index;
  296. }
  297. /**
  298. * 获取时间选择器的时间数组
  299. * @returns {string[]}
  300. */
  301. function getRePortRangeArr() {
  302. var rePortRange = $('#reportrange span').html();
  303. var rePortRangeArr = rePortRange.split(" - ");
  304. return rePortRangeArr;
  305. }
  306. /**
  307. * 清空查询条件
  308. */
  309. function cleanParams() {
  310. $("#queryScopeSearch").val(0);
  311. $('#queryScopeSearch').selectpicker('refresh');
  312. $('#reportrange span').html(moment().subtract(1, 'days').format("YYYY-MM-DD 14:00:00") + ' - ' + moment().format("YYYY-MM-DD 13:59:59"));
  313. $('#unitCodeSearch').empty();
  314. $('#drugFlagSearch').val(0);
  315. $('#qbtj_table').show();
  316. $('#jmtj_table').hide();
  317. $('.sjh').remove();
  318. $('#drugFlagSearch').selectpicker('refresh');
  319. $("#unitCodeSearch").html('');
  320. $("#unitCodeSearch").selectpicker('refresh');
  321. $('#searchTextDrug').empty();
  322. $('#codeSearch').empty();
  323. $('#serialSearch').val(0);
  324. $('#serialSearch').selectpicker('refresh');
  325. }
  326. /**
  327. * 打印报表
  328. */
  329. function print() {
  330. setDefaultPrint();
  331. LODOP = getLodop();
  332. LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "药品发放统计表");
  333. LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A4");
  334. //设置默认打印机
  335. LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
  336. LODOP.SET_PRINT_STYLE("FontSize", 10); //字体大小
  337. LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
  338. //设置默认打印机
  339. LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
  340. LODOP.ADD_PRINT_TEXT('200mm', '140mm', '40mm', '40mm', '第#页/共&页');
  341. LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
  342. var strStyle = "<style>table,td,th {border-width: 1px;" +
  343. "border-style: solid;border-collapse: collapse;table-layout:fixed;word-wrap:break-word;font-size: 14px}</style>";
  344. LODOP.ADD_PRINT_HTM("2mm", "4mm", "RightMargin:4mm", "BottomMargin:15mm", strStyle + document.getElementById("report_table_1").innerHTML);
  345. // LODOP.PREVIEW();
  346. LODOP.PREVIEW();
  347. }
  348. /**
  349. * 统计列表查询参数
  350. */
  351. function queryParams() {
  352. let drugFlags = new Array();
  353. let flag = $("#drugFlagSearch").val();
  354. if (flag == 1) {
  355. drugFlags[0] = 2;
  356. drugFlags[1] = 3;
  357. drugFlags[2] = 5;
  358. } else if (flag == 2) {
  359. drugFlags[0] = 6;
  360. } else if (flag == 3) {
  361. drugFlags[0] = 1;
  362. drugFlags[1] = 4;
  363. }
  364. var temp = {
  365. beginDate: getRePortRangeArr()[0],
  366. endDate: getRePortRangeArr()[1],
  367. chargeItemCode: $('#codeSearch').val(),
  368. unitCode: $('#unitCodeSearch').val() != null ? $('#unitCodeSearch').val()[0] : '',
  369. drugFlags: drugFlags,
  370. queryScope: $("#queryScopeSearch").val(),
  371. serial: $('#serialSearch').val() == '' || $('#serialSearch').val() === '0' ? null : $('#serialSearch').val()
  372. };
  373. return temp;
  374. }