重写了sort对于statuscreateAtstatus和enum属性的判定
This commit is contained in:
parent
fa9e8db57e
commit
d586cdea03
52
es/store.js
52
es/store.js
|
|
@ -1023,24 +1023,44 @@ export default class TreeStore extends CascadeStore {
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
if (v1 > v2) {
|
||||
if (direction === 'desc') {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (v1 < v2) {
|
||||
if (direction === 'desc') {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
const attrDef = this.getSchema()[entity2].attributes[attr];
|
||||
// 处理enum,现在enum是按定义enum的顺序从小到大排列
|
||||
if (attrDef?.type === 'enum') {
|
||||
const enums = attrDef.enumeration;
|
||||
const i1 = enums.indexOf(v1);
|
||||
const i2 = enums.indexOf(v2);
|
||||
assert(i1 >= 0 && i2 >= 0);
|
||||
return direction === 'asc' ? i1 - i2 : i2 - i1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
// createAt为1时被认为是最大的(新建)
|
||||
if (['$$createAt$$', '$$updateAt$$'].includes(attr)) {
|
||||
if (v1 === 1) {
|
||||
return direction === 'asc' ? 1 : -1;
|
||||
}
|
||||
else if (v2 === 1) {
|
||||
return direction === 'asc' ? -1 : 1;
|
||||
}
|
||||
}
|
||||
if (v1 > v2) {
|
||||
if (direction === 'desc') {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (v1 < v2) {
|
||||
if (direction === 'desc') {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
52
lib/store.js
52
lib/store.js
|
|
@ -1025,24 +1025,44 @@ class TreeStore extends CascadeStore_1.CascadeStore {
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
if (v1 > v2) {
|
||||
if (direction === 'desc') {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (v1 < v2) {
|
||||
if (direction === 'desc') {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
const attrDef = this.getSchema()[entity2].attributes[attr];
|
||||
// 处理enum,现在enum是按定义enum的顺序从小到大排列
|
||||
if (attrDef?.type === 'enum') {
|
||||
const enums = attrDef.enumeration;
|
||||
const i1 = enums.indexOf(v1);
|
||||
const i2 = enums.indexOf(v2);
|
||||
(0, assert_1.assert)(i1 >= 0 && i2 >= 0);
|
||||
return direction === 'asc' ? i1 - i2 : i2 - i1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
// createAt为1时被认为是最大的(新建)
|
||||
if (['$$createAt$$', '$$updateAt$$'].includes(attr)) {
|
||||
if (v1 === 1) {
|
||||
return direction === 'asc' ? 1 : -1;
|
||||
}
|
||||
else if (v2 === 1) {
|
||||
return direction === 'asc' ? -1 : 1;
|
||||
}
|
||||
}
|
||||
if (v1 > v2) {
|
||||
if (direction === 'desc') {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (v1 < v2) {
|
||||
if (direction === 'desc') {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
53
src/store.ts
53
src/store.ts
|
|
@ -1229,24 +1229,45 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
if (v1 > v2) {
|
||||
if (direction === 'desc') {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (v1 < v2) {
|
||||
if (direction === 'desc') {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const attrDef = this.getSchema()[entity2].attributes[attr];
|
||||
// 处理enum,现在enum是按定义enum的顺序从小到大排列
|
||||
if (attrDef?.type === 'enum') {
|
||||
const enums = attrDef!.enumeration!;
|
||||
const i1 = enums.indexOf(v1);
|
||||
const i2 = enums.indexOf(v2);
|
||||
assert(i1 >= 0 && i2 >= 0);
|
||||
return direction === 'asc' ? i1 - i2 : i2 - i1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
// createAt为1时被认为是最大的(新建)
|
||||
if (['$$createAt$$', '$$updateAt$$'].includes(attr)) {
|
||||
if (v1 === 1) {
|
||||
return direction === 'asc' ? 1 : -1;
|
||||
}
|
||||
else if (v2 === 1) {
|
||||
return direction === 'asc' ? -1 : 1;
|
||||
}
|
||||
}
|
||||
if (v1 > v2) {
|
||||
if (direction === 'desc') {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (v1 < v2) {
|
||||
if (direction === 'desc') {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue