Kaynağa Gözat

取消数据库打印机序号判断,出库退库开发完成

WANGJIALIANG 3 yıl önce
ebeveyn
işleme
1a8d9250b0

+ 0 - 13
src/main/java/cn/hnthyy/thmz/controller/mz/MzPharmacyController.java

@@ -9,7 +9,6 @@ import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
 import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
 import cn.hnthyy.thmz.entity.his.zd.ZdCommon;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
-import cn.hnthyy.thmz.entity.thmz.DispensingWindows;
 import cn.hnthyy.thmz.entity.thmz.RadSendRecord;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.enums.ConfirmFlagEnum;
@@ -599,12 +598,6 @@ public class MzPharmacyController {
                 resultMap.put("message", "打印失败,次数为空");
                 return resultMap;
             }
-            DispensingWindows windows = dispensingWindowsService.queryLastDispensingWindowsByUserIdCode(tokenUser.getUserIdCode(),null);
-            if (windows == null) {
-                resultMap.put("code", -1);
-                resultMap.put("message", "当前操作人未设置发药基础参数,请先设置!");
-                return resultMap;
-            }
             Map<String, Object> printMap = new HashMap<>();
             MzPatientMi mzPatientMi = mzPatientMiService.queryByPatientId(mzChargeDetail.getPatientId());
             MzVisitTable visit = mzVisitTableService.queryByPatientIdAndTimes(mzChargeDetail.getPatientId(), mzChargeDetail.getTimes());
@@ -884,12 +877,6 @@ public class MzPharmacyController {
                 resultMap.put("message", "次数不能为空");
                 return resultMap;
             }
-            DispensingWindows windows = dispensingWindowsService.queryLastDispensingWindowsByUserIdCode(tokenUser.getUserIdCode(),null);
-            if (windows == null) {
-                resultMap.put("code", -1);
-                resultMap.put("message", "当前操作人未设置发药基础参数,请先设置!");
-                return resultMap;
-            }
             mzChargeDetail.setReceiptNo(Math.abs(mzChargeDetail.getReceiptNo()));//防止退药处方,需将发票号转为正数
             List<MzSendMedicineVo> cfxxList = mzPharmacyService.getFyclPrescriptionDetail(mzChargeDetail);
             if (cfxxList.size() > 0) {

+ 14 - 4
src/main/java/cn/hnthyy/thmz/controller/yk/YpOutDetlController.java

@@ -132,17 +132,22 @@ public class YpOutDetlController {
                 ypOutDetlVo.setSpecification(ypZdDict.getSpecification());
                 ypOutDetlVo.setJbFlag(ypZdDict.getJbFlag());
                 ypOutDetlVo.setManufactoryName(ypZdManufactoryService.queryYpZdManufactoryByCode(ypZdDict.getManuCode()));
+                YpBase ypBase = ypBaseService.queryYpBase(ypOutDetlVo.getChargeCode(), ypOutDetlVo.getSerial(), ypOutDetlVo.getGroupNo());
+                ypOutDetlVo.setLocation(ypBase.getLocation()==null?"":ypBase.getLocation());
                 YpInPlan ypInPlan = new YpInPlan();
                 ypInPlan.setDrawNo(ypOutDetlVo.getDrawYf());
                 ypInPlan.setChargeCode(ypOutDetlVo.getChargeCode());
                 ypInPlan.setSerial(ypOutDetlVo.getSerial());
                 List<YpInPlanDrugVo> ypInPlanDrugVos = ypInPlanService.queryYpInPlanDrug(ypInPlan);
-                ypOutDetlVo.setAmount(ypInPlanDrugVos.get(0).getAmount());
+                if(ypInPlanDrugVos.size() > 0){
+                    ypOutDetlVo.setAmount(ypInPlanDrugVos.get(0).getAmount());
+                }
                 ypOutDetlVo.setAmountOut(ypOutDetlVo.getAmount());
                 if(i > 0){
                     ypOutDetlVo.setKeeperName(ypOutDetlVos.get(0).getKeeperName());
                     ypOutDetlVo.setConfirmName(ypOutDetlVos.get(0).getConfirmName());
                     ypOutDetlVo.setInputName(ypOutDetlVos.get(0).getInputName());
+                    ypOutDetlVo.setGroupNoOutName(ypOutDetlVos.get(0).getGroupNoOutName());
                 }else{
                     ypOutDetlVo.setInputName(employeeService.queryByUserCode(ypOutDetlVo.getInputId()).getEmployeeName());
                     if(StringUtils.isNotBlank(ypOutDetlVo.getConfirmId())){
@@ -151,6 +156,9 @@ public class YpOutDetlController {
                     if(ypOutDetlVos.size() > 0 && StringUtils.isNotBlank(ypOutDetlVos.get(0).getKeeper())){
                         ypOutDetlVo.setKeeperName(employeeService.queryByUserCode(ypOutDetlVos.get(0).getKeeper()).getEmployeeName());
                     }
+                    if(StringUtils.isNotBlank(ypOutDetlVo.getGroupNoOut())){
+                        ypOutDetlVo.setGroupNoOutName(ypZdGroupNameService.queryByGroupNo(ypOutDetlVo.getGroupNoOut()).getGroupName());
+                    }
                 }
             }
             resultMap.put("code", 0);
@@ -353,7 +361,7 @@ public class YpOutDetlController {
     /**
      * 保存退库
      *
-     * @param map
+     * @param list
      * @return
      */
     @UserLoginToken
@@ -367,14 +375,16 @@ public class YpOutDetlController {
                 return resultMap;
             }
             User user = TokenUtil.getUser(httpServletRequest);
+            String drawNo = ypOutDetlService.saveDrugReturn(list,user.getUserIdCode());
             resultMap.put("code", 0);
-            resultMap.put("message", "审核出库信息成功");
+            resultMap.put("message", "退库成功");
+            resultMap.put("data", drawNo);
             return resultMap;
         } catch (Exception e) {
             e.printStackTrace();
             log.error("系统异常,错误信息{}", e);
             resultMap.put("code", -1);
-            resultMap.put("message", "审核出库信息失败");
+            resultMap.put("message", "退库失败,"+e.getMessage());
             return resultMap;
         }
     }

+ 22 - 0
src/main/java/cn/hnthyy/thmz/entity/his/yp/YpBase.java

@@ -51,35 +51,57 @@ public class YpBase {
   private String infusion;
   //小规格
   private String specification2;
+  //1不显示
   private String visibleFlag;
+  //1国产 2进口
   private String countryFlag;
+  //批发价
   private BigDecimal fixPrice;
+  //1可分装
   private String divideFlag;
+  //1新药
   private String newFlag;
   //药库编码
   private String groupNo;
   //厂家
   private String manufactory;
+  //药品类别 yp_zd_drug_kind
   private String drugKind;
+  //排序码
   private String sortNo;
+  //gmp认证
   private String gmp;
+  //1冷冻 2冷藏
   private String coldFlag;
+  //化学成分
   private String chemRemark;
   private String chargeCodeNew;
+  //门诊账单
   private String mzBillItem;
+  //住院账单
   private String zyBillItem;
+  //作废标志 1是
   private String delFlag;
+  //医保标志 1是
   private String ybFlag;
+  //院内码
   private String nCode;
+  //针剂标志
   private String zjFlag;
+  //抗生素标志 1是
   private String zbFlag;
+  //中标供应商
   private String zbSupplyer;
+  //打印名称
   private String printName;
+  //药品分类 yp_zd_class
   private String classCode;
   private String drugnameBak;
   //货位号
   private String location;
+  //新药品序号
   private String serialNew;
+  //医保说明
   private String ybComment;
   private String hzylFlag;
 }

+ 2 - 1
src/main/java/cn/hnthyy/thmz/entity/his/yp/YpZdDict.java

@@ -59,7 +59,7 @@ public class YpZdDict {
     private String pyCode;
     //五笔码 对应 d_code
     private String wbCode;
-    //大输液标志:1:输液
+    //大输液标志:1
     private String infusionFlag;
     //1:不显示
     private String visibleFlag;
@@ -131,6 +131,7 @@ public class YpZdDict {
     private String zsFlag;
     private String auditCode;
     private String comment;
+    //药品大类 0口服1大输液2针剂3草药饮片4草药颗粒9其它
     private String categoriesFlag;
     private String fatherFlag;
     private BigDecimal ybxjPrice;

+ 13 - 5
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpOutDetlMapper.java

@@ -113,9 +113,9 @@ public interface YpOutDetlMapper {
      * @return
      */
     @Select("<script>" +
-            "select dept_code,input_id,confirm_flag,confirm_id,confirm_date,out_date,draw_no,eff_date,draw_yf," +
+            "select dept_code,input_id,confirm_flag,confirm_id,confirm_date,out_date,draw_no,eff_date,draw_yf,stock_amount," +
             "       drawer,serial,out_amt,out_seri,pack_retprice,manu_no," +
-            "       fix_price,acct_sign,buy_price,charge_code,group_no_out,group_no,in_draw_no,in_seri,accept_sign,keeper" +
+            "       fix_price,acct_sign,buy_price,charge_code,group_no_out,group_no,in_draw_no,in_seri,accept_sign,keeper,out_amt as new_out_amt" +
             " from yp_out_detl WITH(NOLOCK)" +
             "<where>" +
             "   <if test=\"drawNo != null and drawNo != ''\">" +
@@ -124,6 +124,9 @@ public interface YpOutDetlMapper {
             "   <if test=\"drawYf != null and drawYf != ''\">" +
             "        AND draw_yf = #{drawYf}" +
             "   </if>" +
+            "   <if test=\"outSeri != null and outSeri != ''\">" +
+            "        AND out_seri = #{outSeri}" +
+            "   </if>" +
             "</where>"+
             " ORDER BY out_seri ASC" +
             "</script>")
@@ -146,11 +149,12 @@ public interface YpOutDetlMapper {
      */
     @Insert("INSERT INTO yp_out_detl ( out_date, out_seri, in_draw_no, in_seri, manu_no, draw_no, draw_yf, dept_code, charge_code, serial, pack_retprice, out_amt,\n" +
             "   drawer, keeper, eff_date, out_type, stock_amount, group_no, group_no_out, buy_price, input_id," +
-            "   sys_date, allo_price, confirm_flag )" +
+            "   sys_date, allo_price, confirm_flag, confirm_id, confirm_date, serial_th )" +
             "   VALUES ( #{outDate,jdbcType=TIMESTAMP}, #{outSeri,jdbcType=INTEGER}, #{inDrawNo,jdbcType=VARCHAR}, #{inSeri,jdbcType=INTEGER}, #{manuNo,jdbcType=VARCHAR}, #{drawNo,jdbcType=VARCHAR}," +
             " #{drawYf,jdbcType=VARCHAR}, #{deptCode,jdbcType=VARCHAR}, #{chargeCode,jdbcType=VARCHAR}, #{serial,jdbcType=VARCHAR}, #{packRetprice,jdbcType=DECIMAL}, #{outAmt,jdbcType=DECIMAL}, " +
             " #{drawer,jdbcType=VARCHAR}, #{keeper,jdbcType=VARCHAR}, #{effDate,jdbcType=TIMESTAMP}, #{outType,jdbcType=CHAR}, #{stockAmount,jdbcType=FLOAT}, #{groupNo,jdbcType=CHAR}, " +
-            " #{groupNoOut,jdbcType=CHAR}, #{buyPrice,jdbcType=FLOAT}, #{inputId,jdbcType=VARCHAR}, #{sysDate,jdbcType=TIMESTAMP}, #{alloPrice,jdbcType=FLOAT}, #{confirmFlag,jdbcType=CHAR} )")
+            " #{groupNoOut,jdbcType=CHAR}, #{buyPrice,jdbcType=FLOAT}, #{inputId,jdbcType=VARCHAR}, #{sysDate,jdbcType=TIMESTAMP}, #{alloPrice,jdbcType=FLOAT}, #{confirmFlag,jdbcType=CHAR}" +
+            ", #{confirmId,jdbcType=VARCHAR}, #{confirmDate,jdbcType=TIMESTAMP}, #{serialTh,jdbcType=INTEGER} )")
     int insertYpOutDetl(YpOutDetl ypOutDetl);
 
     /**
@@ -173,6 +177,9 @@ public interface YpOutDetlMapper {
             "<when test='stockAmount!=null'>",
             ",stock_amount =#{stockAmount,jdbcType=DOUBLE}",
             "</when>",
+            "<when test='amountTh!=null'>",
+            ",amount_th =isnull(amount_th,0)+#{amountTh,jdbcType=DOUBLE}",
+            "</when>",
             "<when test='confirmId!=null'>",
             ",confirm_id =#{confirmId,jdbcType=VARCHAR}",
             "</when>",
@@ -205,7 +212,7 @@ public interface YpOutDetlMapper {
      * @param drawNo 出库单
      * @return
      */
-    @Select("select accept_sign from yp_out_detl where draw_no =#{drawNo}")
+    @Select("select top 1 accept_sign from yp_out_detl where draw_no =#{drawNo}")
     int selectAcceptSign(@Param("drawNo") String drawNo);
 
     /**
@@ -268,4 +275,5 @@ public interface YpOutDetlMapper {
             "</where>",
             "</script>"})
     int selectYpOutDetlDrugReturnCount(YpOutDetl ypOutDetl);
+
 }

+ 1 - 1
src/main/java/cn/hnthyy/thmz/service/his/yp/YpOutDetlService.java

@@ -46,7 +46,7 @@ public interface YpOutDetlService {
      * @return
      * @throws MzException
      */
-    int saveDrugReturn(List<Map> list, String userId)throws MzException;
+    String saveDrugReturn(List<Map> list, String userId)throws MzException;
 
     /**
      * 审核出库单

+ 54 - 3
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpOutDetlServiceImpl.java

@@ -162,12 +162,63 @@ public class YpOutDetlServiceImpl implements YpOutDetlService {
         return 0;
     }
 
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
-    public int saveDrugReturn(List<Map> list, String userId) throws MzException {
+    public String saveDrugReturn(List<Map> list, String userId) throws MzException {
+        Integer ykOutNo = ypConfigService.getNo("yk_out_no");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+        String str = "";
+        if (ykOutNo < 100) {
+            str = "00";
+        } else if (ykOutNo < 1000) {
+            str = "0";
+        }
+        String drawNo = "T"+sdf.format(new Date()) + str + ykOutNo;
+        Date date = new Date();
         for (int i = 0; i < list.size(); i++) {
-
+            Map map = list.get(i);
+            YpOutDetl ypOutDetl = new YpOutDetl();
+            ypOutDetl.setDrawNo(map.get("drawNo").toString());
+            ypOutDetl.setOutSeri(Integer.parseInt(map.get("outSeri").toString()));
+            YpOutDetlVo ypOutDetlVo = ypOutDetlMapper.selectYpOutDetlDetail(ypOutDetl).get(0);
+            ypOutDetl.setAmountTh(-Double.parseDouble(map.get("newOutAmt").toString()));
+            YpInDetl ypInDetl = new YpInDetl();
+            ypInDetl.setCurrentStock(Double.parseDouble(map.get("newOutAmt").toString()));
+            ypInDetl.setInSeri(Integer.parseInt(map.get("inSeri").toString()));
+            ypInDetl.setInDocuNo(map.get("inDrawNo").toString());
+            if(ypOutDetlMapper.updateYpOutDetl(ypOutDetl) != 1){
+                throw new MzException("更新历史出库单异常!");
+            }
+            if(ypInDetlMapper.updateYpInDetl(ypInDetl) != 1){
+                throw new MzException("更新历史入库单异常!");
+            }
+            Double stockAmount = ypBaseMapper.selectStockAmount(ypOutDetlVo.getChargeCode(), ypOutDetlVo.getSerial(), ypOutDetlVo.getGroupNo());
+            YpOutDetl insertYpOutDetl = new YpOutDetl();
+            BeanUtils.copyProperties(ypOutDetlVo,insertYpOutDetl);
+            insertYpOutDetl.setOutDate(date);
+            insertYpOutDetl.setOutSeri(i+1);
+            insertYpOutDetl.setDrawYf("T"+ypOutDetlVo.getDrawNo());
+            insertYpOutDetl.setDrawNo(drawNo);
+            insertYpOutDetl.setKeeper(userId);
+            insertYpOutDetl.setOutType("2");
+            insertYpOutDetl.setAcctType("0");
+            insertYpOutDetl.setStockAmount(stockAmount);
+            insertYpOutDetl.setSysDate(date);
+            insertYpOutDetl.setSerialTh(ypOutDetlVo.getOutSeri());
+            insertYpOutDetl.setInputId(userId);
+            insertYpOutDetl.setConfirmFlag("1");
+            insertYpOutDetl.setConfirmDate(date);
+            insertYpOutDetl.setConfirmId(userId);
+            insertYpOutDetl.setOutAmt(-Double.parseDouble(map.get("newOutAmt").toString()));
+            if(ypOutDetlMapper.insertYpOutDetl(insertYpOutDetl) == 0){
+                throw new MzException("新增出库记录异常!");
+            }
+            if(ypBaseMapper.updateYpBaseStock(ypOutDetl.getAmountTh(),ypOutDetl.getAmountTh()*Double.parseDouble(map.get("newOutAmt").toString()),
+                    insertYpOutDetl.getChargeCode(),insertYpOutDetl.getSerial(),insertYpOutDetl.getGroupNo()) != 1){
+                throw new MzException("更新库存异常!");
+            }
         }
-        return 0;
+        return drawNo;
     }
 
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)

+ 2 - 0
src/main/java/cn/hnthyy/thmz/vo/YpOutDetlVo.java

@@ -63,6 +63,8 @@ public class YpOutDetlVo extends PageBean {
     private String deptCode;
     //出库量
     private Double outAmt;
+    //出库量
+    private Double newOutAmt;
     //盘减标志 0:出库 1:报损 2:退库 8:盘点
     private String outType;
     //记账标志 1:结账

+ 8 - 12
src/main/resources/static/js/yk/drug_delivery.js

@@ -202,8 +202,7 @@ function initRecordTable() {
                 align: "center",
                 valign: 'middle',
                 formatter: function (value, row, index) {
-                    let drawNo = isAudit ? row.drawYf : row.drawNo;
-                    return '<button type="button" class="registration-no-color-foot-button" title="详细" onclick="getDetail(\'' + drawNo + '\')"><i class="fa fa-plus"></i></button>';
+                    return '<button type="button" class="registration-no-color-foot-button" title="详细" onclick="getDetail(\'' + row.drawNo + '\')"><i class="fa fa-plus"></i></button>';
                 }
             }, {
                 field: 'planDate',
@@ -317,7 +316,7 @@ function recordTableQueryParams(params) {
     };
     if ($("#statusFlagSearch").val() === '3' || $("#statusFlagSearch").val() === '4') {
         temp.confirmFlag = $("#statusFlagSearch").val() === '3' ? '0' : '1';
-        temp.outType = '0,1,2';
+        temp.outType = '0,1';
         temp.groupNo = groupNo;
     } else {
         temp.statusFlag = $("#statusFlagSearch").val();
@@ -581,10 +580,7 @@ function initDetailed() {
  * 生产报表数据
  */
 function setPrintHtml() {
-    let date = {drawYf: $("#drawNoLabel").text()};
-    if ($("label[for='drawNoLabel']")[0].innerText === "出库单号") {
-        date = {drawNo: $("#drawNoLabel").text()}
-    }
+    let date = {drawNo: $("#drawNoLabel").text()};
     request({
         url: '/getYpOutDetlPrint',
         method: 'POST',
@@ -607,7 +603,7 @@ function setPrintHtml() {
                 $(".drawNo").html(data['drawNo']);
                 $(".planDate").html($("#planDateLabel").html());
                 $(".confirmDate").html(format(data['confirmDate'], "yyyy-MM-dd HH:mm"));
-                $(".lister").html($(".current_user").innerText);
+                $(".lister").html($(".current_user")[0].innerText);
                 $(".listerAudit").html(data['confirmName']);
             }
             html += '<tr class="sjh">';
@@ -627,8 +623,8 @@ function setPrintHtml() {
             html += '</tr>';
         }
         $("#base_tr").after(html);
-        $(".packRetpriceSum").html(packRetpriceSum);
-        $(".buyPriceSum").html(buyPriceSum);
+        $(".packRetpriceSum").html(keepTwoDecimal(packRetpriceSum));
+        $(".buyPriceSum").html(keepTwoDecimal(buyPriceSum));
         print();
     });
 }
@@ -648,8 +644,8 @@ function print() {
     var strStyle = "<style>table,td,th {border-width: 1px;" +
         "border-style: solid;border-collapse: collapse;table-layout:fixed;word-wrap:break-word;font-size: 13px}</style>";
     LODOP.ADD_PRINT_HTM("2mm", "4mm", "RightMargin:2mm", "BottomMargin:15mm", strStyle + document.getElementById("report_table_1").innerHTML);
-    //LODOP.PRINT();
-    LODOP.PREVIEW();
+    LODOP.PRINT();
+    //LODOP.PREVIEW();
 }
 
 //最后一行新增数据

+ 240 - 30
src/main/resources/static/js/yk/drug_return.js

@@ -1,6 +1,5 @@
 //@ sourceURL=drug_return.js
 var groupYk = window.localStorage["groupYk"];//药房编码
-var applyDrugList = new Array();//请领药品集
 $(function () {
     $(".selectpicker").selectpicker();
     initAllGroup('groupNoSearchText');
@@ -28,15 +27,30 @@ $(function () {
     $("#btn_save").click(function (t) {
         var data = $('#tb_table').bootstrapTable('getData', true);
         if (data.length > 0) {
-            var ypInPlans = [];
+            if(data[0].outAmt < 0){
+                return warningMesageSimaple('当前为历史退库单,请勿重复保存');
+            }
+            if (!confirm("确定保存该退库单吗?")) {
+                return;
+            }
             for (let i = 0; i < data.length; i++) {
                 if (data[i].newOutAmt == 0 || data[i].newOutAmt == null) {
                     return warningMesageSimaple('含有退药数量为0的记录');
                 }
             }
-            saveDrugApply(ypInPlans);
+            saveDrugApply(data);
         }
     });
+    $("#btn_record").click(function () {
+        $("#recordModal").modal("show");
+        $('#reportrange span').html(moment().subtract(7, 'days').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
+        $("#tkForm")[0].reset();
+        initRecordTable();
+    });
+    $("#btn_daily").click(function (t) {
+        initPrintHtml();
+    });
+
     //初始化药品查询弹出框
     initSearchList('<div id="medicinePopoverContent"><table id="tb_table_medicine"></table></div>',
         'drugSearchText', 600, 200);
@@ -82,6 +96,7 @@ $(function () {
  * 保存数据
  */
 function saveDrugApply(data) {
+
     $.ajax({
         type: "POST",
         url: '/thmz/saveDrugReturn',
@@ -95,15 +110,32 @@ function saveDrugApply(data) {
                 return;
             }
             if (res.code == 0) {
-                $('#tb_table').bootstrapTable('refresh');
                 successMesage(res);
+                getDetail(res.data);
             } else {
                 errorMesage(res);
             }
         }
     });
-
-}
+}/*
+/!**
+ * 保存数据
+ *!/
+function saveDrugApply(data) {
+    request({
+        type: "POST",
+        url: '/thmz/saveDrugReturn',
+        data: JSON.stringify(data)
+    }).then((res) => {
+        successMesage(res);
+        if (!confirm("是否需要打印退库单?")) {
+            $('#tb_table').bootstrapTable('removeAll');
+            return;
+        }
+        initPrintHtml();
+        $('#tb_table').bootstrapTable('removeAll');
+    });
+}*/
 
 /**
  * 重置查询表单
@@ -155,7 +187,6 @@ function initTbTable() {
                 valign: 'middle',
                 width: 40,
                 formatter: function (value, row, index) {
-                    //saveData(index, 'id', index + 1,'tb_table');
                     return index + 1;
                 }
             }, {
@@ -196,7 +227,10 @@ function initTbTable() {
                 field: 'outAmt',
                 title: '累计出库量',
                 align: "center",
-                valign: 'middle'
+                valign: 'middle',
+                formatter: function (value, row, index) {
+                    return value < 0 ? '-' : value;
+                }
             },
             {
                 field: 'newOutAmt',
@@ -233,7 +267,7 @@ function initTbTable() {
                     var tdValue = $element.html();
                     tdValue = tdValue.replaceAll("&nbsp;","");
                     tdValue = tdValue.replaceAll("<br>","");
-                    saveData(index, field, tdValue);
+                    saveData(index, field, tdValue, 'tb_table');
                 });
             }
         },
@@ -260,25 +294,6 @@ function initTbTable() {
     });
 }
 
-/**
- * 构建列表查询参数
- * @param params
- */
-function queryParams(params) {
-    var rePortRangeArr = getRePortRangeArr();
-    var temp = {   //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
-        pageSize: params.limit,   //页面大小
-        pageIndex: params.offset / params.limit,  //页码
-        beginTime: rePortRangeArr[0],
-        endTime: rePortRangeArr[1],
-        statusFlag: $("#statusFlagSearch").val() == "" ? null : $("#statusFlagSearch").val(),
-        groupYk: $("#groupYkSearch").val() == "" ? null : $("#groupYkSearch").val(),
-        drawNo: $("#drawNoSearch").val() == "" ? null : $("#drawNoSearch").val(),
-        groupNo: pharmacyGroupNo
-    };
-    return temp;
-}
-
 /**
  * 新增药品列表
  */
@@ -325,7 +340,7 @@ function initAddDrugTable() {
                 formatter: function (value, row, index) {
                     var str = '<button type="button" class="registration-no-color-foot-button" title="选择" onclick="addData(\'' + row.outDate + '\',\''
                         + row.chargeCode + '\',\'' + row.name + '\',\'' + row.specification+ '\',\'' + row.groupNoOutName+ '\',\'' + row.outAmt+ '\',\''
-                        + row.effDate+ '\',\'' + row.drawNo+ '\',\'' + row.inDrawNo+ '\',\'' + row.outSeri+ '\')"><i class="glyphicon glyphicon-plus"></i></button>';
+                        + row.effDate+ '\',\'' + row.drawNo+ '\',\'' + row.inDrawNo+ '\',\'' + row.outSeri+ '\',\'' + row.inSeri+ '\')"><i class="glyphicon glyphicon-plus"></i></button>';
                     return str;
                 }
             }, {
@@ -445,7 +460,7 @@ function initAddDrugTable() {
  * @param field
  * @param values
  */
-function addData(outDate,chargeCode,name,specification,groupNoOutName,outAmt,effDate,drawNo,inDrawNo,outSeri) {
+function addData(outDate,chargeCode,name,specification,groupNoOutName,outAmt,effDate,drawNo,inDrawNo,outSeri,inSeri) {
     var tableData = $table.bootstrapTable('getData');
     for (let i = 0; i < tableData.length; i++) {
         let data = tableData[i];
@@ -465,8 +480,203 @@ function addData(outDate,chargeCode,name,specification,groupNoOutName,outAmt,eff
         effDate: effDate,
         drawNo: drawNo,
         outSeri:outSeri,
+        inSeri:inSeri,
         inDrawNo: inDrawNo
     };
     $table.bootstrapTable('prepend', row);
 }
 
+/**
+ * 查询列表
+ */
+function initRecordTable() {
+    $('#tk_record').bootstrapTable('destroy');
+    $('#tk_record').bootstrapTable({
+        url: '/thmz/getYpOutDetlYk',         //请求后台的URL(*)
+        method: 'POST',                      //请求方式(*)
+        toolbar: '#toolbar',                //工具按钮用哪个容器
+        striped: true,                      //是否显示行间隔色
+        cache: false,                       //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
+        pagination: true,                   //是否显示分页(*)
+        sortable: true,                     //是否启用排序
+        sortOrder: "asc",                   //排序方式
+        queryParams: recordTableQueryParams,           //传递参数(*)
+        sidePagination: "server",          //分页方式:client客户端分页,server服务端分页(*)
+        pageNumber: 1,                       //初始化加载第一页,默认第一页
+        pageSize: 10,                       //每页的记录行数(*)
+        pageList: [10, 20, 40, 100],        //可供选择的每页的行数(*)
+        search: false,                       //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
+        strictSearch: true,
+        showColumns: false,                  //是否显示所有的列
+        showRefresh: false,                  //是否显示刷新按钮
+        minimumCountColumns: 2,             //最少允许的列数
+        clickToSelect: true,                //是否启用点击选中行
+        uniqueId: "ID",                     //每一行的唯一标识,一般为主键列
+        showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
+        cardView: false,                    //是否显示详细视图
+        detailView: false,
+        ajaxOptions: {
+            headers: {
+                'Accept': 'application/json',
+                'Authorization': 'Bearer ' + localStorage.getItem("token")
+            }
+        },
+        columns: [
+            {
+                title: '操作',
+                field: 'op',
+                align: "center",
+                valign: 'middle',
+                formatter: function (value, row, index) {
+                    return '<button type="button" class="registration-no-color-foot-button" title="详细" onclick="getDetail(\'' + row.drawNo + '\')"><i class="fa fa-plus"></i></button>';
+                }
+            }, {
+                field: 'outDate',
+                title: '退库日期',
+                align: "center",
+                valign: 'middle',
+                formatter: function (value, row, index) {
+                    return format(value, "yyyy-MM-dd HH:mm:ss");
+                }
+            }, {
+                field: 'drawNo',
+                title: '退库单号',
+                align: "center",
+                valign: 'middle'
+            }, {
+                field: 'groupNoOut',
+                title: '退药库房',
+                align: "center",
+                valign: 'middle',
+                formatter: function (value, row, index) {
+                    return getGroupName(value);
+                }
+            },
+            {
+                field: 'drawerName',
+                title: '申请人',
+                align: "center",
+                valign: 'middle'
+            },
+            {
+                field: 'keeperName',
+                title: '经发人',
+                align: "center",
+                valign: 'middle'
+            },
+            {
+                field: 'groupNo',
+                title: '发药库房',
+                align: "center",
+                valign: 'middle',
+                formatter: function (value, row, index) {
+                    return getGroupName(value);
+                }
+            }
+        ],
+        onDblClickRow: function (row) {
+            getDetail(row.drawNo);
+        },
+        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.total,//总页数
+                "rows": ress.data   //数据
+            };
+        }
+    });
+}
+
+function recordTableQueryParams(params) {
+    let rePortRangeArr = getRePortRangeArr();
+    let temp = {
+        drawNo: $("#drawNoTkSearch").val() === '' ? null : $("#drawNoTkSearch").val(),
+        outType: 2,
+        groupNo: groupYk,
+        beginTime: rePortRangeArr[0],
+        endTime: rePortRangeArr[1],
+        pageSize: params.limit,   //页面大小
+        pageIndex: params.offset / params.limit  //页码
+    };
+    return JSON.stringify(temp);
+}
+
+function getDetail(drawNo) {
+    $("#recordModal").modal("hide");
+    $("#tb_table").bootstrapTable('refreshOptions',{method: 'GET',
+        url: '/thmz/getYpOutDetlDrugYk',queryParams:{drawNo:drawNo}});
+    $("#tb_table").bootstrapTable('refresh');
+}
+
+function initPrintHtml(){
+    var datas = $('#tb_table').bootstrapTable('getData', true);
+    let html = '';
+    let packRetpriceSum = 0;
+    let buyPriceSum = 0;
+    $('.sjh').remove();
+    for (let i = 0; i < datas.length; i++) {
+        let data = datas[i];
+        let packRetprice = keepTwoDecimal(parseFloat(data['newOutAmt']) * parseFloat(data['packRetprice']));
+        let buyPrice = keepTwoDecimal(parseFloat(data['newOutAmt']) * parseFloat(data['buyPrice']));
+        packRetpriceSum += packRetprice;
+        buyPriceSum += buyPrice;
+        if (i === 0) {
+            $(".printDate").html(format(new Date(), "yyyy-MM-dd HH:mm"));
+            $(".groupName").html(data['groupNoOutName']);
+            $(".drawNo").html(data['drawNo']);
+            $(".planDate").html(format(data['confirmDate'], "yyyy-MM-dd HH:mm"));
+            $(".confirmDate").html(format(data['confirmDate'], "yyyy-MM-dd HH:mm"));
+            $(".lister").html($(".current_user")[0].innerText);
+            $(".listerAudit").html(data['confirmName']);
+        }
+        html += '<tr class="sjh">';
+        html += '<td class="xtd" style="text-align: center;">' + data['chargeCode'] + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + data['location'] + '</td>';
+        html += '<td class="xtd" style="text-align: left;">' + data['name'] + '</td>';
+        html += '<td class="xtd" style="text-align: left;">' + data['specification'] + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + data['newOutAmt'] + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + data['buyPrice'] + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + data['packRetprice'] + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + buyPrice + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + packRetprice + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + data['manuNo'] + '</td>';
+        html += '<td class="xtd" style="text-align: left;">' + data['manufactoryName'] + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + format(data['effDate'], "yyyy-MM-dd") + '</td>';
+        html += '<td class="xtd" style="text-align: center;">' + data['stockAmount'] + '</td>';
+        html += '</tr>';
+    }
+    $("#base_tr").after(html);
+    $(".packRetpriceSum").html(keepTwoDecimal(packRetpriceSum));
+    $(".buyPriceSum").html(keepTwoDecimal(buyPriceSum));;
+    print();
+}
+
+/**
+ * 打印报表
+ */
+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.ADD_PRINT_TEXT('190mm', '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: 13px}</style>";
+    LODOP.ADD_PRINT_HTM("2mm", "4mm", "RightMargin:2mm", "BottomMargin:15mm", strStyle + document.getElementById("report_table_1").innerHTML);
+    //LODOP.PRINT();
+    LODOP.PREVIEW();
+}

+ 147 - 12
src/main/resources/templates/yk/drug_return.html

@@ -8,19 +8,99 @@
 <script src="/thmz/js/dependent/jquery.webui-popover.min.js"></script>
 <script src="/thmz/js/common/pharmacy-com.js"></script>
 <script src="/thmz/js/yk/drug_return.js"></script>
+<script src="/thmz/js/dependent/LodopFuncs.js"></script>
 <div class="row" style="height: calc(100% - 60px);overflow-y: auto;">
     <div class="col-md-12 col-sm-12 col-xs-12">
         <div class="x_panel">
-            <div id="tb_table_toolbar" class="btn-group">
-                <button id="btn_add" type="button" class="btn btn-default">
-                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
-                </button>
-                <button id="btn_delete" type="button" class="btn btn-default">
-                    <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
-                </button>
-                <button id="btn_save" type="button" class="btn btn-default">
-                    <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存
-                </button>
+            <form id="xxform" class="form-horizontal" autocomplete="off">
+                <div class="form-group">
+                    <div class="col-md-12 col-sm-12 col-xs-12">
+                        <button type="button" style="margin-left:3px" id="btn_add" class="btn btn-primary"
+                                title="新增"><i class="fa fa-plus">&nbsp;&nbsp;新增</i>
+                        </button>
+                        <button type="button" style="margin-left:3px" id="btn_delete" class="btn btn-primary"
+                                title="删除"><i class="fa fa-trash-o">&nbsp;&nbsp;删除</i>
+                        </button>
+                        <button type="button" style="margin-left:3px" id="btn_save" class="btn btn-primary"
+                                title="保存"><i class="fa fa-save">&nbsp;&nbsp;保存</i>
+                        </button>
+                        <button type="button" id="btn_daily" class="btn btn-primary"
+                                title="打印"><i class="fa fa-print">&nbsp;&nbsp;打印</i>
+                        </button>
+                        <button type="button" style="margin-left:3px" id="btn_record" class="btn btn-primary"
+                                title="退库记录"><i class="fa fa-list-alt">&nbsp;&nbsp;退库记录</i>
+                        </button>
+                    </div>
+                    <input id="groupNoLabel" type="hidden">
+                </div>
+            </form>
+            <div id="report_table"
+                 style="width:1030px;height: calc(100% - 160px);margin:0 auto;border: 1px solid #337ab7;font-size: 14px;padding: 40px 10px 40px 10px;overflow: scroll;display: none">
+                <div id="report_table_1">
+                    <table id="qbtj_table" class="table table-striped"
+                           style="margin-top: 0px;border: transparent !important;">
+                        <tr style="font-weight: 700;background-color: #EBEBE4;height: 70px;">
+                            <td colspan="14" style="font-size: 21px;text-align: center;border: transparent !important;">
+                                <span class="title">长沙泰和医院西药库退库单</span></td>
+                        </tr>
+                        <tr style="font-weight: 700;background-color: #EBEBE4">
+                            <td colspan="3" style="text-align: left;border: transparent !important;">领用库房:<span
+                                    class="groupName"></span></td>
+                            <td colspan="3" style="text-align: left;border: transparent !important;">出库单号:<span
+                                    class="drawNo"></span></td>
+                            <td colspan="4" style="text-align: left;border: transparent !important;">请领日期:<span
+                                    class="planDate"></span></td>
+                            <td colspan="3" style="text-align: left;border: transparent !important;">审核日期:<span
+                                    class="confirmDate"></span></td>
+                        </tr>
+                        <tr id="base_tr">
+                            <td class="xtd" style="text-align: center;width: 60px;">编码</td>
+                            <td class="xtd" style="text-align: center;width: 80px;">货位号</td>
+                            <td class="xtd" style="text-align: center;width: 140px;">药品名称</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">规格</td>
+                            <td class="xtd" style="text-align: center;width: 40px;">数量</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">购入价</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">零售价</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">购入金额</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">零售金额</td>
+                            <td class="xtd" style="text-align: center;width: 80px;">生产批号</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">生产厂家</td>
+                            <td class="xtd" style="text-align: center;width: 100px;">有效期</td>
+                            <td class="xtd" style="text-align: center;width: 60px;">库存</td>
+                        </tr>
+                        <tr style="border: transparent !important;"></tr>
+                        <tr>
+                            <td colspan="4" class="xtd"
+                                style="text-align: right;border: transparent !important;font-weight: bold;">合计:
+                            </td>
+                            <td colspan="3" class="xtd"
+                                style="text-align: left;border: transparent !important;font-weight: bold;">零售总额:<span
+                                    class="packRetpriceSum"></span></td>
+                            <td colspan="3" class="xtd"
+                                style="text-align: left;border: transparent !important;font-weight: bold;">购入总额:<span
+                                    class="buyPriceSum"></span></td>
+                            <td colspan="3" class="xtd" style="text-align: center;border: transparent !important;">打印日期:<span
+                                    class="printDate"></span></td>
+                        </tr>
+                        <tr style="border: transparent !important;"></tr>
+                        <tr>
+                            <td colspan="2" class="xtd" style="text-align: left;border: transparent !important;">
+                                质量情况:合格
+                            </td>
+                            <td colspan="1" class="xtd" style="text-align: left;border: transparent !important;">发药人:
+                            </td>
+                            <td colspan="3" class="xtd" style="text-align: left;border: transparent !important;">
+                                发药复核人:
+                            </td>
+                            <td colspan="2" class="xtd" style="text-align: left;border: transparent !important;">领药人:
+                            </td>
+                            <td colspan="2" class="xtd" style="text-align: left;border: transparent !important;">
+                                制表人:<span class="lister"></span></td>
+                            <td colspan="3" class="xtd" style="text-align: left;border: transparent !important;">
+                                制表审核人:<span class="listerAudit"></span></td>
+                        </tr>
+                    </table>
+                </div>
             </div>
             <table id="tb_table"></table>
         </div>
@@ -51,7 +131,8 @@
                                     <label class="control-label col-md-4 col-sm-4 col-xs-12" for="groupNoSearchText">药房
                                     </label>
                                     <div class="col-md-8 col-sm-8 col-xs-12">
-                                        <select class="form-control selectpicker show-tick" data-live-search="true" title="请选择"
+                                        <select class="form-control selectpicker show-tick" data-live-search="true"
+                                                title="请选择"
                                                 multiple
                                                 data-max-options="1"
                                                 id="groupNoSearchText">
@@ -78,4 +159,58 @@
         </div>
     </div>
 </div>
-<!--新增请领信息弹窗结尾-->
+<!--新增请领信息弹窗结尾-->
+
+<!--调未审核单弹窗开始-->
+<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true" id="recordModal">
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content" style="width: 130%;margin-top: 50px;margin-left: -100px;">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span>
+                </button>
+                <h4 class="modal-title">退库记录</h4>
+            </div>
+            <div class="modal-body">
+                <div class="row">
+                    <div class="col-md-12 col-sm-12 col-xs-12">
+                        <form id="tkForm" class="form-horizontal" autocomplete="off">
+                            <div class="form-group">
+                                <label class="control-label col-md-1 col-sm-1 col-xs-12" for="drawNoTkSearch">退库单号:
+                                </label>
+                                <div class="col-md-2 col-sm-2 col-xs-12">
+                                    <input id="drawNoTkSearch" class="form-control optional" type="text">
+                                </div>
+                                <label class="control-label col-md-1 col-sm-1 col-xs-12" for="reportrange">
+                                    时间范围
+                                </label>
+                                <div class="col-md-3 col-sm-3 col-xs-12" style="width: 220px;">
+                                    <div id="reportrange" class="pull-left"
+                                         style="background: #fff; cursor: pointer; padding: 6.5px 10px; border: 1px solid #ccc">
+                                        <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
+                                        <span>December 30, 2014 - January 28, 2015</span> <b class="caret"></b>
+                                    </div>
+                                </div>
+                                <div class="col-md-1 col-sm-1 col-xs-12 item">
+                                    <button type="button" style="margin-left:3px" id="btn_query" class="btn btn-primary"
+                                            title="查询"><i class="fa fa-search"></i>
+                                    </button>
+                                </div>
+                            </div>
+                        </form>
+                    </div>
+                    <div class="col-md-12 col-sm-12 col-xs-12">
+                        <table id="tk_record"></table>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!--调未审核单弹窗结尾-->
+<!--加载中提示结尾-->
+<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
+    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
+</object>