import { LightningElement,wire,api,track } from 'lwc'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { NavigationMixin } from 'lightning/navigation'; import initPage from '@salesforce/apex/TopPageLwcController.initPage'; export default class TopPageLwc extends NavigationMixin(LightningElement) { @track title = []; @track raesList = []; @track column = []; @track overlimitdateorderdetails = []; @track accountInfo; @track accountId; @track pageRecords = []; @track csvData = []; @track product_Limit; @track over_view = false; @track overlimit = false; @track hasHos = false; @track activeSections = ['A', 'B','C']; @track isRender = false; @track consumableorderdetailsRecordsview; connectedCallback(){ initPage() .then(result=>{ if(result.result == 'Success'){ this.title = result.title; this.raesList = result.raesList; this.column = result.column; this.accountInfo = result.accountInfo; this.accountId = result.accountInfo.Id; this.pageRecords = result.pageRecords; this.overlimitdateorderdetails = result.overlimitdateorderdetails; this.over_view = result.over_view; this.overlimit = result.overlimit; this.hasHos = result.hasHos; this.product_Limit = result.product_Limit; this.consumableorderdetailsRecordsview = result.consumableorderdetailsRecordsview; console.log('this.accountId:'+this.accountId); console.log('this.accountInfo:'+JSON.stringify(this.accountInfo)); }else{ console.log("Error:"+result.errorMsg); const evt = new ShowToastEvent({ title : '初始化页面失败', message: result.errorMsg, variant: 'error' }); this.dispatchEvent(evt); } }); } renderedCallback(){ if(!this.isRender){ this.isRender = true; var tableStr = productLimitTableJs(this.product_Limit); const container = this.template.querySelector('div.resultDiv'); container.innerHTML = tableStr; } function productLimitTableJs(str){ var csv_data = new Array(); if(str != null && str != ''){ csv_data = productlist(str); } var table = ''; for (var i = 0; i < csv_data.length; i++) { table = table + ''; var row = csv_data[i]; for (var j = 0; j < row.length; j++) { table = table + ''; } table = table + ''; } var table = table + '
产品型号库存下限库存上限
'; var colu = row[j]; table = table + colu + '
'; return table; } function productlist(text_data) { var records = new Array(); var record = new Array(); var column = new Array(); var quot_flg = false; for (var i = 0; i < text_data.size(); i++) { var ch = text_data.charAt(i); if (ch == ',') { if (quot_flg) { column.push(','); } else { record.push(column.join('')); column = new Array(); records.push(record); record = new Array(); } } else if (ch == '|') { if (quot_flg) { column.push('|'); } else { record.push(column.join('')); column = new Array(); } } else if (ch == '"') { if (quot_flg) { if ((i + 1) < text_data.size() && text_data.charAt((i + 1)) == '"') { i++; column.push('"'); } else { quot_flg = false; } } else { quot_flg = true; } } else { column.push(ch); } } if (record.length != 0) { record.push(column.join('')); records.push(record); } return records; } } editProductLimit(event){ const config = { type: 'standard__webPage', attributes: { url: '/LexProductLimitEdit' } }; this[NavigationMixin.Navigate](config); } }