123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- //@ sourceURL=spirit_anesthetic_print.js
- var LODOP; //声明为全局变量
- $(function () {
- initDeptSelect(0,"unitCodeSearch");
- init_daterangepickertime();
- setTimeout(function () {
- getLodop();
- }, 800);
- $("#jmtj_table").hide();
- $(".selectpicker").selectpicker({
- dropuAuto: false
- });
- //初始化页面上面的按钮事件
- $("#btn_search").click(function (t) {
- $('.sjh').remove();
- if($('#drugFlagSearch').val() == 0){
- getSendDrugRecordData();
- }else{
- getSpiritAnestheticPrintData();
- }
- });
- $('#btn_clean').click(function () {
- cleanParams();
- });
- $("#btn_daily").click(function (t) {
- print();
- });
- $("#btn_excel").click(function (t) {
- let id = "qbtj_table";
- let name = "药品发药明细统计表";
- if($("#qbtj_table").is(':hidden')){
- id = "jmtj_table";
- let drugFlag = $("#drugFlagSearch").val();
- if(drugFlag == 1){
- name = "麻、精一及麻黄碱类药品使用登记";
- }else if(drugFlag == 2){
- name = "终止妊娠药统计";
- }else if(drugFlag == 3){
- name = "精二类统计";
- }
- }
- $("#"+id).table2excel({
- exclude:".exclHide",
- filename:name+"("+getRePortRangeArr()[0].substring(0,getRePortRangeArr()[0].indexOf(" ")+1)+").xls"
- })
- });
- $("#drugFlagSearch").change(function (t,d,e) {
- let drugFlag = $("#drugFlagSearch").val();
- let title = "";
- if(drugFlag == 1){
- title = "麻、精一及麻黄碱类药品使用登记";
- $("#jmtj_table").show();
- $("#qbtj_table").hide();
- }else if(drugFlag == 2){
- title = "终止妊娠药统计";
- $("#jmtj_table").show();
- $("#qbtj_table").hide();
- }else if(drugFlag == 3){
- title = "精二类统计";
- $("#jmtj_table").show();
- $("#qbtj_table").hide();
- }else if(drugFlag == 0){
- title = "药品发药明细统计表";
- $("#qbtj_table").show();
- $("#jmtj_table").hide();
- }
- $(".title").html(title);
- $(".dateRange").html($('#reportrange span').html());
- $(".printDate").html(format(new Date(),"yyyy-MM-dd HH:mm"));
- });
- //初始化药品查询弹出框
- initSearchList('<div id="medicinePopoverContent"><table id="tb_table_medicine"></table></div>',
- 'searchTextDrug', 700, 250);
- $('#searchTextDrug').on('input focus',function(e){
- showDrugPopover();
- if($('#searchTextDrug').val() == ''){
- $('#codeSearch').val("");
- $('#serialSearch').val("");
- }
- });
- });
- /**
- * 获取精麻药统计报表
- */
- function getSpiritAnestheticPrintData() {
- $(".dateRange").html($('#reportrange span').html());
- $(".printDate").html(format(new Date(),"yyyy-MM-dd HH:mm"));
- $.ajax({
- type: "GET",
- url: '/thmz/getSpiritAnestheticPrint',
- contentType: "application/json;charset=UTF-8",
- dataType: "json",
- headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
- data: queryParams(),
- success: function (res) {
- if (res == '401' || res == 401) {
- window.location.href = '/thmz/login/view'
- return;
- }
- if (res.code == 0) {
- let html = '';
- let code = '';
- let number = 0;
- let sex;
- let drugFlag = $("#drugFlagSearch").val();
- for (var i = 0; i < res.data.length; i++) {
- let data = res.data[i];
- if(code == ''){
- code = data.chargeItemCode;
- number += parseFloat(data.quantity);
- }else if(code == data.chargeItemCode){
- number += parseFloat(data.quantity);
- }else{
- html += '<tr class="sjh">';
- html += '<td colspan="15" style="text-align: center;font-weight: 700;">共计:' + number + '</td>';
- html += '</tr>';
- code = data.chargeItemCode;
- number = parseFloat(data.quantity);
- }
- if(data.sex == 1){
- sex = "男"
- }else if(data.sex == 2){
- sex = "女"
- }else{
- sex = "未知"
- }
- html += '<tr class="sjh">';
- html += '<td class="xtd" style="text-align: center;mso-number-format: \'\\@\';">' + data.chargeDate.substring(5,11) + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.patientId + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.name + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + sex + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.age + '</td>';
- html += '<td style="mso-number-format: \'\\@\';">' + data.socialNo + '</td>';
- html += '<td>' + data.icdText + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.chargeItemCode + '</td>';
- html += '<td>' + data.drugname + '</td>';
- html += '<td>' + data.specification + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.quantity + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.employeeName.trim() + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.warnDeptName + '</td>';
- html += '<td class="xtd" ></td>';
- html += '<td class="xtd" ></td>';
- html += '</tr>';
- }
- html += '<tr class="sjh">';
- html += '<td colspan="15" style="text-align: center;font-weight: 700;">共计:' + number + '</td>';
- html += '</tr>';
- $("#jmtj_table").append(html);
- } else if (res.code == -1) {
- new PNotify({
- title: '错误提示',
- text: res.message,
- type: 'error',
- hide: true,
- styling: 'bootstrap3'
- });
- }
- }
- });
- }
- /**
- * 获取所有药品类型统计报表
- */
- function getSendDrugRecordData() {
- $('#YWaitDialog').css('top',$('.xtd').offset().top);
- $('#YWaitDialog').show();
- $(".dateRange").html($('#reportrange span').html());
- $(".printDate").html(format(new Date(),"yyyy-MM-dd HH:mm"));
- $.ajax({
- type: "POST",
- url: '/thmz/getSendDrugRecord',
- contentType: "application/json;charset=UTF-8",
- dataType: "json",
- headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
- data: JSON.stringify({
- 'beginDate': getRePortRangeArr()[0],
- 'endDate': getRePortRangeArr()[1],
- 'chargeCode': $('#codeSearch').val()==''?null:$('#codeSearch').val(),
- 'serial': $('#serialSearch').val()==''?null:$('#serialSearch').val(),
- 'warnDept': $('#unitCodeSearch').val()!=null?$('#unitCodeSearch').val()[0]:null,
- 'queryScope': $("#queryScopeSearch").val()
- }),
- success: function (res) {
- $('#YWaitDialog').hide();
- if (res == '401' || res == 401) {
- window.location.href = '/thmz/login/view'
- return;
- }
- if (res.code == 0) {
- let html = '';
- let flag = '';//区分门诊住院 -1住院 其它门诊
- let number = 0;
- let totalNumber = 0;
- let sex;
- for (var i = 0; i < res.data.length; i++) {
- let data = res.data[i];
- if(flag == ''){
- flag = data.id.indexOf("-")!=-1?'0':'1';
- number += parseFloat(data.quantity);
- }else if(flag == (data.id.indexOf("-")!=-1?'0':'1')){
- number += parseFloat(data.quantity);
- }else{
- html += '<tr class="sjh">';
- html += '<td colspan="11" style="text-align: right;font-weight: 700;">小计:' + number + '</td>';
- html += '<td colspan="5"></td>';
- html += '</tr>';
- flag = data.id.indexOf("-")!=-1?'0':'1';
- totalNumber += number;
- number = parseFloat(data.quantity);
- }
- if(data.sex == 1){
- sex = "男"
- }else if(data.sex == 2){
- sex = "女"
- }else{
- sex = "未知"
- }
- let queryScope = data.id.indexOf("-")!=-1?'门诊':'住院';
- let age = data.birthDay!=null?getBirthSlot(data.birthDay,new Date()):'';
- html += '<tr class="sjh">';
- html += '<td class="xtd" style="text-align: center;">' + data.id + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.name + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + sex + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + age.substring(0,age.indexOf('岁')) + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.warnDeptName + '</td>';
- html += '<td>' + data.icdText + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.chargeCode + '</td>';
- html += '<td>' + data.drugName + '</td>';
- html += '<td>' + data.specification + '</td>';
- html += '<td>' + data.abbrName + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.quantity + '</td>';
- html += '<td class="exclHide" style="text-align: center;">' + data.chargeDate + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.employeeName.trim().substring(0,1)+new Array(data.employeeName.trim().length).join('*') + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.supplyName + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + data.frequency + '</td>';
- html += '<td class="xtd" style="text-align: center;">' + queryScope + '</td>';
- html += '</tr>';
- }
- html += '<tr class="sjh">';
- html += '<td colspan="11" style="text-align: right;font-weight: 700;">小计:' + number + '</td>';
- html += '<td colspan="5"></td>';
- html += '</tr>';
- html += '<tr class="sjh">';
- html += '<td colspan="11" style="text-align: right;font-weight: 700;">总计:' + parseFloat(totalNumber+number) + '</td>';
- html += '<td colspan="5"></td>';
- html += '</tr>';
- $("#qbtj_table").append(html);
- } else if (res.code == -1) {
- new PNotify({
- title: '错误提示',
- text: res.message,
- type: 'error',
- hide: true,
- styling: 'bootstrap3'
- });
- }
- }
- });
- }
- /**
- * 获取按钮组选择的下标
- * @param id
- * @returns {number}
- */
- function getIndex(id) {
- var index = 0;
- var item = $("#" + id).find("button");
- for (var i = 0; i <= item.length; i++) {
- if ($(item[i]).hasClass("btn-primary")) {
- index = i;
- break;
- }
- }
- return index;
- }
- /**
- * 获取时间选择器的时间数组
- * @returns {string[]}
- */
- function getRePortRangeArr() {
- var rePortRange = $('#reportrange span').html();
- var rePortRangeArr = rePortRange.split(" - ");
- return rePortRangeArr;
- }
- /**
- * 清空查询条件
- */
- function cleanParams() {
- $("#queryScopeSearch").val(0);
- $('#queryScopeSearch').selectpicker('refresh');
- $('#reportrange span').html(moment().subtract(1, 'days').format("YYYY-MM-DD 14:00:00") + ' - ' + moment().format("YYYY-MM-DD 13:59:59"));
- $('#unitCodeSearch').empty();
- $('#drugFlagSearch').val(0);
- $('#qbtj_table').show();
- $('#jmtj_table').hide();
- $('.sjh').remove();
- $('#drugFlagSearch').selectpicker('refresh');
- $("#unitCodeSearch").html('');
- $("#unitCodeSearch").selectpicker('refresh');
- $('#searchTextDrug').empty();
- $('#codeSearch').empty();
- $('#serialSearch').empty();
- }
- /**
- * 打印报表
- */
- function print() {
- setDefaultPrint();
- LODOP = getLodop();
- LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "药品发放统计表");
- LODOP.SET_PRINT_PAGESIZE(2, 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('200mm','140mm','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();
- }
- /**
- * 统计列表查询参数
- */
- function queryParams() {
- let drugFlags = new Array();
- let flag = $("#drugFlagSearch").val();
- if(flag == 1){
- drugFlags[0] = 2;
- drugFlags[1] = 3;
- drugFlags[2] = 5;
- }else if(flag == 2){
- drugFlags[0] = 6;
- }else if(flag == 3){
- drugFlags[0] = 1;
- drugFlags[1] = 4;
- }
- var temp = {
- beginDate: getRePortRangeArr()[0],
- endDate: getRePortRangeArr()[1],
- chargeItemCode: $('#codeSearch').val(),
- unitCode: $('#unitCodeSearch').val()!=null?$('#unitCodeSearch').val()[0]:'',
- drugFlags: drugFlags,
- queryScope: $("#queryScopeSearch").val()
- };
- return temp;
- }
- function init_daterangepickertime() {
- if (typeof ($.fn.daterangepicker) === 'undefined') {
- return;
- }
- var optionSet1 = {
- startDate: moment().subtract(1, 'days').format("YYYY-MM-DD 00:00:00"),
- endDate: moment().subtract(1, 'days').format("YYYY-MM-DD 23:59:59"),
- minDate: '2012-01-01',
- maxDate: nowString()+' 23:59:59',
- dateLimit: {
- days: 1200
- },
- showDropdowns: true,
- showWeekNumbers: true,
- ranges: {
- '今天': [moment(), moment()],
- '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
- '最近7天': [moment().subtract(6, 'days'), moment()],
- '最近30天': [moment().subtract(29, 'days'), moment()],
- '当月': [moment().startOf('month'), moment().endOf('month')],
- '上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
- },
- opens: 'right',
- buttonClasses: ['btn btn-default'],
- applyClass: 'btn-small btn-primary',
- cancelClass: 'btn-small',
- timePicker: true, //显示时间
- timePicker24Hour: true, //时间制
- timePickerSeconds: true, //时间显示到秒
- timePickerIncrement: 1,
- format: 'YYYY-MM-DD HH:mm:ss',
- separator: ' to ',
- locale: {
- applyLabel: '确定',
- cancelLabel: '取消',
- fromLabel: 'From',
- toLabel: 'To',
- customRangeLabel: '自定义',
- daysOfWeek: ['天', '一', '二', '三', '四', '五', '六'],
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
- firstDay: 1
- }
- };
- $('#reportrange').daterangepicker(optionSet1, function (start, end, label) {
- $('#reportrange span').html(start.format('YYYY-MM-DD HH:mm:ss') + ' - ' + end.format('YYYY-MM-DD HH:mm:ss'));
- });
- $('#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"));
- }
|