فهرست منبع

入库前端限制后端效验

WANGJIALIANG 3 سال پیش
والد
کامیت
be049633c8

+ 2 - 2
src/main/java/cn/hnthyy/thmz/controller/yf/YfWarehouseController.java

@@ -163,7 +163,7 @@ public class YfWarehouseController {
      */
     @UserLoginToken
     @RequestMapping(value = "/saveYpInDetlYf",method = {RequestMethod.POST})
-    public Map<String,Object> saveYpInDetlYf(@RequestBody List<YpOutDetlVo> ypOutDetlVos, HttpServletRequest httpServletRequest){
+    public Map<String,Object> saveYpInDetlYf(@RequestBody List<YpOutDetlVo> ypOutDetlVos, HttpServletRequest httpServletRequest) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             User tokenUser = TokenUtil.getUser(httpServletRequest);
@@ -184,7 +184,7 @@ public class YfWarehouseController {
         } catch (Exception e) {
             log.error(e.toString());
             resultMap.put("code", -1);
-            resultMap.put("message", "入库失败");
+            resultMap.put("message", "入库失败,"+e.getMessage());
             return resultMap;
         }
     }

+ 8 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpOutDetlMapper.java

@@ -199,4 +199,12 @@ public interface YpOutDetlMapper {
             "</where>" +
             "</script>"})
     int updateYpOutDetl(YpOutDetl ypOutDetl);
+
+    /**
+     * 查询药房入库接收状态
+     * @param drawNo 出库单
+     * @return
+     */
+    @Select("select accept_sign from yp_out_detl where draw_no =#{drawNo}")
+    int selectAcceptSign(@Param("drawNo") String drawNo);
 }

+ 4 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpBaseYfServiceImpl.java

@@ -75,6 +75,10 @@ public class YpBaseYfServiceImpl implements YpBaseYfService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     @Override
     public int saveYpBaseYf(List<YpOutDetlVo> ypOutDetlVos, User user) throws MzException {
+        int acceptSign = ypOutDetlMapper.selectAcceptSign(ypOutDetlVos.get(0).getDrawNo());
+        if(acceptSign == 1){
+            throw new MzException("重复入库!");
+        }
         int num = 0;
         String inComment;
         double amount;//拆零后总数

+ 3 - 5
src/main/resources/static/js/yf/pharmacy_warehouse.js

@@ -216,24 +216,22 @@ function saveData(index, field, value) {
  * 药品入库
  */
 function saveDrug(data) {
-    $("#btn_save").attr('disabled', true);
+    $("#btn_save").attr('disabled', 'disabled');
     $.ajax({
         type: "POST",
         url: '/thmz/saveYpInDetlYf',
         contentType: "application/json;charset=UTF-8",
         dataType: "json",
-        async: false,
         headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
         data: JSON.stringify(data),
         success: function (res) {
-            $("#btn_save").attr('disabled', false);
             if (res == '401' || res == 401) {
                 window.location.href = '/thmz/login/view'
                 return;
             }
+            $("#editModal").modal("hide");
+            $('#tb_table').bootstrapTable('refresh');
             if (res.code == 0) {
-                $("#editModal").modal("hide");
-                $('#tb_table').bootstrapTable('refresh');
                 successMesage(res);
             } else {
                 errorMesage(res);