web/scripts/openapi/from.ejs

68 lines
1.5 KiB
Plaintext

import { useTable } from '@/components/table';
import { api } from '/api';
const table = useTable({
data: async (data, paging) => {
return <%= select.api %>({ ...data, ...paging });
},
columns: [
<%_ select.columns.forEach(column => { _%>
{
title: '<%= column.title %>',
dataIndex: '<%= column.dataIndex %>',
},
<%_ }) _%>
],
<%_ if (select.items?.length) { _%>
search: {
items: [
<%_ select.items.forEach(column => { _%>
{
field: '<%= column.field %>',
label: '<%= column.label %>',
type: '<%= column.type %>',
},
<%_ }) _%>
]
},
<%_ } _%>
create: {
title: '<%= create.title %>',
modalProps: {
width: 772,
maskClosable: false,
},
formProps: {
layout: "vertical",
class: "!grid grid-cols-2 gap-x-6",
},
items: [
<%_ create.items.forEach(column => { _%>
{
field: '<%= column.field %>',
label: '<%= column.label %>',
type: '<%= column.type %>',
},
<%_ }) _%>
],
submit: async (data) => {
return <%= create.api %>(data);
}
},
modify: {
extend: true,
title: '<%= modify.title %>',
items: [
<%_ modify.items.forEach(column => { _%>
{
field: '<%= column.field %>',
label: '<%= column.label %>',
type: '<%= column.type %>',
},
<%_ }) _%>
],
submit: async (data) => {
return <%= modify.api %>(data);
}
}
})