From 0f44cb1a0b7b36860e9ce81c1eac9e395d87f0b4 Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期一, 05 六月 2023 13:53:18 +0800 Subject: [PATCH] mergecode into lex dtt --- force-app/main/default/lwc/lexRemoveBox/lexRemoveBox.js | 109 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 66 insertions(+), 43 deletions(-) diff --git a/force-app/main/default/lwc/lexRemoveBox/lexRemoveBox.js b/force-app/main/default/lwc/lexRemoveBox/lexRemoveBox.js index df28e08..81ca3e2 100644 --- a/force-app/main/default/lwc/lexRemoveBox/lexRemoveBox.js +++ b/force-app/main/default/lwc/lexRemoveBox/lexRemoveBox.js @@ -4,45 +4,53 @@ import saveconfirm from '@salesforce/apex/LexRemoveBoxController.removeBoxConfirm'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; // import { NavigationMixin } from 'lightning/navigation'; +//table css +import { loadStyle } from "lightning/platformResourceLoader"; +import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable"; const columns = [ { label: '娑堣�楀搧鍚嶇О', fieldName: 'Name__c', - initialWidth: 350, + wrapText:true, + hideDefaultActions: true, + initialWidth: 400, }, { label: '瑙勬牸', fieldName: 'ProductPacking_list_manual__c', hideDefaultActions: true, - initialWidth: 250, + initialWidth: 50, + cellAttributes: { alignment: "right" }, + }, { label: 'CFDA鐘舵��', fieldName: 'CFDA_Status__c', hideDefaultActions: true, - initialWidth: 250, + initialWidth: 200, }, { label: '娉ㄥ唽璇佺紪鐮佸彿', fieldName: 'Report_Product_Approbation__c', hideDefaultActions: true, - initialWidth: 250, + initialWidth: 200, }, { label: '娉ㄥ唽璇佹晥鏈�', fieldName: 'Report_Product_Expiration__c', hideDefaultActions: true, - initialWidth: 250, + // initialWidth: 250, }, { label: 'BarCode', fieldName: 'Bar_Code__c', hideDefaultActions: true, - initialWidth: 250, + wrapText:true, + initialWidth:400, } ]; @@ -50,12 +58,14 @@ { label: '娑堣�楀搧鍚嶇О', fieldName: 'Name__c', + hideDefaultActions: true, }, { label: 'BarCode', fieldName: 'Bar_Code__c', hideDefaultActions: true, + } , @@ -83,11 +93,23 @@ @track agencyProType @track barcode = '' @track saveFLGbln = false + @track dataSize = 0; //鍔犺浇妗� @track showSpinner = false - + renderedCallback() { + if (!this.stylesLoaded) { + Promise.all([loadStyle(this, WrappedHeaderTable)]) + .then(() => { + console.log("Custom styles loaded"); + this.stylesLoaded = true; + }) + .catch((error) => { + console.error("Error loading custom styles"); + }); + } +} //鍒濆鍖� connectedCallback() { @@ -105,13 +127,7 @@ // this.data = JSON.parse(result.entity.codPageRecords); // this.showTable = true; } else { - console.log('result.msg = ' + result.msg); - const evt = new ShowToastEvent({ - title: '褰曞叆澶辫触', - message: result.msg, - variant: 'error' - }); - this.dispatchEvent(evt); + this.showMyToast('鍒濆鍖栧け璐�',result.msg,'error'); } }).catch((error) => { console.log('error = ' + JSON.stringify(error)); @@ -131,6 +147,8 @@ console.log('鎴愬姛'); this.data = JSON.parse(result.entity.ConsumableorderdetailsRecordsdummy); this.errorDetail = JSON.parse(result.entity.ConsumableorderdetailsRecordserror); + this.dataSize = result.entity.dataSize; + console.log('this.dataSize'+this.dataSize); for (let i in this.data) { this.data[i]['Name__c'] = this.data[i].Prod.Name__c; this.data[i]['ProductPacking_list_manual__c'] = this.data[i].esd.ProductPacking_list_manual__c; @@ -139,21 +157,16 @@ this.data[i]['Report_Product_Expiration__c'] = this.data[i].esd.Report_Product_Expiration__c; this.data[i]['Bar_Code__c'] = this.data[i].esd.Bar_Code__c; } - this.showTable = true; for (let i in this.errorDetail) { this.errorDetail[i]['Name__c'] = this.errorDetail[i].Prod.Name__c; this.errorDetail[i]['Bar_Code__c'] = this.errorDetail[i].esd.Bar_Code__c; this.errorDetail[i]['ErrorReason'] = this.errorDetail[i].ErrorReason; } this.showTables = true; + this.showTable = true; } else{ console.log('result.msg = ' + result.msg); - const evt = new ShowToastEvent({ - title: '鑾峰彇澶辫触', - message: result.msg, - variant: 'error' - }); - this.dispatchEvent(evt); + this.showMyToast('鑾峰彇澶辫触',result.msg,'error'); } }).catch((error) => { console.log('error = ' + JSON.stringify(error)); @@ -169,11 +182,18 @@ } saveConfirm() { console.log('杩涘叆纭'); - if(this.data!=''){ - alert('纭鎷嗙洅鍚�'); - + let msg = "纭鎷嗙洅鍚�"; + if (this.dataSize>0) { + if (confirm(msg) == true) { + this.removeBox(); + } + } else { + this.removeBox(); } - // this.showSpinner = true; + + } + removeBox(){ + this.showSpinner = true; saveconfirm({ saveConsumableorderdetailsRecordsdummy: JSON.stringify(this.data), accountName: this.accountName, @@ -186,34 +206,37 @@ this.saveFLGbln = result.entity.saveFLGbln; // this.showSpinner = false; if(this.saveFLGbln){ - const evt = new ShowToastEvent({ - title: '鎴愬姛', - message: result.msg, - variant: 'Success' - }); - this.dispatchEvent(evt); - - + this.showMyToast(result.msg,'','success'); + this.showSpinner = false; } } else { console.log('result.msg = ' + result.msg); - const evt = new ShowToastEvent({ - title: '澶辫触', - message: result.msg, - variant: 'error' - }); - this.dispatchEvent(evt); + this.showMyToast('鎷嗙洅澶辫触',result.msg,'error'); + this.showSpinner = false; } }) .catch((error) => { console.log('error = ' + JSON.stringify(error)); }); + } - - - - + 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); + } -- Gitblit v1.9.1