mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:45:18 +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,
|
||||
resourceKey,
|
||||
} = props;
|
||||
const { actions = [], fields = [] } = props.schema;
|
||||
const { actions = [], actionDefaultParams = {}, fields = [] } = props.schema;
|
||||
const { data = {}, loading, refresh } = useRequest(() => {
|
||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||
return api.resource(name).get({
|
||||
resourceKey,
|
||||
associatedKey,
|
||||
'fields[appends]': fields.filter(field => get(field, 'interface') === 'subTable').map(field => field.name).join(',')
|
||||
...actionDefaultParams,
|
||||
});
|
||||
});
|
||||
console.log(props);
|
||||
|
@ -12,7 +12,9 @@ import {
|
||||
registerFormFields,
|
||||
FormValidator,
|
||||
setValidationLanguage,
|
||||
FormEffectHooks,
|
||||
} from '@formily/antd';
|
||||
import { merge } from '@formily/shared';
|
||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import { useRequest } from 'umi';
|
||||
import api from '@/api-client';
|
||||
@ -30,6 +32,7 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
||||
onFinish,
|
||||
} = props;
|
||||
console.log(associatedKey);
|
||||
const { title, actionDefaultParams = {}, fields: properties ={} } = props.schema||{};
|
||||
const [resourceKey, setResourceKey] = useState(props.resourceKey);
|
||||
const [visible, setVisible] = useState(false);
|
||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||
@ -38,6 +41,7 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
||||
return api.resource(name).get({
|
||||
resourceKey,
|
||||
associatedKey,
|
||||
...actionDefaultParams,
|
||||
});
|
||||
}, {
|
||||
manual: true,
|
||||
@ -47,7 +51,6 @@ export const DrawerForm = forwardRef((props: any, ref) => {
|
||||
getData: run,
|
||||
}));
|
||||
const actions = createFormActions();
|
||||
const { title, fields: properties ={} } = props.schema||{};
|
||||
console.log({onFinish});
|
||||
return (
|
||||
<Drawer
|
||||
|
@ -25,7 +25,7 @@ export function SimpleTable(props: SimpleTableProps) {
|
||||
associatedName,
|
||||
associatedKey,
|
||||
} = 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 drawerRef = useRef<any>();
|
||||
const name = associatedName ? `${associatedName}.${resourceName}` : resourceName;
|
||||
@ -38,6 +38,7 @@ export function SimpleTable(props: SimpleTableProps) {
|
||||
sorter,
|
||||
filter,
|
||||
viewName,
|
||||
...actionDefaultParams,
|
||||
})
|
||||
.then(({data = [], meta = {}}) => {
|
||||
return {
|
||||
|
@ -23,7 +23,7 @@ export function Table(props: TableProps) {
|
||||
associatedName,
|
||||
associatedKey,
|
||||
} = 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({
|
||||
// associatedKey,
|
||||
// }));
|
||||
@ -38,6 +38,7 @@ export function Table(props: TableProps) {
|
||||
sorter,
|
||||
filter,
|
||||
viewName,
|
||||
...actionDefaultParams,
|
||||
// ...args2,
|
||||
})
|
||||
.then(({data = [], meta = {}}) => {
|
||||
|
@ -192,9 +192,13 @@ export default async (ctx, next) => {
|
||||
} else {
|
||||
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 = {
|
||||
...view.get(),
|
||||
title,
|
||||
actionDefaultParams,
|
||||
original: fields,
|
||||
fields: await (transforms[view.type]||transforms.table)(fields, ctx),
|
||||
actions: actions.filter(action => actionNames.includes(action.name)).map(action => ({
|
||||
|
Loading…
Reference in New Issue
Block a user