Browse Source

盘点生成前增加导出

WANGJIALIANG 2 years ago
parent
commit
1d442c5183

+ 7 - 7
src/main/java/cn/hnthyy/thmz/controller/yf/YfYpZdDeptController.java

@@ -87,7 +87,7 @@ public class YfYpZdDeptController {
     }
 
     /**
-     * 更新住院科室药品停用信息
+     * 更新科室药品停用信息
      *
      * @param YpZdDept
      * @return
@@ -99,32 +99,32 @@ public class YfYpZdDeptController {
         try {
             if (YpZdDept == null) {
                 resultMap.put("code", -1);
-                resultMap.put("message", "更新住院科室药品停用信息失败,药参数为空");
+                resultMap.put("message", "更新科室药品停用信息失败,药参数为空");
                 return resultMap;
             }
             if (StringUtils.isEmpty(YpZdDept.getChargeCode())) {
                 resultMap.put("code", -1);
-                resultMap.put("message", "更新住院科室药品停用信息失败,药品编码为空");
+                resultMap.put("message", "更新科室药品停用信息失败,药品编码为空");
                 return resultMap;
             }
             if (StringUtils.isEmpty(YpZdDept.getDeptCode())) {
                 resultMap.put("code", -1);
-                resultMap.put("message", "更新住院科室药品停用信息失败,科室编码为空");
+                resultMap.put("message", "更新科室药品停用信息失败,科室编码为空");
                 return resultMap;
             }
             int i = ypZdDeptService.modifYpZdDept(YpZdDept);
             if (i == 0) {
                 resultMap.put("code", -1);
-                resultMap.put("message", "更新住院科室药品停用信息失败");
+                resultMap.put("message", "更新科室药品停用信息失败");
                 return resultMap;
             }
             resultMap.put("code", 0);
-            resultMap.put("message", "更新住院科室药品停用信息成功");
+            resultMap.put("message", "更新科室药品停用信息成功");
             return resultMap;
         } catch (Exception e) {
             log.error(e.toString());
             resultMap.put("code", -1);
-            resultMap.put("message", "更新住院科室药品停用信息失败");
+            resultMap.put("message", "更新科室药品停用信息失败");
             return resultMap;
         }
     }

+ 5 - 4
src/main/resources/static/js/common/pharmacy-com.js

@@ -498,9 +498,10 @@ function showSupplyPopover(data) {
 /**
  * 将table导出Excel
  * @param tableid
+ * @param btnid
  * @param sheetName
  */
-function tableToExcel(tableid, sheetName) {
+function tableToExcel(tableid, btnid, sheetName) {
     var uri = 'data:application/vnd.ms-excel;base64,';
     var template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"' +
         'xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>'
@@ -524,9 +525,9 @@ function tableToExcel(tableid, sheetName) {
     if (!tableid.nodeType) tableid = document.getElementById(tableid);
     var ctx = {worksheet: sheetName || 'Worksheet', table: tableid.innerHTML};
     var blobExel = self.baseExel(uri + base64(formatName(template, ctx))); //把base64位文件转化为exel文件
-    document.getElementById("btn_excel").href = URL.createObjectURL(blobExel);
-    document.getElementById("btn_excel").download = ctx.worksheet;
-    console.log(document.getElementById("btn_excel").href);
+    document.getElementById(btnid).href = URL.createObjectURL(blobExel);
+    document.getElementById(btnid).download = ctx.worksheet;
+    console.log(document.getElementById(btnid).href);
 }
 
 /*处理后端返回的base64位文件变成exel文件进行下载

+ 17 - 11
src/main/resources/static/js/yf/yf_inventory.js

@@ -5,7 +5,6 @@ var lastrow;//最后编辑单元格的行
 var lastcell;//最后编辑单元格的列
 $(function () {
     init_daterangepicker();
-    //$("#pharmacyModal").modal("show");
     if(pharmacyGroupNo == null){
         return errorMesageSimaple('药房参数未设置,请在发药参数设置中设置');
     }
@@ -39,6 +38,13 @@ $(function () {
         initTbAddRecord();
         loadTbAddRecord();
     });
+    $("#btn_add_excel").click(function (t) {
+        let name = "长沙泰和医院药品盘点表";
+        $("#tb_add").table2excel({
+            exclude: ".exclHide",
+            filename: name + "(" + getRePortRangeArr()[0].substring(0, getRePortRangeArr()[0].indexOf(" ") + 1) + ").xls"
+        })
+    });
 });
 
 /**
@@ -206,11 +212,11 @@ function initTbAdd() {
         loadonce:true,//如果为ture则数据只从服务器端抓取一次,之后所有操作都是在客户端执行,翻页功能会被禁用
         colNames: ['货位号','编码','药品名称','规格','单价', '账存数量', '实盘数量', '盈亏数量', '盈亏金额','盘点单号','盘点时间', '生产厂商','序号','药房编码','拼音编码'],
         colModel: [
-            {name: 'location', index: 'location',align:'center',width:100, searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','nc']}},
+            {name: 'location', index: 'location',align:'center',width:100,classes:'exclHide', searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','nc']}},
             {name: 'chargeCode', index: 'chargeCode',align:'center',width:100, searchoptions:{sopt:['cn','eq','nc']}},
             {name: 'name', index: 'name',align:'left',width:180, searchoptions:{sopt:['cn','eq','nc']}},
             {name: 'specification', index: 'specification',width:140, searchoptions:{sopt:['cn','eq','nc']}},
-            {name: 'packRetprice', index: 'packRetprice',align:'center',width:100, searchoptions:{sopt:['eq','ne','lt','le','gt','ge']}},
+            {name: 'packRetprice', index: 'packRetprice',align:'center',width:100, searchoptions:{sopt:['eq','ne','lt','le','gt','ge']},classes:'exclHide'},
             {name: 'stockAmount', index: 'stockAmount',align:'center',width:100, searchoptions:{sopt:['eq','ne','lt','le','gt','ge']},
                 formatter:function(cellvalue, options, rowObject){
                     return keepTwoDecimal(cellvalue)
@@ -225,19 +231,19 @@ function initTbAdd() {
             {name: 'profitLossprofitLoss', index: 'profitLossprofitLoss',align:'center',width:100,searchoptions:{sopt:['eq','ne','lt','le','gt','ge']},
                 formatter:function(cellvalue, options, rowObject){
                     return cellvalue==null?0:keepTwoDecimal(cellvalue)
-                }},
+                },classes:'exclHide'},
             {name: 'profitLossprofitMoney', index: 'profitLossprofitMoney',align:'center',width:100,searchoptions:{sopt:['eq','ne','lt','le','gt','ge']},
                 formatter:function(cellvalue, options, rowObject){
                     return cellvalue==null?0:keepTwoDecimal(cellvalue)
-                }},
-            {name: 'drawNo', index: 'drawNo',align:'center',width:120,searchoptions:{sopt:['eq']}},
+                },classes:'exclHide'},
+            {name: 'drawNo', index: 'drawNo',align:'center',width:120,searchoptions:{sopt:['eq']},classes:'exclHide'},
             {name: 'outDate', index: 'outDate',align:'center',width:120,searchoptions:{sopt:['eq']},formatter:function(cellvalue, options, rowObject){
                     return format(cellvalue,"yyyy-MM-dd")
-                }},
+                },classes:'exclHide'},
             {name: 'manufactoryName', index: 'manufactoryName',width:180, searchoptions:{sopt:['cn','eq','nc']}},
-            {name: 'serial', index: 'serial',align:'center',width:100,hidden:true},
-            {name: 'groupNo', index: 'groupNo',align:'center',width:100,hidden:true},
-            {name: 'pyCode', index: 'pyCode',align:'center',width:100,hidden:true}
+            {name: 'serial', index: 'serial',align:'center',width:100,hidden:true,classes:'exclHide'},
+            {name: 'groupNo', index: 'groupNo',align:'center',width:100,hidden:true,classes:'exclHide'},
+            {name: 'pyCode', index: 'pyCode',align:'center',width:100,hidden:true,classes:'exclHide'}
         ],
         jsonReader: {
             root: "data", repeatitems: false
@@ -431,7 +437,7 @@ function getTbAddRecordPrintData(drawNo) {
                     '    </tr>';
                 $("#tj_table").append(html);
                 var date = new Date();
-                tableToExcel('tj_table', '长沙泰和医院药品盘点表('+date.getMonth()+'月)');
+                tableToExcel('tj_table', 'btn_search_excel','长沙泰和医院药品盘点表('+date.getMonth()+'月)');
             } else if (res.code == -1) {
                 new PNotify({
                     title: '错误提示',

+ 4 - 1
src/main/resources/templates/yf/yf_inventory.html

@@ -56,7 +56,7 @@
                         <button type="button" id="btn_print" class="btn btn-primary"
                                 title="打印"><i class="fa fa-print"></i>
                         </button>
-                        <a id="btn_excel" class="btn btn-primary"
+                        <a id="btn_search_excel" class="btn btn-primary"
                                 title="导出Excel"><i class="fa fa-file-excel-o"></i>
                         </a>
                     </div>
@@ -86,6 +86,9 @@
                         <button type="button" id="btn_save" class="btn btn-primary"
                                 title="提交盘点">提交盘点
                         </button>
+                        <a id="btn_add_excel" class="btn btn-primary"
+                           title="导出Excel"><i class="fa fa-file-excel-o"></i>
+                        </a>
                     </div>
                 </form>
             </div>