| | |
| | | import { LightningElement,wire,api,track } from 'lwc'; |
| | | import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | // import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | import { NavigationMixin } from 'lightning/navigation'; |
| | | import initPage from '@salesforce/apex/TopPageLwcController.initPage'; |
| | | // 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; |
| | | // @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); |
| | | } |
| | | }); |
| | | } |
| | | // 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; |
| | | } |
| | | // 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 = '<table border="0" cellpadding="0" cellspacing="0" class="list" Id = "tab1"><tr class="headerRow"><th>产品型号</th><th>库存下限</th><th>库存上限</th></tr>'; |
| | | for (var i = 0; i < csv_data.length; i++) { |
| | | table = table + '<tr class="dataRow">'; |
| | | var row = csv_data[i]; |
| | | for (var j = 0; j < row.length; j++) { |
| | | table = table + '<td class="dataCell" style="text-align: center" id = "input' + j +'">'; |
| | | var colu = row[j]; |
| | | table = table + colu + '</td>'; |
| | | } |
| | | table = table + '</tr>'; |
| | | } |
| | | var table = table + '</table>'; |
| | | return table; |
| | | } |
| | | // function productLimitTableJs(str){ |
| | | // var csv_data = new Array(); |
| | | // if(str != null && str != ''){ |
| | | // csv_data = productlist(str); |
| | | // } |
| | | // var table = '<table border="0" cellpadding="0" cellspacing="0" class="list" Id = "tab1"><tr class="headerRow"><th>产品型号</th><th>库存下限</th><th>库存上限</th></tr>'; |
| | | // for (var i = 0; i < csv_data.length; i++) { |
| | | // table = table + '<tr class="dataRow">'; |
| | | // var row = csv_data[i]; |
| | | // for (var j = 0; j < row.length; j++) { |
| | | // table = table + '<td class="dataCell" style="text-align: center" id = "input' + j +'">'; |
| | | // var colu = row[j]; |
| | | // table = table + colu + '</td>'; |
| | | // } |
| | | // table = table + '</tr>'; |
| | | // } |
| | | // var table = table + '</table>'; |
| | | // 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; |
| | | } |
| | | } |
| | | // 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); |
| | | } |
| | | // editProductLimit(event){ |
| | | // const config = { |
| | | // type: 'standard__webPage', |
| | | // attributes: { |
| | | // url: '/LexProductLimitEdit' |
| | | // } |
| | | // }; |
| | | // this[NavigationMixin.Navigate](config); |
| | | // } |
| | | } |