From 0453b4d1e92d7a4779ad70857891b17ced6abe2e Mon Sep 17 00:00:00 2001
From: ZN <zhang_12370@163.com>
Date: 星期六, 28 三月 2026 15:45:08 +0800
Subject: [PATCH] 同步华玺砂浆 同步

---
 src/views/procurementManagement/procurementLedger/index.vue |  266 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 263 insertions(+), 3 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 101e630..abe5ed9 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -225,6 +225,7 @@
                 v-model="form.supplierId"
                 placeholder="璇烽�夋嫨"
                 clearable
+                @change="handleSupplierChange"
               >
                 <el-option
                   v-for="item in supplierList"
@@ -485,6 +486,11 @@
 							</el-select>
 						</el-form-item>
 					</el-col>
+          <el-col :span="24">
+            <el-form-item label=" ">
+              <el-button type="warning" :disabled="!(productForm.productId && productForm.productModelId && productForm.taxRate)" @click="showPriceReference" icon="Search">鏌ョ湅鍘嗗彶閲囪喘浠锋牸鍙傝��</el-button>
+            </el-form-item>
+          </el-col>
         </el-row>
         <el-row :gutter="30">
           <el-col :span="12">
@@ -695,6 +701,83 @@
       </template>
     </el-dialog>
 
+    <!-- 鍘嗗彶閲囪喘浠锋牸鍙傝�冨脊绐� -->
+    <el-dialog
+      v-model="priceReferenceVisible"
+      :title="`鍘嗗彶閲囪喘浠锋牸鍙傝�� ${productForm.supplierName}-${productForm.productName}-${productForm.productModel}`"
+      width="1000px"
+      append-to-body
+    >
+      <el-table 
+        :data="priceReferenceData" 
+        border 
+        v-loading="priceReferenceLoading" 
+        :default-sort="{ prop: 'updateTime', order: 'descending' }"
+      >
+        <!-- <el-table-column label="鍟嗗搧淇℃伅" min-width="200">
+          <template #default="{ row }">
+            <div class="product-info">
+              <div class="product-name">{{ row.productName }}</div>
+              <div class="product-spec">{{ row.specification }}</div>
+              <div class="product-code">缂栫爜: {{ row.productCode }}</div>
+            </div>
+          </template>
+        </el-table-column> -->
+        <!-- <el-table-column label="渚涘簲鍟�" prop="supplierName" width="200" /> -->
+        <el-table-column label="鍩虹浠锋牸(涓嶅惈绋�)" width="150" align="right">
+          <template #default="{ row }">
+            <span class="price-text">楼{{ row.basePrice }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="瀹為檯浠锋牸(涓嶅惈绋�)" prop="actuallyPrice" width="150" align="right"/>
+        <el-table-column label="鎶樻墸淇℃伅" width="120" align="center">
+          <template #default="{ row }">
+            <div v-if="row.discountType">
+              <el-tag :type="getDiscountTagType(row.discountType)" size="small">
+                {{ getDiscountText(row.discountType) }}
+              </el-tag>
+              <div class="discount-value">{{ row.discountValue }}{{ row.discountType === 'percentage' ? '%' : '鍏�' }}</div>
+            </div>
+            <span v-else class="no-discount">鏃犳姌鎵�</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="鐘舵��" width="100" align="center">
+          <template #default="{ row }">
+            <el-tag :type="getStatusType(row.status)">{{ getStatusText(row.status) }}</el-tag>
+            <!-- <div v-if="isPriceWarning(row)" class="warning-indicator">
+              <el-icon color="#F56C6C"><Warning /></el-icon>
+            </div> -->
+          </template>
+        </el-table-column>
+        <el-table-column label="鐢熸晥鏃堕棿" prop="effectiveTime" width="100" align="center" />
+        <el-table-column label="鏇存柊鏃堕棿" prop="updateTime" width="160" sortable align="center" />
+        <el-table-column label="澶囨敞" width="200" prop="remark" align="center" show-overflow-tooltip />
+        <el-table-column label="鎿嶄綔" width="100" align="center" fixed="right">
+          <template #default="{ row }">
+            <el-button type="success" link @click="selectPriceReference(row)">
+              <el-icon><Check /></el-icon>
+              寮曠敤
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <div class="pagination-container" style="margin-top: 20px; display: flex; justify-content: flex-end;">
+        <el-pagination
+          v-model:current-page="priceReferencePagination.current"
+          v-model:page-size="priceReferencePagination.size"
+          :page-sizes="[10, 20, 50]"
+          :total="priceReferenceTotal"
+          layout="total, sizes, prev, pager, next"
+          @size-change="handlePriceReferenceSizeChange"
+          @current-change="handlePriceReferenceCurrentChange"
+        />
+      </div>
+      <template #footer>
+        <el-button @click="priceReferenceVisible = false">鍏抽棴</el-button>
+      </template>
+    </el-dialog>
+
     <!-- 鎵爜鐧昏瀵硅瘽妗� -->
     <el-dialog
       v-model="scanDialogVisible"
@@ -793,7 +876,7 @@
 import { getToken } from "@/utils/auth";
 import pagination from "@/components/PIMTable/Pagination.vue";
 import { ref, onMounted, reactive, toRefs, getCurrentInstance, nextTick } from "vue";
-import { Search } from "@element-plus/icons-vue";
+import { Search, Check } from "@element-plus/icons-vue";
 import { ElMessageBox } from "element-plus";
 import { userListNoPage } from "@/api/system/user.js";
 import {
@@ -834,6 +917,7 @@
 const fileList = ref([]);
 import useUserStore from "@/store/modules/user";
 import { modelList, productTreeList } from "@/api/basicData/product.js";
+import { listPage as listAdvancedPrice } from "@/api/procurementManagement/advancedPriceManagement.js";
 import dayjs from "dayjs";
 
 const userStore = useUserStore();
@@ -899,6 +983,9 @@
     taxExclusiveTotalPrice: "",
     invoiceType: "",
 		warnNum: "",
+    supplierName: "",
+    productName: "",
+    productModel: "",
   },
   productRules: {
     productId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
@@ -920,6 +1007,139 @@
   },
 });
 const { productForm, productRules } = toRefs(productFormData);
+
+// 閲囪喘浠锋牸绠$悊鍙傝�冨脊绐�
+const priceReferenceVisible = ref(false);
+const priceReferenceLoading = ref(false);
+const priceReferenceData = ref([]);
+const priceReferenceTotal = ref(0);
+const priceReferencePagination = reactive({
+  current: 1,
+  size: 10
+});
+
+const calculateFinalPrice = (row) => {
+  let finalPrice = row.basePrice;
+  if (row.discountType === "percentage") {
+    finalPrice = row.basePrice * (1 - row.discountValue / 100);
+  } else if (row.discountType === "fixed") {
+    finalPrice = row.basePrice - row.discountValue;
+  }
+  let man = Math.max(finalPrice, 0);
+  return man.toFixed(2);
+};
+
+const getDiscountTagType = (discountType) => {
+  const typeMap = {
+    percentage: "success",
+    fixed: "warning",
+    tiered: "info",
+  };
+  return typeMap[discountType] || "info";
+};
+
+const getDiscountText = (discountType) => {
+  const textMap = {
+    percentage: "鐧惧垎姣�",
+    fixed: "鍥哄畾閲戦",
+  };
+  return textMap[discountType] || "鏈煡";
+};
+
+const getStatusType = (status) => {
+  const statusMap = {
+    active: "success",
+    pending: "warning",
+    expired: "info",
+  };
+  return statusMap[status] || "info";
+};
+
+const getStatusText = (status) => {
+  const statusMap = {
+    active: "鏈夋晥",
+    pending: "寰呯敓鏁�",
+    expired: "宸茶繃鏈�",
+  };
+  return statusMap[status] || "鏈煡";
+};
+
+const showPriceReference = () => {
+  if (form.value.supplierId) {
+    const supplier = supplierList.value.find((item) => item.id === form.value.supplierId);
+    if (supplier) {
+      productForm.value.supplierName = supplier.supplierName;
+    }
+  }
+  priceReferenceVisible.value = true;
+  handlePriceReferenceSearch();
+};
+
+const handlePriceReferenceSearch = () => {
+  priceReferenceLoading.value = true;
+  // 妯℃嫙鎼滅储鍙傛暟锛歱roductId 鏄犲皠涓� productName 鎴� ID锛岃繖閲屾牴鎹� advancedPriceManagement 鐨� API 纭畾鍙傛暟
+  // 鍋囪楂樼骇浠锋牸绠$悊鐨� listPage 鎺ユ敹 productId
+  const query = {
+    productId: productForm.value.productId,
+    supplierId: form.value.supplierId,
+    current: priceReferencePagination.current,
+    size: priceReferencePagination.size
+  };
+  listAdvancedPrice(query).then(res => {
+    console.log(res);
+    priceReferenceData.value = res.data.records;
+    priceReferenceTotal.value = res.data.total;
+    priceReferenceLoading.value = false;
+  }).catch(() => {
+    priceReferenceLoading.value = false;
+  });
+};
+
+const handlePriceReferenceSizeChange = (size) => {
+  priceReferencePagination.size = size;
+  handlePriceReferenceSearch();
+};
+
+const handlePriceReferenceCurrentChange = (page) => {
+  priceReferencePagination.current = page;
+  handlePriceReferenceSearch();
+};
+
+const selectPriceReference = (row) => {
+  // 璁$畻鍘嗗彶浠锋牸锛堜綔涓轰笉鍚◣鍗曚环锛夛細鍩虹浠锋牸 - 鎶樻墸
+  let taxExclusivePrice = row.basePrice;
+  if (row.discountType === "percentage") {
+    taxExclusivePrice = row.basePrice * (1 - row.discountValue / 100);
+  } else if (row.discountType === "fixed") {
+    taxExclusivePrice = row.basePrice - row.discountValue;
+  }
+  taxExclusivePrice = Number(Math.max(taxExclusivePrice, 0));
+
+  // 璁剧疆鏁伴噺涓� 1
+  if (!productForm.value.quantity) {
+    productForm.value.quantity = 1;
+  }
+
+  // 濡傛灉宸叉湁绋庣巼锛屽垯璁$畻鍚◣鍗曚环
+  if (productForm.value.taxRate) {
+    const taxRate = Number(productForm.value.taxRate);
+    productForm.value.taxInclusiveUnitPrice = (
+      taxExclusivePrice *
+      (1 + taxRate / 100)
+    ).toFixed(2);
+  } else {
+    // 濡傛灉娌℃湁绋庣巼锛屾殏鏃跺皢鍚◣鍗曚环璁句负涓嶅惈绋庝环鏍硷紝鎻愮ず鐢ㄦ埛閫夋嫨绋庣巼
+    productForm.value.taxInclusiveUnitPrice = taxExclusivePrice.toFixed(2);
+    proxy.$modal.msgWarning("璇烽�夋嫨绋庣巼浠ュ噯纭绠楀惈绋庝环鏍�");
+  }
+
+  // 鑷姩瑙﹀彂璁$畻閫昏緫锛堣绠楁�讳环绛夛級
+  mathNum();
+
+  priceReferenceVisible.value = false;
+  proxy.$modal.msgSuccess("宸插紩鐢ㄥ巻鍙蹭环鏍硷紙涓嶅惈绋庯級");
+};
+
 const upload = reactive({
   // 涓婁紶鐨勫湴鍧�
   url: import.meta.env.VITE_APP_BASE_API + "/file/upload",
@@ -1135,13 +1355,38 @@
 };
 // 鎵撳紑浜у搧寮规
 const openProductForm = (type, row, index) => {
+  if(!form.value.supplierId){
+    proxy.$modal.msgWarning("璇烽�夋嫨渚涘簲鍟�");
+    return;
+  }
   productOperationType.value = type;
   productOperationIndex.value = index;
-  productForm.value = {};
+  productForm.value = {
+    supplierName: "",
+    productName: "",
+    productModel: "",
+  };
   proxy.resetForm("productFormRef");
   if (type === "edit") {
-    productForm.value = { ...row };
+    productForm.value = { 
+      ...row,
+      productName: row.productCategory || "",
+      productModel: row.specificationModel || ""
+    };
+    // 缂栬緫鏃讹紝鏍规嵁 productId 棰勫姞杞借鏍煎瀷鍙峰垪琛紝纭繚涓嬫媺妗嗘樉绀哄悕绉拌�岄潪 ID
+    if (productForm.value.productId) {
+      modelList({ id: productForm.value.productId }).then((res) => {
+        modelOptions.value = res;
+      });
+    }
   }
+  
+  // 纭繚渚涘簲鍟嗗悕绉板缁堝悓姝�
+  const supplier = supplierList.value.find((item) => item.id === form.value.supplierId);
+  if (supplier) {
+    productForm.value.supplierName = supplier.supplierName;
+  }
+  
   productFormVisible.value = true;
   getProductOptions();
 };
@@ -1153,11 +1398,14 @@
 const getModels = (value) => {
   if (value) {
     productForm.value.productCategory = findNodeById(productOptions.value, value) || "";
+    productForm.value.productName = productForm.value.productCategory;
+    productForm.value.productModelId = "";
     modelList({ id: value }).then((res) => {
       modelOptions.value = res;
     });
   } else {
     productForm.value.productCategory = "";
+    productForm.value.productName = "";
     modelOptions.value = [];
   }
 };
@@ -1165,12 +1413,24 @@
   const index = modelOptions.value.findIndex((item) => item.id === value);
   if (index !== -1) {
     productForm.value.specificationModel = modelOptions.value[index].model;
+    productForm.value.productModel = modelOptions.value[index].model;
     productForm.value.unit = modelOptions.value[index].unit;
   } else {
     productForm.value.specificationModel = null;
+    productForm.value.productModel = null;
     productForm.value.unit = null;
   }
 };
+const handleSupplierChange = (value) => {
+  const supplier = supplierList.value.find((item) => item.id === value);
+  if (supplier) {
+    form.value.supplierName = supplier.supplierName;
+    productForm.value.supplierName = supplier.supplierName;
+  } else {
+    form.value.supplierName = "";
+    productForm.value.supplierName = "";
+  }
+};
 const findNodeById = (nodes, productId) => {
   for (let i = 0; i < nodes.length; i++) {
     if (nodes[i].value === productId) {

--
Gitblit v1.9.3