buli
2023-07-10 4f200849487fc6f914e237d5af3ecefd6d802457
force-app/main/default/lwc/customShipmentNumberComp/customShipmentNumberComp.js
@@ -1,17 +1,37 @@
import { LightningElement,api,track } from 'lwc';
import { LightningElement, api, track } from 'lwc';
export default class CustomShipmentNumberComp extends LightningElement {
    @api recordId;
    @api shipmentNumber;
    @api isConinvoice;
    @api esdInvoiceProNotCount;
    connectedCallback(){
    connectedCallback() {
        console.log('shipmentNumber = ' + this.shipmentNumber);
    }
    shipmentNumberBlur(event){
    shipmentNumberBlur(event) {
        debugger
        console.log('shipmentNumberBlur')
        this.shipmentNumber = event.target.value;
        if (this.isConinvoice) {
            if (this.hasDecimals(this.shipmentNumber)) {
                this.showMyToast('错误', '请输入整数', 'Error');
                this.shipmentNumber = 0;
            }else{
                if(this.esdInvoiceProNotCount < this.shipmentNumber){
                    this.showMyToast('错误', '发票数量不能超过还没发票数量!', 'Error');
                    this.shipmentNumber = 0;
                }
            }
        } else {
            //向下取整
            if (this.hasDecimals(this.shipmentNumber)) {
                this.showMyToast('错误', '请输入整数', 'Error');
                this.shipmentNumber = Math.floor(this.shipmentNumber)
            }
        }
        event.target.value = this.shipmentNumber;
        this.dispatchEvent(new CustomEvent('shipmentnumber', {
            composed: true,
            bubbles: true,
@@ -21,4 +41,30 @@
            }
        }));
    }
    hasDecimals(num) {
        return !Number.isInteger(Number(num));
    }
    showMyToast(title, message, variant) {
        this.isShowSpinner = false;
        this.showLoadingSpinner = false;
        this.showAttPop = false;
        this.filesUploaded = [];
        this.fileName = null;
        console.log('show custom message');
        var iconName = '';
        var content = '';
        if (variant.toLowerCase() == '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);
    }
}