From f80d798b83fabb038cf10d745acd34c9c42fed4c Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期一, 22 九月 2025 15:22:36 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/ywx' into dev
---
src/views/inventoryManagement/stockManagement/index.vue | 89 +++++++++++++++++++++++++++++++-------------
1 files changed, 63 insertions(+), 26 deletions(-)
diff --git a/src/views/inventoryManagement/stockManagement/index.vue b/src/views/inventoryManagement/stockManagement/index.vue
index 59dd74c..f2687bf 100644
--- a/src/views/inventoryManagement/stockManagement/index.vue
+++ b/src/views/inventoryManagement/stockManagement/index.vue
@@ -122,11 +122,11 @@
</el-select>
</el-form-item>
</el-col>
- <el-col :span="12">
+ <!-- <el-col :span="12">
<el-form-item label="鏈�浣庡簱瀛橈細" prop="minStock">
<el-input v-model="form.minStock" placeholder="璇疯緭鍏ユ渶浣庡簱瀛�" clearable />
</el-form-item>
- </el-col>
+ </el-col> -->
</el-row>
</el-form>
<template #footer>
@@ -153,9 +153,11 @@
exportStockManage
} from "@/api/inventoryManagement/stockManage.js";
import {
- updateManagement,
-
+ updateManagement,addSutockIn,selectProductRecordListByPuechaserId
} from "@/api/inventoryManagement/stockIn.js";
+
+
+
const userStore = useUserStore()
const { proxy } = getCurrentInstance()
const tableData = ref([])
@@ -235,11 +237,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 +305,61 @@
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 {
+ const stockInData = {
+ nickName: userStore.nickName,// 浣跨敤鏂版牸寮忓寲鍑芥暟
+ details: selectedRows.value.map(product => ({
+ id: product.id,
+ inboundQuantity: Number(product.quantityStock)
+ })),
+ };
+ console.log('鍑嗗鎻愪氦鐨勬暟鎹�:', JSON.parse(JSON.stringify(stockInData)));
+ // 璋冪敤API
+ loading.value = true
+ await addSutockIn(stockInData)
+
+ proxy.$modal.msgSuccess('鏂板鍏ュ簱鎴愬姛')
+ 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) {
+ console.error(`浜у搧 ${item.productName} 鐢熸垚璇疯喘鍗曞け璐�:`, error);
+ proxy.$modal.msgError(`浜у搧 ${item.productName} 鐢熸垚璇疯喘鍗曞け璐ワ紝璇锋墜鍔ㄥ鐞哷);
+
+ }
+ }
}
};
// 鍏抽棴寮规
@@ -394,7 +424,14 @@
}
onMounted(() => {
getList()
- checkStockAndAutoCreatePurchase();
+ checkStockAndCreatePurchase();
+ // 姣忓皬鏃舵鏌ヤ竴娆″簱瀛�
+ const intervalId = setInterval(checkStockAndCreatePurchase, 60 * 60 * 1000);
+
+onUnmounted(() => {
+ // 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
+ clearInterval(intervalId);
+});
})
</script>
--
Gitblit v1.9.3