import { LightningElement, wire, api, track } from 'lwc'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { NavigationMixin } from 'lightning/navigation'; import initPage from '@salesforce/apex/LexConsumableOrderManageController.init1'; import searchConsumableorderdetails from '@salesforce/apex/LexConsumableOrderManageController.searchConsumableorderdetails'; //table css import { loadStyle } from 'lightning/platformResourceLoader'; import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable'; export default class LexConsumableOrderManage extends NavigationMixin( LightningElement ) { @track category1; @track orderDate; @track orderStatus = ''; @track provinceOpts = []; @track raesList = []; @track title = []; @track agencyProType; @track accountid; @track userWorkLocation; @track hasHop = false; @track showHop = false; @track hasSpecial = false; @track cols = []; @track showSpinner = false; @track showPage = false; stylesLoaded = false; //是否一直显示提示 @track isNoteStay = true; connectedCallback() { this.showSpinner = true; initPage() .then((result) => { this.isNoteStay = result.isNoteStay; if (result.result == 'Success') { this.provinceOpts = result.provinceOpts; this.title = result.title; this.raesList = result.raesList; this.agencyProType = result.agencyProType; this.accountid = result.accountid; this.userWorkLocation = result.userWorkLocation; this.hasHop = result.hasHop; this.hasSpecial = result.hasSpecial; this.cols = result.cols; if (this.hasHop == true && this.agencyProType == 'ENG') { this.showHop = true; } for (var i in this.raesList) { if (this.raesList[i].Order_ForHospital__c) { this.raesList[i]['hosUrl'] = '/s/detail/' + this.raesList[i].Order_ForHospital__c; this.raesList[i]['hosName'] = this.raesList[i].Order_ForHospital__r.Name; } this.raesList[i]['nameUrl'] = '/s/lexconsumable?ESetid=' + this.raesList[i].Id; } this.showSpinner = false; this.showPage = true; } else { this.showSpinner = false; console.log('Error:' + result.errorMsg); const evt = new ShowToastEvent({ title: '初始化页面失败', message: result.errorMsg, variant: 'error' }); this.dispatchEvent(evt); } }) .catch((error) => { this.showSpinner = false; console.log('Error:' + error); }); } 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'); }); } } category1Change(event) { this.category1 = event.detail.value; console.log('category1:' + this.category1); } orderDateChange(event) { this.orderDate = event.detail.value; console.log('orderDate:' + this.orderDate); } orderStatusChange(event) { this.orderStatus = event.detail.value; console.log('orderStatus:' + this.orderStatus); } agreementorder(event) { const config = { type: 'standard__webPage', attributes: { url: '/lexconsumable?type=agreementorder' } }; this[NavigationMixin.Navigate](config); } hospitalorder(event) { const config = { type: 'standard__webPage', attributes: { url: '/lexconsumable?type=hospitalorder' } }; this[NavigationMixin.Navigate](config); } promotionorder(event) { const config = { type: 'standard__webPage', attributes: { url: '/lexconsumable?type=promotionorder' } }; this[NavigationMixin.Navigate](config); } searchProduct(event) { this.showSpinner = true; searchConsumableorderdetails({ categoryStr: this.category1, orderDate: this.orderDate, orderStatus: this.orderStatus, accountidStr: this.accountid, agencyProTypeStr: this.agencyProType, userWorkLocationStr: this.userWorkLocation }).then((result) => { if (result.result == 'Success') { this.raesList = result.raesList; for (var i in this.raesList) { if (this.raesList[i].Order_ForHospital__c) { this.raesList[i]['hosUrl'] = '/s/detail/' + this.raesList[i].Order_ForHospital__c; this.raesList[i]['hosName'] = this.raesList[i].Order_ForHospital__r.Name; } this.raesList[i]['nameUrl'] = '/s/lexconsumable?ESetid=' + this.raesList[i].Id; } this.showSpinner = false; this.showMyToast('搜索成功', result.errorMsg, 'success'); } else { this.showSpinner = false; this.raesList = result.raesList; console.log('Error:' + result.errorMsg); if (result.errorMsg == '没有搜索到相关订单') { this.showMyToast(result.errorMsg, '', 'error'); } else { this.showMyToast('搜索失败', result.errorMsg, 'error'); } this.dispatchEvent(evt); } }); } clear(event) { this.category1 = ''; this.orderDate = null; this.orderStatus = ''; searchConsumableorderdetails({ categoryStr: this.category1, orderDate: this.orderDate, orderStatus: this.orderStatus, accountidStr: this.accountid, agencyProTypeStr: this.agencyProType, userWorkLocationStr: this.userWorkLocation }).then((result) => { if (result.result == 'Success') { this.raesList = result.raesList; for (var i in this.raesList) { if (this.raesList[i].Order_ForHospital__c) { this.raesList[i]['hosUrl'] = '/s/detail/' + this.raesList[i].Order_ForHospital__c; this.raesList[i]['hosName'] = this.raesList[i].Order_ForHospital__r.Name; } this.raesList[i]['nameUrl'] = '/s/lexconsumable?ESetid=' + this.raesList[i].Id; } this.showMyToast('搜索成功', result.errorMsg, 'success'); } else { this.raesList = result.raesList; console.log('Error:' + result.errorMsg); if (result.errorMsg == '没有搜索到相关订单') { this.showMyToast(result.errorMsg, '', 'error'); } else { this.showMyToast('搜索失败', result.errorMsg, 'error'); } this.dispatchEvent(evt); } }); } 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 = '