From 9c43ce3f3bf2d0a2f70b73a4ba89eccf5030a683 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期三, 10 五月 2023 17:54:00 +0800
Subject: [PATCH] 查漏补缺

---
 force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js |  235 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 187 insertions(+), 48 deletions(-)

diff --git a/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js b/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js
index 0452b39..05d8284 100644
--- a/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js
+++ b/force-app/main/default/lwc/lexPCLLostReportPage/lexPCLLostReportPage.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-04-20 15:04:03
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-23 16:57:18
+ * @LastEditTime: 2023-04-26 11:45:00
  */
 /*
  * @Description: 
@@ -14,34 +14,155 @@
  * @LastEditors: chen jing wu
  * @LastEditTime: 2023-04-20 17:11:01
  */
-import { api, wire,LightningElement } from 'lwc';
+const columns = [
+    {
+      label: '澶卞崟鍝佺墝',
+      fieldName: 'LostBrandName__c',
+      type: 'list',
+      editable: true
+    },
+    {
+      label: '澶卞崟瀵规墜鍨嬪彿',
+      fieldName: 'LostProductName__c',
+      type: 'text',
+      editable: true
+    },
+    {
+        label: '澶卞崟鏁伴噺',
+        fieldName: 'Quantity__c',
+        type: 'number',
+        editable: true
+    },
+    {
+    label: '澶卞崟瀵规墜鍨嬪彿锛堟墜鍔級',
+    fieldName: 'LostProductMannual__c',
+    type: 'text',
+    editable: true
+    },
+    {
+    label: '澶卞崟浜у搧绫诲埆',
+    fieldName: 'ProductClass__c',
+    type: 'list',
+    editable: true
+    },
+    {
+    label: '澶卞崟浜у搧鍖哄垎',
+    fieldName: 'ProductCategory__c',
+    type: 'list',
+    editable: true
+    }
+    // ...
+  ];
+import { api, wire,track,LightningElement } from 'lwc';
+import { CurrentPageReference } from "lightning/navigation";
 import save from '@salesforce/apex/lexPCLLostReportLwcController.save';
-import jquery from '@salesforce/resourceUrl/jquery183minjs';
-import blockUIcss from '@salesforce/resourceUrl/blockUIcss';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
-import setBrand from '@salesforce/apex/lexPCLLostReportLwcController.setBrand';
-import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
+import setbrand from '@salesforce/apex/lexPCLLostReportLwcController.setBrand';
+import init from '@salesforce/apex/lexPCLLostReportLwcController.init';
 import initForApex from '@salesforce/apex/lexPCLLostReportLwcController.initForApex';
+import multiSelectCombobox from 'c/multiSelectCombobox'
+import searchBrands from '@salesforce/apex/lexPCLLostReportLwcController.searchBrands';
 export default class LexPCLLostReportPage extends LightningElement {
-    @api oppId;
+    @api oppId = '0061000001R2xjWAAR';
     @api lostReportId;
-    @api pageStatus;
-    @api lostType;
+    @api pageStatus = 'Create';
+    @api lostType = '澶卞崟';
     @api submitFlag;
+    searchResult;
+    LostReport;
     brandCount;
-    constructor() {
-        super();
-
-        // Set the default values for properties using ternary operators
-        this.oppId = this.getParamValue('oppId') || '';
-        this.lostReportId = this.getParamValue('Id') || '';
-        this.pageStatus = this.getParamValue('pageStatus') || '';
-        this.lostType = this.getParamValue('lostType') || '';
-        this.submitFlag = this.getParamValue('submitFlag') || '';
+    brandOptions = [];
+    connectedCallback() {
+        this.initAll();
+        searchBrands().then(result=>{
+            this.brandOptions = JSON.parse(result);
+            console.log(this.brandOptions);
+            const multiCombobox = this.template.querySelector('c-multi-select-combobox');
+            multiCombobox.refreshOptions(this.brandOptions);
+        }).catch(error=>{
+            console.log("error");
+            console.log(error);
+        });
     }
-    connectedCallback(){
-        
+
+    
+    //澶卞崟绫诲瀷
+    RecordTypeOptions = [{ label: '--鏃�--', value: '' },
+                    { label: '澶卞崟', value: '澶卞崟' },
+                    { label: '閮ㄥ垎澶卞崟', value: '閮ㄥ垎澶卞崟' }];
+    @wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+            console.log(111);
+            console.log(currentPageReference);
+
+        if (currentPageReference) {
+            const urlValue = currentPageReference.state.recordId;
+            if (urlValue) {
+            let str = `${urlValue}`;
+            console.log("str");
+            console.log(str);
+            this.oppId = str;
+            }
+        }
+    }
+    // connectedCallback(){
+    //     this.initAll();
+    // }
+    
+    
+    // connectedCallback(){
+    //     console.log("1");
+    //     initForApex({
+    //         oppId1: this.oppId,
+    //         lostReportId1: this.lostReportId,
+    //         pageStatus1: this.pageStatus,
+    //         lostType1: this.lostType,
+    //         submitFlag1: this.submitFlag
+    //     }).then(()=>{
+    //         console.log("2");
+    //         init().then(result=>{
+    //             console.log("3");
+    //             console.log(result);
+    //             if(result.message == '鎻愪氦鎴愬姛锛�'){
+    //                 this.showToast(result.message,"success");
+    //                 this.LostReport = result.LostReport;
+    //             }else{
+    //                 console.log("211");
+    //                 this.showToast(result.message,"error");
+    //                 console.log("985");
+    //             }
+    //         });
+    //     });
+    // }
+    
+    initAll(){
+        console.log(this.oppId);
+        console.log(this.lostReportId);
+        console.log(this.pageStatus);
+        console.log(this.lostType);
+        console.log(this.submitFlag);
+        initForApex({
+                    oppId1: this.oppId,
+                    lostReportId1: this.lostReportId,
+                    pageStatus1: this.pageStatus,
+                    lostType1: this.lostType,
+                    submitFlag1: this.submitFlag
+                }).then(()=>{
+                    console.log("2");
+                    init().then(result=>{
+                        console.log("3");
+                        console.log(result);
+                        if(result.message == '鎻愪氦鎴愬姛锛�'){
+                            this.showToast(result.message,"success");
+                            this.LostReport = result.LostReport;
+                        }else{
+                            console.log("211");
+                            //this.showToast(result.message,"error");
+                            console.log("985");
+                        }
+                    });
+                });
     }
 
     getParamValue(paramName) {
@@ -50,42 +171,49 @@
         return params.get(paramName);
     }
     saveJs() {
-        this.blockMyself();
-        save();
+        save().then(result=>{
+            if(result){
+                this.showToast(result,"success");
+                this.clearBrandMannualName();
+            }
+        })
     }
     addBrandJs() {
-        this.blockMyself();
-        addBrand();
+        addBrand().then(()=>{
+        });
     }
     submitJS() {
-        this.blockMyself();
-        submit();
+        submit().then(result=>{
+            if(result.get('error')){
+                this.showToast(result.get('error'),"error");
+            }else{
+                this[NavigationMixin.Navigate]({
+                    type: 'standard__recordPage',
+                    attributes: {
+                        uri: result.get('uri'),
+                        Id: result.get('Id'),
+                        pageStatus: result.get('pageStatus'),
+                        submitFlag: result.get('submitFlag')
+                    }
+                }); 
+            }
+        });
     }
     addProductJs(number) {
-        this.blockMyself();
-        addProduct(number);
+        addProduct().then(()=>{
+        });
     }
     RemoveJs(number) {
-        this.blockMyself();
-        Remove(number);
+        Remove().then(()=>{ 
+        });
     }
     // add tcm 20211118 start
     searchJs(topNum, secondNum) {
-        this.blockMyself();
-        search(topNum, secondNum);
-    }
-    blockMyself(){
-        Promise.all([
-            loadScript(this,PleaseWaitDialog),
-            loadStyle(this,blockUIcss),
-            loadScript(this, jquery)
-            //loadScript(this, jq + "/dist/jquery.min.js")
-        ]).then(() =>{
-            blockme();
-        }).catch(error => {
-            console.log("321");
-            console.log('Failed to load the JQuery : ' +error);
+        search().then(()=>{
         });
+    }
+    get pageStatusIsCreateOrEdit() {
+        return this.pageStatus === 'Create' || this.pageStatus === 'Edit';
     }
     
     // add tcm 20211118 end
@@ -120,12 +248,13 @@
         //console.log('setLostTotalAmount end');
     }
     setBrandName(brandNumber) {
-        this.blockMyself();
-        setbrand(brandNumber);
+        setbrand().then(()=>{
+            this.clearBrandMannualName();
+        });
     }
     setBrandMannualName(brandNumber) {
-        this.blockMyself();
-        setbrandmannual(brandNumber);
+        setbrandmannual().then(()=>{
+        });
     }
     // 澶卞崟鍝佺墝涓嶇瓑浜庡叾浠栨椂,澶卞崟鍝佺墝锛堟墜鍔級娓呯┖骞朵笖涓嶅厑璁稿~鍐�,澶卞崟鍝佺墝绛変簬鍏朵粬鏃�,澶卞崟瀵规墜鍨嬪彿涓嶅彲鐢�  thh 2022-01-13 start
     clearBrandMannualName(){
@@ -146,4 +275,14 @@
             }
         });
     }
+    showToast(msg,type) {
+        const event = new ShowToastEvent({
+            title: '',
+            message: msg,
+            variant: type
+        });
+        this.dispatchEvent(event);
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+    
 }
\ No newline at end of file

--
Gitblit v1.9.1