diff --git a/es/components/detail/web.pc.js b/es/components/detail/web.pc.js index 369a32c7..e3bbed03 100644 --- a/es/components/detail/web.pc.js +++ b/es/components/detail/web.pc.js @@ -3,7 +3,7 @@ import { Tag, Descriptions, Image, Space } from 'antd'; import { getLabel, getType, getValue } from '../../utils/usefulFn'; import { get } from 'oak-domain/lib/utils/lodash'; function RenderRow(props) { - const { type, value, color } = props; + const { type, value, color, t } = props; if (type === 'image') { if (value instanceof Array) { return ( @@ -21,6 +21,9 @@ function RenderRow(props) { {value} ; } + if (['boolean', 'bool'].includes(type)) { + return value ? t('common::yes') : t('common:no'); + } return value; } export default function Render(props) { @@ -38,7 +41,7 @@ export default function Render(props) { const stateValue = get(data, ele.path); const color = getColor(ele.attr, stateValue) || 'default'; return ( - + ); })} ); diff --git a/es/features/runningTree.d.ts b/es/features/runningTree.d.ts index 35b393e5..fe2bc6e3 100644 --- a/es/features/runningTree.d.ts +++ b/es/features/runningTree.d.ts @@ -363,7 +363,7 @@ export declare class RunningTree extends * @param path */ redoBranchModis(path: string): void; - execute(path: string, action?: ED[T]['Action'], opers?: Array<{ + execute(path?: string, action?: ED[T]['Action'], opers?: Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation']; }>): Promise<{ diff --git a/es/features/runningTree.js b/es/features/runningTree.js index e5f6aedf..def64e65 100644 --- a/es/features/runningTree.js +++ b/es/features/runningTree.js @@ -2382,12 +2382,12 @@ export class RunningTree extends Feature { } } async execute(path, action, opers) { - const node = this.findNode(path); + const node = path && this.findNode(path); // assert(node.isDirty()); - node.setExecuting(true); + node && node.setExecuting(true); let pollute = false; try { - let operations = this.getOperations(path) || []; + let operations = path && this.getOperations(path) || []; if (opers) { operations.push(...opers); } @@ -2401,7 +2401,7 @@ export class RunningTree extends Feature { operation1.operation.action = action; } } - else { + else if (node) { // 老的写法,直接对一个非脏的结点execute某个action,也可以支持 assert(node instanceof SingleNode); node.update(this.logSerailNumber, {}, action); @@ -2422,8 +2422,8 @@ export class RunningTree extends Feature { .filter((ele) => !!ele) .map((ele) => ele.operation), undefined, () => { // 清空缓存 - this.clean(path, undefined, true); - if (node instanceof SingleNode) { + path && this.clean(path, undefined, true); + if (node && node instanceof SingleNode) { assert(operations.length === 1); // 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108 // if (operations[0].operation.action === 'create') { @@ -2432,18 +2432,18 @@ export class RunningTree extends Feature { // node.setId(id); // } } - node.setExecuting(false); + node && node.setExecuting(false); }); return result; } - this.clean(path, undefined, true); - node.setExecuting(false); + path && this.clean(path, undefined, true); + node && node.setExecuting(false); return { message: 'No Operation' }; } catch (err) { - node.setExecuting(false); + node && node.setExecuting(false); if (pollute) { - this.clean(path); + path && this.clean(path); } throw err; } diff --git a/es/utils/usefulFn.js b/es/utils/usefulFn.js index f06c1eb4..14a12a74 100644 --- a/es/utils/usefulFn.js +++ b/es/utils/usefulFn.js @@ -61,14 +61,17 @@ export function resolvePath(dataSchema, entity, path) { } else if (relation === 2) { // entity entityId - if (attr === 'entityId') { - attrType = 'ref'; - } _entity = attr; } else if (typeof relation === 'string') { _entity = relation; } + else if (relation instanceof Array) { + _entity = relation[0]; + } + else { + assert(relation === -1); + } idx++; } return { diff --git a/lib/features/runningTree.d.ts b/lib/features/runningTree.d.ts index 35b393e5..fe2bc6e3 100644 --- a/lib/features/runningTree.d.ts +++ b/lib/features/runningTree.d.ts @@ -363,7 +363,7 @@ export declare class RunningTree extends * @param path */ redoBranchModis(path: string): void; - execute(path: string, action?: ED[T]['Action'], opers?: Array<{ + execute(path?: string, action?: ED[T]['Action'], opers?: Array<{ entity: keyof ED; operation: ED[keyof ED]['Operation']; }>): Promise<{ diff --git a/lib/features/runningTree.js b/lib/features/runningTree.js index 098877b1..03e9823c 100644 --- a/lib/features/runningTree.js +++ b/lib/features/runningTree.js @@ -2385,12 +2385,12 @@ class RunningTree extends Feature_1.Feature { } } async execute(path, action, opers) { - const node = this.findNode(path); + const node = path && this.findNode(path); // assert(node.isDirty()); - node.setExecuting(true); + node && node.setExecuting(true); let pollute = false; try { - let operations = this.getOperations(path) || []; + let operations = path && this.getOperations(path) || []; if (opers) { operations.push(...opers); } @@ -2404,7 +2404,7 @@ class RunningTree extends Feature_1.Feature { operation1.operation.action = action; } } - else { + else if (node) { // 老的写法,直接对一个非脏的结点execute某个action,也可以支持 (0, assert_1.assert)(node instanceof SingleNode); node.update(this.logSerailNumber, {}, action); @@ -2425,8 +2425,8 @@ class RunningTree extends Feature_1.Feature { .filter((ele) => !!ele) .map((ele) => ele.operation), undefined, () => { // 清空缓存 - this.clean(path, undefined, true); - if (node instanceof SingleNode) { + path && this.clean(path, undefined, true); + if (node && node instanceof SingleNode) { (0, assert_1.assert)(operations.length === 1); // 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108 // if (operations[0].operation.action === 'create') { @@ -2435,18 +2435,18 @@ class RunningTree extends Feature_1.Feature { // node.setId(id); // } } - node.setExecuting(false); + node && node.setExecuting(false); }); return result; } - this.clean(path, undefined, true); - node.setExecuting(false); + path && this.clean(path, undefined, true); + node && node.setExecuting(false); return { message: 'No Operation' }; } catch (err) { - node.setExecuting(false); + node && node.setExecuting(false); if (pollute) { - this.clean(path); + path && this.clean(path); } throw err; } diff --git a/lib/utils/usefulFn.js b/lib/utils/usefulFn.js index 176dcd27..bfb5ad0d 100644 --- a/lib/utils/usefulFn.js +++ b/lib/utils/usefulFn.js @@ -66,14 +66,17 @@ function resolvePath(dataSchema, entity, path) { } else if (relation === 2) { // entity entityId - if (attr === 'entityId') { - attrType = 'ref'; - } _entity = attr; } else if (typeof relation === 'string') { _entity = relation; } + else if (relation instanceof Array) { + _entity = relation[0]; + } + else { + (0, assert_1.assert)(relation === -1); + } idx++; } return { diff --git a/src/components/detail/web.pc.tsx b/src/components/detail/web.pc.tsx index c0887b31..022c4485 100644 --- a/src/components/detail/web.pc.tsx +++ b/src/components/detail/web.pc.tsx @@ -13,8 +13,8 @@ import { getLabel, getType, getValue, getWidth } from '../../utils/usefulFn'; import { get } from 'oak-domain/lib/utils/lodash'; -function RenderRow(props: { value: any; color: string; type: AttrRender['type'] }) { - const { type, value, color } = props; +function RenderRow(props: { value: any; color: string; type: AttrRender['type'], t: (k: string) => string }) { + const { type, value, color, t } = props; if (type === 'image') { if (value instanceof Array) { return ( @@ -38,6 +38,9 @@ function RenderRow(props: { value: any; color: string; type: AttrRender['type'] {value} } + if (['boolean', 'bool'].includes(type)) { + return value ? t('common::yes') : t('common:no'); + } return value; } @@ -115,6 +118,7 @@ export default function Render( type={renderType!} value={renderValue} color={color} + t={t} /> ); diff --git a/src/features/runningTree.ts b/src/features/runningTree.ts index 8bfa5dc7..93aed669 100644 --- a/src/features/runningTree.ts +++ b/src/features/runningTree.ts @@ -2926,18 +2926,18 @@ export class RunningTree extends Feature } } - async execute(path: string, action?: ED[T]['Action'], opers?: Array<{ + async execute(path?: string, action?: ED[T]['Action'], opers?: Array<{ entity: keyof ED, operation: ED[keyof ED]['Operation'], }>) { - const node = this.findNode(path)!; + const node = path && this.findNode(path)!; // assert(node.isDirty()); - node.setExecuting(true); + node && node.setExecuting(true); let pollute = false; try { - let operations = this.getOperations(path) || []; + let operations = path && this.getOperations(path) || []; if (opers) { operations.push(...opers); } @@ -2952,7 +2952,7 @@ export class RunningTree extends Feature operation1.operation.action = action; } } - else { + else if (node) { // 老的写法,直接对一个非脏的结点execute某个action,也可以支持 assert(node instanceof SingleNode); node.update(this.logSerailNumber, {}, action); @@ -2980,8 +2980,8 @@ export class RunningTree extends Feature undefined, () => { // 清空缓存 - this.clean(path, undefined, true); - if (node instanceof SingleNode) { + path && this.clean(path, undefined, true); + if (node && node instanceof SingleNode) { assert(operations.length === 1); // 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108 // if (operations[0].operation.action === 'create') { @@ -2990,21 +2990,21 @@ export class RunningTree extends Feature // node.setId(id); // } } - node.setExecuting(false); + node && node.setExecuting(false); } ); return result; } - this.clean(path, undefined, true); - node.setExecuting(false); + path && this.clean(path, undefined, true); + node && node.setExecuting(false); return { message: 'No Operation' }; } catch (err) { - node.setExecuting(false); + node && node.setExecuting(false); if (pollute) { - this.clean(path); + path && this.clean(path); } throw err; } diff --git a/src/utils/usefulFn.ts b/src/utils/usefulFn.ts index d1bb67b4..ffbac214 100644 --- a/src/utils/usefulFn.ts +++ b/src/utils/usefulFn.ts @@ -91,12 +91,14 @@ export function resolvePath( } } 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; + } else if (relation instanceof Array) { + _entity = relation[0]; + } + else { + assert(relation === -1); } idx++; }