一些小的修正
This commit is contained in:
parent
e5320e868d
commit
c4971901b8
|
|
@ -219,8 +219,15 @@ class ListNode<ED extends EntityDict,
|
|||
getChild(path: string): SingleNode<ED, T, Cxt, AD> {
|
||||
const idx = parseInt(path, 10);
|
||||
assert(typeof idx === 'number');
|
||||
if (idx < this.children.length) {
|
||||
return this.children[idx];
|
||||
}
|
||||
else {
|
||||
const idx2 = idx - this.children.length;
|
||||
// assert(idx2 < this.newBorn.length); // 在删除结点时可能还是会跑到
|
||||
return this.newBorn[idx2];
|
||||
}
|
||||
}
|
||||
|
||||
getChildren() {
|
||||
return this.children;
|
||||
|
|
@ -242,17 +249,13 @@ class ListNode<ED extends EntityDict,
|
|||
}
|
||||
|
||||
setValue(value: SelectRowShape<ED[T]['OpSchema'], ED[T]['Selection']['data']>[]) {
|
||||
this.children = [];
|
||||
value.forEach(
|
||||
(ele, idx) => {
|
||||
if (this.children[idx]) {
|
||||
this.children[idx].setValue(ele);
|
||||
}
|
||||
else {
|
||||
const node = new SingleNode(this.entity, this.schema, this.cache, this.projection, this.projectionShape, this);
|
||||
this.children[idx] = node;
|
||||
node.setValue(ele);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -686,7 +689,7 @@ class SingleNode<ED extends EntityDict,
|
|||
const projection = await this.getProjection();
|
||||
if (this.id) {
|
||||
this.refreshing = true;
|
||||
const { result: [ value ]} = await this.cache.refresh(this.entity, {
|
||||
const { result: [value] } = await this.cache.refresh(this.entity, {
|
||||
data: projection,
|
||||
filter: {
|
||||
id: this.id,
|
||||
|
|
@ -980,6 +983,7 @@ export class RunningTree<ED extends EntityDict, Cxt extends Context<ED>, AD exte
|
|||
|
||||
async getValue(path: string) {
|
||||
const node = this.findNode(path);
|
||||
if (node) {
|
||||
let value: ReturnType<typeof node.getValue> | undefined = node.getValue();
|
||||
|
||||
if (node.isDirty()) {
|
||||
|
|
@ -990,6 +994,8 @@ export class RunningTree<ED extends EntityDict, Cxt extends Context<ED>, AD exte
|
|||
|
||||
return value instanceof Array ? value : [value];
|
||||
}
|
||||
return [undefined];
|
||||
}
|
||||
|
||||
isDirty(path: string) {
|
||||
const node = this.findNode(path);
|
||||
|
|
@ -1227,7 +1233,7 @@ export class RunningTree<ED extends EntityDict, Cxt extends Context<ED>, AD exte
|
|||
const parentNode = this.findNode(parent);
|
||||
|
||||
const node = parentNode.getChild(path);
|
||||
assert (parentNode instanceof ListNode && node instanceof SingleNode); // 现在应该不可能remove一个list吧,未来对list的处理还要细化
|
||||
assert(parentNode instanceof ListNode && node instanceof SingleNode); // 现在应该不可能remove一个list吧,未来对list的处理还要细化
|
||||
if (node.getValue().id) {
|
||||
// 如果有id,说明是删除数据
|
||||
await this.getAspectProxy().operate({
|
||||
|
|
|
|||
|
|
@ -9,3 +9,4 @@ export * from './types/Feature';
|
|||
export * from './types/ExceptionRoute';
|
||||
export { BasicFeatures } from './features';
|
||||
export * from './features/cache';
|
||||
export * from './features/upload';
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ type OakComponentMethods<ED extends EntityDict, T extends keyof ED> = {
|
|||
subscribed?: () => void;
|
||||
subscribe: () => void;
|
||||
unsubscribe: () => void;
|
||||
reRender: (extra?: any) => Promise<void>;
|
||||
reRender: (extra?: Record<string, any>) => Promise<void>;
|
||||
pushNode: (path?: string, options?: Pick<CreateNodeOptions<ED, keyof ED>, 'updateData' | 'beforeExecute' | 'afterExecute'>) => void;
|
||||
removeNode: (parent: string, path: string) => void;
|
||||
setUpdateData: (attr: string, input: any) => void;
|
||||
|
|
@ -223,7 +223,7 @@ function createPageOptions<ED extends EntityDict,
|
|||
newOakActions: Array,
|
||||
},
|
||||
methods: {
|
||||
async reRender() {
|
||||
async reRender(extra) {
|
||||
if (this.data.oakFullpath) {
|
||||
const $rows = await features.runningTree.getValue(this.data.oakFullpath);
|
||||
const data = await formData.call(this, $rows as any, features);
|
||||
|
|
@ -254,6 +254,9 @@ function createPageOptions<ED extends EntityDict,
|
|||
oakLegalActions,
|
||||
});
|
||||
}
|
||||
if (extra) {
|
||||
assign(data, extra);
|
||||
}
|
||||
|
||||
this.setData(data);
|
||||
}
|
||||
|
|
@ -679,7 +682,7 @@ function createComponentOptions<ED extends EntityDict,
|
|||
}
|
||||
},
|
||||
|
||||
async reRender() {
|
||||
async reRender(extra) {
|
||||
if (this.data.oakFullpath) {
|
||||
const $rows = await features.runningTree.getValue(this.data.oakFullpath);
|
||||
const data = await formData.call(this, $rows as any, features);
|
||||
|
|
@ -711,6 +714,9 @@ function createComponentOptions<ED extends EntityDict,
|
|||
});
|
||||
} */
|
||||
|
||||
if (extra) {
|
||||
assign(data, extra);
|
||||
}
|
||||
this.setData(data);
|
||||
}
|
||||
},
|
||||
|
|
@ -721,7 +727,9 @@ function createComponentOptions<ED extends EntityDict,
|
|||
if (path2 && parent2) {
|
||||
const oakFullpath2 = `${parent2}.${path2}`;
|
||||
if (oakFullpath2 !== this.data.oakFullpath) {
|
||||
this.data.oakFullpath = oakFullpath2;
|
||||
this.setData({
|
||||
oakFullpath: oakFullpath2,
|
||||
});
|
||||
this.reRender();
|
||||
}
|
||||
}
|
||||
|
|
@ -852,7 +860,10 @@ function createComponentOptions<ED extends EntityDict,
|
|||
async ready() {
|
||||
const { oakPath, oakParent } = this.data;
|
||||
if (oakParent && oakPath) {
|
||||
this.data.oakFullpath = `${oakParent}.${oakPath}`;
|
||||
const oakFullpath = `${oakParent}.${oakPath}`;
|
||||
this.setData({
|
||||
oakFullpath,
|
||||
});
|
||||
this.reRender();
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue