更新了filter中原本不能处理一对多的情况
This commit is contained in:
parent
fcab7b6c75
commit
3f79d9d572
|
|
@ -3,7 +3,7 @@ import { Tag, Descriptions, Image, Space } from 'antd';
|
||||||
import { getLabel, getType, getValue } from '../../utils/usefulFn';
|
import { getLabel, getType, getValue } from '../../utils/usefulFn';
|
||||||
import { get } from 'oak-domain/lib/utils/lodash';
|
import { get } from 'oak-domain/lib/utils/lodash';
|
||||||
function RenderRow(props) {
|
function RenderRow(props) {
|
||||||
const { type, value, color } = props;
|
const { type, value, color, t } = props;
|
||||||
if (type === 'image') {
|
if (type === 'image') {
|
||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
return (<Space wrap>
|
return (<Space wrap>
|
||||||
|
|
@ -21,6 +21,9 @@ function RenderRow(props) {
|
||||||
{value}
|
{value}
|
||||||
</Tag>;
|
</Tag>;
|
||||||
}
|
}
|
||||||
|
if (['boolean', 'bool'].includes(type)) {
|
||||||
|
return value ? t('common::yes') : t('common:no');
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
export default function Render(props) {
|
export default function Render(props) {
|
||||||
|
|
@ -38,7 +41,7 @@ export default function Render(props) {
|
||||||
const stateValue = get(data, ele.path);
|
const stateValue = get(data, ele.path);
|
||||||
const color = getColor(ele.attr, stateValue) || 'default';
|
const color = getColor(ele.attr, stateValue) || 'default';
|
||||||
return (<Descriptions.Item key={index} label={renderLabel} span={ele.attribute.span || 1}>
|
return (<Descriptions.Item key={index} label={renderLabel} span={ele.attribute.span || 1}>
|
||||||
<RenderRow type={renderType} value={renderValue} color={color}/>
|
<RenderRow type={renderType} value={renderValue} color={color} t={t}/>
|
||||||
</Descriptions.Item>);
|
</Descriptions.Item>);
|
||||||
})}
|
})}
|
||||||
</Descriptions>);
|
</Descriptions>);
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
||||||
* @param path
|
* @param path
|
||||||
*/
|
*/
|
||||||
redoBranchModis(path: string): void;
|
redoBranchModis(path: string): void;
|
||||||
execute<T extends keyof ED>(path: string, action?: ED[T]['Action'], opers?: Array<{
|
execute<T extends keyof ED>(path?: string, action?: ED[T]['Action'], opers?: Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}>): Promise<{
|
}>): Promise<{
|
||||||
|
|
|
||||||
|
|
@ -2382,12 +2382,12 @@ export class RunningTree extends Feature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async execute(path, action, opers) {
|
async execute(path, action, opers) {
|
||||||
const node = this.findNode(path);
|
const node = path && this.findNode(path);
|
||||||
// assert(node.isDirty());
|
// assert(node.isDirty());
|
||||||
node.setExecuting(true);
|
node && node.setExecuting(true);
|
||||||
let pollute = false;
|
let pollute = false;
|
||||||
try {
|
try {
|
||||||
let operations = this.getOperations(path) || [];
|
let operations = path && this.getOperations(path) || [];
|
||||||
if (opers) {
|
if (opers) {
|
||||||
operations.push(...opers);
|
operations.push(...opers);
|
||||||
}
|
}
|
||||||
|
|
@ -2401,7 +2401,7 @@ export class RunningTree extends Feature {
|
||||||
operation1.operation.action = action;
|
operation1.operation.action = action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (node) {
|
||||||
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
||||||
assert(node instanceof SingleNode);
|
assert(node instanceof SingleNode);
|
||||||
node.update(this.logSerailNumber, {}, action);
|
node.update(this.logSerailNumber, {}, action);
|
||||||
|
|
@ -2422,8 +2422,8 @@ export class RunningTree extends Feature {
|
||||||
.filter((ele) => !!ele)
|
.filter((ele) => !!ele)
|
||||||
.map((ele) => ele.operation), undefined, () => {
|
.map((ele) => ele.operation), undefined, () => {
|
||||||
// 清空缓存
|
// 清空缓存
|
||||||
this.clean(path, undefined, true);
|
path && this.clean(path, undefined, true);
|
||||||
if (node instanceof SingleNode) {
|
if (node && node instanceof SingleNode) {
|
||||||
assert(operations.length === 1);
|
assert(operations.length === 1);
|
||||||
// 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108
|
// 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108
|
||||||
// if (operations[0].operation.action === 'create') {
|
// if (operations[0].operation.action === 'create') {
|
||||||
|
|
@ -2432,18 +2432,18 @@ export class RunningTree extends Feature {
|
||||||
// node.setId(id);
|
// node.setId(id);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
this.clean(path, undefined, true);
|
path && this.clean(path, undefined, true);
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
return { message: 'No Operation' };
|
return { message: 'No Operation' };
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
if (pollute) {
|
if (pollute) {
|
||||||
this.clean(path);
|
path && this.clean(path);
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,14 +61,17 @@ export function resolvePath(dataSchema, entity, path) {
|
||||||
}
|
}
|
||||||
else if (relation === 2) {
|
else if (relation === 2) {
|
||||||
// entity entityId
|
// entity entityId
|
||||||
if (attr === 'entityId') {
|
|
||||||
attrType = 'ref';
|
|
||||||
}
|
|
||||||
_entity = attr;
|
_entity = attr;
|
||||||
}
|
}
|
||||||
else if (typeof relation === 'string') {
|
else if (typeof relation === 'string') {
|
||||||
_entity = relation;
|
_entity = relation;
|
||||||
}
|
}
|
||||||
|
else if (relation instanceof Array) {
|
||||||
|
_entity = relation[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(relation === -1);
|
||||||
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
||||||
* @param path
|
* @param path
|
||||||
*/
|
*/
|
||||||
redoBranchModis(path: string): void;
|
redoBranchModis(path: string): void;
|
||||||
execute<T extends keyof ED>(path: string, action?: ED[T]['Action'], opers?: Array<{
|
execute<T extends keyof ED>(path?: string, action?: ED[T]['Action'], opers?: Array<{
|
||||||
entity: keyof ED;
|
entity: keyof ED;
|
||||||
operation: ED[keyof ED]['Operation'];
|
operation: ED[keyof ED]['Operation'];
|
||||||
}>): Promise<{
|
}>): Promise<{
|
||||||
|
|
|
||||||
|
|
@ -2385,12 +2385,12 @@ class RunningTree extends Feature_1.Feature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async execute(path, action, opers) {
|
async execute(path, action, opers) {
|
||||||
const node = this.findNode(path);
|
const node = path && this.findNode(path);
|
||||||
// assert(node.isDirty());
|
// assert(node.isDirty());
|
||||||
node.setExecuting(true);
|
node && node.setExecuting(true);
|
||||||
let pollute = false;
|
let pollute = false;
|
||||||
try {
|
try {
|
||||||
let operations = this.getOperations(path) || [];
|
let operations = path && this.getOperations(path) || [];
|
||||||
if (opers) {
|
if (opers) {
|
||||||
operations.push(...opers);
|
operations.push(...opers);
|
||||||
}
|
}
|
||||||
|
|
@ -2404,7 +2404,7 @@ class RunningTree extends Feature_1.Feature {
|
||||||
operation1.operation.action = action;
|
operation1.operation.action = action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (node) {
|
||||||
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
||||||
(0, assert_1.assert)(node instanceof SingleNode);
|
(0, assert_1.assert)(node instanceof SingleNode);
|
||||||
node.update(this.logSerailNumber, {}, action);
|
node.update(this.logSerailNumber, {}, action);
|
||||||
|
|
@ -2425,8 +2425,8 @@ class RunningTree extends Feature_1.Feature {
|
||||||
.filter((ele) => !!ele)
|
.filter((ele) => !!ele)
|
||||||
.map((ele) => ele.operation), undefined, () => {
|
.map((ele) => ele.operation), undefined, () => {
|
||||||
// 清空缓存
|
// 清空缓存
|
||||||
this.clean(path, undefined, true);
|
path && this.clean(path, undefined, true);
|
||||||
if (node instanceof SingleNode) {
|
if (node && node instanceof SingleNode) {
|
||||||
(0, assert_1.assert)(operations.length === 1);
|
(0, assert_1.assert)(operations.length === 1);
|
||||||
// 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108
|
// 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108
|
||||||
// if (operations[0].operation.action === 'create') {
|
// if (operations[0].operation.action === 'create') {
|
||||||
|
|
@ -2435,18 +2435,18 @@ class RunningTree extends Feature_1.Feature {
|
||||||
// node.setId(id);
|
// node.setId(id);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
this.clean(path, undefined, true);
|
path && this.clean(path, undefined, true);
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
return { message: 'No Operation' };
|
return { message: 'No Operation' };
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
if (pollute) {
|
if (pollute) {
|
||||||
this.clean(path);
|
path && this.clean(path);
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,17 @@ function resolvePath(dataSchema, entity, path) {
|
||||||
}
|
}
|
||||||
else if (relation === 2) {
|
else if (relation === 2) {
|
||||||
// entity entityId
|
// entity entityId
|
||||||
if (attr === 'entityId') {
|
|
||||||
attrType = 'ref';
|
|
||||||
}
|
|
||||||
_entity = attr;
|
_entity = attr;
|
||||||
}
|
}
|
||||||
else if (typeof relation === 'string') {
|
else if (typeof relation === 'string') {
|
||||||
_entity = relation;
|
_entity = relation;
|
||||||
}
|
}
|
||||||
|
else if (relation instanceof Array) {
|
||||||
|
_entity = relation[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(0, assert_1.assert)(relation === -1);
|
||||||
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ import { getLabel, getType, getValue, getWidth } from '../../utils/usefulFn';
|
||||||
import { get } from 'oak-domain/lib/utils/lodash';
|
import { get } from 'oak-domain/lib/utils/lodash';
|
||||||
|
|
||||||
|
|
||||||
function RenderRow(props: { value: any; color: string; type: AttrRender['type'] }) {
|
function RenderRow(props: { value: any; color: string; type: AttrRender['type'], t: (k: string) => string }) {
|
||||||
const { type, value, color } = props;
|
const { type, value, color, t } = props;
|
||||||
if (type === 'image') {
|
if (type === 'image') {
|
||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -38,6 +38,9 @@ function RenderRow(props: { value: any; color: string; type: AttrRender['type']
|
||||||
{value}
|
{value}
|
||||||
</Tag>
|
</Tag>
|
||||||
}
|
}
|
||||||
|
if (['boolean', 'bool'].includes(type)) {
|
||||||
|
return value ? t('common::yes') : t('common:no');
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,6 +118,7 @@ export default function Render(
|
||||||
type={renderType!}
|
type={renderType!}
|
||||||
value={renderValue}
|
value={renderValue}
|
||||||
color={color}
|
color={color}
|
||||||
|
t={t}
|
||||||
/>
|
/>
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2926,18 +2926,18 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute<T extends keyof ED>(path: string, action?: ED[T]['Action'], opers?: Array<{
|
async execute<T extends keyof ED>(path?: string, action?: ED[T]['Action'], opers?: Array<{
|
||||||
entity: keyof ED,
|
entity: keyof ED,
|
||||||
operation: ED[keyof ED]['Operation'],
|
operation: ED[keyof ED]['Operation'],
|
||||||
}>) {
|
}>) {
|
||||||
const node = this.findNode(path)!;
|
const node = path && this.findNode(path)!;
|
||||||
// assert(node.isDirty());
|
// assert(node.isDirty());
|
||||||
|
|
||||||
node.setExecuting(true);
|
node && node.setExecuting(true);
|
||||||
|
|
||||||
let pollute = false;
|
let pollute = false;
|
||||||
try {
|
try {
|
||||||
let operations = this.getOperations(path) || [];
|
let operations = path && this.getOperations(path) || [];
|
||||||
if (opers) {
|
if (opers) {
|
||||||
operations.push(...opers);
|
operations.push(...opers);
|
||||||
}
|
}
|
||||||
|
|
@ -2952,7 +2952,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
||||||
operation1.operation.action = action;
|
operation1.operation.action = action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (node) {
|
||||||
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
||||||
assert(node instanceof SingleNode);
|
assert(node instanceof SingleNode);
|
||||||
node.update(this.logSerailNumber, {}, action);
|
node.update(this.logSerailNumber, {}, action);
|
||||||
|
|
@ -2980,8 +2980,8 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
||||||
undefined,
|
undefined,
|
||||||
() => {
|
() => {
|
||||||
// 清空缓存
|
// 清空缓存
|
||||||
this.clean(path, undefined, true);
|
path && this.clean(path, undefined, true);
|
||||||
if (node instanceof SingleNode) {
|
if (node && node instanceof SingleNode) {
|
||||||
assert(operations.length === 1);
|
assert(operations.length === 1);
|
||||||
// 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108
|
// 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108
|
||||||
// if (operations[0].operation.action === 'create') {
|
// if (operations[0].operation.action === 'create') {
|
||||||
|
|
@ -2990,21 +2990,21 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
||||||
// node.setId(id);
|
// node.setId(id);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
this.clean(path, undefined, true);
|
path && this.clean(path, undefined, true);
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
|
|
||||||
return { message: 'No Operation' };
|
return { message: 'No Operation' };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.setExecuting(false);
|
node && node.setExecuting(false);
|
||||||
if (pollute) {
|
if (pollute) {
|
||||||
this.clean(path);
|
path && this.clean(path);
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,14 @@ export function resolvePath<ED extends EntityDict & BaseEntityDict>(
|
||||||
}
|
}
|
||||||
} else if (relation === 2) {
|
} else if (relation === 2) {
|
||||||
// entity entityId
|
// entity entityId
|
||||||
if (attr === 'entityId') {
|
|
||||||
attrType = 'ref';
|
|
||||||
}
|
|
||||||
_entity = attr as keyof ED;
|
_entity = attr as keyof ED;
|
||||||
} else if (typeof relation === 'string') {
|
} else if (typeof relation === 'string') {
|
||||||
_entity = relation as keyof ED;
|
_entity = relation as keyof ED;
|
||||||
|
} else if (relation instanceof Array) {
|
||||||
|
_entity = relation[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert(relation === -1);
|
||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue