From 8fb70056a7ba43efce6551b061d164310ea61113 Mon Sep 17 00:00:00 2001
From: "liang.chao" <1360241448@qq.com>
Date: Wed, 27 Aug 2025 11:43:36 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
 src/views/material/ma/type/index.vue | 273 +++++++++++++++++++--------
 1 file changed, 191 insertions(+), 82 deletions(-)
diff --git a/src/views/material/ma/type/index.vue b/src/views/material/ma/type/index.vue
index 61f1689a..9afa6d2b 100644
--- a/src/views/material/ma/type/index.vue
+++ b/src/views/material/ma/type/index.vue
@@ -35,8 +35,8 @@
               @mouseleave="onMouseleave()"
             >
               {{
-                node.label.slice(0, 3) + "..."
-              }}
+                  node.label.slice(0, 3) + "..."
+                }}
               {{ node.label }}
 
               
@@ -96,10 +96,12 @@
               icon="el-icon-search"
               size="mini"
               @click="handleQuery"
-              >查询查询
+            
             重置重置
+            
           
         
@@ -112,7 +114,7 @@
               icon="el-icon-download"
               size="mini"
               @click="handleExport"
-              >导出
+            >导出
             
           
           
           
-                
-                    {{(queryParams.pageNum - 1) * 10 + scope.$index + 1}}
-                
-            
+            
+              {{ (queryParams.pageNum - 1) * 10 + scope.$index + 1 }}
+            
+          
           
                 编辑
               
+              
+                修改库存
+              
               
           
             
-                
-                  
-                
+              
+                
+              
             
           
           
       
     
+    
+    
+      
+        
+          
+            
+              
+            
+          
+        
+        
+          
+            
+              
+            
+          
+        
+      
+      
+    
 
     
-      
+      
     
 
     
@@ -689,21 +743,22 @@
           
           
             
-              
+              
             
           
           
             
               
-                
-                
+                
+                
               
             
           
           
             
               
-                
+                
               
             
           
@@ -733,19 +788,21 @@ import {
   queryKeeperMatApi,
   queryKeeperNameApi,
   delMaType,
+  // 添加更新库存的API
+  updateStorageNumApi,
   addMaType,
   updateMaType,
   getUserTypeList,
   updatePartType,
   getUserListApi
 } from "@/api/ma/base";
-import { getKeeperIds} from "@/api/ma/typeConfigKeeper";
-import { getRepairIds } from "@/api/ma/typeConfigRepair";
-import { imgUpLoad } from "@/api/system/upload";
+import {getKeeperIds} from "@/api/ma/typeConfigKeeper";
+import {getRepairIds} from "@/api/ma/typeConfigRepair";
+import {imgUpLoad} from "@/api/system/upload";
 
 export default {
   name: "Type",
-  components: { Treeselect },
+  components: {Treeselect},
   data() {
     return {
       // 遮罩层
@@ -760,7 +817,7 @@ export default {
       showSearch: true,
       // 总条数
       total: 0,
-      unitValueOptions: [{id:"0",name:"整数"},{id:"1",name:"小数"}],
+      unitValueOptions: [{id: "0", name: "整数"}, {id: "1", name: "小数"}],
       // 库管员用户数据
       keeperList: null,
       keeperDataRange: [],
@@ -815,7 +872,6 @@ export default {
         children: "children",
         label: "label",
       },
-
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -826,7 +882,21 @@ export default {
         // status: undefined,
         // typeId: undefined
       },
-
+      // 修改库存对话框相关数据
+      storageOpen: false,
+      storageTitle: "修改库存",
+      storageForm: {
+        typeId: '',
+        currentStorage: 0,
+        storageNum: 0,
+        reason: ''
+      },
+      storageRules: {
+        storageNum: [
+          {required: true, message: "新库存数量不能为空", trigger: "blur"},
+          {type: 'number', min: 0, message: "库存数量不能为负数", trigger: "blur"}
+        ],
+      },
       // 表单校验
       rules: {
         typeName: [
@@ -874,7 +944,6 @@ export default {
         afterPrice: "",
         useDate: "",
       },
-
       /* 新增弹框等数据源定义 */
       addTitleVisible: false,
       addTitle: "", // 新增弹框标题
@@ -931,6 +1000,37 @@ export default {
         this.KeeperOptions = response.rows;
       });
     },
+    /** 修改库存按钮操作 */
+    updateStorageNum(row) {
+      this.storageForm = {
+        typeId: row.typeId,
+        currentStorage: row.storageNum || 0,
+        storageNum: row.storageNum || 0,
+      };
+      this.storageOpen = true;
+    },
+
+    /** 提交库存修改表单 */
+    submitStorageForm() {
+      this.$refs["storageForm"].validate((valid) => {
+        if (valid) {
+          // 转换为数字类型
+          this.storageForm.storageNum = Number(this.storageForm.storageNum);
+
+          updateStorageNumApi(this.storageForm).then(response => {
+            if (response.code === 200) {
+              this.$modal.msgSuccess("库存修改成功");
+              this.storageOpen = false;
+              this.getList(); // 刷新列表
+            } else {
+              this.$modal.msgError(response.msg || "库存修改失败");
+            }
+          }).catch(error => {
+            this.$modal.msgError("库存修改失败");
+          });
+        }
+      });
+    },
     async getRepairerData() {
       const itemName = "wei_xiu_role_ids";
       let roleIdsTemp = []
@@ -946,7 +1046,6 @@ export default {
     },
 
 
-
     /** 查询物资类型 */
     async getKeeperDataList(data) {
       let keepdataRes = await queryKeeperDataApi({
@@ -966,19 +1065,19 @@ export default {
       getMaTypeList().then((response) => {
         this.treeOptions = response.data;
         console.log(this.treeOptions)
-        if (this.treeOptions.length > 0 ){
-            if(this.treeOptions[0].children&&this.treeOptions[0].children.length > 0) {
-              const firstNode = this.treeOptions[0].children[0];
-              this.queryParams.typeId = firstNode.id;
-              this.queryParams.level = 1;
-              this.queryParams.houseId = firstNode.houseId;
-              this.getList();
-            }else{
-              this.queryParams.typeId = this.treeOptions[0].id;
-              this.queryParams.level = 0;
-              this.queryParams.houseId = this.treeOptions[0].id;
-              this.getList();
-            }
+        if (this.treeOptions.length > 0) {
+          if (this.treeOptions[0].children && this.treeOptions[0].children.length > 0) {
+            const firstNode = this.treeOptions[0].children[0];
+            this.queryParams.typeId = firstNode.id;
+            this.queryParams.level = 1;
+            this.queryParams.houseId = firstNode.houseId;
+            this.getList();
+          } else {
+            this.queryParams.typeId = this.treeOptions[0].id;
+            this.queryParams.level = 0;
+            this.queryParams.houseId = this.treeOptions[0].id;
+            this.getList();
+          }
         }
       });
     },
@@ -1088,10 +1187,10 @@ export default {
       const typeId = row.typeId;
       getMaType(typeId).then((response) => {
         this.form = response.data;
-        if(response.data.repairerId){
+        if (response.data.repairerId) {
           this.form.repairerArr = response.data.repairerId.split(",")
         }
-        if(response.data.keeperId){
+        if (response.data.keeperId) {
           this.form.keeperArr = response.data.keeperId.split(",")
         }
         this.form.isCharging = this.form.isCharging + "";
@@ -1116,10 +1215,10 @@ export default {
       getMaType(typeId).then((response) => {
         this.form = response.data;
         this.leasePriceTemp = response.data.leasePrice;
-        if(response.data.repairerId){
+        if (response.data.repairerId) {
           this.form.repairerArr = response.data.repairerId.split(",")
         }
-        if(response.data.keeperId){
+        if (response.data.keeperId) {
           this.form.keeperArr = response.data.keeperId.split(",")
         }
         this.form.isCharging = this.form.isCharging + "";
@@ -1141,35 +1240,36 @@ export default {
       console.log(this.form, "提交参数---");
       this.$refs["form"].validate((valid) => {
         if (valid) {
-          if(this.form.keeperArr != null && this.form.keeperArr.length > 0){
+          if (this.form.keeperArr != null && this.form.keeperArr.length > 0) {
             this.form.keeperId = this.form.keeperArr.join(",")
           }
-          if(this.form.repairerArr != null && this.form.repairerArr.length > 0){
+          if (this.form.repairerArr != null && this.form.repairerArr.length > 0) {
             this.form.repairerId = this.form.repairerArr.join(",")
           }
           if (this.form.typeId != undefined) {
-            if(this.form.leasePrice!=this.leasePriceTemp){
+            if (this.form.leasePrice != this.leasePriceTemp) {
               this.$modal
                 .confirm("是否确认修改后的内部租赁价?")
                 .then(() => {
                   this.form.isUpdateLeasePrice = true;
                   updateMaType(this.form).then((response) => {
-                  this.$modal.msgSuccess("修改成功");
-                  this.open = false;
-                  this.getList();
-                  // this.getTreeData();
+                    this.$modal.msgSuccess("修改成功");
+                    this.open = false;
+                    this.getList();
+                    // this.getTreeData();
+                  });
+                })
+                .catch(() => {
                 });
-                    })
-                    .catch(() => {});
-                }else{
-                  updateMaType(this.form).then((response) => {
-                  this.$modal.msgSuccess("修改成功");
-                  this.open = false;
-                  this.getList();
-                  // this.getTreeData();
-                });
-                }
-            }else {
+            } else {
+              updateMaType(this.form).then((response) => {
+                this.$modal.msgSuccess("修改成功");
+                this.open = false;
+                this.getList();
+                // this.getTreeData();
+              });
+            }
+          } else {
             addMaType(this.form).then((response) => {
               this.$modal.msgSuccess("新增成功");
               this.open = false;
@@ -1193,7 +1293,8 @@ export default {
           this.getList();
           // this.getTreeData();
         })
-        .catch(() => {});
+        .catch(() => {
+        });
     },
 
     handleRemove(file, fileList) {
@@ -1327,7 +1428,8 @@ export default {
           this.$modal.msgSuccess("删除成功");
           this.getTreeData();
         })
-        .catch(() => {});
+        .catch(() => {
+        });
     },
     // 获取班组长列表
     getTeamLeaderList() {
@@ -1353,7 +1455,7 @@ export default {
     },
     /* 确定 */
     onSubmit() {
-      const { id, typeName, isEnter, keeperUserId } = this.addFormParams;
+      const {id, typeName, isEnter, keeperUserId} = this.addFormParams;
       console.log("level", this.levelTemp);
       console.log("idTemp", this.idTemp);
       const addParams = {
@@ -1416,7 +1518,8 @@ export default {
             }
           }
         });
-      } catch (error) {}
+      } catch (error) {
+      }
     },
 
     onMousemove(data) {
@@ -1437,23 +1540,28 @@ export default {
 ::v-deep .btn-items .el-button + .el-button {
   margin-left: 6px;
 }
+
 .btn-items {
   margin-left: 4px;
+
   .el-button--text {
     font-size: 16px;
   }
 }
+
 ::v-deep .el-tree .el-tree-node__expand-icon.expanded {
   -webkit-transform: rotate(0deg);
   transform: rotate(0deg);
 }
+
 ::v-deep .el-tree .el-icon-caret-right:before {
   content: "\e783";
   font-size: 16px;
 }
+
 ::v-deep
-  .el-tree
-  .el-tree-node__expand-icon.expanded.el-icon-caret-right:before {
+.el-tree
+.el-tree-node__expand-icon.expanded.el-icon-caret-right:before {
   content: "\e781";
   font-size: 16px;
   color: #1890ff;
@@ -1462,14 +1570,15 @@ export default {
 ::v-deep .el-tree-node__content > .el-tree-node__expand-icon {
   color: #1890ff !important;
 }
+
 ::v-deep .el-tree-node__expand-icon.is-leaf {
   color: transparent !important;
 }
 
 ::v-deep
-  .el-tree--highlight-current
-  .el-tree-node.is-current
-  > .el-tree-node__content {
+.el-tree--highlight-current
+.el-tree-node.is-current
+> .el-tree-node__content {
   background-color: #8decf1;
 }