From 80a3f59e2d3df07805bc67e329300b8de90a5b3a Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期二, 11 七月 2023 14:13:08 +0800 Subject: [PATCH] Merge branch 'LEXCommunityLiJun' into LEXUpgrade2023-Deloitte --- force-app/main/default/lwc/customShipmentNumberComp/customShipmentNumberComp.js | 88 +++++++++++++++++++++++++++++++++++++------ 1 files changed, 75 insertions(+), 13 deletions(-) diff --git a/force-app/main/default/lwc/customShipmentNumberComp/customShipmentNumberComp.js b/force-app/main/default/lwc/customShipmentNumberComp/customShipmentNumberComp.js index 4b9be8d..b5cad1a 100644 --- a/force-app/main/default/lwc/customShipmentNumberComp/customShipmentNumberComp.js +++ b/force-app/main/default/lwc/customShipmentNumberComp/customShipmentNumberComp.js @@ -1,24 +1,86 @@ -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){ - console.log('shipmentNumberBlur') + shipmentNumberBlur(event) { + debugger; + console.log('shipmentNumberBlur'); this.shipmentNumber = event.target.value; - - this.dispatchEvent(new CustomEvent('shipmentnumber', { - composed: true, - bubbles: true, - cancelable: true, - detail: { - data: { shipmentnumber: this.shipmentNumber, recordId: this.recordId } + 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, + cancelable: true, + detail: { + data: { + shipmentnumber: this.shipmentNumber, + recordId: this.recordId + } + } + }) + ); } -} \ No newline at end of file + + 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); + } +} -- Gitblit v1.9.1