| 
					
				 | 
			
			
				@@ -0,0 +1,188 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//@ 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $("#class_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 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            id = 'class_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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#class_table").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#class_table").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#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 totalInMoneyRet = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let totalOutMoneyRet = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (var i = 0; i < res.data.length; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    let data = res.data[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (statisticalMethod == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        let inMoneyRet = isEmpty(data.inMoneyRet)?0:keepTwoDecimal(data.inMoneyRet); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        let outMoneyRet = isEmpty(data.outMoneyRet)?0:keepTwoDecimal(data.outMoneyRet); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        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: center;">' + data.inMoneyBuy + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        html += '<td class="xtd" style="text-align: center;">' + inMoneyRet + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        html += '<td class="xtd" style="text-align: center;">' + outMoneyRet + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        html += '</tr>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        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: center;">' + data.name + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        html += '<td class="xtd" style="text-align: center;">' + inMoneyBuy + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        html += '<td class="xtd" style="text-align: center;">' + inMoneyRet + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        totalInMoneyRet += inMoneyBuy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        totalOutMoneyRet += inMoneyRet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (statisticalMethod == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    html += '<tr class="sjh">'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    html += '<td colspan="3" style="text-align: right;font-weight: 700;">总计:</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    html += '<td style="text-align: center;">' + keepTwoDecimal(totalInMoneyRet) + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    html += '<td style="text-align: center;">' + 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: center;">' + keepTwoDecimal(totalInMoneyRet) + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    html += '<td style="text-align: center;">' + keepTwoDecimal(totalOutMoneyRet) + '</td>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    html += '</tr>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (statisticalMethod == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $("#sum_table").append(html); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $("#class_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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $('#class_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('280mm', '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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |