From c49a9d727dd7620c3a9cb67c512b29bab842b1eb Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 04 十一月 2025 10:41:17 +0800
Subject: [PATCH] 仓储物流-查询条件加一个日期

---
 src/views/inventoryManagement/stockManagement/index.vue |  107 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 81 insertions(+), 26 deletions(-)

diff --git a/src/views/inventoryManagement/stockManagement/index.vue b/src/views/inventoryManagement/stockManagement/index.vue
index 59dd74c..3cb8221 100644
--- a/src/views/inventoryManagement/stockManagement/index.vue
+++ b/src/views/inventoryManagement/stockManagement/index.vue
@@ -5,6 +5,16 @@
         <span class="search_title">渚涘簲鍟嗗悕绉帮細</span>
         <el-input v-model="searchForm.supplierName" style="width: 240px" placeholder="璇疯緭鍏�" @change="handleQuery"
           clearable prefix-icon="Search" />
+				<span class="search_title ml10">鍏ュ簱鏃ユ湡锛�</span>
+				<el-date-picker
+					v-model="searchForm.timeStr"
+					type="date"
+					placeholder="璇烽�夋嫨鏃ユ湡"
+					value-format="YYYY-MM-DD"
+					format="YYYY-MM-DD"
+					clearable
+					@change="handleQuery"
+				/>
         <el-button type="primary" @click="handleQuery" style="margin-left: 10px">鎼滅储</el-button>
       </div>
       <div>
@@ -19,13 +29,13 @@
         :summary-method="summarizeMainTable" height="calc(100vh - 18.5em)">
         <el-table-column align="center" type="selection" width="55" />
         <el-table-column align="center" label="搴忓彿" type="index" width="60" />
-        <el-table-column label="搴撳瓨鏃ユ湡" prop="createTime" width="100" show-overflow-tooltip />
         <el-table-column label="鍏ュ簱鏃ユ湡" prop="createTime" width="100" show-overflow-tooltip />
         <el-table-column label="渚涘簲鍟嗗悕绉�" prop="supplierName" width="240" show-overflow-tooltip />
         <el-table-column label="浜у搧澶х被" prop="productCategory" width="100" show-overflow-tooltip />
         <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" width="200" show-overflow-tooltip />
         <el-table-column label="鍗曚綅" prop="unit" width="80" show-overflow-tooltip />
         <el-table-column label="搴撳瓨鏁伴噺" prop="inboundNum0" width="100" show-overflow-tooltip />
+        <el-table-column label="鏈�浣庡簱瀛樻暟閲�" prop="minStock" width="130" show-overflow-tooltip />
         <el-table-column label="鍚◣鍗曚环" prop="taxInclusiveUnitPrice" width="100" show-overflow-tooltip />
         <el-table-column label="鍚◣鎬讳环" prop="taxInclusiveTotalPrice" width="100" show-overflow-tooltip />
         <el-table-column label="绋庣巼(%)" prop="taxRate" width="100" show-overflow-tooltip />
@@ -153,9 +163,11 @@
   exportStockManage
 } from "@/api/inventoryManagement/stockManage.js";
 import {
-  updateManagement,
-  
+  updateManagement,addSutockIn,selectProductRecordListByPuechaserId,updateStockIn
 } from "@/api/inventoryManagement/stockIn.js";
+
+
+
 const userStore = useUserStore()
 const { proxy } = getCurrentInstance()
 const tableData = ref([])
@@ -172,13 +184,14 @@
 })
 const total = ref(0)
 const fileList = ref([])
-
+const loading = ref(false);
 // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
 const operationType = ref('')
 const dialogFormVisible = ref(false)
 const data = reactive({
   searchForm: {
     supplierName: '',
+		timeStr: '',
   },
   form: {
     supplierId: null,
@@ -200,6 +213,7 @@
     stockQuantity: '',
     boundTime: '',
     minStock: '', // 鏂板鏈�浣庡簱瀛樺瓧娈�
+    salesLedgerProductId: null,
   },
   rules: {
     supplierName: [{ required: true, message: '璇疯緭鍏ヤ緵搴斿晢鍚嶇О', trigger: 'blur' }],
@@ -235,11 +249,13 @@
   getStockManagePage({ ...searchForm.value, ...page }).then(res => {
     tableLoading.value = false
     tableData.value = res.data.records
-    console.log('res', res)
+    // console.log('res', res)
     // tableData.value.map(item => {
     //   item.children = []
     // })
     total.value = res.data.total
+    // 鏁版嵁鍔犺浇瀹屾垚鍚庢鏌ュ簱瀛�
+    checkStockAndCreatePurchase();
   }).catch(() => {
     tableLoading.value = false
   })
@@ -301,35 +317,67 @@
   console.log(form.value)
   proxy.$refs["formRef"].validate(valid => {
     if (valid) {
-      // if (productData.value.length > 0) {
-      //   form.value.productData = proxy.HaveJson(productData.value)
-      // } else {
-      //   proxy.$modal.msgWarning('璇锋坊鍔犱骇鍝佷俊鎭�')
-      //   return
-      // }
-      // let tempFileIds = []
-      // if (fileList.value.length > 0) {
-      //   tempFileIds = fileList.value.map(item => item.tempId)
-      // }
-      // form.value.tempFileIds = tempFileIds
-      // form.value.type = 1
+
       updateManagement(form.value).then(res => {
         proxy.$modal.msgSuccess("鎻愪氦鎴愬姛")
         closeDia()
         getList()
         // 鎻愪氦鍚庢鏌ュ簱瀛樺苟灏濊瘯鍒涘缓璇疯喘鍗�
-        checkStockAndAutoCreatePurchase();
+        checkStockAndCreatePurchase();
       })
     }
   })
 }
-// 妫�鏌ュ簱瀛樺苟鑷姩鍒涘缓璇疯喘鍗�
-const checkStockAndAutoCreatePurchase = async () => {
-  try {
-    await checkStockAndCreatePurchase();
-  } catch (error) {
-    console.error('鑷姩琛ヨ揣澶辫触:', error);
-    proxy.$modal.msgError('鑷姩琛ヨ揣澶辫触锛岃鎵嬪姩澶勭悊');
+// const handList = () => {
+//   selectProductRecordListByPuechaserId().then(res => {
+//     productModelList.value = res.data.filter(item => item.productName === value)
+//     console.log('productModelList.value', productModelList.value)
+//   })
+// } 
+// 妫�鏌ュ簱瀛樺苟鍒涘缓璇疯喘鍗�
+const checkStockAndCreatePurchase = async () => {
+  const stockList = tableData.value;
+  // handList()
+  for (const item of stockList) {
+    if (item.inboundNum0 < item.minStock) {
+      try {
+        console.log('item', item)
+          // const stockInData = {
+          //   nickName: userStore.nickName,// 浣跨敤鏂版牸寮忓寲鍑芥暟
+          //   details: [{
+          //     id: item.salesLedgerProductId,
+          //     inboundQuantity: item.minStock - item.inboundNum0
+          //   }]
+          // };
+          const stockInData = {
+            id: item.id,
+            quantityStock: item.minStock + item.totalInboundNum,// 浣跨敤鏂版牸寮忓寲鍑芥暟
+          };
+          
+
+        console.log('鍑嗗鎻愪氦鐨勬暟鎹�:', JSON.parse(JSON.stringify(stockInData)));
+
+          loading.value = true
+          // await addSutockIn(stockInData)
+          await updateStockIn(stockInData)
+          proxy.$modal.msgSuccess(`浜у搧 ${item.productCategory} 淇敼鍏ュ簱鎴愬姛`)
+          loading.value = false
+        // // 鐢熸垚璇疯喘鍗�
+        // const createRes = await createPurchaseRequest({
+        //   productId: item.productId,
+        //   requiredQuantity: item.minStock - item.inboundNum0,
+        //   supplierId: item.supplierId
+        // });
+        // if (createRes.code === 200) {
+        //   // 娴佽浆璇疯喘鍗曞埌閲囪喘妯″潡
+        //   await transferPurchaseRequest({ requestId: createRes.data.id });
+        //   proxy.$modal.msgSuccess(`浜у搧 ${item.productName} 璇疯喘鍗曞凡鐢熸垚骞舵祦杞琡);
+        // }
+      } catch (error) {
+        proxy.$modal.msgError(`浜у搧 ${item.productCategory} 鐢熸垚璇疯喘鍗曞け璐ワ紝璇锋墜鍔ㄥ鐞哷);
+
+      }
+    }
   }
 };
 // 鍏抽棴寮规
@@ -394,7 +442,14 @@
 }
 onMounted(() => {
   getList()
-  checkStockAndAutoCreatePurchase();
+  checkStockAndCreatePurchase();
+    // 姣忓皬鏃舵鏌ヤ竴娆″簱瀛�
+    const intervalId = setInterval(checkStockAndCreatePurchase, 60 * 60 * 1000); 
+
+onUnmounted(() => {
+  // 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
+  clearInterval(intervalId); 
+});
 })
 </script>
 

--
Gitblit v1.9.3