From 4488f711dbc01a8db6753907cae2ef4021dede68 Mon Sep 17 00:00:00 2001
From: FUYU <fuyu@prec-tech.com>
Date: 星期三, 13 十二月 2023 16:30:27 +0800
Subject: [PATCH] 修改前备份

---
 force-app/main/default/lwc/customShippingUnitPriceComp/customShippingUnitPriceComp.js |   51 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/lwc/customShippingUnitPriceComp/customShippingUnitPriceComp.js b/force-app/main/default/lwc/customShippingUnitPriceComp/customShippingUnitPriceComp.js
index 45bfe3a..6e05114 100644
--- a/force-app/main/default/lwc/customShippingUnitPriceComp/customShippingUnitPriceComp.js
+++ b/force-app/main/default/lwc/customShippingUnitPriceComp/customShippingUnitPriceComp.js
@@ -1,24 +1,41 @@
-import { LightningElement,api,track } from 'lwc';
+import { LightningElement, api, track } from 'lwc';
 
 export default class CustomShippingUnitPriceComp extends LightningElement {
     @api recordId;
-    @track shipmentUnitPrice = 0.00;
+    @api shippingUnitPrice;
 
-    connectedCallback(){
-        console.log('CustomShippingUnitPriceComp recordId = ' + this.recordId);
+    connectedCallback() {
+        console.log('shippingUnitPrice = ' + this.shippingUnitPrice);
     }
 
-    shipmentUnitPriceBlur(event){
-        console.log('shipmentUnitPriceBlur')
-        this.shipmentUnitPrice = event.target.value;
-
-        this.dispatchEvent(new CustomEvent('shipmentunitprice', {
-            composed: true,
-            bubbles: true,
-            cancelable: true,
-            detail: {
-                data: { shipmentunitprice: this.shipmentUnitPrice, recordId: this.recordId }
-            }
-        }));
+    limitDecimals(event) {
+        const value = parseFloat(event.target.value); // 灏嗚緭鍏ュ�艰浆鎹负鏁板瓧绫诲瀷
+        const roundedValue = Math.round(value * 100) / 100; // 灏嗘暟瀛楀洓鑸嶄簲鍏ュ埌涓や綅灏忔暟
+        if (isNaN(value) || isNaN(roundedValue)) {
+            // 濡傛灉鏁板瓧鏃犳晥锛屽垯娓呯┖杈撳叆妗�
+            event.target.value = '';
+        } else if (roundedValue !== value) {
+            // 濡傛灉杈撳叆妗嗙殑鍊艰秴鍑轰簡涓や綅灏忔暟锛屽垯淇敼涓轰袱浣嶅皬鏁�
+            event.target.value = roundedValue.toFixed(2);
+        }
     }
-}
\ No newline at end of file
+
+    shipmentUnitPriceBlur(event) {
+        console.log('shipmentUnitPriceBlur');
+        this.shippingUnitPrice = event.target.value;
+
+        this.dispatchEvent(
+            new CustomEvent('shipmentunitprice', {
+                composed: true,
+                bubbles: true,
+                cancelable: true,
+                detail: {
+                    data: {
+                        shipmentunitprice: this.shippingUnitPrice,
+                        recordId: this.recordId
+                    }
+                }
+            })
+        );
+    }
+}

--
Gitblit v1.9.1