| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- //@ sourceURL=drug_in_out_count.js
- var LODOP; //声明为全局变量
- var groupYk = window.localStorage["groupYk"];
- $(function () {
- if (groupYk == null) {
- return errorMesageSimaple('药库参数未设置,请在发药参数设置中设置');
- }
- init_daterangepicker();
- setTimeout(function () {
- getLodop();
- }, 800);
- $("#kind_table").hide();
- $("#class_sum_table").hide();
- $(".selectpicker").selectpicker({
- dropuAuto: false
- });
- //初始化页面上面的按钮事件
- $("#btn_search").click(function (t) {
- $('.sjh').remove();
- getRecordData();
- });
- $('#btn_clean').click(function () {
- cleanParams();
- });
- $("#btn_daily").click(function (t) {
- print();
- });
- $("#btn_excel").click(function (t) {
- let statisticalMethod = $("#statisticalMethod").val();
- let id = "";
- if (statisticalMethod === "0") {
- id = 'sum_table';
- } else if (statisticalMethod === "2") {
- id = 'class_sum_table';
- } else {
- id = 'kind_table';
- }
- $("#" + id).table2excel({
- exclude: ".exclHide",
- filename: $("#" + id + " .title").html() + "(" + getRePortRangeArr()[0].substring(0, getRePortRangeArr()[0].indexOf(" ") + 1) + ").xls"
- })
- });
- $("#statisticalMethod").change(function (t, d, e) {
- let statisticalMethod = $("#statisticalMethod").val();
- if (statisticalMethod === "0") {
- $("#sum_table").show();
- $("#kind_table").hide();
- $("#class_sum_table").hide();
- }else if (statisticalMethod === "2") {
- $("#sum_table").hide();
- $("#kind_table").hide();
- $("#class_sum_table").show();
- } else {
- $("#kind_table").show();
- $("#sum_table").hide();
- $("#class_sum_table").hide();
- }
- $(".dateRange").html($('#reportrange span').html());
- $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
- });
- });
- /**
- * 获取汇总药品统计报表
- */
- function getRecordData() {
- let statisticalMethod = $('#statisticalMethod').val();
- let data = {
- 'beginDate': getRePortRangeArr()[0],
- 'endDate': getRePortRangeArr()[1],
- 'flag': statisticalMethod,
- 'groupNo': groupYk,
- };
- $('#YWaitDialog').css('top', $('.xtd').offset().top);
- $('#YWaitDialog').show();
- $(".dateRange").html($('#reportrange span').html());
- $(".groupName").html(getGroupName(groupYk));
- $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
- $.ajax({
- type: "POST",
- url: '/thmz/getDrugMoneyCount',
- contentType: "application/json;charset=UTF-8",
- dataType: "json",
- headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
- data: JSON.stringify(data),
- success: function (res) {
- $('#YWaitDialog').hide();
- if (res == '401' || res == 401) {
- window.location.href = '/thmz/login/view'
- return;
- }
- if (res.code == 0) {
- let html = '';
- let totalInMoneyBuy = 0;
- let totalInMoneyRet = 0;
- let totalOutMoneyRet = 0;
- for (var i = 0; i < res.data.length; i++) {
- let data = res.data[i];
- let inMoneyBuy = isEmpty(data.inMoneyBuy)?0:keepTwoDecimal(data.inMoneyBuy);
- let inMoneyRet = isEmpty(data.inMoneyRet)?0:keepTwoDecimal(data.inMoneyRet);
- let outMoneyRet = isEmpty(data.outMoneyRet)?0:keepTwoDecimal(data.outMoneyRet);
- if (statisticalMethod == 0) {
- html += '<tr class="sjh">';
- html += '<td class="xtd" style="text-align: center;">' + (i + 1) + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.countDate + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + inMoneyBuy + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + inMoneyRet + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + outMoneyRet + '</td>';
- html += '</tr>';
- totalInMoneyBuy += inMoneyBuy;
- totalInMoneyRet += inMoneyRet;
- totalOutMoneyRet += outMoneyRet;
- }else if (statisticalMethod == 2) {
- let inMoneyBuy = isEmpty(data.inMoneyBuy)?0:keepTwoDecimal(data.inMoneyBuy);
- let inMoneyRet = isEmpty(data.inMoneyRet)?0:keepTwoDecimal(data.inMoneyRet);
- let outMoneyRet = isEmpty(data.outMoneyRet)?0:keepTwoDecimal(data.outMoneyRet);
- html += '<tr class="sjh">';
- html += '<td colspan="2" class="xtd" style="text-align: left;">' + data.kindName + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + inMoneyBuy + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + inMoneyRet + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + outMoneyRet + '</td>';
- html += '</tr>';
- totalInMoneyBuy += inMoneyBuy;
- totalInMoneyRet += inMoneyRet;
- totalOutMoneyRet += outMoneyRet
- } else {
- let inMoneyBuy = isEmpty(data.inMoneyBuy)?0:keepTwoDecimal(data.inMoneyBuy);
- let inMoneyRet = isEmpty(data.inMoneyRet)?0:keepTwoDecimal(data.inMoneyRet);
- html += '<tr class="sjh">';
- html += '<td class="xtd" style="text-align: left;">' + data.name + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + inMoneyBuy + '</td>';
- html += '<td class="xtd" style="text-align: right;">' + inMoneyRet + '</td>';
- totalInMoneyRet += inMoneyBuy;
- totalOutMoneyRet += inMoneyRet
- }
- }
- if (statisticalMethod == 0 || statisticalMethod == 2) {
- html += '<tr class="sjh">';
- html += '<td colspan="2" style="text-align: right;font-weight: 700;">总计:</td>';
- html += '<td style="text-align: right;">' + keepTwoDecimal(totalInMoneyBuy) + '</td>';
- html += '<td style="text-align: right;">' + keepTwoDecimal(totalInMoneyRet) + '</td>';
- html += '<td style="text-align: right;">' + keepTwoDecimal(totalOutMoneyRet) + '</td>';
- html += '</tr>';
- }else{
- html += '<tr class="sjh">';
- html += '<td style="text-align: right;font-weight: 700;">总计:</td>';
- html += '<td style="text-align: right;">' + keepTwoDecimal(totalInMoneyRet) + '</td>';
- html += '<td style="text-align: right;">' + keepTwoDecimal(totalOutMoneyRet) + '</td>';
- html += '</tr>';
- }
- if (statisticalMethod == 0) {
- $("#sum_table").append(html);
- }else if (statisticalMethod == 2) {
- $("#class_sum_table").append(html);
- }else {
- $("#kind_table").append(html);
- }
- } else if (res.code == -1) {
- new PNotify({
- title: '错误提示',
- text: res.message,
- type: 'error',
- hide: true,
- styling: 'bootstrap3'
- });
- }
- }
- });
- }
- /**
- * 获取时间选择器的时间数组
- * @returns {string[]}
- */
- function getRePortRangeArr() {
- var rePortRange = $('#reportrange span').html();
- var rePortRangeArr = rePortRange.split(" - ");
- return rePortRangeArr;
- }
- /**
- * 清空查询条件
- */
- function cleanParams() {
- $("#statisticalMethod").val(0);
- $('#statisticalMethod').selectpicker('refresh');
- $('#reportrange span').html(moment().subtract(1, 'days').format("YYYY-MM-DD") + ' - ' + moment().subtract(1, 'days').format("YYYY-MM-DD"));
- $('#sum_table').show();
- $('#kind_table').hide();
- $('#class_sum_table').hide();
- $('.sjh').remove();
- }
- /**
- * 打印报表
- */
- function print() {
- setDefaultPrint();
- LODOP = getLodop();
- LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "药品出入库统计表");
- LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
- //设置默认打印机
- LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
- LODOP.SET_PRINT_STYLE("FontSize", 10); //字体大小
- LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
- //设置默认打印机
- LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
- LODOP.ADD_PRINT_TEXT('285mm', '100mm', '40mm', '40mm', '第#页/共&页');
- LODOP.SET_PRINT_STYLEA(0, "ItemType", 2);
- var strStyle = "<style>table,td,th {border-width: 1px;" +
- "border-style: solid;border-collapse: collapse;table-layout:fixed;word-wrap:break-word;font-size: 14px}</style>";
- LODOP.ADD_PRINT_HTM("2mm", "4mm", "RightMargin:4mm", "BottomMargin:15mm", strStyle + document.getElementById("report_table_1").innerHTML);
- LODOP.PRINT();
- //LODOP.PREVIEW();
- }
|