|
|
@@ -0,0 +1,417 @@
|
|
|
+//@ sourceURL=spirit_anesthetic_print.js
|
|
|
+var LODOP; //声明为全局变量
|
|
|
+//默认打印机下标
|
|
|
+var printIndex = -1;
|
|
|
+$(function () {
|
|
|
+ initDeptSelect(0,"unitCodeSearch");
|
|
|
+ init_daterangepickertime();
|
|
|
+ setTimeout(function () {
|
|
|
+ getLodop();
|
|
|
+ }, 800);
|
|
|
+
|
|
|
+ $(".selectpicker").selectpicker({
|
|
|
+ dropuAuto: false
|
|
|
+ });
|
|
|
+
|
|
|
+ //初始化页面上面的按钮事件
|
|
|
+ $("#btn_search").click(function (t) {
|
|
|
+ getSpiritAnestheticPrintData();
|
|
|
+ });
|
|
|
+ $('#btn_clean').click(function () {
|
|
|
+ cleanParams();
|
|
|
+ });
|
|
|
+ $("#btn_daily").click(function (t) {
|
|
|
+ print();
|
|
|
+ });
|
|
|
+ $("#drugFlagSearch").change(function (t,d,e) {
|
|
|
+ let drugFlag = $("#drugFlagSearch").val();
|
|
|
+ let title = "";
|
|
|
+ if(drugFlag == 0){
|
|
|
+ title = "麻醉药品、精神一类药品使用登记"
|
|
|
+ }else if(drugFlag == 1){
|
|
|
+ title = "终止妊娠药统计"
|
|
|
+ }else if(drugFlag == 2){
|
|
|
+ title = "精二及麻黄碱类统计"
|
|
|
+ }
|
|
|
+ $("#title").html(title);
|
|
|
+ $("#dateRange").html($('#reportrange span').html());
|
|
|
+ $("#printDate").html(format(new Date(),"yyyy-MM-dd HH:mm"));
|
|
|
+ });
|
|
|
+
|
|
|
+ //初始化药品查询弹出框
|
|
|
+ initDrugSearchList();
|
|
|
+ $('#searchText').on('input focus',function(e){
|
|
|
+ showDrugPopover();
|
|
|
+ if($('#searchText').val() == ''){
|
|
|
+ $('#codeSearch').val("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取统计报表
|
|
|
+ */
|
|
|
+function getSpiritAnestheticPrintData() {
|
|
|
+ $("#dateRange").html($('#reportrange span').html());
|
|
|
+ $("#printDate").html(format(new Date(),"yyyy-MM-dd HH:mm"));
|
|
|
+ $('#searchText').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;
|
|
|
+ $('.sjh').remove();
|
|
|
+ for (var i = 0; i < res.data.length; i++) {
|
|
|
+ let data = res.data[i];
|
|
|
+ if(code == ''){
|
|
|
+ code = data.chargeItemCode;
|
|
|
+ if(number > 0){
|
|
|
+ html += '<tr class="sjh">';
|
|
|
+ html += '<td colspan="15" style="text-align: center;font-weight: 700;">共计:' + number + '</td>';
|
|
|
+ html += '</tr>';
|
|
|
+ number = 0;
|
|
|
+ }
|
|
|
+ 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 = '';
|
|
|
+ number = parseFloat(data.quantity);
|
|
|
+ }
|
|
|
+ if(data.sex == 1){
|
|
|
+ sex = "男"
|
|
|
+ }else if(data.sex == 2){
|
|
|
+ sex = "女"
|
|
|
+ }else{
|
|
|
+ sex = "未知"
|
|
|
+ }
|
|
|
+ html += '<tr class="sjh">';
|
|
|
+ html += '<td style="text-align: center;">' + data.chargeDate.substring(5,11) + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + data.patientId + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + data.name + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + sex + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + data.age + '</td>';
|
|
|
+ html += '<td>' + data.socialNo + '</td>';
|
|
|
+ html += '<td>' + data.icdText + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + data.chargeItemCode + '</td>';
|
|
|
+ html += '<td>' + data.drugname + '</td>';
|
|
|
+ html += '<td>' + data.specification + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + data.quantity + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + data.employeeName + '</td>';
|
|
|
+ html += '<td style="text-align: center;">' + data.warnDeptName + '</td>';
|
|
|
+ html += '<td></td>';
|
|
|
+ html += '<td></td>';
|
|
|
+ html += '</tr>';
|
|
|
+ }
|
|
|
+ html += '<tr class="sjh">';
|
|
|
+ html += '<td colspan="15" style="text-align: center;font-weight: 700;">共计:' + number + '</td>';
|
|
|
+ html += '</tr>';
|
|
|
+ $("#tj_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 setPrint() {
|
|
|
+ if (printIndex >= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ type: "GET",
|
|
|
+ url: '/thmz/getLastWindowsByCurrentUser',
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
|
|
|
+ async: false,
|
|
|
+ success: function (res) {
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view'
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.code == 0) {
|
|
|
+ printIndex = res.data.cgPrintIndex;
|
|
|
+ } else {
|
|
|
+ printIndex = -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 清空查询条件
|
|
|
+ */
|
|
|
+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);
|
|
|
+ $('#drugFlagSearch').selectpicker('refresh');
|
|
|
+ $('#searchText').empty();
|
|
|
+ $('#codeSearch').empty();
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 打印报表
|
|
|
+ */
|
|
|
+function print() {
|
|
|
+ setPrint();
|
|
|
+ LODOP = getLodop();
|
|
|
+ LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "药房精麻药品发放统计表");
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(2, 0, 0,"A4");
|
|
|
+ //设置默认打印机
|
|
|
+ LODOP.SET_PRINTER_INDEX(printIndex);
|
|
|
+ LODOP.SET_PRINT_STYLE("FontSize", 10); //字体大小
|
|
|
+ LODOP.SET_PRINT_STYLEA(0,"ItemType",2);
|
|
|
+ //设置默认打印机
|
|
|
+ LODOP.SET_PRINTER_INDEX(printIndex);
|
|
|
+ LODOP.ADD_PRINT_TEXT('195mm','140mm','40mm','40mm','第#页/共&页');
|
|
|
+ LODOP.SET_PRINT_STYLEA(0,"ItemType",2);
|
|
|
+ var strStyle="<style>table{width: 1050px;} 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("0mm", "2mm", "RightMargin:0mm", "BottomMargin:15mm",strStyle+ document.getElementById("report_table_1").innerHTML);
|
|
|
+ //LODOP.PRINT();
|
|
|
+ LODOP.PREVIEW();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//显示查询的药品悬浮窗
|
|
|
+function showDrugPopover() {
|
|
|
+ $('#tb_table_medicine').bootstrapTable('destroy');
|
|
|
+ $('#tb_table_medicine').bootstrapTable({
|
|
|
+ url: '/thmz/getYpZdDictBase', //请求后台的URL(*)
|
|
|
+ method: 'GET', //请求方式(*)
|
|
|
+ toolbar: '#toolbar', //工具按钮用哪个容器
|
|
|
+ striped: true, //是否显示行间隔色
|
|
|
+ cache: true, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
|
|
|
+ pagination: false, //是否显示分页(*)
|
|
|
+ sortable: true, //是否启用排序
|
|
|
+ sortOrder: "asc", //排序方式
|
|
|
+ queryParams:queryParamsDrugTable, //传递参数(*)
|
|
|
+ sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
|
|
|
+ pageNumber: 1, //初始化加载第一页,默认第一页
|
|
|
+ pageSize: 5, //每页的记录行数(*)
|
|
|
+ pageList: [5, 10, 25, 50, 100], //可供选择的每页的行数(*)
|
|
|
+ search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
|
|
|
+ strictSearch: true,
|
|
|
+ showColumns: false, //是否显示所有的列
|
|
|
+ showRefresh: false, //是否显示刷新按钮
|
|
|
+ minimumCountColumns: 2, //最少允许的列数
|
|
|
+ clickToSelect: true, //是否启用点击选中行
|
|
|
+ uniqueId: "ID", //每一行的唯一标识,一般为主键列
|
|
|
+ showToggle: false, //是否显示详细视图和列表视图的切换按钮
|
|
|
+ cardView: false, //是否显示详细视图
|
|
|
+ detailView: false,
|
|
|
+ //rowStyle:rowStyle,//通过自定义函数设置行样式
|
|
|
+ ajaxOptions: {
|
|
|
+ headers: {
|
|
|
+ 'Accept': 'application/json',
|
|
|
+ 'Authorization': 'Bearer ' + localStorage.getItem("token")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ field: 'code',
|
|
|
+ title: '编码',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ },{
|
|
|
+ field: 'name',
|
|
|
+ title: '药品名',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'specification',
|
|
|
+ title: '规格',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ }, {
|
|
|
+ field: 'manufactoryName',
|
|
|
+ title: '厂家',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'packRetprice',
|
|
|
+ title: '单价',
|
|
|
+ align: "center",
|
|
|
+ visible: false,
|
|
|
+ valign: 'middle'
|
|
|
+ }, {
|
|
|
+ field: 'stockAmount',
|
|
|
+ title: '药库库存',
|
|
|
+ align: "center",
|
|
|
+ visible: false,
|
|
|
+ valign: 'middle'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ responseHandler: function (res) {
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view'
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var ress = eval(res);
|
|
|
+ if (ress.code == -1) {
|
|
|
+ errorMesage(res);
|
|
|
+ return {
|
|
|
+ "total": 0,//总页数
|
|
|
+ "rows": {} //数据
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ "total": ress.data.length,//总页数
|
|
|
+ "rows": ress.data //数据
|
|
|
+ };
|
|
|
+ },
|
|
|
+ onClickRow: function (row, $element) {
|
|
|
+ $('#searchText').webuiPopover('hide');
|
|
|
+ $('#codeSearch').val(row.code);
|
|
|
+ $('#searchText').val(row.name);
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 药品列表查询参数
|
|
|
+ */
|
|
|
+function queryParamsDrugTable() {
|
|
|
+ var temp = {
|
|
|
+ groupYk: 11,
|
|
|
+ searchText: $("#searchText").val() == "" ? null : $("#searchText").val(),
|
|
|
+ };
|
|
|
+ return temp;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 统计列表查询参数
|
|
|
+ */
|
|
|
+function queryParams() {
|
|
|
+ let drugFlags = new Array();
|
|
|
+ let flag = $("#drugFlagSearch").val();
|
|
|
+ if(flag == 0){
|
|
|
+ drugFlags[0] = 2;
|
|
|
+ drugFlags[1] = 3;
|
|
|
+ }else if(flag == 1){
|
|
|
+ drugFlags[0] = 6;
|
|
|
+ }else if(flag == 2){
|
|
|
+ drugFlags[0] = 1;
|
|
|
+ drugFlags[1] = 4;
|
|
|
+ drugFlags[2] = 5;
|
|
|
+ }
|
|
|
+ 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 14:00:00"),
|
|
|
+ endDate: moment().format("YYYY-MM-DD 13:59:59"),
|
|
|
+ minDate: '2012-01-01',
|
|
|
+ maxDate: nowString(),
|
|
|
+ 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 14:00:00") + ' - ' + moment().format("YYYY-MM-DD 13:59:59"));
|
|
|
+}
|