From 997535cc8926f00fb0e2b6ccf082c84fabdcb4c7 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 18 九月 2025 13:39:18 +0800
Subject: [PATCH] yys  采购价格管理

---
 src/api/procurementManagement/advancedPriceManagement.js          |  284 +------------------------------
 src/views/procurementManagement/advancedPriceManagement/index.vue |  242 ++++++++------------------
 2 files changed, 86 insertions(+), 440 deletions(-)

diff --git a/src/api/procurementManagement/advancedPriceManagement.js b/src/api/procurementManagement/advancedPriceManagement.js
index c1dd47c..a30921c 100644
--- a/src/api/procurementManagement/advancedPriceManagement.js
+++ b/src/api/procurementManagement/advancedPriceManagement.js
@@ -2,301 +2,37 @@
 import request from "@/utils/request";
 
 // 鍒嗛〉鏌ヨ浠锋牸鍒楄〃
-export function getPriceList(query) {
+export function listPage(query) {
   return request({
-    url: "/procurement/price/list",
+    url: "/procurementPriceManagement/listPage",
     method: "get",
     params: query,
   });
 }
 
-// 鑾峰彇浠锋牸璇︽儏
-export function getPriceDetail(id) {
-  return request({
-    url: `/procurement/price/detail/${id}`,
-    method: "get",
-  });
-}
-
 // 鏂板浠锋牸
-export function addPrice(data) {
+export function add(data) {
   return request({
-    url: "/procurement/price/add",
+    url: "/procurementPriceManagement/add",
     method: "post",
     data: data,
   });
 }
 
 // 鏇存柊浠锋牸
-export function updatePrice(data) {
+export function update(data) {
   return request({
-    url: "/procurement/price/update",
-    method: "put",
+    url: "/procurementPriceManagement/update",
+    method: "post",
     data: data,
   });
 }
 
 // 鍒犻櫎浠锋牸
-export function deletePrice(id) {
+export function del(data) {
   return request({
-    url: `/procurement/price/delete/${id}`,
+    url: `/procurementPriceManagement/del`,
     method: "delete",
-  });
-}
-
-// 鎵归噺鍒犻櫎浠锋牸
-export function batchDeletePrice(ids) {
-  return request({
-    url: "/procurement/price/batchDelete",
-    method: "delete",
-    data: { ids },
-  });
-}
-
-// 澶嶅埗浠锋牸
-export function copyPrice(id) {
-  return request({
-    url: `/procurement/price/copy/${id}`,
-    method: "post",
-  });
-}
-
-// 搴旂敤浠锋牸锛堝皢寰呯敓鏁堢姸鎬佹敼涓烘湁鏁堬級
-export function applyPrice(id) {
-  return request({
-    url: `/procurement/price/apply/${id}`,
-    method: "put",
-  });
-}
-
-// 鏆傚仠浠锋牸
-export function suspendPrice(id) {
-  return request({
-    url: `/procurement/price/suspend/${id}`,
-    method: "put",
-  });
-}
-
-// 鎵归噺璁剧疆鎶樻墸
-export function batchSetDiscount(data) {
-  return request({
-    url: "/procurement/price/batchDiscount",
-    method: "post",
-    data: data,
-  });
-}
-
-// 鑾峰彇鎶樻墸閰嶇疆
-export function getDiscountConfig(id) {
-  return request({
-    url: `/procurement/price/discount/${id}`,
-    method: "get",
-  });
-}
-
-// 璁剧疆鍗曚釜鍟嗗搧鎶樻墸
-export function setDiscount(data) {
-  return request({
-    url: "/procurement/price/setDiscount",
-    method: "post",
-    data: data,
-  });
-}
-
-// 鑾峰彇闃舵鎶樻墸閰嶇疆
-export function getTieredDiscount(id) {
-  return request({
-    url: `/procurement/price/tieredDiscount/${id}`,
-    method: "get",
-  });
-}
-
-// 璁剧疆闃舵鎶樻墸
-export function setTieredDiscount(data) {
-  return request({
-    url: "/procurement/price/setTieredDiscount",
-    method: "post",
-    data: data,
-  });
-}
-
-// 鑾峰彇浠锋牸鎺у埗璁剧疆
-export function getPriceControlConfig() {
-  return request({
-    url: "/procurement/price/controlConfig",
-    method: "get",
-  });
-}
-
-// 鏇存柊浠锋牸鎺у埗璁剧疆
-export function updatePriceControlConfig(data) {
-  return request({
-    url: "/procurement/price/controlConfig",
-    method: "put",
-    data: data,
-  });
-}
-
-// 鑾峰彇浠锋牸棰勮鍒楄〃
-export function getPriceWarnings(query) {
-  return request({
-    url: "/procurement/price/warnings",
-    method: "get",
-    params: query,
-  });
-}
-
-// 澶勭悊浠锋牸棰勮
-export function handlePriceWarning(id, action) {
-  return request({
-    url: `/procurement/price/warning/${id}`,
-    method: "put",
-    data: { action },
-  });
-}
-
-// 鑾峰彇浠锋牸鍘嗗彶璁板綍
-export function getPriceHistory(id, query) {
-  return request({
-    url: `/procurement/price/history/${id}`,
-    method: "get",
-    params: query,
-  });
-}
-
-// 鑾峰彇浠锋牸缁熻鏁版嵁
-export function getPriceStatistics(query) {
-  return request({
-    url: "/procurement/price/statistics",
-    method: "get",
-    params: query,
-  });
-}
-
-// 瀵煎嚭浠锋牸鏁版嵁
-export function exportPriceData(query) {
-  return request({
-    url: "/procurement/price/export",
-    method: "get",
-    params: query,
-    responseType: 'blob',
-  });
-}
-
-// 瀵煎叆浠锋牸鏁版嵁
-export function importPriceData(file) {
-  const formData = new FormData();
-  formData.append('file', file);
-  return request({
-    url: "/procurement/price/import",
-    method: "post",
-    data: formData,
-    headers: {
-      'Content-Type': 'multipart/form-data',
-    },
-  });
-}
-
-// 鑾峰彇浠锋牸妯℃澘
-export function downloadPriceTemplate() {
-  return request({
-    url: "/procurement/price/template",
-    method: "get",
-    responseType: 'blob',
-  });
-}
-
-// 浠锋牸瀹℃壒
-export function approvePrice(id, data) {
-  return request({
-    url: `/procurement/price/approve/${id}`,
-    method: "put",
-    data: data,
-  });
-}
-
-// 浠锋牸椹冲洖
-export function rejectPrice(id, data) {
-  return request({
-    url: `/procurement/price/reject/${id}`,
-    method: "put",
-    data: data,
-  });
-}
-
-// 鑾峰彇渚涘簲鍟嗗垪琛紙鐢ㄤ簬涓嬫媺閫夋嫨锛�
-export function getSupplierOptions() {
-  return request({
-    url: "/procurement/price/suppliers",
-    method: "get",
-  });
-}
-
-// 鑾峰彇鍟嗗搧鍒楄〃锛堢敤浜庝笅鎷夐�夋嫨锛�
-export function getProductOptions(query) {
-  return request({
-    url: "/procurement/price/products",
-    method: "get",
-    params: query,
-  });
-}
-
-// 鑾峰彇鍟嗗搧璇︾粏淇℃伅
-export function getProductInfo(productId) {
-  return request({
-    url: `/procurement/price/productInfo/${productId}`,
-    method: "get",
-  });
-}
-
-// 浠锋牸姣旇緝鍒嗘瀽
-export function comparePrices(data) {
-  return request({
-    url: "/procurement/price/compare",
-    method: "post",
-    data: data,
-  });
-}
-
-// 鑾峰彇浠锋牸瓒嬪娍鏁版嵁
-export function getPriceTrend(id, period) {
-  return request({
-    url: `/procurement/price/trend/${id}`,
-    method: "get",
-    params: { period },
-  });
-}
-
-// 浠锋牸棰勬祴
-export function predictPrice(id, data) {
-  return request({
-    url: `/procurement/price/predict/${id}`,
-    method: "post",
-    data: data,
-  });
-}
-
-// 鑾峰彇甯傚満浠锋牸鍙傝��
-export function getMarketPriceReference(productCode) {
-  return request({
-    url: `/procurement/price/marketRef/${productCode}`,
-    method: "get",
-  });
-}
-
-// 浠锋牸鍙樺姩閫氱煡璁剧疆
-export function updateNotificationSettings(data) {
-  return request({
-    url: "/procurement/price/notifications",
-    method: "put",
-    data: data,
-  });
-}
-
-// 鑾峰彇浠锋牸鍙樺姩閫氱煡璁剧疆
-export function getNotificationSettings() {
-  return request({
-    url: "/procurement/price/notifications",
-    method: "get",
+    data
   });
 }
diff --git a/src/views/procurementManagement/advancedPriceManagement/index.vue b/src/views/procurementManagement/advancedPriceManagement/index.vue
index 89fbc4b..b720149 100644
--- a/src/views/procurementManagement/advancedPriceManagement/index.vue
+++ b/src/views/procurementManagement/advancedPriceManagement/index.vue
@@ -11,14 +11,6 @@
             <el-option v-for="supplier in supplierList" :key="supplier.id" :label="supplier.name" :value="supplier.id" />
           </el-select>
         </el-form-item>
-        <el-form-item label="浠锋牸鐘舵�侊細">
-          <el-select v-model="searchForm.priceStatus" placeholder="璇烽�夋嫨鐘舵��" clearable style="width: 150px">
-            <el-option label="鏈夋晥" value="active" />
-            <el-option label="寰呯敓鏁�" value="pending" />
-            <el-option label="宸茶繃鏈�" value="expired" />
-            <el-option label="宸叉殏鍋�" value="suspended" />
-          </el-select>
-        </el-form-item>
         <el-form-item>
           <el-button type="primary" @click="handleSearch" :loading="loading">
             <el-icon><Search /></el-icon>
@@ -42,10 +34,6 @@
         <el-button type="success" @click="openBatchDiscountDialog">
           <el-icon><Discount /></el-icon>
           鎵归噺鎶樻墸
-        </el-button>
-        <el-button type="warning" @click="openPriceControlDialog">
-          <el-icon><Setting /></el-icon>
-          浠锋牸鎺у埗
         </el-button>
         <el-button type="info" @click="exportData">
           <el-icon><Download /></el-icon>
@@ -81,7 +69,7 @@
         <el-table-column label="渚涘簲鍟�" prop="supplierName" width="150" />
         <el-table-column label="鍩虹浠锋牸" width="120" align="right">
           <template #default="{ row }">
-            <span class="price-text">楼{{ row.basePrice.toFixed(2) }}</span>
+            <span class="price-text">楼{{ row.basePrice }}</span>
           </template>
         </el-table-column>
         <el-table-column label="鎶樻墸淇℃伅" width="150">
@@ -97,17 +85,17 @@
         </el-table-column>
         <el-table-column label="瀹為檯浠锋牸" width="120" align="right">
           <template #default="{ row }">
-            <span class="final-price">楼{{ calculateFinalPrice(row).toFixed(2) }}</span>
+            <span class="final-price">楼{{ calculateFinalPrice(row) }}</span>
           </template>
         </el-table-column>
         <el-table-column label="浠锋牸鎺у埗" width="120">
           <template #default="{ row }">
             <div class="price-control">
-              <div v-if="row.priceControl?.minPrice" class="control-item">
-                鏈�浣�: 楼{{ row.priceControl.minPrice.toFixed(2) }}
+              <div v-if="row.minPrice" class="control-item">
+                鏈�浣�: 楼{{ row.minPrice }}
               </div>
-              <div v-if="row.priceControl?.maxPrice" class="control-item">
-                鏈�楂�: 楼{{ row.priceControl.maxPrice.toFixed(2) }}
+              <div v-if="row.maxPrice" class="control-item">
+                鏈�楂�: 楼{{ row.maxPrice }}
               </div>
             </div>
           </template>
@@ -128,10 +116,6 @@
               <el-icon><Edit /></el-icon>
               缂栬緫
             </el-button>
-            <el-button type="success" link @click="openDiscountDialog(row)">
-              <el-icon><Discount /></el-icon>
-              鎶樻墸
-            </el-button>
             <el-button type="danger" link @click="handleDelete(row)">
               <el-icon><Delete /></el-icon>
               鍒犻櫎
@@ -143,10 +127,10 @@
       <!-- 鍒嗛〉 -->
       <div class="pagination-wrapper">
         <el-pagination
-          v-model:current-page="pagination.currentPage"
-          v-model:page-size="pagination.pageSize"
+          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"
@@ -207,7 +191,6 @@
                 <el-option label="鏃犳姌鎵�" value="" />
                 <el-option label="鐧惧垎姣旀姌鎵�" value="percentage" />
                 <el-option label="鍥哄畾閲戦" value="fixed" />
-                <el-option label="闃舵鎶樻墸" value="tiered" />
               </el-select>
             </el-form-item>
           </el-col>
@@ -234,35 +217,6 @@
             </el-form-item>
           </el-col>
         </el-row>
-
-        <!-- 闃舵鎶樻墸璁剧疆 -->
-        <div v-if="formData.discountType === 'tiered'">
-          <el-form-item label="闃舵鎶樻墸">
-            <el-table :data="formData.tieredDiscount" border size="small">
-              <el-table-column label="鏈�灏忔暟閲�" width="120">
-                <template #default="{ row, $index }">
-                  <el-input-number v-model="row.minQty" :min="0" size="small" />
-                </template>
-              </el-table-column>
-              <el-table-column label="鏈�澶ф暟閲�" width="120">
-                <template #default="{ row, $index }">
-                  <el-input-number v-model="row.maxQty" :min="0" size="small" />
-                </template>
-              </el-table-column>
-              <el-table-column label="鎶樻墸鐜�(%)" width="120">
-                <template #default="{ row, $index }">
-                  <el-input-number v-model="row.discount" :min="0" :max="100" :precision="2" size="small" />
-                </template>
-              </el-table-column>
-              <el-table-column label="鎿嶄綔" width="80">
-                <template #default="{ row, $index }">
-                  <el-button type="danger" link @click="removeTieredRow($index)">鍒犻櫎</el-button>
-                </template>
-              </el-table-column>
-            </el-table>
-            <el-button type="primary" link @click="addTieredRow" class="mt-2">娣诲姞闃舵</el-button>
-          </el-form-item>
-        </div>
 
         <!-- 浠锋牸鎺у埗 -->
         <el-divider content-position="left">浠锋牸鎺у埗</el-divider>
@@ -378,12 +332,13 @@
 </template>
 
 <script setup>
-import { ref, reactive, computed, onMounted } from 'vue'
+import {ref, reactive, computed, onMounted, getCurrentInstance} from 'vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import {
   Search, Refresh, Plus, Discount, Setting, Download, Delete, Edit, 
   Warning
 } from '@element-plus/icons-vue'
+import { listPage, update, del, add } from '@/api/procurementManagement/advancedPriceManagement'
 
 // 鍝嶅簲寮忔暟鎹�
 const loading = ref(false)
@@ -398,15 +353,15 @@
 // 鎼滅储琛ㄥ崟
 const searchForm = reactive({
   productName: '',
-  supplierId: '',
-  priceStatus: ''
+  supplierId: ''
 })
+
+const total = ref(0)
 
 // 鍒嗛〉
 const pagination = reactive({
-  currentPage: 1,
-  pageSize: 20,
-  total: 0
+  current: 1,
+  size: 20
 })
 
 
@@ -430,6 +385,8 @@
   reason: '',
   remark: ''
 })
+
+const tableData = ref([])
 
 // 鎵归噺鎶樻墸琛ㄥ崟
 const batchDiscountForm = reactive({
@@ -456,44 +413,6 @@
   reason: [{ required: true, message: '璇烽�夋嫨璋冧环鍘熷洜', trigger: 'change' }]
 }
 
-// 妯℃嫙鏁版嵁
-const tableData = ref([
-  {
-    id: 1,
-    productName: '楂樺己搴﹁灪鏍�',
-    productCode: 'HQ001',
-    specification: 'M12脳80',
-    supplierName: '浼樿川浜旈噾渚涘簲鍟�',
-    basePrice: 2.50,
-    discountType: 'percentage',
-    discountValue: 10,
-    priceControl: { minPrice: 2.00, maxPrice: 3.00 },
-    status: 'active',
-    effectiveTime: '2025-01-01 00:00:00',
-    updateTime: '2025-09-17 10:30:00',
-    unit: '涓�',
-    reason: 'market',
-    remark: '甯傚満浠锋牸璋冩暣'
-  },
-  {
-    id: 2,
-    productName: '涓嶉攬閽㈢',
-    productCode: 'BXG002',
-    specification: '桅25脳2.0',
-    supplierName: '閽㈡潗璐告槗鍏徃',
-    basePrice: 45.80,
-    discountType: 'fixed',
-    discountValue: 5,
-    priceControl: { minPrice: 40.00, maxPrice: 50.00 },
-    status: 'pending',
-    effectiveTime: '2025-10-01 00:00:00',
-    updateTime: '2025-09-16 14:20:00',
-    unit: '绫�',
-    reason: 'cost',
-    remark: '鍘熸潗鏂欐垚鏈笂娑�'
-  }
-])
-
 const supplierList = ref([
   { id: 1, name: '浼樿川浜旈噾渚涘簲鍟�' },
   { id: 2, name: '閽㈡潗璐告槗鍏徃' },
@@ -506,17 +425,6 @@
   { id: 3, name: '閾濆悎閲戝瀷鏉�' }
 ])
 
-
-// 璁$畻灞炴��
-const finalTableData = computed(() => {
-  return tableData.value.filter(item => {
-    if (searchForm.productName && !item.productName.includes(searchForm.productName)) return false
-    if (searchForm.supplierId && item.supplierId !== searchForm.supplierId) return false
-    if (searchForm.priceStatus && item.status !== searchForm.priceStatus) return false
-    
-    return true
-  })
-})
 
 // 鏂规硶
 const calculateFinalPrice = (row) => {
@@ -541,8 +449,7 @@
 const getDiscountText = (discountType) => {
   const textMap = {
     percentage: '鐧惧垎姣�',
-    fixed: '鍥哄畾閲戦',
-    tiered: '闃舵鎶樻墸'
+    fixed: '鍥哄畾閲戦'
   }
   return textMap[discountType] || '鏈煡'
 }
@@ -551,8 +458,7 @@
   const statusMap = {
     active: 'success',
     pending: 'warning',
-    expired: 'info',
-    suspended: 'danger'
+    expired: 'info'
   }
   return statusMap[status] || 'info'
 }
@@ -561,8 +467,7 @@
   const statusMap = {
     active: '鏈夋晥',
     pending: '寰呯敓鏁�',
-    expired: '宸茶繃鏈�',
-    suspended: '宸叉殏鍋�'
+    expired: '宸茶繃鏈�'
   }
   return statusMap[status] || '鏈煡'
 }
@@ -577,16 +482,17 @@
 const handleSearch = () => {
   loading.value = true
   // 妯℃嫙API璋冪敤
-  setTimeout(() => {
+  listPage({ ...searchForm, ...pagination}).then(res => {
+    tableData.value = res.data.records
+    total.value = res.data.total
     loading.value = false
-  }, 500)
+  })
 }
 
 const resetSearch = () => {
   Object.assign(searchForm, {
     productName: '',
-    supplierId: '',
-    priceStatus: ''
+    supplierId: ''
   })
   handleSearch()
 }
@@ -647,32 +553,28 @@
   try {
     await formRef.value.validate()
     submitLoading.value = true
-    
-    // 妯℃嫙API璋冪敤
-    setTimeout(() => {
-      if (dialogType.value === 'add') {
-        const newItem = {
-          id: Date.now(),
-          ...formData,
-          priceControl: {
-            minPrice: formData.minPrice,
-            maxPrice: formData.maxPrice
-          },
-          status: 'pending',
-          updateTime: new Date().toLocaleString()
+
+    if (dialogType.value === 'add') {
+      add(formData).then(res => {
+        if (res.code === 200){
+          ElMessage.success('鏂板鎴愬姛')
+          handleSearch()
         }
-        tableData.value.unshift(newItem)
-        ElMessage.success('鏂板鎴愬姛')
-      } else {
-        // 缂栬緫閫昏緫
-        ElMessage.success('缂栬緫鎴愬姛')
-      }
-      
-      dialogVisible.value = false
-      submitLoading.value = false
-    }, 1000)
+      })
+    } else {
+      update(formData).then(res => {
+        if (res.code === 200){
+          ElMessage.success('缂栬緫鎴愬姛')
+          handleSearch()
+        }
+      })
+    }
+
   } catch (error) {
     console.error('琛ㄥ崟楠岃瘉澶辫触:', error)
+  }finally {
+    dialogVisible.value = false
+    submitLoading.value = false
   }
 }
 
@@ -689,10 +591,13 @@
   selectedRows.value.forEach(row => {
     row.discountType = batchDiscountForm.discountType
     row.discountValue = batchDiscountForm.discountValue
+    update(row).then(res => {
+      handleSearch()
+    })
   })
-  
-  ElMessage.success(`宸蹭负 ${selectedRows.value.length} 涓晢鍝佽缃姌鎵)
+  ElMessage.success('鎶樻墸璁剧疆鎴愬姛')
   batchDiscountVisible.value = false
+
 }
 
 const openPriceControlDialog = () => {
@@ -704,23 +609,19 @@
   priceControlVisible.value = false
 }
 
-const openDiscountDialog = (row) => {
-  // 鍗曚釜鍟嗗搧鎶樻墸璁剧疆
-  openDialog('edit', row)
-}
-
-
 const handleDelete = (row) => {
   ElMessageBox.confirm('纭畾瑕佸垹闄よ繖鏉¤褰曞悧锛�', '鎻愮ず', {
     confirmButtonText: '纭畾',
     cancelButtonText: '鍙栨秷',
     type: 'warning'
   }).then(() => {
-    const index = tableData.value.findIndex(item => item.id === row.id)
-    if (index !== -1) {
-      tableData.value.splice(index, 1)
-      ElMessage.success('鍒犻櫎鎴愬姛')
-    }
+   let ids = [row.id]
+    del(ids).then(res => {
+      if(res.code === 200){
+        ElMessage.success('鍒犻櫎鎴愬姛')
+        handleSearch()
+      }
+    })
   })
 }
 
@@ -735,14 +636,12 @@
     cancelButtonText: '鍙栨秷',
     type: 'warning'
   }).then(() => {
-    selectedRows.value.forEach(row => {
-      const index = tableData.value.findIndex(item => item.id === row.id)
-      if (index !== -1) {
-        tableData.value.splice(index, 1)
+     del(selectedRows.value.map(item => item.id)).then(i =>{
+       if(i.code === 200){
+        ElMessage.success('鍒犻櫎鎴愬姛')
+        handleSearch()
       }
-    })
-    ElMessage.success('鎵归噺鍒犻櫎鎴愬姛')
-    selectedRows.value = []
+     })
   })
 }
 
@@ -751,17 +650,28 @@
 }
 
 const handleSizeChange = (size) => {
-  pagination.pageSize = size
+  pagination.size = size
   handleSearch()
 }
 
 const handleCurrentChange = (page) => {
-  pagination.currentPage = page
+  pagination.current = page
   handleSearch()
 }
+const { proxy } = getCurrentInstance();
 
 const exportData = () => {
-  ElMessage.success('鏁版嵁瀵煎嚭鍔熻兘寮�鍙戜腑...')
+  ElMessageBox.confirm("鍐呭灏嗚瀵煎嚭锛屾槸鍚︾‘璁ゅ鍑猴紵", "瀵煎嚭", {
+    confirmButtonText: "纭",
+    cancelButtonText: "鍙栨秷",
+    type: "warning",
+  })
+      .then(() => {
+        proxy.download("/procurementPriceManagement/export", {}, "閲囪喘浠锋牸绠$悊.xlsx");
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
 }
 
 // 鐢熷懡鍛ㄦ湡

--
Gitblit v1.9.3