mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:57:20 +00:00
feat: add actionDefaultParams to views
This commit is contained in:
parent
71024dbaa0
commit
4bc2df296d
@ -17,13 +17,13 @@ export function Details(props: any) {
|
|||||||
associatedKey,
|
associatedKey,
|
||||||
resourceKey,
|
resourceKey,
|
||||||
} = props;
|
} = props;
|
||||||
const { actions = [], fields = [] } = props.schema;
|
const { actions = [], actionDefaultParams = {}, fields = [] } = props.schema;
|
||||||
const { data = {}, loading, refresh } = useRequest(() => {
|
const { data = {}, loading, refresh } = useRequest(() => {
|
||||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||||
return api.resource(name).get({
|
return api.resource(name).get({
|
||||||
resourceKey,
|
resourceKey,
|
||||||
associatedKey,
|
associatedKey,
|
||||||
'fields[appends]': fields.filter(field => get(field, 'interface') === 'subTable').map(field => field.name).join(',')
|
...actionDefaultParams,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
console.log(props);
|
console.log(props);
|
||||||
|
@ -12,7 +12,9 @@ import {
|
|||||||
registerFormFields,
|
registerFormFields,
|
||||||
FormValidator,
|
FormValidator,
|
||||||
setValidationLanguage,
|
setValidationLanguage,
|
||||||
|
FormEffectHooks,
|
||||||
} from '@formily/antd';
|
} from '@formily/antd';
|
||||||
|
import { merge } from '@formily/shared';
|
||||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||||
import { useRequest } from 'umi';
|
import { useRequest } from 'umi';
|
||||||
import api from '@/api-client';
|
import api from '@/api-client';
|
||||||
@ -30,6 +32,7 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
|||||||
onFinish,
|
onFinish,
|
||||||
} = props;
|
} = props;
|
||||||
console.log(associatedKey);
|
console.log(associatedKey);
|
||||||
|
const { title, actionDefaultParams = {}, fields: properties ={} } = props.schema||{};
|
||||||
const [resourceKey, setResourceKey] = useState(props.resourceKey);
|
const [resourceKey, setResourceKey] = useState(props.resourceKey);
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||||
@ -38,6 +41,7 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
|||||||
return api.resource(name).get({
|
return api.resource(name).get({
|
||||||
resourceKey,
|
resourceKey,
|
||||||
associatedKey,
|
associatedKey,
|
||||||
|
...actionDefaultParams,
|
||||||
});
|
});
|
||||||
}, {
|
}, {
|
||||||
manual: true,
|
manual: true,
|
||||||
@ -47,7 +51,6 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
|||||||
getData: run,
|
getData: run,
|
||||||
}));
|
}));
|
||||||
const actions = createFormActions();
|
const actions = createFormActions();
|
||||||
const { title, fields: properties ={} } = props.schema||{};
|
|
||||||
console.log({onFinish});
|
console.log({onFinish});
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
|
@ -25,7 +25,7 @@ export function SimpleTable(props: SimpleTableProps) {
|
|||||||
associatedName,
|
associatedName,
|
||||||
associatedKey,
|
associatedKey,
|
||||||
} = props;
|
} = props;
|
||||||
const { rowKey = 'id', name: viewName, fields = [], rowViewName, actions = [], paginated = true, defaultPerPage = 10 } = schema;
|
const { rowKey = 'id', name: viewName, actionDefaultParams = {}, fields = [], rowViewName, actions = [], paginated = true, defaultPerPage = 10 } = schema;
|
||||||
const { sourceKey = 'id' } = activeTab.field||{};
|
const { sourceKey = 'id' } = activeTab.field||{};
|
||||||
const drawerRef = useRef<any>();
|
const drawerRef = useRef<any>();
|
||||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||||
@ -38,6 +38,7 @@ export function SimpleTable(props: SimpleTableProps) {
|
|||||||
sorter,
|
sorter,
|
||||||
filter,
|
filter,
|
||||||
viewName,
|
viewName,
|
||||||
|
...actionDefaultParams,
|
||||||
})
|
})
|
||||||
.then(({data = [], meta = {}}) => {
|
.then(({data = [], meta = {}}) => {
|
||||||
return {
|
return {
|
||||||
|
@ -23,7 +23,7 @@ export function Table(props: TableProps) {
|
|||||||
associatedName,
|
associatedName,
|
||||||
associatedKey,
|
associatedKey,
|
||||||
} = props;
|
} = props;
|
||||||
const { name: viewName, fields, defaultTabName, rowKey = 'id', actions = [], paginated = true, defaultPerPage = 10 } = schema;
|
const { name: viewName, fields, actionDefaultParams = {}, defaultTabName, rowKey = 'id', actions = [], paginated = true, defaultPerPage = 10 } = schema;
|
||||||
// const { data, mutate } = useRequest(() => api.resource(name).list({
|
// const { data, mutate } = useRequest(() => api.resource(name).list({
|
||||||
// associatedKey,
|
// associatedKey,
|
||||||
// }));
|
// }));
|
||||||
@ -38,6 +38,7 @@ export function Table(props: TableProps) {
|
|||||||
sorter,
|
sorter,
|
||||||
filter,
|
filter,
|
||||||
viewName,
|
viewName,
|
||||||
|
...actionDefaultParams,
|
||||||
// ...args2,
|
// ...args2,
|
||||||
})
|
})
|
||||||
.then(({data = [], meta = {}}) => {
|
.then(({data = [], meta = {}}) => {
|
||||||
|
@ -192,9 +192,13 @@ export default async (ctx, next) => {
|
|||||||
} else {
|
} else {
|
||||||
title = `创建${title}`;
|
title = `创建${title}`;
|
||||||
}
|
}
|
||||||
|
const actionDefaultParams:any = {};
|
||||||
|
const appends = fields.filter(field => get(field, 'interface') === 'subTable').map(field => field.name).join(',');
|
||||||
|
actionDefaultParams['fields[appends]'] = appends;
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
...view.get(),
|
...view.get(),
|
||||||
title,
|
title,
|
||||||
|
actionDefaultParams,
|
||||||
original: fields,
|
original: fields,
|
||||||
fields: await (transforms[view.type]||transforms.table)(fields, ctx),
|
fields: await (transforms[view.type]||transforms.table)(fields, ctx),
|
||||||
actions: actions.filter(action => actionNames.includes(action.name)).map(action => ({
|
actions: actions.filter(action => actionNames.includes(action.name)).map(action => ({
|
||||||
|
Loading…
Reference in New Issue
Block a user