From 3f15d0eef89e52f3fd6d1be13ff3af010b6f0ee9 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 05 十一月 2025 15:27:44 +0800
Subject: [PATCH] 录入日期改为可选择

---
 src/views/inventoryManagement/stockManagement/index.vue |  168 ++++++++++++++++++++++++-------------------------------
 1 files changed, 74 insertions(+), 94 deletions(-)

diff --git a/src/views/inventoryManagement/stockManagement/index.vue b/src/views/inventoryManagement/stockManagement/index.vue
index 84dc029..0954a8d 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>
@@ -16,17 +26,17 @@
     <div class="table_list">
       <el-table :data="tableData" border v-loading="tableLoading" @selection-change="handleSelectionChange"
         :expand-row-keys="expandedRowKeys" :row-key="row => row.id" show-summary style="width: 100%"
+        :row-class-name="tableRowClassName"
         :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="warnNum" 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 />
@@ -52,7 +62,7 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="浜у搧澶х被锛�" prop="productId">
-              <el-select disabled v-model="form.productCategory" placeholder="璇烽�夋嫨" clearable filterable @change="handleProductChange">
+              <el-select disabled v-model="form.productCategory" placeholder="璇烽�夋嫨" clearable filterable>
                 <el-option v-for="item in productList" :key="item.id" :label="item.productName"
                            :value="item.productName" />
               </el-select>
@@ -62,8 +72,7 @@
         <el-row :gutter="30">
           <el-col :span="12">
             <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productManageId">
-              <el-select disabled v-model="form.specificationModel" placeholder="璇峰厛閫夋嫨浜у搧澶х被" clearable filterable :disabled="!form.productCategory"
-                         @change="handleModelChange">
+              <el-select disabled v-model="form.specificationModel" placeholder="璇峰厛閫夋嫨浜у搧澶х被" clearable filterable :disabled="!form.productCategory">
                 <el-option v-for="item in productModelList" :key="item.id" :label="item.model"
                            :value="item.id" />
               </el-select>
@@ -123,11 +132,11 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <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 :span="12">-->
+<!--          <el-form-item label="搴撳瓨棰勮鏁伴噺锛�" prop="warnNum">-->
+<!--            <el-input v-model="form.warnNum" placeholder="璇疯緭鍏ユ渶浣庡簱瀛�" clearable />-->
+<!--          </el-form-item>-->
+<!--        </el-col>-->
         </el-row>
       </el-form>
       <template #footer>
@@ -142,19 +151,17 @@
 
 <script setup>
 import pagination from '@/components/PIMTable/Pagination.vue'
-import { ref } from 'vue'
+import { ref, reactive, toRefs, onMounted, getCurrentInstance } from 'vue'
 import { ElMessageBox } from "element-plus";
 import useUserStore from '@/store/modules/user'
 import { userListNoPageByTenantId } from "@/api/system/user.js";
 import { productTreeList,modelList } from "@/api/basicData/product.js"
 import {
-  getStockManagePage ,
-  updateStockManage,
+  getStockManagePage,
   delStockManage,
-  exportStockManage
 } from "@/api/inventoryManagement/stockManage.js";
 import {
-  updateManagement,addSutockIn,selectProductRecordListByPuechaserId,updateStockIn
+  updateManagement,updateStockIn
 } from "@/api/inventoryManagement/stockIn.js";
 
 
@@ -182,6 +189,7 @@
 const data = reactive({
   searchForm: {
     supplierName: '',
+		timeStr: '',
   },
   form: {
     supplierId: null,
@@ -202,7 +210,7 @@
     inboundBatch: '',
     stockQuantity: '',
     boundTime: '',
-    minStock: '', // 鏂板鏈�浣庡簱瀛樺瓧娈�
+		warnNum: '', // 鏂板鏈�浣庡簱瀛樺瓧娈�
     salesLedgerProductId: null,
   },
   rules: {
@@ -218,7 +226,7 @@
     boundTime: [{ required: true, message: '璇烽�夋嫨搴撳瓨鏃堕棿', trigger: 'change' }],
     inboundTime: [{ required: true, message: '璇烽�夋嫨鍏ュ簱鏃堕棿', trigger: 'change' }],
     inboundPerson: [{ required: true, message: '璇烽�夋嫨鍑哄簱浜�', trigger: 'change' }],
-    minStock: [{ required: true, message: '璇疯緭鍏ユ渶浣庡簱瀛�', trigger: 'blur' }], 
+		warnNum: [{ required: true, message: '璇疯緭鍏ユ渶浣庡簱瀛�', trigger: 'blur' }], 
   }
 })
 const { searchForm, form, rules } = toRefs(data)
@@ -239,13 +247,9 @@
   getStockManagePage({ ...searchForm.value, ...page }).then(res => {
     tableLoading.value = false
     tableData.value = res.data.records
-    // console.log('res', res)
-    // tableData.value.map(item => {
-    //   item.children = []
-    // })
     total.value = res.data.total
     // 鏁版嵁鍔犺浇瀹屾垚鍚庢鏌ュ簱瀛�
-    checkStockAndCreatePurchase();
+    // checkStockAndCreatePurchase();
   }).catch(() => {
     tableLoading.value = false
   })
@@ -265,6 +269,16 @@
   return proxy.summarizeTable(param, ['contractAmount', 'taxInclusiveTotalPrice', 'taxExclusiveTotalPrice']);
 };
 
+// 琛ㄦ牸琛岀被鍚�
+const tableRowClassName = ({ row }) => {
+  const stock = Number(row?.inboundNum0 ?? 0);
+  const warn = Number(row?.warnNum ?? 0);
+  if (!Number.isFinite(stock) || !Number.isFinite(warn)) {
+    return '';
+  }
+  return stock < warn ? 'row-low-stock' : '';
+};
+
 // 鎵撳紑寮规
 const openForm = async (type, row) => {
   operationType.value = type
@@ -272,11 +286,6 @@
   productData.value = []
   let userLists = await userListNoPageByTenantId()
   userList.value = userLists.data
-  // customerList().then(res => {
-  //   customerOption.value = res
-  // })
-  // console.log('userStore.id', userStore.id)
-  // form.value.entryPerson = userStore.id
   if (type === 'edit') {
     form.value = { ...row }
     productTreeList().then(res =>{
@@ -289,14 +298,6 @@
         }
       })
     })
-
-
-    // getSalesLedgerWithProducts({ id: row.id, type: 1 }).then(res => {
-
-    //   form.value.entryPerson = Number(res.entryPerson)
-    //   productData.value = form.value.productData
-    //   fileList.value = form.value.salesLedgerFiles
-    // })
   }
   form.value.entryDate = getCurrentDate() // 璁剧疆榛樿褰曞叆鏃ユ湡涓哄綋鍓嶆棩鏈�
   dialogFormVisible.value = true
@@ -313,63 +314,33 @@
         closeDia()
         getList()
         // 鎻愪氦鍚庢鏌ュ簱瀛樺苟灏濊瘯鍒涘缓璇疯喘鍗�
-        checkStockAndCreatePurchase();
+        // checkStockAndCreatePurchase();
       })
     }
   })
 }
-// 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} 鐢熸垚璇疯喘鍗曞け璐ワ紝璇锋墜鍔ㄥ鐞哷);
-
-      }
-    }
-  }
-};
+// const checkStockAndCreatePurchase = async () => {
+//   const stockList = tableData.value;
+//   // handList()
+//   for (const item of stockList) {
+//     if (item.inboundNum0 < item.warnNum) {
+//       try {
+// 				const stockInData = {
+// 					id: item.id,
+// 					quantityStock: item.warnNum + item.totalInboundNum,// 浣跨敤鏂版牸寮忓寲鍑芥暟
+// 				};
+// 				loading.value = true
+// 				await updateStockIn(stockInData)
+// 				proxy.$modal.msgSuccess(`浜у搧 ${item.productCategory} 淇敼鍏ュ簱鎴愬姛`)
+// 				loading.value = false
+//       } catch (error) {
+//         proxy.$modal.msgError(`浜у搧 ${item.productCategory} 鐢熸垚璇疯喘鍗曞け璐ワ紝璇锋墜鍔ㄥ鐞哷);
+//
+//       }
+//     }
+//   }
+// };
 // 鍏抽棴寮规
 const closeDia = () => {
   proxy.resetForm("formRef")
@@ -432,15 +403,24 @@
 }
 onMounted(() => {
   getList()
-  checkStockAndCreatePurchase();
+  // checkStockAndCreatePurchase();
     // 姣忓皬鏃舵鏌ヤ竴娆″簱瀛�
-    const intervalId = setInterval(checkStockAndCreatePurchase, 60 * 60 * 1000); 
+    // const intervalId = setInterval(checkStockAndCreatePurchase, 60 * 60 * 1000);
 
-onUnmounted(() => {
-  // 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
-  clearInterval(intervalId); 
-});
+// onUnmounted(() => {
+//   // 缁勪欢鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
+//   clearInterval(intervalId);
+// });
 })
 </script>
 
-<style scoped lang="scss"></style>
+<style scoped lang="scss">
+:deep(.row-low-stock td) {
+  background-color: #fde2e2;
+  color: #c45656;
+}
+
+:deep(.row-low-stock:hover > td) {
+  background-color: #fcd4d4;
+}
+</style>

--
Gitblit v1.9.3