更新了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 { 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 (<Space wrap>
|
||||
|
|
@ -21,6 +21,9 @@ function RenderRow(props) {
|
|||
{value}
|
||||
</Tag>;
|
||||
}
|
||||
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 (<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>);
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
|||
* @param path
|
||||
*/
|
||||
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;
|
||||
operation: ED[keyof ED]['Operation'];
|
||||
}>): Promise<{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
|||
* @param path
|
||||
*/
|
||||
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;
|
||||
operation: ED[keyof ED]['Operation'];
|
||||
}>): Promise<{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
</Tag>
|
||||
}
|
||||
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}
|
||||
/>
|
||||
</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,
|
||||
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<ED extends EntityDict & BaseEntityDict> 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<ED extends EntityDict & BaseEntityDict> 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<ED extends EntityDict & BaseEntityDict> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,12 +91,14 @@ export function resolvePath<ED extends EntityDict & BaseEntityDict>(
|
|||
}
|
||||
} 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++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue