Bladeren bron

物资模拟借去异常修复

pm 9 maanden geleden
bovenliggende
commit
b8c44c6a78

+ 8 - 0
src/api/mes/material/information.js

@@ -88,3 +88,11 @@ export function insertIsMaterialsCheckRecord(data) {
     }
   })
 }
+//查询异常还错柜子的物资
+export function getExMaterials(query) {
+  return request({
+    url: '/iscs/materials/getExMaterials',
+    method: 'get',
+    params: query
+  })
+}

+ 165 - 161
src/views/mes/material/Lending/demo2.vue

@@ -5,30 +5,34 @@
       <div style="display: flex;padding-left: 10px">
         <h4>1.选择物资柜</h4>
         <el-select
-          style="width: 215px;margin: 10px 20px;"
-          v-model="queryParams.materialsCabinetId"
-          placeholder="请选择物资柜"
-          @change="handleCabinetChange"
+            style="width: 215px;margin: 10px 20px;"
+            v-model="queryParams.materialsCabinetId"
+            placeholder="请选择物资柜"
+            @change="handleCabinetChange"
         >
           <el-option
-            v-for="dict in cabinets"
-            :key="dict.value"
-            :label="dict.label"
-            :value="dict.value"
+              v-for="dict in cabinets"
+              :key="dict.value"
+              :label="dict.label"
+              :value="dict.value"
           />
         </el-select>
       </div>
       <div style="display: flex;padding-left: 10px">
         <h4>2.</h4>
-        <el-button @click="changeDoor(true)" style="width:60px;height:30px;padding:5px 8px;margin: 12px 10px">开柜门</el-button>
+        <el-button @click="changeDoor(true)" style="width:60px;height:30px;padding:5px 8px;margin: 12px 10px">开柜门
+        </el-button>
       </div>
       <div style="display: flex;padding-left: 10px">
         <h4>3.取物资/还物资</h4>
-<!--        <el-input v-model="inputStatus" style="width:150px"></el-input>-->
+        <!--        <el-input v-model="inputStatus" style="width:150px"></el-input>-->
       </div>
       <div style="display: flex;padding-left: 10px">
         <h4>4.</h4>
-        <el-button :disabled="!doorOpen" @click="changeDoor(false)" style="width:60px;height:30px;padding:5px 8px;margin: 12px 10px">关柜门</el-button>
+        <el-button :disabled="!doorOpen" @click="changeDoor(false)"
+                   style="width:60px;height:30px;padding:5px 8px;margin: 12px 10px"
+        >关柜门
+        </el-button>
       </div>
 
     </div>
@@ -37,8 +41,9 @@
 </template>
 
 <script>
-import Konva from "konva";
+import Konva from 'konva'
 import {
+  getExMaterials,
   getIsMaterialsCabinets,
   listMaterials,
   selectMaterialsById,
@@ -56,36 +61,36 @@ export default {
       listInCabinet: [], // 存储物资柜内的物资
       listOutOfCabinet: [], // 存储物资柜外的物资
       cabinets: [], // 物资所属柜
-      doorOpen:false,
+      doorOpen: false,
       queryParams: {
         current: 1,
         size: -1,
         materialsCabinetId: null,
-        loanState:null
+        loanState: null
       },
-      inputStatus:'当前柜门已关闭',//柜门开关状态
+      inputStatus: '当前柜门已关闭',//柜门开关状态
       materialElements: [], // 存储物资图标对象
-      materialsToUpdate: [], // 存储需要更新的物资
-    };
+      materialsToUpdate: [] // 存储需要更新的物资
+    }
   },
   mounted() {
     this.$nextTick(() => {
-      this.initKonva();
-      this.inputStatus='当前柜门已关闭'
+      this.initKonva()
+      this.inputStatus = '当前柜门已关闭'
       this.materialsCabinets()
-    });
+    })
   },
   methods: {
-    changeDoor(value){
-      this.doorOpen = value;
-      if(this.doorOpen){
+    changeDoor(value) {
+      this.doorOpen = value
+      if (this.doorOpen) {
         this.$message.success('柜门已打开')
         this.updateDraggableStatus()
-        this.inputStatus="当前柜门已打开"
-      }else {
+        this.inputStatus = '当前柜门已打开'
+      } else {
         this.$message.info('柜门已关闭')
-        this.inputStatus="当前柜门已关闭"
-        this.updateMaterialsBatch(); // 柜门关闭时调用批量更新接口
+        this.inputStatus = '当前柜门已关闭'
+        this.updateMaterialsBatch() // 柜门关闭时调用批量更新接口
       }
     },
     // 获取物资柜信息
@@ -95,52 +100,69 @@ export default {
           this.cabinets = response.data.records.map((item) => ({
             value: item.cabinetId,
             label: item.cabinetName
-          }));
+          }))
         }
-      });
+      })
     },
     handleCabinetChange() {
       // 清空之前渲染的物资元素
-      this.clearMaterialsFromLayer();
+      this.clearMaterialsFromLayer()
 
       // 获取柜内和柜外物资
       Promise.all([this.getMaterialsInCabinet(), this.getMaterialsOutOfCabinet()])
-        .then(() => {
-          // 在所有数据获取完成后,统一渲染物资
-          this.addMaterialsToLayer();
-        });
+          .then(() => {
+            // 在所有数据获取完成后,统一渲染物资
+            this.addMaterialsToLayer()
+          })
     },
 
-    getMaterialsInCabinet() {
+    async getMaterialsInCabinet() {
       this.queryParams.loanState = '1'; // 设置查询条件为物资柜内
-      return listMaterials(this.queryParams).then((res) => {
-        this.listInCabinet = res.data.records;
-      });
+
+      try {
+        const res1 = await listMaterials(this.queryParams);
+        this.listInCabinet = res1.data.records;
+
+        const data1 = {
+          materialsCabinetId: this.queryParams.materialsCabinetId
+        };
+
+        const res2 = await getExMaterials(data1);
+        this.listInCabinet = [...this.listInCabinet, ...res2.data];
+        console.log(this.listInCabinet, '柜子内的数据demo2');
+
+      } catch (error) {
+        console.error('Error fetching data:', error);
+      }
     },
 
     getMaterialsOutOfCabinet() {
-      this.queryParams.loanState = '0'; // 设置查询条件为物资柜外
-      const data={
+      this.queryParams.loanState = '0' // 设置查询条件为物资柜外
+
+      const data = {
         current: 1,
         size: -1,
-        loanState: '0',
+        loanState: '0'
       }
-      return listMaterials(data).then((res) => {
-        this.listOutOfCabinet = res.data.records.filter((item) => {return item.materialsCabinetId!=null && item.materialsCabinetId!=='0'});
-        console.log(this.listOutOfCabinet,'柜子外的数据demo2')
-      });
+       listMaterials(data).then((res) => {
+        // item.status!=='3'这个判断的意思是放错柜子的数据不显示的柜子外 因为异常数据以及放在柜子里了 item.materialsCabinetId不显示未绑定柜子的 item.materialsCabinetId不显示绑定柜子是0的
+        this.listOutOfCabinet = res.data.records.filter((item) => {
+          return item.materialsCabinetId != null && item.materialsCabinetId !== '0' && item.status !== '3'
+        })
+      })
+
     },
     // 初始化Konva舞台
     initKonva() {
       this.stage = new Konva.Stage({
         container: this.$refs.container,
         width: 1600,
-        height: 1000,
-      });
+        height: 1000
+      })
 
-      this.bgLayer = new Konva.Layer();
-      const bgImage = new Image();
-      bgImage.src = require('@/assets/images/table.png');
+      this.bgLayer = new Konva.Layer()
+      const bgImage = new Image()
+      bgImage.src = require('@/assets/images/table.png')
       bgImage.onload = () => {
         const konvaImage = new Konva.Image({
           x: 600,
@@ -148,37 +170,37 @@ export default {
           image: bgImage,
           width: 500,
           height: 700,
-          draggable: false,
-        });
-        this.bgLayer.add(konvaImage);
-        this.bgLayer.draw();
-      };
-      this.stage.add(this.bgLayer);
+          draggable: false
+        })
+        this.bgLayer.add(konvaImage)
+        this.bgLayer.draw()
+      }
+      this.stage.add(this.bgLayer)
     },
 
     // 清除Konva图层中的所有物资元素
     clearMaterialsFromLayer() {
-      if (!this.bgLayer) return;
-      const materialNodes = this.bgLayer.find('.material');
-      console.log('清除物资:', materialNodes);
-      materialNodes.forEach(node => node.destroy()); // 清除已渲染的物资元素
-      this.materialElements = []; // 清空已存储的物资图标对象
-      this.bgLayer.draw(); // 重新绘制图层
+      if (!this.bgLayer) return
+      const materialNodes = this.bgLayer.find('.material')
+      console.log('清除物资:', materialNodes)
+      materialNodes.forEach(node => node.destroy()) // 清除已渲染的物资元素
+      this.materialElements = [] // 清空已存储的物资图标对象
+      this.bgLayer.draw() // 重新绘制图层
     },
 
     // 物资拖动结束时的处理
     handleDragEnd(e) {
-      const materialId = e.target.getAttr('materialId'); // 获取物资ID
-      const position = e.target.getClientRect(); // 获取物资当前的位置信息
-      const material = e.target.getAttr('material'); // 获取物资对象
-console.log(material,'物资移动');
-      const isInCabinet = material.inCabinet; // 物资是否在柜子内
+      const materialId = e.target.getAttr('materialId') // 获取物资ID
+      const position = e.target.getClientRect() // 获取物资当前的位置信息
+      const material = e.target.getAttr('material') // 获取物资对象
+      console.log(material, '物资移动')
+      const isInCabinet = material.inCabinet // 物资是否在柜子内
 
       selectMaterialsById(material.materialsId).then((res) => {
-        console.log(res, '一大啊啊啊是');
-        const originalCabinetId = res.data.materialsCabinetId;//原来的柜子ID
-        const currentCabinetId = this.queryParams.materialsCabinetId; // 归还目标柜子ID
-        console.log(originalCabinetId,currentCabinetId, 'originalCabinetId');
+        console.log(res, '一大啊啊啊是')
+        const originalCabinetId = res.data.materialsCabinetId//原来的柜子ID
+        const currentCabinetId = this.queryParams.materialsCabinetId // 归还目标柜子ID
+        console.log(originalCabinetId, currentCabinetId, 'originalCabinetId')
 
         if (!currentCabinetId || position.x < 600 || position.x > 1100 || position.y < 25 || position.y > 725) {
           // **物资移出柜子**
@@ -188,12 +210,12 @@ console.log(material,'物资移动');
               materialsId: materialId,
               loanState: 0,  // "借出"
               loanUserId: 106
-            });
-            material.inCabinet = false; // 更新状态
+            })
+            material.inCabinet = false // 更新状态
           }
         } else {
           // **物资归还到柜子**
-          if (!isInCabinet&&originalCabinetId === currentCabinetId) {
+          if (!isInCabinet && originalCabinetId === currentCabinetId) {
             console.log('2--------')
             // **物资从外部归还**
             this.materialsToUpdate.push({
@@ -201,69 +223,51 @@ console.log(material,'物资移动');
               loanState: 1,  // "归还"
               restitutionToId: currentCabinetId,
               restitutionUserId: 106
-            });
-            material.inCabinet = true;
-            material.materialsCabinetId = currentCabinetId; // 更新物资的柜子ID
+            })
+            material.inCabinet = true
+            material.materialsCabinetId = currentCabinetId // 更新物资的柜子ID
           } else if (originalCabinetId !== currentCabinetId) {
             console.log('3--------')
-            // **物资从柜子 A 归还到柜子 B,需要确认**
-            // 查找柜子名称
-            const originalCabinetName = this.cabinets.find(cabinet => cabinet.value === originalCabinetId)?.label || '未知柜子';
-            const currentCabinetName = this.cabinets.find(cabinet => cabinet.value === currentCabinetId)?.label || '未知柜子';
-            this.$confirm(
-              `物资原本属于 ${originalCabinetName},确定要归还到 ${currentCabinetName} 吗?`,
-              '确认归还',
-              {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
-              }
-            ).then(() => {
-              // **用户确认变更柜子**
-              this.materialsToUpdate.push({
-                materialsId: materialId,
-                loanState: 1,
-                restitutionToId: currentCabinetId,
-                restitutionUserId: 106
-              });
-              material.materialsCabinetId = currentCabinetId; // 更新柜子ID
-              this.bgLayer.draw();
-            }).catch(() => {
-              // **用户取消,还原到原位置**
-              e.target.position({ x: 1200, y: 120 });
-              this.bgLayer.draw();
-            });
+            // **用户确认变更柜子**
+            this.materialsToUpdate.push({
+              materialsId: materialId,
+              loanState: 1,
+              restitutionToId: currentCabinetId,
+              restitutionUserId: 106
+            })
+            material.materialsCabinetId = currentCabinetId // 更新柜子ID
+            this.bgLayer.draw()
           } else {
             // **物资仍在同一个柜子内**
-            console.log('物资仍在同一个柜子内');
+            console.log('物资仍在同一个柜子内')
             // 如果需要,可以在这里添加一些逻辑
           }
         }
       }).catch((error) => {
-        console.error('获取物资信息失败:', error);
+        console.error('获取物资信息失败:', error)
         // 处理错误情况
-      });
+      })
     },
 
-
     // 将物资添加到Konva图层
     addMaterialsToLayer() {
-      if (!this.bgLayer) return;
+      if (!this.bgLayer) return
 
-      const itemWidth = 60;
-      const itemHeight = 60;
-      const spacing = 40;
+      const itemWidth = 60
+      const itemHeight = 60
+      const spacing = 40
 
       // 清除之前的物资元素
-      this.clearMaterialsFromLayer();
+      this.clearMaterialsFromLayer()
 
       // 渲染柜内物资
+      console.log(this.listInCabinet,'物资柜内部数据')
       this.listInCabinet.forEach((material, index) => {
-        const x = 720 + (index % 3) * (itemWidth + spacing);
-        const y = 120 + Math.floor(index / 3) * (itemHeight + spacing);
+        const x = 720 + (index % 3) * (itemWidth + spacing)
+        const y = 120 + Math.floor(index / 3) * (itemHeight + spacing)
 
-        const materialImage = new Image();
-        materialImage.src = material.materialsTypeIcon;
+        const materialImage = new Image()
+        materialImage.src = material.materialsTypeIcon
         materialImage.onload = () => {
           const group = new Konva.Group({
             x: x,
@@ -271,14 +275,14 @@ console.log(material,'物资移动');
             draggable: this.doorOpen, // 初始时根据 doorOpen 状态设置可拖拽
             name: 'material',
             materialId: material.materialsId,
-            material: material,
-          });
+            material: material
+          })
 
           const konvaMaterialImage = new Konva.Image({
             image: materialImage,
             width: itemWidth,
-            height: itemHeight,
-          });
+            height: itemHeight
+          })
 
           const text = new Konva.Text({
             x: 0,
@@ -287,30 +291,30 @@ console.log(material,'物资移动');
             fontSize: 12,
             fill: 'black',
             align: 'center',
-            width: itemWidth,
-          });
+            width: itemWidth
+          })
 
-          group.add(konvaMaterialImage);
-          group.add(text);
+          group.add(konvaMaterialImage)
+          group.add(text)
 
           // 给物资设置初始的柜内状态
-          material.inCabinet = true;  // 设置物资最初处于柜子内
+          material.inCabinet = true  // 设置物资最初处于柜子内
 
-          group.on('dragend', this.handleDragEnd); // 添加dragend事件监听
+          group.on('dragend', this.handleDragEnd) // 添加dragend事件监听
 
-          this.bgLayer.add(group);
-          this.bgLayer.draw();
-          this.materialElements.push(group);
-        };
-      });
+          this.bgLayer.add(group)
+          this.bgLayer.draw()
+          this.materialElements.push(group)
+        }
+      })
 
       // 渲染柜外物资
       this.listOutOfCabinet.forEach((material, index) => {
-        const x = 1200 + (index % 3) * (itemWidth + spacing); // 左侧显示柜外物资
-        const y = 120 + Math.floor(index / 3) * (itemHeight + spacing);
+        const x = 1200 + (index % 3) * (itemWidth + spacing) // 左侧显示柜外物资
+        const y = 120 + Math.floor(index / 3) * (itemHeight + spacing)
 
-        const materialImage = new Image();
-        materialImage.src = material.materialsTypeIcon;
+        const materialImage = new Image()
+        materialImage.src = material.materialsTypeIcon
         materialImage.onload = () => {
           const group = new Konva.Group({
             x: x,
@@ -318,14 +322,14 @@ console.log(material,'物资移动');
             draggable: this.doorOpen, // 初始时设为可拖拽
             name: 'material',
             materialId: material.materialsId,
-            material: material,
-          });
+            material: material
+          })
 
           const konvaMaterialImage = new Konva.Image({
             image: materialImage,
             width: itemWidth,
-            height: itemHeight,
-          });
+            height: itemHeight
+          })
 
           const text = new Konva.Text({
             x: 0,
@@ -334,47 +338,47 @@ console.log(material,'物资移动');
             fontSize: 12,
             fill: 'black',
             align: 'center',
-            width: itemWidth,
-          });
+            width: itemWidth
+          })
 
-          group.add(konvaMaterialImage);
-          group.add(text);
+          group.add(konvaMaterialImage)
+          group.add(text)
 
           // 给物资设置初始的柜外状态
-          material.inCabinet = false;  // 设置物资最初处于柜子外
+          material.inCabinet = false  // 设置物资最初处于柜子外
 
-          group.on('dragend', this.handleDragEnd); // 添加dragend事件监听
+          group.on('dragend', this.handleDragEnd) // 添加dragend事件监听
 
-          this.bgLayer.add(group);
-          this.bgLayer.draw();
-          this.materialElements.push(group);
-        };
-      });
+          this.bgLayer.add(group)
+          this.bgLayer.draw()
+          this.materialElements.push(group)
+        }
+      })
     },
 
 // 监听 doorOpen 状态变化时更新物资的 draggable 状态
     updateDraggableStatus() {
       this.materialElements.forEach(group => {
-        group.draggable(this.doorOpen);  // 动态更新 draggable 状态
-      });
-      this.bgLayer.draw();
+        group.draggable(this.doorOpen)  // 动态更新 draggable 状态
+      })
+      this.bgLayer.draw()
     },
 
-
     // 批量更新物资状态
     updateMaterialsBatch() {
-      if (this.materialsToUpdate.length === 0) return; // 如果没有需要更新的物资,直接返回
+      console.log('我调用了这里 归还')
+      if (this.materialsToUpdate.length === 0) return // 如果没有需要更新的物资,直接返回
       updateIsMaterialById(this.materialsToUpdate).then(response => {
         if (response.data) {
-          this.$message.success('物资更新成功');
-          this.materialsToUpdate = []; // 清空需要更新的物资列表
+          this.$message.success('物资更新成功')
+          this.materialsToUpdate = [] // 清空需要更新的物资列表
         } else {
-          this.$message.error('物资更新失败');
+          this.$message.error('物资更新失败')
         }
-      });
+      })
     }
   }
-};
+}
 </script>
 
 <style scoped lang="scss">

+ 2 - 1
src/views/mes/material/Lending/demo4.vue

@@ -150,7 +150,8 @@ export default {
 
     // 按单个 cabinetId 查询物资数据
     fetchMaterialsByCabinetId(id) {
-      const params = { current: 1, size: -1, materialsCabinetId: id }
+      // 搜索对应检查记录的检查物资柜物资 而且是在物资柜中的数据
+      const params = { current: 1, size: -1, materialsCabinetId: id, loanState:'1'}
       return new Promise((resolve, reject) => {
         listMaterials(params)
           .then(res => {

+ 0 - 311
src/views/mes/material/Lending/index.vue

@@ -1,311 +0,0 @@
-<template>
-  <div class="mapBox">
-    <el-select
-      style="width: 215px;margin: 20px"
-      v-model="queryParams.materialsCabinetId"
-      placeholder="请选择物资柜"
-      @change="handleCabinetChange"
-    >
-      <el-option
-        v-for="dict in cabinets"
-        :key="dict.value"
-        :label="dict.label"
-        :value="dict.value"
-      />
-    </el-select>
-    <div id="container" ref="container" style="width: 100%; height: 90vh; background-color: white;"></div>
-  </div>
-</template>
-
-<script>
-import Konva from "konva";
-import { getIsMaterialsCabinets, listMaterials, updateIsMaterialById } from '@/api/mes/material/information'
-
-export default {
-  name: 'Lending',
-  data() {
-    return {
-      stage: null,
-      layer: null,
-      bgLayer: null,
-      list: [], // 三号柜子的物资
-      listInCabinet: [], // 存储物资柜内的物资
-      listOutOfCabinet: [], // 存储物资柜外的物资
-      cabinets: [], // 物资所属柜
-      queryParams: {
-        current: 1,
-        size: -1,
-        materialsCabinetId: null,
-        loanState:null
-      },
-      materialElements: [], // 存储物资图标对象
-    };
-  },
-  mounted() {
-    this.$nextTick(() => {
-      this.initKonva();
-      this.materialsCabinets()
-    });
-  },
-  methods: {
-    // 获取物资柜信息
-    materialsCabinets() {
-      getIsMaterialsCabinets(this.queryParams).then((response) => {
-        if (response?.data?.records) {
-          this.cabinets = response.data.records.map((item) => ({
-            value: item.cabinetId,
-            label: item.cabinetName
-          }));
-        }
-      });
-    },
-    handleCabinetChange() {
-      // 清空之前渲染的物资元素
-      this.clearMaterialsFromLayer();
-
-      // 获取柜内和柜外物资
-      Promise.all([this.getMaterialsInCabinet(), this.getMaterialsOutOfCabinet()])
-        .then(() => {
-          // 在所有数据获取完成后,统一渲染物资
-          this.addMaterialsToLayer();
-        });
-    },
-
-    getMaterialsInCabinet() {
-      this.queryParams.loanState = '1'; // 设置查询条件为物资柜内
-      return listMaterials(this.queryParams).then((res) => {
-        this.listInCabinet = res.data.records;
-      });
-    },
-
-    getMaterialsOutOfCabinet() {
-      this.queryParams.loanState = '0'; // 设置查询条件为物资柜外
-      const data={
-        current: 1,
-        size: -1,
-        loanState: '0',
-      }
-      return listMaterials(data).then((res) => {
-        this.listOutOfCabinet = res.data.records;
-      });
-    },
-    // 初始化Konva舞台
-    initKonva() {
-      this.stage = new Konva.Stage({
-        container: this.$refs.container,
-        width: 1200,
-        height: 1000,
-      });
-
-      this.bgLayer = new Konva.Layer();
-      const bgImage = new Image();
-      bgImage.src = require('@/assets/images/table.png');
-      bgImage.onload = () => {
-        const konvaImage = new Konva.Image({
-          x: 600,
-          y: 25,
-          image: bgImage,
-          width: 500,
-          height: 700,
-          draggable: false,
-        });
-        this.bgLayer.add(konvaImage);
-        this.bgLayer.draw();
-      };
-      this.stage.add(this.bgLayer);
-    },
-
-    // 清除Konva图层中的所有物资元素
-    clearMaterialsFromLayer() {
-      if (!this.bgLayer) return;
-      const materialNodes = this.bgLayer.find('.material');
-      console.log('清除物资:', materialNodes);
-      materialNodes.forEach(node => node.destroy()); // 清除已渲染的物资元素
-      this.materialElements = []; // 清空已存储的物资图标对象
-      this.bgLayer.draw(); // 重新绘制图层
-    },
-
-    // 将物资添加到Konva图层
-    // 物资拖动结束时的处理
-    handleDragEnd(e) {
-      const materialId = e.target.getAttr('materialId'); // 获取物资ID
-      const position = e.target.getClientRect(); // 获取物资当前的位置信息
-
-      // 获取物资的原始位置状态
-      const material = e.target.getAttr('material'); // 获取物资对象
-      const isInCabinet = material.inCabinet; // 判断物资是否在柜子内(根据你存储的状态)
-
-      // 判断物资是否从柜子外进入柜子内
-      if (position.x < 600 || position.x > 1100 || position.y < 25 || position.y > 725) {
-        // 物资移出柜子
-        if (isInCabinet) {
-          // 物资从柜子内移出
-          this.updateMaterialLoan(materialId, 106);
-          material.inCabinet = false; // 更新物资状态
-        }
-      } else {
-        // 物资进入柜子区域
-        if (!isInCabinet) {
-          // 物资从柜子外进入柜子内
-          this.updateMaterialReturn(materialId, this.queryParams.materialsCabinetId, 106);
-          material.inCabinet = true; // 更新物资状态
-        }
-      }
-    },
-
-    // 将物资添加到Konva图层
-    addMaterialsToLayer() {
-      if (!this.bgLayer) return;
-
-      const itemWidth = 60;
-      const itemHeight = 60;
-      const spacing = 40;
-
-      // 清除之前的物资元素
-      this.clearMaterialsFromLayer();
-
-      // 渲染柜内物资
-      this.listInCabinet.forEach((material, index) => {
-        const x = 720 + (index % 3) * (itemWidth + spacing);
-        const y = 120 + Math.floor(index / 3) * (itemHeight + spacing);
-
-        const materialImage = new Image();
-        materialImage.src = material.materialsTypeIcon;
-        materialImage.onload = () => {
-          const group = new Konva.Group({
-            x: x,
-            y: y,
-            draggable: true,
-            name: 'material',
-            materialId: material.materialsId,
-            material: material,
-          });
-
-          const konvaMaterialImage = new Konva.Image({
-            image: materialImage,
-            width: itemWidth,
-            height: itemHeight,
-          });
-
-          const text = new Konva.Text({
-            x: 0,
-            y: itemHeight + 5,
-            text: material.materialsName,
-            fontSize: 12,
-            fill: 'black',
-            align: 'center',
-            width: itemWidth,
-          });
-
-          group.add(konvaMaterialImage);
-          group.add(text);
-
-          // 给物资设置初始的柜内状态
-          material.inCabinet = true;  // 设置物资最初处于柜子内
-
-          group.on('dragend', this.handleDragEnd); // 添加dragend事件监听
-
-          this.bgLayer.add(group);
-          this.bgLayer.draw();
-          this.materialElements.push(group);
-        };
-      });
-
-      // 渲染柜外物资
-      this.listOutOfCabinet.forEach((material, index) => {
-        const x = 50 + (index % 3) * (itemWidth + spacing); // 左侧显示柜外物资
-        const y = 120 + Math.floor(index / 3) * (itemHeight + spacing);
-
-        const materialImage = new Image();
-        materialImage.src = material.materialsTypeIcon;
-        materialImage.onload = () => {
-          const group = new Konva.Group({
-            x: x,
-            y: y,
-            draggable: true,
-            name: 'material',
-            materialId: material.materialsId,
-            material: material,
-          });
-
-          const konvaMaterialImage = new Konva.Image({
-            image: materialImage,
-            width: itemWidth,
-            height: itemHeight,
-          });
-
-          const text = new Konva.Text({
-            x: 0,
-            y: itemHeight + 5,
-            text: material.materialsName,
-            fontSize: 12,
-            fill: 'black',
-            align: 'center',
-            width: itemWidth,
-          });
-
-          group.add(konvaMaterialImage);
-          group.add(text);
-
-          // 给物资设置初始的柜外状态
-          material.inCabinet = false;  // 设置物资最初处于柜子外
-
-          group.on('dragend', this.handleDragEnd); // 添加dragend事件监听
-
-          this.bgLayer.add(group);
-          this.bgLayer.draw();
-          this.materialElements.push(group);
-        };
-      });
-    },
-
-
-    // 领取物资的方法
-    updateMaterialLoan(materialId, loanUserId) {
-      const params = {
-        materialsId: materialId,
-        loanState: 0,  // 物资状态为 "借出"
-        loanUserId: loanUserId
-      };
-
-      updateIsMaterialById(params).then(response => {
-        if (response.data) {
-          console.log('物资领取成功');
-          this.$message.success('物资领取成功');
-        } else {
-          console.error('物资领取失败');
-          this.$message.error('物资领取失败');
-        }
-      });
-    },
-
-// 归还物资的方法
-    updateMaterialReturn(materialId, restitutionToId, restitutionUserId) {
-      const params = {
-        materialsId: materialId,
-        loanState: 1,  // 物资状态为 "归还"
-        restitutionToId: restitutionToId,
-        restitutionUserId: restitutionUserId
-      };
-
-      updateIsMaterialById(params).then(response => {
-        if (response.data) {
-          console.log('物资归还成功');
-          this.$message.success('物资归还成功');
-        } else {
-          console.error('物资归还失败');
-          this.$message.error('物资归还失败');
-        }
-      });
-    }
-  }
-};
-</script>
-
-<style scoped lang="scss">
-.mapBox {
-  width: 100%;
-  height: 100%;
-  //background-color: pink;
-}
-</style>

+ 6 - 1
src/views/mes/material/inspectionplan/index.vue

@@ -371,7 +371,7 @@
         :total="recordtotal"
         :page.sync="recordCurrent"
         :limit.sync="recordSize"
-        @pagination="PlanDialogDetail"
+        @pagination="handlePagination"
       />
       <div slot="footer" class="dialog-footer">
         <el-button v-no-more-click @click="cancelDetail">关 闭</el-button>
@@ -675,9 +675,14 @@ export default {
       })
     },
     // 签名弹窗内部详情查看
+    handlePagination() {
+      // 确保传递当前选中的 row 参数
+      this.PlanDialogDetail(this.RecordselectedRow);
+    },
     PlanDialogDetail(row){
       this.openRecord=true
       this.RecordselectedRow = row || this.RecordselectedRow;
+      console.log(this.RecordselectedRow,'存储了参数 详情')
       const data = {
         planId: this.RecordselectedRow.planId,
         cabinetId: this.RecordselectedRow.cabinetId,