usefulFn中过去几个没有处理的exception
This commit is contained in:
parent
4363f9de3e
commit
050219aae0
|
|
@ -45,44 +45,31 @@ export function resolvePath(dataSchema, entity, path) {
|
||||||
idx++;
|
idx++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
const relation = judgeRelation(dataSchema, _entity, attr, true);
|
||||||
const relation = judgeRelation(dataSchema, _entity, attr);
|
if (relation === 1) {
|
||||||
if (relation === 1) {
|
const attributes = getAttributes(dataSchema[_entity].attributes);
|
||||||
const attributes = getAttributes(dataSchema[_entity].attributes);
|
attribute = attributes[attr];
|
||||||
attribute = attributes[attr];
|
attrType = attribute.type;
|
||||||
attrType = attribute.type;
|
if (attr === 'id') {
|
||||||
if (attr === 'id') {
|
attrType = 'ref';
|
||||||
attrType = 'ref';
|
}
|
||||||
}
|
else {
|
||||||
else {
|
if (attrType === 'ref') {
|
||||||
if (attrType === 'ref') {
|
attr = attribute.ref;
|
||||||
attr = attribute.ref;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (relation === 2) {
|
|
||||||
// entity entityId
|
|
||||||
if (attr === 'entityId') {
|
|
||||||
attrType = 'ref';
|
|
||||||
}
|
|
||||||
_entity = attr;
|
|
||||||
}
|
|
||||||
else if (typeof relation === 'string') {
|
|
||||||
_entity = relation;
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
}
|
||||||
catch (err) {
|
else if (relation === 2) {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
// entity entityId
|
||||||
console.warn(`存在非「${_entity}」schema属性: ${path}`);
|
if (attr === 'entityId') {
|
||||||
|
attrType = 'ref';
|
||||||
}
|
}
|
||||||
return {
|
_entity = attr;
|
||||||
entity: 'notExist',
|
|
||||||
attr: path,
|
|
||||||
attrType: undefined,
|
|
||||||
attribute,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
else if (typeof relation === 'string') {
|
||||||
|
_entity = relation;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
entity: _entity,
|
entity: _entity,
|
||||||
|
|
@ -123,11 +110,15 @@ export function getLabel(attribute, entity, attr, t) {
|
||||||
}
|
}
|
||||||
if (attr === '$$createAt$$' ||
|
if (attr === '$$createAt$$' ||
|
||||||
attr === '$$updateAt$$' ||
|
attr === '$$updateAt$$' ||
|
||||||
attr === '$$deleteAt$$') {
|
attr === '$$deleteAt$$' ||
|
||||||
|
attr === '$$seq$$') {
|
||||||
return t(`common::${attr}`, {
|
return t(`common::${attr}`, {
|
||||||
'#oakModule': 'oak-frontend-base',
|
'#oakModule': 'oak-frontend-base',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (attr === 'id') {
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
return t(`${entity}:attr.${attr}`, {});
|
return t(`${entity}:attr.${attr}`, {});
|
||||||
}
|
}
|
||||||
// 目前width属性可以是undefined,只有特殊type或用户自定义才有值,这样其余attr属性可以自适应
|
// 目前width属性可以是undefined,只有特殊type或用户自定义才有值,这样其余attr属性可以自适应
|
||||||
|
|
|
||||||
|
|
@ -50,44 +50,31 @@ function resolvePath(dataSchema, entity, path) {
|
||||||
idx++;
|
idx++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
const relation = (0, relation_1.judgeRelation)(dataSchema, _entity, attr, true);
|
||||||
const relation = (0, relation_1.judgeRelation)(dataSchema, _entity, attr);
|
if (relation === 1) {
|
||||||
if (relation === 1) {
|
const attributes = getAttributes(dataSchema[_entity].attributes);
|
||||||
const attributes = getAttributes(dataSchema[_entity].attributes);
|
attribute = attributes[attr];
|
||||||
attribute = attributes[attr];
|
attrType = attribute.type;
|
||||||
attrType = attribute.type;
|
if (attr === 'id') {
|
||||||
if (attr === 'id') {
|
attrType = 'ref';
|
||||||
attrType = 'ref';
|
}
|
||||||
}
|
else {
|
||||||
else {
|
if (attrType === 'ref') {
|
||||||
if (attrType === 'ref') {
|
attr = attribute.ref;
|
||||||
attr = attribute.ref;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (relation === 2) {
|
|
||||||
// entity entityId
|
|
||||||
if (attr === 'entityId') {
|
|
||||||
attrType = 'ref';
|
|
||||||
}
|
|
||||||
_entity = attr;
|
|
||||||
}
|
|
||||||
else if (typeof relation === 'string') {
|
|
||||||
_entity = relation;
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
}
|
||||||
catch (err) {
|
else if (relation === 2) {
|
||||||
if (process.env.NODE_ENV === 'development') {
|
// entity entityId
|
||||||
console.warn(`存在非「${_entity}」schema属性: ${path}`);
|
if (attr === 'entityId') {
|
||||||
|
attrType = 'ref';
|
||||||
}
|
}
|
||||||
return {
|
_entity = attr;
|
||||||
entity: 'notExist',
|
|
||||||
attr: path,
|
|
||||||
attrType: undefined,
|
|
||||||
attribute,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
else if (typeof relation === 'string') {
|
||||||
|
_entity = relation;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
entity: _entity,
|
entity: _entity,
|
||||||
|
|
@ -131,11 +118,15 @@ function getLabel(attribute, entity, attr, t) {
|
||||||
}
|
}
|
||||||
if (attr === '$$createAt$$' ||
|
if (attr === '$$createAt$$' ||
|
||||||
attr === '$$updateAt$$' ||
|
attr === '$$updateAt$$' ||
|
||||||
attr === '$$deleteAt$$') {
|
attr === '$$deleteAt$$' ||
|
||||||
|
attr === '$$seq$$') {
|
||||||
return t(`common::${attr}`, {
|
return t(`common::${attr}`, {
|
||||||
'#oakModule': 'oak-frontend-base',
|
'#oakModule': 'oak-frontend-base',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (attr === 'id') {
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
return t(`${entity}:attr.${attr}`, {});
|
return t(`${entity}:attr.${attr}`, {});
|
||||||
}
|
}
|
||||||
exports.getLabel = getLabel;
|
exports.getLabel = getLabel;
|
||||||
|
|
|
||||||
|
|
@ -85,42 +85,30 @@ export function resolvePath<ED extends EntityDict & BaseEntityDict>(
|
||||||
idx++;
|
idx++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
const relation = judgeRelation(dataSchema, _entity, attr, true);
|
||||||
const relation = judgeRelation(dataSchema, _entity, attr);
|
if (relation === 1) {
|
||||||
if (relation === 1) {
|
const attributes = getAttributes(
|
||||||
const attributes = getAttributes(
|
dataSchema[_entity].attributes
|
||||||
dataSchema[_entity].attributes
|
);
|
||||||
);
|
attribute = attributes[attr];
|
||||||
attribute = attributes[attr];
|
attrType = attribute.type;
|
||||||
attrType = attribute.type;
|
if (attr === 'id') {
|
||||||
if (attr === 'id') {
|
attrType = 'ref';
|
||||||
attrType = 'ref';
|
} else {
|
||||||
} else {
|
if (attrType === 'ref') {
|
||||||
if (attrType === 'ref') {
|
attr = attribute.ref as string;
|
||||||
attr = attribute.ref as string;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (relation === 2) {
|
|
||||||
// entity entityId
|
|
||||||
if (attr === 'entityId') {
|
|
||||||
attrType = 'ref';
|
|
||||||
}
|
|
||||||
_entity = attr as keyof ED;
|
|
||||||
} else if (typeof relation === 'string') {
|
|
||||||
_entity = relation as keyof ED;
|
|
||||||
}
|
}
|
||||||
idx++;
|
} else if (relation === 2) {
|
||||||
} catch (err) {
|
// entity entityId
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (attr === 'entityId') {
|
||||||
console.warn(`存在非「${_entity as string}」schema属性: ${path}`);
|
attrType = 'ref';
|
||||||
}
|
}
|
||||||
return {
|
_entity = attr as keyof ED;
|
||||||
entity: 'notExist',
|
} else if (typeof relation === 'string') {
|
||||||
attr: path,
|
_entity = relation as keyof ED;
|
||||||
attrType: undefined,
|
|
||||||
attribute,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
entity: _entity,
|
entity: _entity,
|
||||||
|
|
@ -174,12 +162,16 @@ export function getLabel<ED extends EntityDict & BaseEntityDict>(
|
||||||
if (
|
if (
|
||||||
attr === '$$createAt$$' ||
|
attr === '$$createAt$$' ||
|
||||||
attr === '$$updateAt$$' ||
|
attr === '$$updateAt$$' ||
|
||||||
attr === '$$deleteAt$$'
|
attr === '$$deleteAt$$' ||
|
||||||
|
attr === '$$seq$$'
|
||||||
) {
|
) {
|
||||||
return t(`common::${attr}`, {
|
return t(`common::${attr}`, {
|
||||||
'#oakModule': 'oak-frontend-base',
|
'#oakModule': 'oak-frontend-base',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (attr === 'id') {
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
return t(`${entity as string}:attr.${attr}`, {});
|
return t(`${entity as string}:attr.${attr}`, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue