| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- //@ sourceURL=drug_out_statistics.js
- var LODOP; //声明为全局变量
- var groupYk = window.localStorage["groupYk"];
- var hospitalName ='沭阳铭和医院'
- $(function () {
- getAjaxRequst("/thmz/queryHospitalName",{},true,function (res) {
- hospitalName = res.data
- $('.hospitalName').text(hospitalName)
- })
- if (groupYk == null) {
- return errorMesageSimaple('药库参数未设置,请在发药参数设置中设置');
- }
- init_daterangepicker();
- setTimeout(function () {
- getLodop();
- }, 800);
- $("#money_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 = 'ck_bs_table';
- } else {
- id = 'money_table';
- }
- $("#" + id).table2excel({
- exclude: ".exclHide",
- filename: $("#" + id + " .title").html() + "(" + getRePortRangeArr()[0] + ").xls"
- })
- });
- $("#statisticalMethod").change(function (t, d, e) {
- let statisticalMethod = $("#statisticalMethod").val();
- if (statisticalMethod == 0) {
- $("#ck_bs_table").show();
- $("#money_table").hide();
- } else {
- $("#money_table").show();
- $("#ck_bs_table").hide();
- }
- $(".dateRange").html($('#reportrange span').html());
- $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
- });
- });
- /**
- * 获取汇总药品统计报表
- */
- function getRecordData() {
- let statisticalMethod = $('#statisticalMethod').val();
- if (statisticalMethod == 0) {
- url = '/thmz/getDrugOutStatistics';
- } else {
- url = '/thmz/getDeptDrugMoney';
- }
- 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: url,
- 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) {
- console.log(res);
- let html = '';
- let totalBuyPriceSum = 0;
- let totalPackRetpriceSum = 0;
- let totalAmount = 0;
- let totalDrawCount = 0;
- for (var i = 0; i < res.data.length; i++) {
- let data = res.data[i];
- if (statisticalMethod == 0) {
- let buyPriceSum = isEmpty(data.buyPriceSum) ? 0 : keepTwoDecimal(data.buyPriceSum);
- let packRetpriceSum = isEmpty(data.packRetpriceSum) ? 0 : keepTwoDecimal(data.packRetpriceSum);
- html += '<tr class="sjh">';
- if (i > 0 && i != (res.data.length - 1) && data.deptName === res.data[i - 1].deptName) {
- html += '<td class="xtd" style="text-align: center;"></td>';
- } else {
- html += '<td class="xtd" style="text-align: center;">' + data.deptName + '</td>';
- }
- html += '<td class="xtd" style="text-align: center;">' + data.kindName + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.drawCount + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.amount + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + buyPriceSum + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + packRetpriceSum + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + keepTwoDecimal(packRetpriceSum - buyPriceSum) + '</td>';
- html += '</tr>';
- totalBuyPriceSum += buyPriceSum;
- totalPackRetpriceSum += packRetpriceSum;
- totalAmount += data.amount;
- totalDrawCount += data.drawCount;
- } else {
- let totalMoney = isEmpty(data.totalMoney) ? 0 : keepTwoDecimal(data.totalMoney);
- totalPackRetpriceSum += totalMoney;
- html += '<tr class="sjh">';
- if (i > 0 && i != (res.data.length - 1) && data.deptName === res.data[i - 1].deptName) {
- html += '<td class="xtd" style="text-align: center;"></td>';
- } else {
- html += '<td class="xtd" style="text-align: center;">' + data.type + "-" + data.deptName + '</td>';
- }
- html += '<td class="xtd" style="text-align: center;">' + data.kindName + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + totalMoney + '</td>';
- for (let j = 0; j < res.typeSumData.length; j++) {
- if(res.typeSumData[j].deptCode == data.deptCode && res.typeSumData[j].type == data.type){
- html += '<td class="xtd" style="text-align: center;">' + keepTwoDecimal(totalMoney/res.typeSumData[j].totalMoney*100) + '%</td>';
- break;
- }
- }
- html += '</tr>';
- if (i > 0 && i != (res.data.length - 1) && data.deptName !== res.data[i + 1].deptName) {
- html += '<tr class="sjh">';
- html += '<td class="xtd" colspan="2" style="text-align: right;font-weight: 700;">科室总额</td>';
- html += '<td class="xtd" colspan="2" style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
- html += '</tr>';
- totalPackRetpriceSum = 0;
- }
- }
- }
- if (statisticalMethod == 0) {
- html += '<tr class="sjh">';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">合计</td>';
- html += '<td style="text-align: right;font-weight: 700;">' + totalDrawCount + '</td>';
- html += '<td style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalAmount) + '</td>';
- html += '<td style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalBuyPriceSum) + '</td>';
- html += '<td style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
- html += '<td style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum - totalBuyPriceSum) + '</td>';
- html += '</tr>';
- }
- totalBuyPriceSum = 0;
- totalPackRetpriceSum = 0;
- for (var i = 0; i < res.sumData.length; i++) {
- let sumData = res.sumData[i];
- if (i == 0) {
- if (statisticalMethod == 0) {
- html += '<tr class="sjh">';
- html += '<td colspan="7" style="text-align: center;font-weight: 700;">小类汇总</td>';
- html += '</tr>';
- html += '<tr class="sjh">';
- html += '<td style="text-align: center;font-weight: 700;">分类</td>';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">购入金额</td>';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">零售金额</td>';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">差额</td>';
- html += '</tr>';
- } else {
- html += '<tr class="sjh">';
- html += '<td colspan="4" style="text-align: center;font-weight: 700;">类别汇总</td>';
- html += '</tr>';
- html += '<tr class="sjh">';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">药品类别</td>';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">零售金额</td>';
- html += '</tr>';
- }
- }
- if (statisticalMethod == 0) {
- html += '<tr class="sjh">';
- html += '<td style="text-align: center;">' + sumData.kindName + '</td>';
- html += '<td colspan="2" style="text-align: center;">' + keepTwoDecimal(sumData.buyPriceSum) + '</td>';
- html += '<td colspan="2" style="text-align: center;">' + keepTwoDecimal(sumData.packRetpriceSum) + '</td>';
- html += '<td colspan="2" style="text-align: center;">' + keepTwoDecimal(sumData.differencePrice) + '</td>';
- html += '</tr>';
- } else {
- totalPackRetpriceSum += keepTwoDecimal(sumData.totalMoney);
- html += '<tr class="sjh">';
- html += '<td colspan="2" style="text-align: center;">' + sumData.kindName + '</td>';
- html += '<td colspan="2" style="text-align: right;">' + keepTwoDecimal(sumData.totalMoney) + '</td>';
- html += '</tr>';
- }
- }
- if (statisticalMethod == 1) {
- html += '<tr class="sjh">';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">总计</td>';
- html += '<td colspan="2" style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
- html += '</tr>';
- }
- if (!isEmpty(res.hzData)) {
- for (var i = 0; i < res.hzData.length; i++) {
- let hzData = res.hzData[i];
- if (i == 0) {
- html += '<tr class="sjh">';
- html += '<td colspan="7" style="text-align: center;font-weight: 700;">大类汇总</td>';
- html += '</tr>';
- html += '<tr class="sjh">';
- html += '<td style="text-align: center;font-weight: 700;">分类</td>';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">购入金额</td>';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">零售金额</td>';
- html += '<td colspan="2" style="text-align: center;font-weight: 700;">差额</td>';
- html += '</tr>';
- }
- if (hzData.buyPriceSum == 0 && hzData.packRetpriceSum == 0) {
- continue;
- }
- html += '<tr class="sjh">';
- html += '<td style="text-align: center;">' + hzData.typeName + '</td>';
- html += '<td colspan="2" style="text-align: center;">' + keepTwoDecimal(hzData.buyPriceSum) + '</td>';
- html += '<td colspan="2" style="text-align: center;">' + keepTwoDecimal(hzData.packRetpriceSum) + '</td>';
- html += '<td colspan="2" style="text-align: center;">' + keepTwoDecimal(hzData.differencePrice) + '</td>';
- html += '</tr>';
- totalBuyPriceSum += keepTwoDecimal(hzData.buyPriceSum);
- totalPackRetpriceSum += keepTwoDecimal(hzData.packRetpriceSum);
- }
- html += '<tr class="sjh">';
- html += '<td style="text-align: center;font-weight: 700;">合计</td>';
- html += '<td colspan="2" style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalBuyPriceSum) + '</td>';
- html += '<td colspan="2" style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
- html += '<td colspan="2" style="text-align: right;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum - totalBuyPriceSum) + '</td>';
- html += '</tr>';
- html += '<tr class="sjh">';
- html += '<td style="text-align: left;font-weight: 700;border: transparent !important;"><br>入库记账:</td>';
- html += '<td colspan="2" style="text-align: left;font-weight: 700;border: transparent !important;"><br>验收人:</td>';
- html += '<td colspan="2" style="text-align: left;font-weight: 700;border: transparent !important;;"><br>复核人:</td>';
- html += '<td colspan="2" style="text-align: left;font-weight: 700;border: transparent !important;;"><br>药品会计:</td>';
- html += '</tr>';
- html += '<tr class="sjh">';
- html += '<td colspan="7" style="text-align: left;font-weight: 700;border: transparent !important;"><br>科室主任:</td>';
- html += '</tr>';
- }
- if (statisticalMethod == 0) {
- $("#ck_bs_table").append(html);
- } else {
- $("#money_table").append(html);
- }
- } else if (res.code == -1) {
- new PNotify({
- title: '错误提示',
- text: res.message,
- type: 'error',
- hide: true,
- styling: 'bootstrap3'
- });
- }
- }
- });
- }
- /**
- * 清空查询条件
- */
- 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"));
- $('#ck_bs_table').show();
- $('#money_table').hide();
- $('.sjh').remove();
- }
- /**
- * 打印报表
- */
- function print() {
- setDefaultPrint();
- LODOP = getLodop();
- LODOP.PRINT_INITA(6, 0, "221mm", "93mm", "药品出入库统计表");
- LODOP.SET_PRINT_PAGESIZE(1, "221mm", "93mm", "");
- //设置默认打印机
- LODOP.SET_PRINTER_INDEX(defaultPrintIndex);
- LODOP.SET_PRINT_STYLE("FontSize", 10); //字体大小
- 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();
- }
|