spirit_anesthetic_print.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. //@ sourceURL=spirit_anesthetic_print.js
  2. var LODOP; //声明为全局变量
  3. $(function () {
  4. initDeptSelect(0, "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 class="xtd" style="text-align: center;">' + data.employeeName + '</td>';
  154. html += '<td class="xtd" style="text-align: center;">' + data.warnDeptName + '</td>';
  155. html += '<td class="xtd" ></td>';
  156. html += '<td class="xtd" ></td>';
  157. html += '</tr>';
  158. }
  159. html += '<tr class="sjh">';
  160. html += '<td colspan="15" style="text-align: center;font-weight: 700;">共计:' + number + '</td>';
  161. html += '</tr>';
  162. $("#jmtj_table").append(html);
  163. } else if (res.code == -1) {
  164. new PNotify({
  165. title: '错误提示',
  166. text: res.message,
  167. type: 'error',
  168. hide: true,
  169. styling: 'bootstrap3'
  170. });
  171. }
  172. }
  173. });
  174. }
  175. /**
  176. * 获取所有药品类型统计报表
  177. */
  178. function getSendDrugRecordData() {
  179. $('#YWaitDialog').css('top', $('.xtd').offset().top);
  180. $('#YWaitDialog').show();
  181. $(".dateRange").html($('#reportrange span').html());
  182. $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
  183. $.ajax({
  184. type: "POST",
  185. url: '/thmz/getSendDrugRecord',
  186. contentType: "application/json;charset=UTF-8",
  187. dataType: "json",
  188. headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
  189. data: JSON.stringify({
  190. 'beginDate': getRePortRangeArr()[0],
  191. 'endDate': getRePortRangeArr()[1],
  192. 'chargeCode': $('#codeSearch').val() == '' ? null : $('#codeSearch').val(),
  193. 'serial': $('#serialSearch').val() == '' ? null : $('#serialSearch').val(),
  194. 'warnDept': $('#unitCodeSearch').val() != null ? $('#unitCodeSearch').val()[0] : null,
  195. 'queryScope': $("#queryScopeSearch").val()
  196. }),
  197. success: function (res) {
  198. $('#YWaitDialog').hide();
  199. if (res == '401' || res == 401) {
  200. window.location.href = '/thmz/login/view'
  201. return;
  202. }
  203. if (res.code == 0) {
  204. let html = '';
  205. let flag = '';//区分门诊住院 -1住院 其它门诊
  206. let number = 0;
  207. let totalNumber = 0;
  208. let sex;
  209. for (var i = 0; i < res.data.length; i++) {
  210. let data = res.data[i];
  211. if (flag == '') {
  212. flag = data.id.indexOf("-") != -1 ? '0' : '1';
  213. number += parseFloat(data.quantity);
  214. } else if (flag == (data.id.indexOf("-") != -1 ? '0' : '1')) {
  215. number += parseFloat(data.quantity);
  216. } else {
  217. html += '<tr class="sjh">';
  218. html += '<td colspan="11" style="text-align: right;font-weight: 700;">小计:' + number + '</td>';
  219. html += '<td colspan="5"></td>';
  220. html += '</tr>';
  221. flag = data.id.indexOf("-") != -1 ? '0' : '1';
  222. totalNumber += number;
  223. number = parseFloat(data.quantity);
  224. }
  225. if (data.sex == 1) {
  226. sex = "男"
  227. } else if (data.sex == 2) {
  228. sex = "女"
  229. } else {
  230. sex = "未知"
  231. }
  232. let queryScope = data.id.indexOf("-") != -1 ? '门诊' : '住院';
  233. let age = data.birthDay != null ? getBirthSlot(data.birthDay, new Date()) : '';
  234. html += '<tr class="sjh">';
  235. html += '<td class="xtd" style="text-align: center;">' + data.id + '</td>';
  236. html += '<td class="xtd" style="text-align: center;">' + data.name + '</td>';
  237. html += '<td class="xtd" style="text-align: center;">' + sex + '</td>';
  238. html += '<td class="xtd" style="text-align: center;">' + age.substring(0, age.indexOf('岁')) + '</td>';
  239. html += '<td class="xtd" style="text-align: center;">' + data.warnDeptName + '</td>';
  240. html += '<td>' + data.icdText + '</td>';
  241. html += '<td class="xtd" style="text-align: center;">' + data.chargeCode + '</td>';
  242. html += '<td>' + data.drugName + '</td>';
  243. html += '<td>' + data.specification + '</td>';
  244. html += '<td>' + data.abbrName + '</td>';
  245. html += '<td class="xtd" style="text-align: center;">' + data.quantity + '</td>';
  246. html += '<td class="exclHide" style="text-align: center;">' + data.chargeDate + '</td>';
  247. let doctorName ='';
  248. if(data.employeeName!=null){
  249. doctorName = data.employeeName.trim().substring(0, 1) + new Array(data.employeeName.trim().length).join('*');
  250. }
  251. html += '<td class="xtd" style="text-align: center;">' + doctorName + '</td>';
  252. html += '<td class="xtd" style="text-align: center;">' + data.supplyName + '</td>';
  253. html += '<td class="xtd" style="text-align: center;">' + data.frequency + '</td>';
  254. html += '<td class="xtd" style="text-align: center;">' + queryScope + '</td>';
  255. html += '</tr>';
  256. }
  257. html += '<tr class="sjh">';
  258. html += '<td colspan="11" style="text-align: right;font-weight: 700;">小计:' + number + '</td>';
  259. html += '<td colspan="5"></td>';
  260. html += '</tr>';
  261. html += '<tr class="sjh">';
  262. html += '<td colspan="11" style="text-align: right;font-weight: 700;">总计:' + parseFloat(totalNumber + number) + '</td>';
  263. html += '<td colspan="5"></td>';
  264. html += '</tr>';
  265. $("#qbtj_table").append(html);
  266. } else if (res.code == -1) {
  267. new PNotify({
  268. title: '错误提示',
  269. text: res.message,
  270. type: 'error',
  271. hide: true,
  272. styling: 'bootstrap3'
  273. });
  274. }
  275. }
  276. });
  277. }
  278. /**
  279. * 获取按钮组选择的下标
  280. * @param id
  281. * @returns {number}
  282. */
  283. function getIndex(id) {
  284. var index = 0;
  285. var item = $("#" + id).find("button");
  286. for (var i = 0; i <= item.length; i++) {
  287. if ($(item[i]).hasClass("btn-primary")) {
  288. index = i;
  289. break;
  290. }
  291. }
  292. return index;
  293. }
  294. /**
  295. * 获取时间选择器的时间数组
  296. * @returns {string[]}
  297. */
  298. function getRePortRangeArr() {
  299. var rePortRange = $('#reportrange span').html();
  300. var rePortRangeArr = rePortRange.split(" - ");
  301. return rePortRangeArr;
  302. }
  303. /**
  304. * 清空查询条件
  305. */
  306. function cleanParams() {
  307. $("#queryScopeSearch").val(0);
  308. $('#queryScopeSearch').selectpicker('refresh');
  309. $('#reportrange span').html(moment().subtract(1, 'days').format("YYYY-MM-DD 14:00:00") + ' - ' + moment().format("YYYY-MM-DD 13:59:59"));
  310. $('#unitCodeSearch').empty();
  311. $('#drugFlagSearch').val(0);
  312. $('#qbtj_table').show();
  313. $('#jmtj_table').hide();
  314. $('.sjh').remove();
  315. $('#drugFlagSearch').selectpicker('refresh');
  316. $("#unitCodeSearch").html('');
  317. $("#unitCodeSearch").selectpicker('refresh');
  318. $('#searchTextDrug').empty();
  319. $('#codeSearch').empty();
  320. $('#serialSearch').empty();
  321. }
  322. /**
  323. * 打印报表
  324. */
  325. function print() {
  326. setDefaultPrint();
  327. LODOP = getLodop();
  328. LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "药品发放统计表");
  329. LODOP.SET_PRINT_PAGESIZE(2, 0, 0, "A4");
  330. //设置默认打印机
  331. LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
  332. LODOP.SET_PRINT_STYLE("FontSize", 10); //字体大小
  333. LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
  334. //设置默认打印机
  335. LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
  336. LODOP.ADD_PRINT_TEXT('200mm', '140mm', '40mm', '40mm', '第#页/共&页');
  337. LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
  338. var strStyle = "<style>table,td,th {border-width: 1px;" +
  339. "border-style: solid;border-collapse: collapse;table-layout:fixed;word-wrap:break-word;font-size: 14px}</style>";
  340. LODOP.ADD_PRINT_HTM("2mm", "4mm", "RightMargin:4mm", "BottomMargin:15mm", strStyle + document.getElementById("report_table_1").innerHTML);
  341. LODOP.PRINT();
  342. //LODOP.PREVIEW();
  343. }
  344. /**
  345. * 统计列表查询参数
  346. */
  347. function queryParams() {
  348. let drugFlags = new Array();
  349. let flag = $("#drugFlagSearch").val();
  350. if (flag == 1) {
  351. drugFlags[0] = 2;
  352. drugFlags[1] = 3;
  353. drugFlags[2] = 5;
  354. } else if (flag == 2) {
  355. drugFlags[0] = 6;
  356. } else if (flag == 3) {
  357. drugFlags[0] = 1;
  358. drugFlags[1] = 4;
  359. }
  360. var temp = {
  361. beginDate: getRePortRangeArr()[0],
  362. endDate: getRePortRangeArr()[1],
  363. chargeItemCode: $('#codeSearch').val(),
  364. unitCode: $('#unitCodeSearch').val() != null ? $('#unitCodeSearch').val()[0] : '',
  365. drugFlags: drugFlags,
  366. queryScope: $("#queryScopeSearch").val()
  367. };
  368. return temp;
  369. }
  370. function init_daterangepickertime() {
  371. if (typeof ($.fn.daterangepicker) === 'undefined') {
  372. return;
  373. }
  374. var optionSet1 = {
  375. startDate: moment().subtract(1, 'days').format("YYYY-MM-DD 00:00:00"),
  376. endDate: moment().subtract(1, 'days').format("YYYY-MM-DD 23:59:59"),
  377. minDate: '2012-01-01',
  378. maxDate: nowString() + ' 23:59:59',
  379. dateLimit: {
  380. days: 1200
  381. },
  382. showDropdowns: true,
  383. showWeekNumbers: true,
  384. ranges: {
  385. '今天': [moment(), moment()],
  386. '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
  387. '最近7天': [moment().subtract(6, 'days'), moment()],
  388. '最近30天': [moment().subtract(29, 'days'), moment()],
  389. '当月': [moment().startOf('month'), moment().endOf('month')],
  390. '上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
  391. },
  392. opens: 'right',
  393. buttonClasses: ['btn btn-default'],
  394. applyClass: 'btn-small btn-primary',
  395. cancelClass: 'btn-small',
  396. timePicker: true, //显示时间
  397. timePicker24Hour: true, //时间制
  398. timePickerSeconds: true, //时间显示到秒
  399. timePickerIncrement: 1,
  400. format: 'YYYY-MM-DD HH:mm:ss',
  401. separator: ' to ',
  402. locale: {
  403. applyLabel: '确定',
  404. cancelLabel: '取消',
  405. fromLabel: 'From',
  406. toLabel: 'To',
  407. customRangeLabel: '自定义',
  408. daysOfWeek: ['天', '一', '二', '三', '四', '五', '六'],
  409. monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
  410. firstDay: 1
  411. }
  412. };
  413. $('#reportrange').daterangepicker(optionSet1, function (start, end, label) {
  414. $('#reportrange span').html(start.format('YYYY-MM-DD HH:mm:ss') + ' - ' + end.format('YYYY-MM-DD HH:mm:ss'));
  415. });
  416. $('#reportrange span').html(moment().subtract(1, 'days').format("YYYY-MM-DD 00:00:00") + ' - ' + moment().subtract(1, 'days').format("YYYY-MM-DD 23:59:59"));
  417. }