增加时间排序

master
wuzuowei 8 months ago
parent 6c70d7ef1c
commit e3b0eb1e3d

@ -78,7 +78,46 @@
BindTable();
});
//定义排序函数
function dateData(property, bol) { //property是你需要排序传入的key,bol为true时是升序false为降序
return function (a, b) {
var value1 = a[property];
var value2 = b[property];
// console.log("定义排序函数", a, b, property, bol, value1, Date.parse(value1))
if (bol) {
// 升序
return Date.parse(value1) - Date.parse(value2);
} else {
// 降序
return Date.parse(value2) - Date.parse(value1)
}
}
}
let num =0
function clickSort(type) {
num ++
// console.log("触发点击排序", type)
// console.log("打印数据11111", data); //监听message事件打印一下看数据格式
let value = ""
if (type == "发起日期") {
value ="RDT"
}
if (type == "送达日期") {
value = "ADT"
}
if (num % 2 == 0) {
data.sort(dateData(value, true))
} else {
data.sort(dateData(value, false))
}
// console.log("打印数据33333333333333", data[0], data.sort(dateData("RDT", true))); //监听message事件打印一下看数据格式
BindTable();
}
function SearchIt() {
if (keyword == null)
@ -137,8 +176,8 @@
}
tablet += "<th>" + window.lang.fqrq + "</th>";
tablet += "<th>" + window.lang.sdrq + "</th>";
tablet += "<th onclick=clickSort('发起日期'); style='cursor:pointer'>" + window.lang.fqrq + "</th>";
tablet += "<th onclick=clickSort('送达日期'); style='cursor:pointer'>" + window.lang.sdrq + "</th>";
tablet += "<th>" + window.lang.qixian + "</th>";
tablet += "<th>" + window.lang.zhuangtai + "</th>";
tablet += "<th>" + window.lang.leixing + "</th>";

Loading…
Cancel
Save