import { LightningElement, wire, api, track } from 'lwc'; import { NavigationMixin } from 'lightning/navigation'; import init from '@salesforce/apex/LexSaleAndDeliveryController.init'; import { ShowToastEvent } from "lightning/platformShowToastEvent"; import searchOrderInstatus from '@salesforce/apex/LexSaleAndDeliveryController.searchOrderInstatus'; import searchConsumableorderdetails from '@salesforce/apex/LexSaleAndDeliveryController.searchConsumableorderdetails'; import searchConsumableorFinish from '@salesforce/apex/LexSaleAndDeliveryController.searchConsumableorFinish'; const columns = [ { label: '出库日', fieldName: 'Outbound_Date__c', type: 'date', initialWidth : 100, hideDefaultActions: true , sortable: true }, { label: '出库单号', fieldName: 'url', type : 'url', initialWidth : 175, typeAttributes: { label: { fieldName: 'Name' }, target: '_blank' }, hideDefaultActions: true, sortable: true }, { label: '客户名', fieldName: 'ShipmentAccount__c', hideDefaultActions: true , wrapText:true, sortable: true }, { label: '科室', fieldName: 'Order_ForCustomerText__c', hideDefaultActions: true }, { label: '出库单状态', fieldName: 'SummonsStatus_c__c', hideDefaultActions: true , sortable: true, initialWidth : 100 }, { label: '开票状态', fieldName: 'Billed_Status__c', hideDefaultActions: true, sortable: true, initialWidth : 100 }, { label: '未发票金额(元)', fieldName: 'InvoiceNotPro_money__c', hideDefaultActions: true, initialWidth : 150 }, { label: '创建日期', fieldName: 'CreatedDate', hideDefaultActions: true, sortable: true , type: "date", typeAttributes:{ year: "numeric", month: "long", day: "2-digit", hour: "2-digit", minute: "2-digit" }, initialWidth : 200 } ]; const editColumns = [ { label: '出库日', fieldName: 'Outbound_Date__c', type: 'date', hideDefaultActions: true , sortable: true }, { label: '出库单号', fieldName: 'url', type : 'url', typeAttributes: { label: { fieldName: 'Name' }, target: '_blank' }, hideDefaultActions: true, sortable: true }, { label: '客户名', fieldName: 'ShipmentAccount__c', hideDefaultActions: true , sortable: true }, { label: '科室', fieldName: 'Order_ForCustomerText__c', hideDefaultActions: true }, { label: '出库单状态', fieldName: 'SummonsStatus_c__c', hideDefaultActions: true , sortable: true, initialWidth : 100 }, { label: '开票状态', fieldName: 'Billed_Status__c', hideDefaultActions: true, sortable: true, initialWidth : 100 }, { label: '未发票金额(元)', fieldName: 'InvoiceNotPro_money__c', hideDefaultActions: true, initialWidth : 150 }, { label: '创建日期', fieldName: 'CreatedDate', hideDefaultActions: true, sortable: true }, // { // label: '单位', // hideDefaultActions: true, // type:'customUnit', // }, // { // label: '出货数量', // hideDefaultActions: true, // type:'customShipment', // }, // { // label: '出货单价(元)', // hideDefaultActions: true, // type:'customShipmentUnitPrice', // } ]; export default class LexSaleAndDelivery extends NavigationMixin(LightningElement) { columns = columns; @track isShowSpinner = true; @track message = ''; @track deliveryFromDate = ''; @track deliveryToDate = ''; @track deliveryOrderNo = ''; @track contactName = ''; @track data = []; @track userinfoId = ''; @track accountid = ''; @track agencyProType = ''; @track userWorkLocation = ''; @track showTable = false; @track hidecheckboxcolumn = true; //排序 defaultSortDirection = 'asc'; sortDirection = 'asc'; sortedBy; connectedCallback() { init().then((r) => { r = JSON.parse(JSON.stringify(r)); console.log('r = ' + JSON.stringify(r)); if (r.status == 'Success') { this.userinfoId = r.entity.userinfoId; this.accountid = r.entity.accountid; this.agencyProType = r.entity.agencyProType; this.userWorkLocation = r.entity.userWorkLocation; this.data = r.entity.raesList; for(var i in this.data){ this.data[i]['url'] = '/s/lexsummonscreat?ESetid='+this.data[i].Id; } console.log('this.data = ' + JSON.stringify(this.data)); this.isShowSpinner = false; this.showTable = true; } else { console.log('r = ' + JSON.stringify(r)) this.showToast('Error', r.msg); } }).catch((error) => { console.log('error = ' + JSON.stringify(error)) }) } //新建出库单 neworderhead(){ this[NavigationMixin.Navigate]({ type: 'standard__webPage', attributes: { url: '/lexsummonscreat' } }); } //已出库未开票的出库单 searchOrderInstatusJs() { this.isShowSpinner = true; this.showTable = false; console.log('searchOrderInstatusJs'); searchOrderInstatus({ orderDate: this.deliveryFromDate, deliverDate: this.deliveryToDate, accountid: this.accountid, agencyProType: this.agencyProType, userWorkLocation: this.userWorkLocation, category1: this.deliveryOrderNo, category2: this.contactName }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log('r = ' + JSON.stringify(r)); if (r.status == 'Success') { this.data = r.entity.raesList; for(var i in this.data){ this.data[i]['url'] = '/s/lexsummonscreat?ESetid='+this.data[i].Id; } this.message = r.msg; if(this.message == '没有搜索到相关出库单。'){ this.showToast('Error', this.message); }else{ this.showToast('Success', this.message); } this.isShowSpinner = false; this.showTable = true; } else { this.showToast('Error', r.msg); } }).catch((error) => { console.log('error = ' + JSON.stringify(error)) }) } //还没出库的出库单 searchConsumableorderdetailsJs(){ this.isShowSpinner = true; this.showTable = false; console.log('searchConsumableorderdetailsJs'); searchConsumableorderdetails({ orderDate: this.deliveryFromDate, deliverDate: this.deliveryToDate, accountid: this.accountid, agencyProType: this.agencyProType, userWorkLocation: this.userWorkLocation, category1: this.deliveryOrderNo, category2: this.contactName }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log('r = ' + JSON.stringify(r)); if (r.status == 'Success') { this.data = r.entity.raesList; for(var i in this.data){ this.data[i]['url'] = '/s/lexsummonscreat?ESetid='+this.data[i].Id; } this.message = r.msg; if(this.message == '没有搜索到相关出库单。'){ this.showToast('Error', this.message); }else{ this.showToast('Success', this.message); } this.isShowSpinner = false; this.showTable = true; } else { this.showToast('Error', r.msg); } }).catch((error) => { console.log('error = ' + JSON.stringify(error)) }) } //已出库已开票的出库单 searchConsumableorFinishJs(){ this.isShowSpinner = true; this.showTable = false; console.log('searchConsumableorFinishJs'); searchConsumableorFinish({ orderDate: this.deliveryFromDate, deliverDate: this.deliveryToDate, accountid: this.accountid, agencyProType: this.agencyProType, userWorkLocation: this.userWorkLocation, category1: this.deliveryOrderNo, category2: this.contactName }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log('r = ' + JSON.stringify(r)); if (r.status == 'Success') { this.data = r.entity.raesList; for(var i in this.data){ this.data[i]['url'] = '/s/lexsummonscreat?ESetid='+this.data[i].Id; } this.message = r.msg; if(this.message == '没有搜索到相关出库单。'){ this.showToast('Error', this.message); }else{ this.showToast('Success', this.message); } this.isShowSpinner = false; this.showTable = true; } else { this.showToast('Error', r.msg); } }).catch((error) => { console.log('error = ' + JSON.stringify(error)) }) } //清空 clearJs() { this.deliveryFromDate = ''; this.deliveryToDate = ''; this.deliveryOrderNo = ''; this.contactName = ''; } //Capture the event fired from the paginator component handlePaginatorChange(event){ this.recordsToDisplay = event.detail.recordsToDisplay; this.preSelected = event.detail.preSelected; if(this.recordsToDisplay && this.recordsToDisplay > 0){ this.rowNumberOffset = this.recordsToDisplay[0].rowNumber-1; }else{ this.rowNumberOffset = 0; } } //排序 onHandleSort(event) { const { fieldName: sortedBy, sortDirection } = event.detail; const cloneData = [...this.data]; cloneData.sort(this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)); this.data = cloneData; this.sortDirection = sortDirection; this.sortedBy = sortedBy; } sortBy(field, reverse, primer) { const key = primer ? function (x) { return primer(x[field]); } : function (x) { return x[field]; }; return function (a, b) { a = key(a); b = key(b); return reverse * ((a > b) - (b > a)); }; } dataChange(event) { let fieldName = event.target.getAttribute("data-field"); let value = event.detail.value; switch (fieldName) { case 'deliveryFromDate': this.deliveryFromDate = value; break case 'deliveryToDate': this.deliveryToDate = value; break case 'deliveryOrderNo': this.deliveryOrderNo = value; break case 'contactName': this.contactName = value; break default: console.log('no data'); } } editProductLimit(){ this[NavigationMixin.Navigate]({ type: 'standard__webPage', attributes: { url: '/lexoutboundorderimport' } }); } showToast(type, msg) { this.isShowSpinner = false; const event = new ShowToastEvent({ title: type, variant: type, message: msg }); this.dispatchEvent(event); } @track isModalOpen = false; openModal(){ this.isModalOpen = true; } }