From d4534c231f7c25ca64d40c8bcaadf83f64b640c3 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: 星期五, 12 十二月 2025 11:05:43 +0800
Subject: [PATCH] 修改新增

---
 src/views/work/qualityInfo/inventoryRecord/components/editDialog.vue |   49 +++++++++++++++++++++++--------------------------
 1 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/src/views/work/qualityInfo/inventoryRecord/components/editDialog.vue b/src/views/work/qualityInfo/inventoryRecord/components/editDialog.vue
index 5ab3fe4..cc212cb 100644
--- a/src/views/work/qualityInfo/inventoryRecord/components/editDialog.vue
+++ b/src/views/work/qualityInfo/inventoryRecord/components/editDialog.vue
@@ -9,7 +9,7 @@
         :close-on-click-modal="false"
     >
       <el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" >
-        <el-form-item v-if="state.isAdmin" label="企业:" prop="companyId">
+        <el-form-item v-if="state.isAdmin" label="单位:" prop="companyId">
           <el-select v-model="state.form.companyId" placeholder="请选择" :disabled="state.title =='查看'" clearable @change="getDeptList">
             <el-option
                 v-for="item in state.companyList"
@@ -44,7 +44,7 @@
         <el-form-item label="库存数量:">
           <el-input v-model.trim="state.originInventory" readonly placeholder="库存数量"></el-input>
         </el-form-item>
-        <el-form-item label="材料清单:" prop="warehousingRecordDetails">
+        <el-form-item label="出入库:" prop="warehousingRecordDetails">
           <el-button
               type="primary"
               plain
@@ -163,6 +163,7 @@
 import {listUser} from "@/api/system/user";
 import {getWarehousingRecordDetail, updateWarehousingRecord} from "@/api/outsourcingCooperate/outsourcingCooperate";
 import {getMaterialList} from "@/api/outsourcingCooperate/outsourcingCooperate";
+import {getEmployeeRecords} from "@/api/onlineEducation/user";
 import useUserStore from "@/store/modules/user";
 const emit = defineEmits(["getList"]);
 const dialogVisible = ref(false)
@@ -170,7 +171,7 @@
 const dialogRef = ref();
 const checkList = (rule, value, callback) => {
   if (state.form.warehousingRecordDetails.length == 0) {
-    callback(new Error('材料清单不可为空'))
+    callback(new Error('出入库不可为空'))
   } else {
     callback()
   }
@@ -208,7 +209,7 @@
   if(isAdmin){
     state.companyList = companyList
   }
-  await getUserList()
+  await getUserList(companyId)
   await getMaterials(companyId)
   state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看'
   state.form.companyId = companyId
@@ -223,7 +224,7 @@
 }
 
 const calculateInventoryExcludingCurrent = (currentRow) => {
-  if(!state.form.materialId) return 0
+  // if(!state.form.materialId) return 0
   let inventory = state.materialList.find(i=>i.id == state.form.materialId)?.inventory || 0;
   if(Array.isArray(state.form.warehousingRecordDetails) && state.form.warehousingRecordDetails.length>0){
     for(let i of state.form.warehousingRecordDetails){
@@ -240,7 +241,7 @@
 }
 
 const calculateInventory = () => {
-  if(state.form.materialId){
+  // if(state.form.materialId){
     let inventory = state.materialList.find(i=>i.id == state.form.materialId)?.inventory || 0
     if(Array.isArray(state.form.warehousingRecordDetails) && state.form.warehousingRecordDetails.length>0){
       for(let i of state.form.warehousingRecordDetails){
@@ -256,9 +257,9 @@
     if(inventory < 0){
       ElMessage.warning('库存不足,无法出库')
     }
-  }else{
-    state.originInventory = 0
-  }
+  // }else{
+  //   state.originInventory = 0
+  // }
 }
 
 const checkRemain = (scope) => {
@@ -290,13 +291,14 @@
 }
 
 const getInventory = ()=>{
-  state.form.warehousingRecordDetails = state.form.warehousingRecordDetails.map(i=>{
-    return {
-      ...i,
-      specification: state.materialList.find(i=>i.id == state.form.materialId)?.specification,
-      materialUnit: state.materialList.find(i=>i.id == state.form.materialId)?.materialUnit
-    }
-  })
+  state.form.warehousingRecordDetails = []
+  // state.form.warehousingRecordDetails = state.form.warehousingRecordDetails.map(i=>{
+  //   return {
+  //     ...i,
+  //     specification: state.materialList.find(i=>i.id == state.form.materialId)?.specification,
+  //     materialUnit: state.materialList.find(i=>i.id == state.form.materialId)?.materialUnit
+  //   }
+  // })
   calculateInventory()
 }
 
@@ -383,19 +385,13 @@
 const getDeptList = async ()=>{
   state.form.materialId = null
   await getMaterials(state.form.companyId)
+  await getUserList(state.form.companyId)
 }
 
-const getUserList = async ()=> {
-  const res = await listUser({pageIndex: 1,pageSize: 999})
+const getUserList = async (companyId)=> {
+  const res = await getEmployeeRecords({companyId: companyId})
   if(res.code == 200){
-    state.userList = res.data.list?res.data.list.map(item=>{
-      const user = item.id
-      const {id, ...data} = item
-      return {
-        ...data,
-        userId: user
-      }
-    }):[]
+    state.userList = res.data ? res.data :[]
   }else{
     ElMessage.warning(res.message)
   }
@@ -411,6 +407,7 @@
     warehousingRecordDetails: [],
     delDetails: []
   }
+  state.originInventory = 0
   superRef.value.clearValidate();
   superRef.value.resetFields()
   dialogVisible.value = false;

--
Gitblit v1.9.2