From 71b93327e8f3fb3bffffc7c033c1f782e7b6ab32 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 22 五月 2023 17:37:16 +0800
Subject: [PATCH] test

---
 force-app/main/default/lwc/inventoryEditingLWC/inventoryEditingLWC.js |   90 +++++++++++++++++++++++++++-----------------
 1 files changed, 55 insertions(+), 35 deletions(-)

diff --git a/force-app/main/default/lwc/inventoryEditingLWC/inventoryEditingLWC.js b/force-app/main/default/lwc/inventoryEditingLWC/inventoryEditingLWC.js
index 2f064df..f3ed3c7 100644
--- a/force-app/main/default/lwc/inventoryEditingLWC/inventoryEditingLWC.js
+++ b/force-app/main/default/lwc/inventoryEditingLWC/inventoryEditingLWC.js
@@ -5,7 +5,6 @@
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 export default class InventoryEditingLWC extends LightningElement {
     // @track invRecord = {ProductNumber : Product_Number_FIELD,Inventory1: ONE_FIELD,Inventory2 : TWO_FIELD,key : Math.random().toString(36).substring(2, 15)};
-    @track invRecord = {ProductNumber : Product_Number_FIELD,Inventory1: ONE_FIELD,Inventory2 : TWO_FIELD,key : Math.random().toString(36).substring(2, 15)};
     @track invRecords = [];
     toSaveLabel = 'Save';
 
@@ -22,9 +21,16 @@
     }
 
     addRow(){
-        console.log('=====>杩涘叆琛岄」鐩�');
-        const len = this.invRecords.length;
-        this.invRecords.push({ProductNumber : Product_Number_FIELD,Inventory1: ONE_FIELD,Inventory2 : TWO_FIELD,key : Math.random().toString(36).substring(2, 15)});
+        // console.log('=====>杩涘叆琛岄」鐩�');
+        // const len = this.invRecords.length;
+        // this.invRecords.push({ProductNumber : Product_Number_FIELD,Inventory1: ONE_FIELD,Inventory2 : TWO_FIELD,key : Math.random().toString(36).substring(2, 15)});
+        let objRow = {
+            ProductNumber: '',
+            Inventory1: '',
+            Inventory2: '',
+            id: ++this.keyIndex
+        }
+        this.invRecords = [...this.invRecords, Object.create(objRow)];
     }
     removeRow(event){
         const indexPos = event.currentTarget.name;
@@ -35,42 +41,56 @@
     }
     handleClick(){
         console.log('淇濆瓨');
-        this.toSaveLabel = 'Saving...'
-        let toSaveList = this.invRecords.slice(0);;
-        toSaveList.forEach((element, index) => {
-            console.log( index + ' ==> ' + JSON.stringify(element.Name));
-            let eleType = typeof element.Name;
-            console.log( 'typeof ==> ' + eleType);
-            if(element.Name === '' || eleType=='object'){
-                toSaveList.splice(index);
-            }
-        });
-        // refreshApex(this.invRecord);
-         
+        console.log('this.invRecords'+JSON.stringify(this.invRecords));
         this.inventoryTempRecords();
         console.log( 'Save ==> ' + JSON.stringify(toSaveList));
     }
 
-    handleProductChange(event){   
+    handleProductChange(event){ 
+        if (event.target.name == 'productNumber') {
+            this.invRecords[event.currentTarget.dataset.index].productNumber = event.target.value;
+            console.log('===>invrecords'+JSON.stringify(this.invRecords));
+           
+        }
+        else if (event.target.name == 'inventory1') {
+            this.invRecords[event.currentTarget.dataset.index].inventory1 = event.target.value;
+        }
+        else if (event.target.name == 'inventory2') {
+            this.invRecords[event.currentTarget.dataset.index].inventory2 = event.target.value;
+        }
+     
+     
 
-        let foundelement = this.invRecords.find(ele => ele.key == event.target.dataset.id);
-        console.log('=====>foundelement'+foundelement);
-        foundelement.productNumber = event.target.value;
-        this.accRecords = [this.accRecords];
-        console.log(' ==>绗竴琛�' +  JSON.stringify(this.invRecords));
-    }
-    handleinv1Change(event){
-        let foundelement = this.invRecords.find(ele => ele.key == event.target.dataset.id);
-        foundelement.inventory1 = event.target.value;
-        this.accRecords = [this.accRecords];
-        console.log(' ==> 绗簩' +  JSON.stringify(this.invRecords));
-    }
+    //     let foundelement = this.invRecords.find(ele => ele.key == event.target.dataset.id);
+    //     console.log('=====>foundelement'+foundelement);
+    //     foundelement.productNumber = event.target.value;
+    //     this.invRecords = [this.invRecords];
+    //     console.log(' ==>绗竴琛�' +   foundelement.productNumber);
+    //     console.log(' ==>绗竴琛�' +  JSON.stringify(this.invRecords));
+    // }
+    // handleinv1Change(event){
+    //     let foundelement = this.invRecords.find(ele => ele.key == event.target.dataset.id);
+    //     foundelement.Inventory1 = event.target.value;
+    //     this.invRecords = [this.invRecords];
+    //     // if( foundelement.Inventory1)
+    //     console.log(' ==> 绗簩' +  JSON.stringify(this.invRecords));
 
-    handleinv2Change(event){
-        let foundelement = this.invRecords.find(ele => ele.key == event.target.dataset.id);
-        foundelement.inventory2 = event.target.value;
-        this.accRecords = [this.accRecords];
-        console.log(' ==>绗笁' +  JSON.stringify(this.invRecords));
+    // }
+
+    // handleinv2Change(event){
+    //     let foundelement = this.invRecords.find(ele => ele.key == event.target.dataset.id);
+    //     foundelement.Inventory2 = event.target.value;
+    //     this.invRecords = [this.invRecords];
+    //     console.log(' ==>绗笁' +  JSON.stringify(this.invRecords));
     }
-   
+    
+
+
+
+    //鏁板瓧楠岃瘉
+isNum(num){
+    var reNum =/^[0-9]+$/;
+    return (reNum.test(num));
+    }
+    
 }
\ No newline at end of file

--
Gitblit v1.9.1