fix:刷新crud未执行切刷新service的问题

This commit is contained in:
lvxiaojiao 2024-04-24 16:11:09 +08:00
parent 1cb5f905b6
commit 6279ca0c0e
6 changed files with 28 additions and 48 deletions

View File

@ -2762,7 +2762,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
headerToolbarRender: this.renderHeaderToolbar,
footerToolbarRender: this.renderFooterToolbar,
data: store.mergedData,
loading: store.loading
loading: store.loading,
host: this
}
)}
{render(

View File

@ -1381,7 +1381,8 @@ export default class CRUD2 extends React.Component<CRUD2Props, any> {
onSort: this.handleQuerySearch,
onSelect: this.handleSelect,
data: store.mergedData,
loading: store.loading
loading: store.loading,
host: this
}
)}
{/* spinner可以交给孩子处理 */}

View File

@ -1123,11 +1123,9 @@ export class CardsRenderer extends Cards {
* Cards在scope上注册getComponentByName查询组件时会优先找到CardsCRUD联动的动作都会失效
* CRUD处理
*/
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给Cards这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.receive?.(values, subPath);
if (this.props?.host) {
// CRUD会把自己透传给Cards这样可以保证找到CRUD
return this.props.host.receive?.(values, subPath);
}
if (subPath) {
@ -1151,13 +1149,10 @@ export class CardsRenderer extends Cards {
}
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给Cards这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.reload?.(subPath, query, ctx);
if (this.props?.host) {
// CRUD会把自己透传给Cards这样可以保证找到CRUD
return this.props.host.reload?.(subPath, query, ctx);
}
if (subPath) {

View File

@ -1112,17 +1112,14 @@ export class ListRenderer extends List {
receive(values: any, subPath?: string) {
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
/**
* List在scope上注册getComponentByName查询组件时会优先找到ListCRUD联动的动作都会失效
* CRUD处理
*/
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给List这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.receive?.(values, subPath);
if (this.props?.host) {
// CRUD会把自己透传给List这样可以保证找到CRUD
return this.props.host.receive?.(values, subPath);
}
if (subPath) {
@ -1146,13 +1143,10 @@ export class ListRenderer extends List {
}
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给List这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.reload?.(subPath, query, ctx);
if (this.props?.host) {
// CRUD会把自己透传给List这样可以保证找到CRUD
return this.props?.host.reload?.(subPath, query, ctx);
}
if (subPath) {

View File

@ -2842,17 +2842,14 @@ export default class Table extends React.Component<TableProps, object> {
export class TableRenderer extends Table {
receive(values: any, subPath?: string) {
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
/**
* Table在scope上注册getComponentByName查询组件时会优先找到TableCRUD联动的动作都会失效
* CRUD处理
*/
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给Table这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.receive?.(values, subPath);
if (this.props?.host) {
// CRUD会把自己透传给Table这样可以保证找到CRUD
return this.props.host.receive?.(values, subPath);
}
if (subPath) {
@ -2904,13 +2901,10 @@ export class TableRenderer extends Table {
}
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给Table这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.reload?.(subPath, query, ctx);
if (this.props?.host) {
// CRUD会把自己透传给Table这样可以保证找到CRUD
return this.props.host.reload?.(subPath, query, ctx);
}
if (subPath) {

View File

@ -2131,17 +2131,14 @@ export default class Table2 extends React.Component<Table2Props, object> {
export class TableRenderer extends Table2 {
receive(values: any, subPath?: string) {
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
/**
* Table在scope上注册getComponentByName查询组件时会优先找到TableCRUD联动的动作都会失效
* CRUD处理
*/
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给Table这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.receive?.(values, subPath);
if (this.props?.host) {
// CRUD会把自己透传给Table这样可以保证找到CRUD
return this.props.host.receive?.(values, subPath);
}
if (subPath) {
@ -2153,11 +2150,9 @@ export class TableRenderer extends Table2 {
const scoped = this.context as IScopedContext;
const parents = scoped?.parent?.getComponents();
if (Array.isArray(parents) && parents.length) {
// CRUD的name会透传给Table这样可以保证找到CRUD
const crud = parents.find(cmpt => cmpt?.props?.name === this.props?.name);
return crud?.reload?.(subPath, query, ctx);
if (this.props?.host) {
// CRUD会把自己透传给Table这样可以保证找到CRUD
return this.props.host.reload?.(subPath, query, ctx);
}
if (subPath) {