buli
2023-05-30 41ad0c0840a6135b7acf2280f0eebdc29bf6479b
force-app/main/default/lwc/lexProductLimitEdit/lexProductLimitEdit.js
@@ -93,18 +93,21 @@
            console.log('数字'+this.isNum(this.invRecords[i]["inventory1"]));
            if(this.isNum(this.invRecords[i]["inventory1"]) == false || this.isNum(this.invRecords[i]["inventory2"]==false)){
                alert("输入格式不正确,请输入数字!");
                // alert("输入格式不正确,请输入数字!");
                this.showMyToast('保存失败','输入格式不正确,请输入数字','error');
                this.showSpinner = false;
                return;
            }
            if(this.invRecords[i]["inventory1"] == ''||this.invRecords[i]["inventory1"] == null ||this.invRecords[i]["inventory2"] == null ||
            this.invRecords[i]["inventory2"] == ''){
                alert('请输入' +this.invRecords[i]["productNumber"] + '库存上下限信息!');
                // alert('请输入' +this.invRecords[i]["productNumber"] + '库存上下限信息!');
                this.showMyToast('保存失败','请输入' +this.invRecords[i]["productNumber"] + '库存上下限信息','error');
                this.showSpinner = false;
                return;
            }
            if(Number(this.invRecords[i]["inventory1"])>Number(this.invRecords[i]["inventory2"])){
                alert( this.invRecords[i]["productNumber"]  + '库存下限大于上限!');
                // alert( this.invRecords[i]["productNumber"]  + '库存下限大于上限!');
                this.showMyToast('保存失败',this.invRecords[i]["productNumber"]  + '库存下限大于上限','error');
                this.showSpinner = false;
                return;
            }
@@ -122,28 +125,17 @@
                userPro_Type:this.userPro_Type
            }).then((result) => {
                result = JSON.parse(JSON.stringify(result));
                console.log('result'+JSON.stringify(result));
                console.log('result===>'+JSON.stringify(result));
                if(result.status == 'Success'){
                    const evt = new ShowToastEvent({
                  title: "保存成功",
                  message: result.msg,
                  variant: "Success",
               });
               this.dispatchEvent(evt);
                    this.showMyToast('保存成功','','success');
                    this.showSpinner = false;
                    this[NavigationMixin.Navigate]({
                        type: 'standard__webPage',
                        attributes: {
                            url: '/lextoppage'
                        }
                    });
                    // setTimeout(this.toLexToppage(),5000 );
                    setTimeout(() => {
                        this.toLexToppage();
                    }, 500);
                }else{
                    const evt = new ShowToastEvent({
                  title: "保存失败",
                  message: result.msg,
                  variant: "Error",
               });
               this.dispatchEvent(evt);
                    this.showMyToast('保存失败',result.msg,'error');
                    this.showSpinner = false;
                }
@@ -174,4 +166,28 @@
    var reNum =/^[0-9]+$/;
    return (reNum.test(num));
    }
    showMyToast(title, message, variant) {
        console.log('show custom message');
        var iconName = '';
        var content = '';
        if(variant == 'success'){
           iconName = 'utility:check';
        }else{
           iconName = 'utility:error';
        }
        if(message != ''){
           content = '<h2><strong>'+title+'<strong/></h2><h5>'+message+'</h5>';
        }else{
           content = '<h2><strong>'+title+'<strong/></h2>';
        }
        this.template.querySelector('c-common-toast').showToast(variant,content,iconName,10000);
        }
        toLexToppage(){
            this[NavigationMixin.Navigate]({
                type: 'standard__webPage',
                attributes: {
                    url: '/lextoppage'
                }
            });
        }
}