Files
django-vue3-admin-gd/backend/system/management/commands/tpl/frontend_data.ts.tpl
2025-07-01 11:58:13 +08:00

79 lines
2.0 KiB
Smarty
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
import type { VbenFormSchema } from '#/adapter/form';
import type { OnActionClickFn } from '#/adapter/vxe-table';
import type { ${app_name_camel}${model_name}Api } from '#/models/$app_name/${model_name_snake}';
import { z } from '#/adapter/form';
import { $$t } from '#/locales';
import { format_datetime } from '#/utils/date';
/**
* 获取编辑表单的字段配置
*/
export function useSchema(): VbenFormSchema[] {
return [
$form_fields
];
}
export function useColumns(
onActionClick?: OnActionClickFn<${app_name_camel}${model_name}Api.${app_name_camel}${model_name}>,
): VxeTableGridOptions<${app_name_camel}${model_name}Api.${app_name_camel}${model_name}>['columns'] {
return [
{
align: 'left',
field: 'id',
},
{
cellRender: {
name: 'CellTag',
options: [
{ label: $$t('common.enabled'), value: true },
{ label: $$t('common.disabled'), value: false },
],
},
field: 'status',
title: '状态',
width: 100,
},
{
field: 'remark',
title: '备注',
},
{
field: 'create_time',
title: '创建时间',
width: 180,
formatter: ({ cellValue }) => format_datetime(cellValue),
},
{
align: 'right',
cellRender: {
attrs: {
nameField: 'name',
nameTitle: $$t('${app_name}.{model_name_snake}.name'),
onClick: onActionClick,
},
name: 'CellOperation',
options: [
'edit', //
{
code: 'view', // code
text: '数据', //
},
{
code: 'delete', //
},
],
},
field: 'operation',
fixed: 'right',
headerAlign: 'center',
showOverflow: false,
title: '操作',
width: 200,
},
];
}