import { LightningElement,track } from 'lwc';
|
|
|
|
export default class NewOrderList extends NavigationMixin(LightningElement) {
|
@track data = [];
|
//排序
|
defaultSortDirection = 'asc';
|
sortDirection = 'asc';
|
sortedBy;
|
|
|
onHandleSort(event) {
|
console.log('===>进入方法');
|
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));
|
};
|
}
|
|
|
// @track orderList =[];
|
// @wire(getOrderList)
|
// result({error,data}){
|
// if(data){
|
// this.orderList = data;
|
// console.log("return is "+this.record);
|
// JSON.stringify("===>data",data);
|
// }
|
// if(error){
|
// this.error= error;
|
// console.log("retrun is "+this.error);
|
// }
|
// }
|
// showDetail(event){
|
// var orderdetailUrl = event.currentTarget.dataset.name;
|
// console.log('===>orderdetailUrl'+orderdetailUrl);
|
// this[NavigationMixin.Navigate]({
|
// type: 'standard__recordPage',
|
// attributes: {
|
// recordId: orderdetailUrl,
|
// objectApiName: 'Consumable_order__c',
|
// actionName: 'view'
|
// }
|
// });
|
// }
|
}
|