ZN
4 天以前 4486457e02c39a14d20ea791403f28ec0d5e8103
feat(procurementLedger): 添加历史采购价格参考功能

- 在采购台账商品表单中增加“查看历史采购价格参考”按钮
- 添加历史价格参考弹窗,展示商品的历史采购价格、折扣信息和供应商
- 支持选择历史价格自动填充当前表单的含税单价
- 移除高级价格管理中的模拟供应商和商品数据,使用实际接口数据
已修改2个文件
139 ■■■■■ 文件已修改
src/views/procurementManagement/advancedPriceManagement/index.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/procurementManagement/procurementLedger/index.vue 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/procurementManagement/advancedPriceManagement/index.vue
@@ -8,7 +8,7 @@
        </el-form-item>
        <el-form-item label="供应商:">
          <el-select v-model="searchForm.supplierId" placeholder="请选择供应商" clearable style="width: 200px">
            <el-option v-for="supplier in supplierList" :key="supplier.id" :label="supplier.name" :value="supplier.id" />
            <el-option v-for="supplier in supplierList" :key="supplier.id" :label="supplier.supplierName" :value="supplier.id" />
          </el-select>
        </el-form-item>
        <el-form-item>
@@ -454,15 +454,6 @@
  });
const supplierList = ref([
  { id: 1, name: '优质五金供应商' },
  { id: 2, name: '钢材贸易公司' },
  { id: 3, name: '建材批发商' }
])
const productList = ref([
  { id: 1, name: '高强度螺栓' },
  { id: 2, name: '不锈钢管' },
  { id: 3, name: '铝合金型材' }
])
src/views/procurementManagement/procurementLedger/index.vue
@@ -552,6 +552,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">
@@ -636,6 +641,62 @@
          <el-button type="primary" @click="submitProduct">确认</el-button>
          <el-button @click="closeProductDia">取消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 历史采购价格参考弹窗 -->
    <el-dialog
      v-model="priceReferenceVisible"
      title="历史采购价格参考"
      width="1000px"
      append-to-body
    >
      <el-table
        v-loading="priceReferenceLoading"
        :data="priceReferenceData"
        border
        style="width: 100%"
      >
        <el-table-column label="商品名称" prop="productName" min-width="150" show-overflow-tooltip />
        <el-table-column label="规格型号" prop="specification" width="150" show-overflow-tooltip />
        <el-table-column label="供应商" prop="supplierName" width="200" show-overflow-tooltip />
        <el-table-column label="基础价格" width="120" align="right">
          <template #default="{ row }">
            <span style="color: #f56c6c; font-weight: bold;">¥{{ row.basePrice }}</span>
          </template>
        </el-table-column>
        <el-table-column label="折扣信息" width="120" align="center">
          <template #default="{ row }">
            <el-tag v-if="row.discountType === 'percentage'" type="success">
              {{ row.discountValue }}%
            </el-tag>
            <el-tag v-else-if="row.discountType === 'fixed'" type="warning">
              -¥{{ row.discountValue }}
            </el-tag>
            <span v-else>无折扣</span>
          </template>
        </el-table-column>
        <el-table-column label="生效时间" prop="effectiveTime" width="180" align="center" />
        <el-table-column label="操作" width="100" align="center" fixed="right">
          <template #default="{ row }">
            <el-button type="primary" link @click="selectPriceReference(row)">选择</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>
@@ -903,6 +964,7 @@
let nextApproverId = 2;
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();
@@ -996,6 +1058,72 @@
  },
});
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 showPriceReference = () => {
  priceReferenceVisible.value = true;
  handlePriceReferenceSearch();
};
const handlePriceReferenceSearch = () => {
  priceReferenceLoading.value = true;
  // 模拟搜索参数:productId 映射为 productName 或 ID,这里根据 advancedPriceManagement 的 API 确定参数
  // 假设高级价格管理的 listPage 接收 productId
  const query = {
    productId: productForm.value.productId,
    specificationId: productForm.value.productModelId,
    current: priceReferencePagination.current,
    size: priceReferencePagination.size
  };
  listAdvancedPrice(query).then(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 actualPrice = row.basePrice;
   if (row.discountType === 'percentage') {
     actualPrice = row.basePrice * (1 - row.discountValue / 100);
   } else if (row.discountType === 'fixed') {
     actualPrice = row.basePrice - row.discountValue;
   }
   // 填充含税单价,保留两位小数
   productForm.value.taxInclusiveUnitPrice = Number(Math.max(actualPrice, 0)).toFixed(2);
   // 如果已经输入了数量,则自动计算总价
   if (productForm.value.quantity) {
     mathNum();
   }
   priceReferenceVisible.value = false;
   proxy.$modal.msgSuccess("已引用历史价格");
 };
const upload = reactive({
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/file/upload",