提交 d4869208 编写于 作者: 杨广俊's avatar 杨广俊

排序bug

上级 cc1edb0b
...@@ -64,6 +64,7 @@ export function deepCopy(obj) { ...@@ -64,6 +64,7 @@ export function deepCopy(obj) {
* @param {Function} converFun 字段转换函数 * @param {Function} converFun 字段转换函数
*/ */
export function arraySort(originData, isUp = true, sortedField, converFun) { export function arraySort(originData, isUp = true, sortedField, converFun) {
// debugger
let sortedData = originData.slice(), swap, sourceA, sourceB; let sortedData = originData.slice(), swap, sourceA, sourceB;
for(let i = 0; i < sortedData.length - 1; i ++) { for(let i = 0; i < sortedData.length - 1; i ++) {
for(let j = 0; j < sortedData.length - i -1; j++) { for(let j = 0; j < sortedData.length - i -1; j++) {
...@@ -85,7 +86,7 @@ export function arraySort(originData, isUp = true, sortedField, converFun) { ...@@ -85,7 +86,7 @@ export function arraySort(originData, isUp = true, sortedField, converFun) {
sourceA = 0 sourceA = 0
sourceB = 0 sourceB = 0
} }
if(isUp) { if(isUp) {
if(sourceA - 0 > sourceB - 0) { if(sourceA - 0 > sourceB - 0) {
swap = sortedData[j] swap = sortedData[j]
sortedData[j] = sortedData[j + 1] sortedData[j] = sortedData[j + 1]
......
...@@ -166,7 +166,11 @@ export default { ...@@ -166,7 +166,11 @@ export default {
orderAction(orderName, isSortUp) { orderAction(orderName, isSortUp) {
let orderType = isSortUp ? -1 : 1; let orderType = isSortUp ? -1 : 1;
let orderData = this.oldParmDataDoctList.slice(); let orderData = this.oldParmDataDoctList.slice();
if(orderName === "newTime") { if(orderName === "doctorFirstNameChar") {
orderData = arraySort(orderData, isSortUp, orderName, (fieldValue) => {
return fieldValue.charCodeAt(0)
})
} else if(orderName === "newTime") {
orderData = arraySort(orderData, isSortUp, orderName, (fieldValue) => { orderData = arraySort(orderData, isSortUp, orderName, (fieldValue) => {
return new Date(fieldValue.replace(/-/g, "/")).getTime() / 1000 return new Date(fieldValue.replace(/-/g, "/")).getTime() / 1000
}) })
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册