From 02f95a1596a6cc64df2b6e305672dc9f57cf0d2b Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 22 九月 2025 09:03:56 +0800
Subject: [PATCH] yys  采购价格管理

---
 src/views/procurementManagement/procurementPlan/index.vue         |  231 ++++++++++++++++----------------------
 src/api/procurementManagement/procurementPlan.js                  |  110 ++---------------
 src/views/procurementManagement/advancedPriceManagement/index.vue |    2 
 3 files changed, 113 insertions(+), 230 deletions(-)

diff --git a/src/api/procurementManagement/procurementPlan.js b/src/api/procurementManagement/procurementPlan.js
index 04c58b3..48a1a74 100644
--- a/src/api/procurementManagement/procurementPlan.js
+++ b/src/api/procurementManagement/procurementPlan.js
@@ -1,127 +1,47 @@
 import request from "@/utils/request";
 
 // 鍒嗛〉鏌ヨ閲囪喘璁″垝鍒楄〃
-export function getProcurementPlanList(query) {
+export function listPage(query) {
   return request({
-    url: "/procurement/plan/list",
+    url: "/procurementPlan/listPage",
     method: "get",
     params: query,
   });
 }
 
 // 鏂板閲囪喘璁″垝
-export function addProcurementPlan(data) {
+export function add(data) {
   return request({
-    url: "/procurement/plan/add",
+    url: "/procurementPlan/add",
     method: "post",
-    data: data,
+    data,
   });
 }
 
 // 淇敼閲囪喘璁″垝
-export function updateProcurementPlan(data) {
+export function update(data) {
   return request({
-    url: "/procurement/plan/update",
-    method: "put",
-    data: data,
+    url: "/procurementPlan/update",
+    method: "post",
+    data,
   });
 }
 
 // 鍒犻櫎閲囪喘璁″垝
-export function deleteProcurementPlan(ids) {
+export function del(data) {
   return request({
-    url: "/procurement/plan/delete",
+    url: "/procurementPlan/del",
     method: "delete",
-    data: ids,
+    data,
   });
 }
 
-// 鏍规嵁ID鑾峰彇閲囪喘璁″垝璇︽儏
-export function getProcurementPlanById(id) {
+// 鍒犻櫎閲囪喘璁″垝
+export function listPageCopy(query) {
   return request({
-    url: `/procurement/plan/${id}`,
-    method: "get",
-  });
-}
-
-// 鎵ц閲囪喘璁″垝璁$畻
-export function calculateProcurementPlan(data) {
-  return request({
-    url: "/procurement/plan/calculate",
-    method: "post",
-    data: data,
-  });
-}
-
-
-// 鑾峰彇浜у搧鐜版湁搴撳瓨淇℃伅
-export function getProductExistingStock(productIds) {
-  return request({
-    url: "/inventory/existingStock/productInfo",
-    method: "post",
-    data: productIds,
-  });
-}
-
-// 鑾峰彇浜у搧瀹夊叏搴撳瓨淇℃伅
-export function getProductSafetyStock(productIds) {
-  return request({
-    url: "/inventory/safetyStock/productInfo",
-    method: "post",
-    data: productIds,
-  });
-}
-
-// 鑾峰彇浜у搧棰勮鍑哄簱淇℃伅
-export function getProductExpectedOutbound(productIds) {
-  return request({
-    url: "/inventory/expectedOutbound/productInfo",
-    method: "post",
-    data: productIds,
-  });
-}
-
-// 鑾峰彇浜у搧棰勮鍏ュ簱淇℃伅
-export function getProductExpectedInbound(productIds) {
-  return request({
-    url: "/inventory/expectedInbound/productInfo",
-    method: "post",
-    data: productIds,
-  });
-}
-
-// 瀵煎嚭閲囪喘璁″垝
-export function exportProcurementPlan(query) {
-  return request({
-    url: "/procurement/plan/export",
+    url: "/stockin/listPageCopy",
     method: "get",
     params: query,
-    responseType: "blob",
   });
 }
 
-// 鐢熸垚閲囪喘璁㈠崟
-export function generatePurchaseOrder(data) {
-  return request({
-    url: "/procurement/plan/generateOrder",
-    method: "post",
-    data: data,
-  });
-}
-
-// 楠岃瘉璁$畻鍏紡
-export function validateFormula(formula) {
-  return request({
-    url: "/procurement/plan/validateFormula",
-    method: "post",
-    data: { formula },
-  });
-}
-
-// 鑾峰彇璁$畻鍏紡妯℃澘
-export function getFormulaTemplates() {
-  return request({
-    url: "/procurement/plan/formulaTemplates",
-    method: "get",
-  });
-}
diff --git a/src/views/procurementManagement/advancedPriceManagement/index.vue b/src/views/procurementManagement/advancedPriceManagement/index.vue
index b720149..597b39b 100644
--- a/src/views/procurementManagement/advancedPriceManagement/index.vue
+++ b/src/views/procurementManagement/advancedPriceManagement/index.vue
@@ -361,7 +361,7 @@
 // 鍒嗛〉
 const pagination = reactive({
   current: 1,
-  size: 20
+  size: 10
 })
 
 
diff --git a/src/views/procurementManagement/procurementPlan/index.vue b/src/views/procurementManagement/procurementPlan/index.vue
index fec52ed..14424cc 100644
--- a/src/views/procurementManagement/procurementPlan/index.vue
+++ b/src/views/procurementManagement/procurementPlan/index.vue
@@ -9,7 +9,7 @@
         <el-form-item label="鐘舵��">
           <el-select v-model="searchForm.status" placeholder="璇烽�夋嫨鐘舵��" clearable style="width: 150px">
             <el-option label="鍚敤" value="active" />
-            <el-option label="绂佺敤" value="inactive" />
+            <el-option label="绂佺敤" value="disabled" />
           </el-select>
         </el-form-item>
         <el-form-item>
@@ -63,7 +63,7 @@
             </el-tag>
           </template>
         </el-table-column>
-        <el-table-column prop="lastCalculateTime" label="鏈�鍚庤绠楁椂闂�" width="160" />
+        <el-table-column prop="updateTime" label="鏈�鍚庤绠楁椂闂�" width="160" />
         <el-table-column label="鎿嶄綔" width="200" fixed="right" align="center">
           <template #default="{ row }">
             <el-button type="primary" link @click="handleEdit(row)">缂栬緫</el-button>
@@ -79,7 +79,7 @@
           v-model:current-page="pagination.current"
           v-model:page-size="pagination.size"
           :page-sizes="[10, 20, 50, 100]"
-          :total="pagination.total"
+          :total="total"
           layout="total, sizes, prev, pager, next, jumper"
           @size-change="handleSizeChange"
           @current-change="handleCurrentChange"
@@ -128,11 +128,10 @@
 
             <el-row :gutter="20">
               <el-col :span="12">
-                <el-form-item label="鏁版嵁鐘舵��" prop="dataStatus">
-                  <el-select v-model="formData.dataStatus" placeholder="璇烽�夋嫨鐘舵��" style="width: 100%">
-                    <el-option label="鑽夌" value="draft" />
-                    <el-option label="宸插鏍�" value="approved" />
-                    <el-option label="宸茬鐢�" value="disabled" />
+                <el-form-item label="鐘舵��" prop="status">
+                  <el-select v-model="formData.status" placeholder="璇烽�夋嫨鐘舵��" style="width: 100%">
+                    <el-option label="鍚敤" value="active" />
+                    <el-option label="绂佺敤" value="disabled" />
                   </el-select>
                 </el-form-item>
               </el-col>
@@ -152,7 +151,7 @@
             <el-tab-pane label="闇�姹傚弬鏁�" name="demand">
               <div class="checkbox-group">
                 <el-checkbox v-model="formData.considerExistingStock">鑰冭檻鐜版湁搴撳瓨</el-checkbox>
-                <el-checkbox v-model="formData.warehouseMRPControl">浠撳簱杩愯MRP鐨勬帶鍒�</el-checkbox>
+                <el-checkbox v-model="formData.warehouseControl">浠撳簱杩愯MRP鐨勬帶鍒�</el-checkbox>
                 <el-checkbox v-model="formData.calculateTotalDemand">璁$畻鎬婚渶姹�</el-checkbox>
                 <el-checkbox v-model="formData.considerSafetyStock">鑰冭檻瀹夊叏搴撳瓨</el-checkbox>
                 <el-checkbox v-model="formData.considerLockedStock">鑰冭檻閿佸簱</el-checkbox>
@@ -163,7 +162,7 @@
             <el-tab-pane label="璁$畻鍙傛暟" name="calculation">
               <div class="checkbox-group">
                 <el-checkbox v-model="formData.considerExistingStock">鑰冭檻鐜版湁搴撳瓨</el-checkbox>
-                <el-checkbox v-model="formData.warehouseMRPControl">浠撳簱杩愯MRP鐨勬帶鍒�</el-checkbox>
+                <el-checkbox v-model="formData.warehouseControl">浠撳簱杩愯MRP鐨勬帶鍒�</el-checkbox>
                 <el-checkbox v-model="formData.calculateTotalDemand">璁$畻鎬婚渶姹�</el-checkbox>
                 <el-checkbox v-model="formData.considerSafetyStock">鑰冭檻瀹夊叏搴撳瓨</el-checkbox>
                 <el-checkbox v-model="formData.considerLockedStock">鑰冭檻閿佸簱</el-checkbox>
@@ -240,12 +239,12 @@
           style="width: 100%; margin-top: 20px;"
         >
           <el-table-column type="selection" width="55" />
-          <el-table-column prop="productName" label="浜у搧鍚嶇О" min-width="150" />
-          <el-table-column prop="productCode" label="浜у搧缂栫爜" width="120" />
-          <el-table-column prop="existingStock" label="鐜版湁搴撳瓨" width="100" align="right" />
-          <el-table-column prop="safetyStock" label="瀹夊叏搴撳瓨" width="100" align="right" />
-          <el-table-column prop="expectedOutbound" label="棰勮鍑哄簱" width="100" align="right" />
-          <el-table-column prop="expectedInbound" label="棰勮鍏ュ簱" width="100" align="right" />
+          <el-table-column prop="productCategory" label="浜у搧澶х被" min-width="150" />
+          <el-table-column prop="specificationModel" label="浜у搧瑙勬牸" width="120" />
+          <el-table-column prop="inboundNum0" label="鐜版湁搴撳瓨" width="100" align="right" />
+          <el-table-column prop="inboundNum" label="瀹夊叏搴撳瓨" width="100" align="right" />
+          <el-table-column prop="inboundNum" label="棰勮鍑哄簱" width="100" align="right" />
+          <el-table-column prop="inboundNum0" label="棰勮鍏ュ簱" width="100" align="right" />
         </el-table>
       </div>
 
@@ -279,12 +278,12 @@
         </el-alert>
 
         <el-table :data="calculateResult" stripe border style="width: 100%; margin-top: 20px;">
-          <el-table-column prop="productName" label="浜у搧鍚嶇О" min-width="150" />
-          <el-table-column prop="productCode" label="浜у搧缂栫爜" width="120" />
-          <el-table-column prop="existingStock" label="鐜版湁搴撳瓨" width="100" align="right" />
-          <el-table-column prop="safetyStock" label="瀹夊叏搴撳瓨" width="100" align="right" />
-          <el-table-column prop="expectedOutbound" label="棰勮鍑哄簱鏁伴噺" width="120" align="right" />
-          <el-table-column prop="expectedInbound" label="棰勮鍏ュ簱鏁伴噺" width="120" align="right" />
+          <el-table-column prop="productCategory" label="浜у搧澶х被" min-width="150" />
+          <el-table-column prop="specificationModel" label="浜у搧瑙勬牸" width="120" />
+          <el-table-column prop="inboundNum0" label="鐜版湁搴撳瓨" width="100" align="right" />
+          <el-table-column prop="inboundNum" label="瀹夊叏搴撳瓨" width="100" align="right" />
+          <el-table-column prop="inboundNum" label="棰勮鍑哄簱鏁伴噺" width="120" align="right" />
+          <el-table-column prop="inboundNum0" label="棰勮鍏ュ簱鏁伴噺" width="120" align="right" />
           <el-table-column prop="weeklyNetDemand" label="鎸夊懆鍑�闇�姹�" width="120" align="right">
             <template #default="{ row }">
               <el-tag :type="row.weeklyNetDemand > 0 ? 'warning' : 'success'" size="small">
@@ -305,7 +304,7 @@
       <template #footer>
         <div class="dialog-footer">
           <el-button @click="calculateDialogVisible = false">鍏抽棴</el-button>
-          <el-button type="primary" @click="handleCreatePurchaseOrder">鐢熸垚閲囪喘璁㈠崟</el-button>
+          <el-button type="primary" @click="handleCreatePurchaseOrder">纭</el-button>
         </div>
       </template>
     </el-dialog>
@@ -313,9 +312,10 @@
 </template>
 
 <script setup>
-import { ref, reactive, onMounted } from 'vue'
+import {ref, reactive, onMounted, getCurrentInstance} from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { Search, Refresh, Plus, Download } from '@element-plus/icons-vue'
+import {listPage,add,update,del,listPageCopy} from "@/api/procurementManagement/procurementPlan.js"
 
 // 鍝嶅簲寮忔暟鎹�
 const loading = ref(false)
@@ -337,8 +337,7 @@
 // 鍒嗛〉鏁版嵁
 const pagination = reactive({
   current: 1,
-  size: 20,
-  total: 0
+  size: 20
 })
 
 // 琛ㄥ崟鏁版嵁
@@ -346,12 +345,12 @@
   code: '',
   planName: '',
   description: '',
-  dataStatus: '',
+  status: '',
   isSystemPreset: false,
   formula: '',
   // 璁$畻鍙傛暟
   considerExistingStock: false,
-  warehouseMRPControl: false,
+  warehouseControl: false,
   calculateTotalDemand: false,
   considerSafetyStock: false,
   considerLockedStock: false,
@@ -371,8 +370,8 @@
   planName: [
     { required: true, message: '璇疯緭鍏ヨ鍒掑悕绉�', trigger: 'blur' }
   ],
-  dataStatus: [
-    { required: true, message: '璇烽�夋嫨鏁版嵁鐘舵��', trigger: 'change' }
+  status: [
+    { required: true, message: '璇烽�夋嫨鐘舵��', trigger: 'change' }
   ],
   formula: [
     { required: true, message: '璇疯緭鍏ヨ绠楀叕寮�', trigger: 'blur' }
@@ -380,56 +379,10 @@
 }
 
 // 琛ㄦ牸鏁版嵁
-const tableData = ref([
-  {
-    id: 1,
-    planName: '甯歌浜у搧閲囪喘璁″垝',
-    description: '鍩轰簬鍘嗗彶閿�鍞暟鎹殑甯歌浜у搧閲囪喘璁″垝',
-    formula: '棰勮鍑哄簱鏁伴噺 - 鐜版湁搴撳瓨 + 瀹夊叏搴撳瓨 - 棰勮鍏ュ簱鏁伴噺',
-    status: 'active',
-    lastCalculateTime: '2024-12-01 10:30:00',
-    remark: '閫傜敤浜庡父瑙勪骇鍝�'
-  },
-  {
-    id: 2,
-    planName: '瀛h妭鎬т骇鍝侀噰璐鍒�',
-    description: '鑰冭檻瀛h妭鍥犵礌鐨勫鑺傛�т骇鍝侀噰璐鍒�',
-    formula: '棰勮鍑哄簱鏁伴噺 - 鐜版湁搴撳瓨 + 瀹夊叏搴撳瓨 * 1.2 - 棰勮鍏ュ簱鏁伴噺',
-    status: 'active',
-    lastCalculateTime: '2024-11-28 15:20:00',
-    remark: '閫傜敤浜庡鑺傛�т骇鍝�'
-  }
-])
+const tableData = ref([])
 
 // 浜у搧鍒楄〃鏁版嵁
 const productList = ref([
-  {
-    id: 1,
-    productName: '浜у搧A',
-    productCode: 'PA001',
-    existingStock: 100,
-    safetyStock: 50,
-    expectedOutbound: 200,
-    expectedInbound: 30
-  },
-  {
-    id: 2,
-    productName: '浜у搧B',
-    productCode: 'PB002',
-    existingStock: 80,
-    safetyStock: 30,
-    expectedOutbound: 150,
-    expectedInbound: 20
-  },
-  {
-    id: 3,
-    productName: '浜у搧C',
-    productCode: 'PC003',
-    existingStock: 120,
-    safetyStock: 60,
-    expectedOutbound: 180,
-    expectedInbound: 25
-  },
   {
     id: 4,
     productName: '浜у搧D',
@@ -462,7 +415,7 @@
     suggestedPurchase: 120
   }
 ])
-
+const total = ref(0)
 // 鏂规硶
 const handleSearch = () => {
   pagination.current = 1
@@ -479,11 +432,13 @@
 
 const loadData = () => {
   loading.value = true
-  // 妯℃嫙API璋冪敤
-  setTimeout(() => {
-    pagination.total = tableData.value.length
-    loading.value = false
-  }, 500)
+  listPage({...searchForm,...pagination}).then(res => {
+    if(res.code === 200){
+      tableData.value = res.data.records
+      total.value = res.data.total
+      loading.value = false
+    }
+  })
 }
 
 const handleAdd = () => {
@@ -507,13 +462,13 @@
       cancelButtonText: '鍙栨秷',
       type: 'warning'
     })
-    
-    const index = tableData.value.findIndex(item => item.id === row.id)
-    if (index > -1) {
-      tableData.value.splice(index, 1)
+    let ids = [row.id]
+    del(ids).then(res =>{
+     if(res.code === 200){
       ElMessage.success('鍒犻櫎鎴愬姛')
       loadData()
     }
+   })
   } catch {
     // 鐢ㄦ埛鍙栨秷鍒犻櫎
   }
@@ -530,25 +485,25 @@
     submitLoading.value = true
 
     if (dialogType.value === 'add') {
-      // 鏂板
-      const newItem = {
-        ...formData,
-        id: Date.now(),
-        lastCalculateTime: '-'
-      }
-      tableData.value.unshift(newItem)
-      ElMessage.success('鏂板鎴愬姛')
+      add(formData).then(res => {
+        if(res.code === 200){
+          ElMessage.success('鏂板鎴愬姛')
+          dialogVisible.value = false
+          loadData()
+        }
+      })
     } else {
       // 缂栬緫
-      const index = tableData.value.findIndex(item => item.id === formData.id)
-      if (index > -1) {
-        tableData.value[index] = { ...formData }
-        ElMessage.success('缂栬緫鎴愬姛')
-      }
+      update(formData).then(res => {
+        if(res.code === 200){
+          ElMessage.success('缂栬緫鎴愬姛')
+          dialogVisible.value = false
+          loadData()
+        }
+      })
     }
 
-    dialogVisible.value = false
-    loadData()
+
   } catch (error) {
     ElMessage.error('鎿嶄綔澶辫触')
   } finally {
@@ -561,12 +516,12 @@
     code: '',
     planName: '',
     description: '',
-    dataStatus: '',
+    status: '',
     isSystemPreset: false,
-    formula: '',
+    formula: '棰勮鍑哄簱鏁伴噺 - 鐜版湁搴撳瓨 + 瀹夊叏搴撳瓨 - 棰勮鍏ュ簱鏁伴噺',
     // 璁$畻鍙傛暟
     considerExistingStock: false,
-    warehouseMRPControl: false,
+    warehouseControl: false,
     calculateTotalDemand: false,
     considerSafetyStock: false,
     considerLockedStock: false,
@@ -597,9 +552,12 @@
 const loadProductList = () => {
   productLoading.value = true
   // 妯℃嫙鍔犺浇浜у搧鏁版嵁
-  setTimeout(() => {
-    productLoading.value = false
-  }, 500)
+  listPageCopy({size:-1}).then(res => {
+    if(res.code === 200){
+      productList.value = res.data.records
+      productLoading.value = false
+    }
+  })
 }
 
 const handleProductSelectionChange = (selection) => {
@@ -621,39 +579,44 @@
 
 const calculateWithSelectedProducts = () => {
   // 妯℃嫙璁$畻杩囩▼
-  setTimeout(() => {
-    // 鏍规嵁閫夋嫨鐨勪骇鍝佹洿鏂拌绠楃粨鏋�
-    const result = selectedProducts.value.map(product => {
-      // 杩欓噷搴旇鏍规嵁瀹為檯鐨勮绠楀叕寮忚繘琛岃绠�
-      // 绀轰緥锛氶璁″嚭搴撴暟閲� - 鐜版湁搴撳瓨 + 瀹夊叏搴撳瓨 - 棰勮鍏ュ簱鏁伴噺
-      const weeklyNetDemand = product.expectedOutbound - product.existingStock + product.safetyStock - product.expectedInbound
-      const suggestedPurchase = Math.max(0, weeklyNetDemand)
-      
-      return {
-        productName: product.productName,
-        productCode: product.productCode,
-        existingStock: product.existingStock,
-        safetyStock: product.safetyStock,
-        expectedOutbound: product.expectedOutbound,
-        expectedInbound: product.expectedInbound,
-        weeklyNetDemand: weeklyNetDemand,
-        suggestedPurchase: suggestedPurchase
-      }
-    })
-    
-    calculateResult.value = result
-    calculateDialogVisible.value = true
-  }, 1000)
+  // 鏍规嵁閫夋嫨鐨勪骇鍝佹洿鏂拌绠楃粨鏋�
+  const result = selectedProducts.value.map(product => {
+    // 杩欓噷搴旇鏍规嵁瀹為檯鐨勮绠楀叕寮忚繘琛岃绠�
+    // 绀轰緥锛氶璁″嚭搴撴暟閲� - 鐜版湁搴撳瓨 + 瀹夊叏搴撳瓨 - 棰勮鍏ュ簱鏁伴噺
+    const weeklyNetDemand = product.inboundNum - product.inboundNum0 + product.inboundNum - product.inboundNum0
+    const suggestedPurchase = Math.max(0, weeklyNetDemand)
+
+    return {
+      productCategory: product.productCategory,
+      specificationModel: product.specificationModel,
+      inboundNum0: product.inboundNum0,
+      inboundNum: product.inboundNum,
+      weeklyNetDemand: weeklyNetDemand,
+      suggestedPurchase: suggestedPurchase
+    }
+  })
+
+  calculateResult.value = result
+  calculateDialogVisible.value = true
 }
 
 
 const handleCreatePurchaseOrder = () => {
-  ElMessage.success('姝e湪鐢熸垚閲囪喘璁㈠崟...')
   calculateDialogVisible.value = false
 }
-
+const { proxy } = getCurrentInstance();
 const handleExport = () => {
-  ElMessage.success('姝e湪瀵煎嚭鏁版嵁...')
+  ElMessageBox.confirm("鍐呭灏嗚瀵煎嚭锛屾槸鍚︾‘璁ゅ鍑猴紵", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  })
+      .then(() => {
+        proxy.download("/procurementPlan/export", {}, "閲囪喘璁″垝.xlsx");
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
 }
 
 

--
Gitblit v1.9.3