19626
2023-04-24 09b83c021646c56cec56b77dc091893401563f9f
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-24 16:46:31
 */
/*
 * @Description: 
@@ -15,12 +15,14 @@
 * @LastEditTime: 2023-04-20 17:11:01
 */
import { api, wire,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 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';
export default class LexPCLLostReportPage extends LightningElement {
@@ -29,20 +31,53 @@
    @api pageStatus;
    @api lostType;
    @api submitFlag;
    LostReport;
    brandCount;
    constructor() {
        super();
    lostReportObj;
    //失单类型
    RecordTypeOptions = [{ label: '--无--', value: '' },
                    { label: '失单', value: '失单' },
                    { label: '部分失单', value: '部分失单' }];
    // @wire(CurrentPageReference)
    // getStateParameters(currentPageReference) {
    //         console.log(111);
    //         console.log(currentPageReference);
        // 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') || '';
    }
    connectedCallback(){
    }
    //     if (currentPageReference) {
    //         const urlValue = currentPageReference.state.recordId;
    //         if (urlValue) {
    //         let str = `${urlValue}`;
    //         console.log("str");
    //         console.log(str);
    //         this.oppId = str;
    //         }
    //     }
    // }
    // 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");
    //             }
    //         });
    //     });
    // }
    getParamValue(paramName) {
        // Use the URLSearchParams API to get the value of a query parameter
@@ -51,28 +86,57 @@
    }
    saveJs() {
        this.blockMyself();
        save();
        save().then(result=>{
            if(result){
                this.showToast(result,"success");
                this.unblock();
                this.clearBrandMannualName();
            }
        })
    }
    addBrandJs() {
        this.blockMyself();
        addBrand();
        addBrand().then(()=>{
            this.unblock();
        });
    }
    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')
                    }
                });
                this.unblock();
            }
        });
    }
    addProductJs(number) {
        this.blockMyself();
        addProduct(number);
        addProduct().then(()=>{
            this.unblock();
        });
    }
    RemoveJs(number) {
        this.blockMyself();
        Remove(number);
        Remove().then(()=>{
            this.unblock();
        });
    }
    // add tcm 20211118 start
    searchJs(topNum, secondNum) {
        this.blockMyself();
        search(topNum, secondNum);
        search().then(()=>{
            this.unblock();
        });
    }
    blockMyself(){
        Promise.all([
@@ -86,6 +150,22 @@
            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() {
        return this.pageStatus === 'Create' || this.pageStatus === 'Edit';
    }
    
    // add tcm 20211118 end
@@ -121,11 +201,16 @@
    }
    setBrandName(brandNumber) {
        this.blockMyself();
        setbrand(brandNumber);
        setbrand().then(()=>{
            this.clearBrandMannualName();
            this.unblock();
        });
    }
    setBrandMannualName(brandNumber) {
        this.blockMyself();
        setbrandmannual(brandNumber);
        setbrandmannual().then(()=>{
            this.unblock();
        });
    }
    // 失单品牌不等于其他时,失单品牌(手动)清空并且不允许填写,失单品牌等于其他时,失单对手型号不可用  thh 2022-01-13 start
    clearBrandMannualName(){
@@ -146,4 +231,14 @@
            }
        });
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}