liwentao
2023-04-28 ee2e046f6f8a0e804a0f0de82dbf25fe3d2693e8
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-24 16:46:31
 * @LastEditTime: 2023-04-26 11:45:00
 */
/*
 * @Description: 
@@ -14,45 +14,102 @@
 * @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 init from '@salesforce/apex/lexPCLLostReportLwcController.init';
import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
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;
    lostReportObj;
    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);
        });
    }
    //失单类型
    RecordTypeOptions = [{ label: '--无--', value: '' },
                    { label: '失单', value: '失单' },
                    { label: '部分失单', value: '部分失单' }];
    // @wire(CurrentPageReference)
    // getStateParameters(currentPageReference) {
    //         console.log(111);
    //         console.log(currentPageReference);
    @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;
    //         }
    //     }
        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");
@@ -78,6 +135,35 @@
    //         });
    //     });
    // }
    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) {
        // Use the URLSearchParams API to get the value of a query parameter
@@ -85,23 +171,18 @@
        return params.get(paramName);
    }
    saveJs() {
        this.blockMyself();
        save().then(result=>{
            if(result){
                this.showToast(result,"success");
                this.unblock();
                this.clearBrandMannualName();
            }
        })
    }
    addBrandJs() {
        this.blockMyself();
        addBrand().then(()=>{
            this.unblock();
        });
    }
    submitJS() {
        this.blockMyself();
        submit().then(result=>{
            if(result.get('error')){
                this.showToast(result.get('error'),"error");
@@ -114,54 +195,21 @@
                        pageStatus: result.get('pageStatus'),
                        submitFlag: result.get('submitFlag')
                    }
                });
                this.unblock();
                });
            }
        });
    }
    addProductJs(number) {
        this.blockMyself();
        addProduct().then(()=>{
            this.unblock();
        });
    }
    RemoveJs(number) {
        this.blockMyself();
        Remove().then(()=>{
            this.unblock();
        Remove().then(()=>{
        });
    }
    // add tcm 20211118 start
    searchJs(topNum, secondNum) {
        this.blockMyself();
        search().then(()=>{
            this.unblock();
        });
    }
    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);
        });
    }
    unblock(){
        Promise.all([
            loadScript(this,PleaseWaitDialog),
            loadStyle(this,blockUIcss),
            loadScript(this, jquery)
            //loadScript(this, jq + "/dist/jquery.min.js")
        ]).then(() =>{
            unblockUI();
        }).catch(error => {
            console.log("321");
            console.log('Failed to load the JQuery : ' +error);
        });
    }
    get pageStatusIsCreateOrEdit() {
@@ -200,16 +248,12 @@
        //console.log('setLostTotalAmount end');
    }
    setBrandName(brandNumber) {
        this.blockMyself();
        setbrand().then(()=>{
            this.clearBrandMannualName();
            this.unblock();
        });
    }
    setBrandMannualName(brandNumber) {
        this.blockMyself();
        setbrandmannual().then(()=>{
            this.unblock();
        });
    }
    // 失单品牌不等于其他时,失单品牌(手动)清空并且不允许填写,失单品牌等于其他时,失单对手型号不可用  thh 2022-01-13 start