From baddb052ccd4a91ef1881ba663e6a4e55b05f4fb Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 14 十月 2026 15:51:55 +0800
Subject: [PATCH] feat(hrm): 社保公积金方案表单加「适用部门」与默认缴费基数,修比例输入精度

---
 src/views/erp/purchase/order/modules/item-form.vue |   50 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/src/views/erp/purchase/order/modules/item-form.vue b/src/views/erp/purchase/order/modules/item-form.vue
index 37b3d5f..fac9041 100644
--- a/src/views/erp/purchase/order/modules/item-form.vue
+++ b/src/views/erp/purchase/order/modules/item-form.vue
@@ -10,11 +10,10 @@
   erpPriceMultiply,
 } from '@vben/utils';
 
-import { Input, InputNumber, Select } from 'ant-design-vue';
+import { Input, InputNumber, Select, Switch } from 'ant-design-vue';
 
 import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
 import { getItemPage } from '#/api/mdm/item';
-import { getStockCount } from '#/api/erp/stock/stock';
 
 import { useFormItemColumns } from '../data';
 
@@ -124,16 +123,15 @@
   const newRow = {
     id: undefined,
     productId: undefined,
-    productUnitName: undefined, // 浜у搧鍗曚綅
-    productBarCode: undefined, // 浜у搧鏉$爜
+    productUnitName: undefined,
     productPrice: undefined,
-    stockCount: undefined,
     count: 1,
     totalProductPrice: undefined,
     taxPercent: 0,
     taxPrice: undefined,
     totalPrice: undefined,
     remark: undefined,
+    qcCheckFlag: false,
   };
   tableData.value.push(newRow);
   // 閫氱煡鐖剁粍浠舵洿鏂�
@@ -159,10 +157,8 @@
   }
   row.productId = productId;
   row.productUnitId = product.unitMeasureId;
-  row.productBarCode = product.barCode;
   row.productUnitName = product.unitMeasureName;
   row.productName = product.name;
-  row.stockCount = (await getStockCount(productId)) || 0;
   row.productPrice = product.purchasePrice || 0;
   row.count = row.count || 1;
   handleRowChange(row);
@@ -170,6 +166,7 @@
 
 /** 澶勭悊琛屾暟鎹彉鏇� */
 function handleRowChange(row: any) {
+  recalcRow(row);
   const index = tableData.value.findIndex((item) => item.seq === row.seq);
   if (index === -1) {
     tableData.value.push(row);
@@ -179,13 +176,28 @@
   emit('update:items', [...tableData.value]);
 }
 
-/** 鍒濆鍖栬鏁版嵁 */
-function initRow(row: ErpPurchaseOrderApi.PurchaseOrderItem) {
+/**
+ * 閲嶇畻琛岄噾棰濓紙鍗曚环涓�**鍚◣**鍗曚环锛�
+ * 鍚◣閲戦 = 鍚◣鍗曚环 脳 鏁伴噺锛涚◣棰� = 鍚◣閲戦 脳 绋庣巼锛涗笉鍚◣閲戦 = 鍚◣閲戦 - 绋庨
+ */
+function recalcRow(row: ErpPurchaseOrderApi.PurchaseOrderItem) {
   if (row.productPrice && row.count) {
-    row.totalProductPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
+    const taxInclusivePrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
     row.taxPrice =
-      erpPriceMultiply(row.totalProductPrice, (row.taxPercent || 0) / 100) ?? 0;
-    row.totalPrice = row.totalProductPrice + row.taxPrice;
+      erpPriceMultiply(taxInclusivePrice, (row.taxPercent || 0) / 100) ?? 0;
+    row.totalProductPrice = taxInclusivePrice - row.taxPrice;
+    row.totalPrice = taxInclusivePrice;
+  }
+}
+
+/**
+ * 鍒濆鍖栬鏁版嵁
+ * 宸叉湁鍗曟嵁鐨勬槑缁嗚锛堝甫 id锛夋部鐢ㄥ悗绔繑鍥炵殑閲戦锛岄伩鍏嶅巻鍙插崟鎹鏂板彛寰勮鐩栵紱
+ * 鍙湁鏈繚瀛樼殑鏂板琛屾墠鎸夋柊鍙e緞閲嶇畻銆�
+ */
+function initRow(row: ErpPurchaseOrderApi.PurchaseOrderItem) {
+  if (!row.id) {
+    recalcRow(row);
   }
 }
 
@@ -261,6 +273,16 @@
       <Input v-if="!disabled" v-model:value="row.remark" class="w-full" />
       <span v-else>{{ row.remark || '-' }}</span>
     </template>
+    <template #qcCheckFlag="{ row }">
+      <Switch
+        v-if="!disabled"
+        v-model:checked="row.qcCheckFlag"
+        checked-children="鏄�"
+        un-checked-children="鍚�"
+        @change="handleRowChange(row)"
+      />
+      <span v-else>{{ row.qcCheckFlag ? '鏄�' : '鍚�' }}</span>
+    </template>
     <template #taxPercent="{ row }">
       <InputNumber
         v-if="!disabled"
@@ -295,11 +317,11 @@
           <div class="flex space-x-4">
             <span>鏁伴噺锛歿{ erpCountInputFormatter(summaries.count) }}</span>
             <span>
-              閲戦锛歿{ erpPriceInputFormatter(summaries.totalProductPrice) }}
+              涓嶅惈绋庨噾棰濓細{{ erpPriceInputFormatter(summaries.totalProductPrice) }}
             </span>
             <span>绋庨锛歿{ erpPriceInputFormatter(summaries.taxPrice) }}</span>
             <span>
-              绋庨鍚堣锛歿{ erpPriceInputFormatter(summaries.totalPrice) }}
+              鍚◣鍚堣锛歿{ erpPriceInputFormatter(summaries.totalPrice) }}
             </span>
           </div>
         </div>

--
Gitblit v1.9.3