Browse Source

新增资产借用功能模块

LinWuTai 1 year ago
parent
commit
fad952fc16

+ 7 - 6
ruoyi-admin/src/main/java/com/ruoyi/borrow/service/impl/TbAssetBorrowRecordServiceImpl.java

@@ -104,12 +104,6 @@ public class TbAssetBorrowRecordServiceImpl implements ITbAssetBorrowRecordServi
     {
         Long assetId = tbAssetBorrowRecord.getAssetId();
 
-        // 判断是否已借出
-        TbAssetBorrowRecord isLentRecord = tbAssetBorrowRecordMapper.selectLentRecordByAssetId(assetId);
-        if (isLentRecord != null) {
-            throw new RuntimeException("资产已借出");
-        }
-
         TbAssetInformation tbAssetInformation;
         if (assetId != null) {
             tbAssetInformation = assetInformationMapper.selectTbAssetInformationById(assetId);
@@ -125,6 +119,13 @@ public class TbAssetBorrowRecordServiceImpl implements ITbAssetBorrowRecordServi
             }
             tbAssetBorrowRecord.setAssetId(tbAssetInformation.getId());
         }
+
+        // 判断是否已借出
+        TbAssetBorrowRecord isLentRecord = tbAssetBorrowRecordMapper.selectLentRecordByAssetId(tbAssetInformation.getId());
+        if (isLentRecord != null) {
+            throw new RuntimeException("资产已借出");
+        }
+
         tbAssetBorrowRecord.setBorrowLocationNumber(tbAssetInformation.getLocationNumber());
 
         tbAssetBorrowRecord.setCreateTime(DateUtils.getNowDate());

+ 2 - 0
ruoyi-ui/src/views/asset/borrow/index.vue

@@ -443,6 +443,8 @@ export default {
       updateBorrow(form).then(response => {
         this.$modal.msgSuccess(message);
         this.getList();
+      }).catch((e) => {
+        this.getList();
       })
     },
     /** 提交按钮 */