|
|
@@ -0,0 +1,201 @@
|
|
|
+//@ sourceURL=drug_use_quantity_count.js
|
|
|
+var LODOP; //声明为全局变量
|
|
|
+var groupYk = window.localStorage["groupYk"];
|
|
|
+$(function () {
|
|
|
+ if (groupYk == null) {
|
|
|
+ return errorMesageSimaple('药库参数未设置,请在发药参数设置中设置');
|
|
|
+ }
|
|
|
+ init_daterangepicker();
|
|
|
+ $('#reportrange span').html(moment().subtract(1, 'month').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
|
|
|
+ setTimeout(function () {
|
|
|
+ getLodop();
|
|
|
+ }, 800);
|
|
|
+ initDynamicSelect("queryYpZdClasses", "classCode");
|
|
|
+ initDynamicSelect("queryYpZdDrugKindAll", "drugKind");
|
|
|
+ initDynamicSelect("allUnitCode", 'deptCode');
|
|
|
+ initForm(0);
|
|
|
+ $("#out_detl_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" || statisticalMethod === "1") {
|
|
|
+ id = 'use_table';
|
|
|
+ } else {
|
|
|
+ id = 'out_detl_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) {
|
|
|
+ $(".title").html('药品使用量统计');
|
|
|
+ $(".sl").html('数量');
|
|
|
+ initForm(0)
|
|
|
+ } else if (statisticalMethod == 1) {
|
|
|
+ $(".title").html('未使用药品统计');
|
|
|
+ $(".sl").html('库存');
|
|
|
+ initForm(0)
|
|
|
+ } else {
|
|
|
+ initForm(1)
|
|
|
+ }
|
|
|
+ $('.sjh').remove();
|
|
|
+ $(".dateRange").html($('#reportrange span').html());
|
|
|
+ $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取汇总药品统计报表
|
|
|
+ */
|
|
|
+function getRecordData() {
|
|
|
+ let statisticalMethod = $('#statisticalMethod').val();
|
|
|
+ let data = {
|
|
|
+ 'beginDate': getRePortRangeArrTime()[0],
|
|
|
+ 'endDate': getRePortRangeArrTime()[1],
|
|
|
+ 'flag': statisticalMethod,
|
|
|
+ 'groupNo': groupYk,
|
|
|
+ 'deptCode': isEmpty($('#deptCode').val()) ? null : $('#deptCode').val()[0],
|
|
|
+ 'drugKind': isEmpty($('#drugKind').val()) ? null : $('#drugKind').val()[0],
|
|
|
+ 'classCode': isEmpty($('#classCode').val()) ? null : $('#classCode').val()[0]
|
|
|
+ };
|
|
|
+ $('#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"));
|
|
|
+ request({
|
|
|
+ url: '/getDrugUseQuantitySort',
|
|
|
+ method: 'POST',
|
|
|
+ data: JSON.stringify(data)
|
|
|
+ }).then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ let html = '';
|
|
|
+ let totalPackRetpriceSum = 0;
|
|
|
+ let totalBuyPriceSum = 0;
|
|
|
+ let totalAmount = 0;
|
|
|
+ for (var i = 0; i < res.data.length; i++) {
|
|
|
+ let data = res.data[i];
|
|
|
+ let packRetpriceSum = isEmpty(data.price) ? 0 : keepTwoDecimal(data.price);
|
|
|
+ if (statisticalMethod == 2) {
|
|
|
+ packRetpriceSum = isEmpty(data.lsje) ? 0 : keepTwoDecimal(data.lsje);
|
|
|
+ let buyPriceSum = isEmpty(data.grje) ? 0 : keepTwoDecimal(data.grje);
|
|
|
+ html += '<tr class="sjh">';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + (i + 1) + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: left;">' + data.name + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: left;">' + data.kind_name + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: left;">' + data.class_name + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + data.specification + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: right;">' + packRetpriceSum + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: right;">' + buyPriceSum + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + data.out_amt + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + data.dept_name + '</td>';
|
|
|
+ html += '</tr>';
|
|
|
+ totalPackRetpriceSum += packRetpriceSum;
|
|
|
+ totalBuyPriceSum += buyPriceSum;
|
|
|
+ } else {
|
|
|
+ html += '<tr class="sjh">';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + (i + 1) + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + data.code + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: left;">' + data.name + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + data.specification + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: right;">' + packRetpriceSum + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: center;">' + keepTwoDecimal(data.quantity) + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: right;">' + keepTwoDecimal(data.quantity * packRetpriceSum) + '</td>';
|
|
|
+ html += '<td class="xtd" style="text-align: left;">' + data.manuName + '</td>';
|
|
|
+ html += '</tr>';
|
|
|
+ totalPackRetpriceSum += packRetpriceSum;
|
|
|
+ totalAmount += data.quantity;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (statisticalMethod == 0) {
|
|
|
+ html += '<tr class="sjh">';
|
|
|
+ html += '<td colspan="5" style="text-align: center;font-weight: 700;">合计</td>';
|
|
|
+ html += '<td style="text-align: left;font-weight: 700;">' + totalAmount + '</td>';
|
|
|
+ html += '<td colspan="3" style="text-align: left;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
|
|
|
+ html += '</tr>';
|
|
|
+ } else if (statisticalMethod == 2) {
|
|
|
+ html += '<tr class="sjh">';
|
|
|
+ html += '<td colspan="5" style="text-align: center;font-weight: 700;">合计</td>';
|
|
|
+ html += '<td style="text-align: left;font-weight: 700;">' + keepTwoDecimal(totalPackRetpriceSum) + '</td>';
|
|
|
+ html += '<td colspan="3" style="text-align: left;font-weight: 700;">' + keepTwoDecimal(totalBuyPriceSum) + '</td>';
|
|
|
+ html += '</tr>';
|
|
|
+ }
|
|
|
+ if (statisticalMethod == 2) {
|
|
|
+ $("#out_detl_table").append(html);
|
|
|
+ } else {
|
|
|
+ $("#use_table").append(html);
|
|
|
+ }
|
|
|
+ successMesage(res);
|
|
|
+ $('#YWaitDialog').hide();
|
|
|
+ }, err => {
|
|
|
+ $('#YWaitDialog').hide();
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 清空查询条件
|
|
|
+ */
|
|
|
+function cleanParams() {
|
|
|
+ $("#statisticalMethod").val(0);
|
|
|
+ $("select").selectpicker('refresh');
|
|
|
+ $('#reportrange span').html(moment().subtract(1, 'month').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
|
|
|
+ $('.sjh').remove();
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 打印报表
|
|
|
+ */
|
|
|
+function print() {
|
|
|
+ setDefaultPrint();
|
|
|
+ LODOP = getLodop();
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
|
|
|
+ LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "药品使用情况统计表");
|
|
|
+ LODOP.ADD_PRINT_TEXT('288mm', '100mm', '40mm', '40mm', '第#页/共&页');
|
|
|
+ //设置默认打印机
|
|
|
+ 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();
|
|
|
+}
|
|
|
+
|
|
|
+function initForm(flag) {
|
|
|
+ if (flag == 0) {
|
|
|
+ $("#classCode").val(null);
|
|
|
+ $("#drugKind").val(null);
|
|
|
+ $("#deptCode").val(null);
|
|
|
+ $("#classCode").attr("disabled", "disabled");
|
|
|
+ $("#drugKind").attr("disabled", "disabled");
|
|
|
+ $("#deptCode").attr("disabled", "disabled");
|
|
|
+ $("#use_table").show();
|
|
|
+ $("#out_detl_table").hide();
|
|
|
+ } else {
|
|
|
+ $("#classCode").attr("disabled", false);
|
|
|
+ $("#drugKind").attr("disabled", false);
|
|
|
+ $("#deptCode").attr("disabled", false);
|
|
|
+ $("#use_table").hide();
|
|
|
+ $("#out_detl_table").show();
|
|
|
+ }
|
|
|
+ $("select").selectpicker('refresh');
|
|
|
+}
|