Browse Source

新增资产借用功能模块

LinWuTai 1 year ago
parent
commit
4ac75b6c56

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

@@ -107,21 +107,21 @@ public class TbAssetBorrowRecordServiceImpl implements ITbAssetBorrowRecordServi
         // 判断是否已借出
         TbAssetBorrowRecord isLentRecord = tbAssetBorrowRecordMapper.selectLentRecordByAssetId(assetId);
         if (isLentRecord != null) {
-            return 0;
+            throw new RuntimeException("资产已借出");
         }
 
         TbAssetInformation tbAssetInformation;
         if (assetId != null) {
             tbAssetInformation = assetInformationMapper.selectTbAssetInformationById(assetId);
             if (tbAssetInformation == null) {
-                return 0;
+                throw new RuntimeException("资产不存在");
             }
         } else {
             String assetNumber = tbAssetBorrowRecord.getAssetNumber();
             tbAssetInformation = assetInformationMapper.selectTbAssetInformationByAssetNumber(assetNumber);
 
             if (tbAssetInformation == null) {
-                return 0;
+                throw new RuntimeException("资产不存在");
             }
             tbAssetBorrowRecord.setAssetId(tbAssetInformation.getId());
         }
@@ -160,8 +160,8 @@ public class TbAssetBorrowRecordServiceImpl implements ITbAssetBorrowRecordServi
             // 根据资产Id判断是否已借出
             TbAssetBorrowRecord isLentRecord = tbAssetBorrowRecordMapper.selectLentRecordByAssetId(tbAssetBorrowRecord.getAssetId());
             // 判断是否非同一个
-            if (!tbAssetBorrowRecord.getId().equals(isLentRecord.getId())) {
-                return 0;
+            if (isLentRecord != null && !tbAssetBorrowRecord.getId().equals(isLentRecord.getId())) {
+                throw new RuntimeException("资产已借出");
             }
 
             // 已设置归还时间

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

@@ -423,6 +423,13 @@ export default {
       this.form.returnLocationNumber = this.form.borrowLocationNumber
     },
     onReturn(e, row) {
+      this.$modal.confirm('是否确认更改该数据项?').then(() => {
+        this.onSubmitReturn(e, row)
+      }).catch(() => {
+        this.getList();
+      })
+    },
+    onSubmitReturn(e, row) {
       const form = row
       let message;
       if (e === 1) {