|
|
@@ -1,12 +1,16 @@
|
|
|
-import type { VbenFormProps } from '#/adapter/form';
|
|
|
-import type { VxeGridProps } from '#/adapter/vxe-table';
|
|
|
+import type {
|
|
|
+ OnActionClickFn,
|
|
|
+ VbenFormProps,
|
|
|
+ VbenFormSchema,
|
|
|
+ VxeGridProps,
|
|
|
+ VxeTableGridOptions,
|
|
|
+} from '#/adapter';
|
|
|
|
|
|
import { DatabaseApi, TenantApi } from '#/api';
|
|
|
import { dataTypeOptions } from '#/api/model';
|
|
|
|
|
|
-export const searchFormOptions: VbenFormProps = {
|
|
|
- showCollapseButton: false,
|
|
|
- schema: [
|
|
|
+export const useSearchSchema = (): VbenFormSchema[] => {
|
|
|
+ return [
|
|
|
{
|
|
|
component: 'Input',
|
|
|
fieldName: 'name',
|
|
|
@@ -17,18 +21,13 @@ export const searchFormOptions: VbenFormProps = {
|
|
|
fieldName: 'description',
|
|
|
label: '说明',
|
|
|
},
|
|
|
- ],
|
|
|
+ ];
|
|
|
};
|
|
|
|
|
|
-export const gridOptions: VxeGridProps<DatabaseApi.RecordItem> = {
|
|
|
- toolbarConfig: {
|
|
|
- refresh: true,
|
|
|
- print: false,
|
|
|
- export: false,
|
|
|
- zoom: true,
|
|
|
- custom: true,
|
|
|
- },
|
|
|
- columns: [
|
|
|
+export function useColumns(
|
|
|
+ onActionClick?: OnActionClickFn<DatabaseApi.RecordItem>,
|
|
|
+): VxeTableGridOptions<DatabaseApi.RecordItem>['columns'] {
|
|
|
+ return [
|
|
|
{ title: '序号', type: 'seq', width: 50 },
|
|
|
{
|
|
|
align: 'left',
|
|
|
@@ -38,35 +37,46 @@ export const gridOptions: VxeGridProps<DatabaseApi.RecordItem> = {
|
|
|
},
|
|
|
{ align: 'left', field: 'description', title: '备注' },
|
|
|
{
|
|
|
- field: 'action',
|
|
|
+ align: 'right',
|
|
|
+ cellRender: {
|
|
|
+ attrs: {
|
|
|
+ nameField: 'name',
|
|
|
+ nameTitle: '表名',
|
|
|
+ onClick: onActionClick,
|
|
|
+ },
|
|
|
+ name: 'CellAction',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ code: 'edit',
|
|
|
+ auth: ['table:edit'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'create',
|
|
|
+ label: '创建表',
|
|
|
+ auth: ['table:create'],
|
|
|
+ confirm: {
|
|
|
+ title: '提示',
|
|
|
+ content: `创建表如果表存在会先删除原表,确定要创建表吗?`,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'delete',
|
|
|
+ auth: ['table:delete'],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ field: 'operation',
|
|
|
fixed: 'right',
|
|
|
- slots: { default: 'action' },
|
|
|
+ headerAlign: 'center',
|
|
|
+ showOverflow: false,
|
|
|
title: '操作',
|
|
|
- width: 170,
|
|
|
+ width: 100,
|
|
|
},
|
|
|
- ],
|
|
|
- height: 'auto',
|
|
|
- keepSource: true,
|
|
|
- proxyConfig: {
|
|
|
- ajax: {
|
|
|
- query: async ({ page }, formValues) => {
|
|
|
- return await DatabaseApi.getPage({
|
|
|
- pageIndex: page.currentPage,
|
|
|
- pageSize: page.pageSize,
|
|
|
- ...formValues,
|
|
|
- });
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ ];
|
|
|
+}
|
|
|
|
|
|
-export const formOptions: VbenFormProps = {
|
|
|
- commonConfig: {
|
|
|
- componentProps: {
|
|
|
- class: 'w-full',
|
|
|
- },
|
|
|
- },
|
|
|
- schema: [
|
|
|
+export const useSchema = (): VbenFormSchema[] => {
|
|
|
+ return [
|
|
|
{
|
|
|
component: 'ApiSelect',
|
|
|
componentProps: {
|
|
|
@@ -99,22 +109,13 @@ export const formOptions: VbenFormProps = {
|
|
|
label: '说明',
|
|
|
rules: 'required',
|
|
|
},
|
|
|
- ],
|
|
|
- wrapperClass: 'grid-cols-1',
|
|
|
+ ];
|
|
|
};
|
|
|
|
|
|
-export const gridColumnOptions: VxeGridProps<DatabaseApi.BasicColumnRecord> = {
|
|
|
- rowConfig: {
|
|
|
- isCurrent: true,
|
|
|
- isHover: true,
|
|
|
- keyField: 'columnName',
|
|
|
- drag: true,
|
|
|
- useKey: true,
|
|
|
- },
|
|
|
- columnConfig: {
|
|
|
- useKey: true,
|
|
|
- },
|
|
|
- columns: [
|
|
|
+export function useColumnColumns(
|
|
|
+ onActionClick?: OnActionClickFn<DatabaseApi.BasicColumnRecord>,
|
|
|
+): VxeTableGridOptions<DatabaseApi.BasicColumnRecord>['columns'] {
|
|
|
+ return [
|
|
|
{ title: '序号', type: 'seq', width: 50 },
|
|
|
{
|
|
|
align: 'left',
|
|
|
@@ -126,35 +127,37 @@ export const gridColumnOptions: VxeGridProps<DatabaseApi.BasicColumnRecord> = {
|
|
|
{ align: 'left', field: 'dataType', title: '类型', width: 100 },
|
|
|
{ align: 'left', field: 'description', title: '说明' },
|
|
|
{
|
|
|
- field: 'action',
|
|
|
+ align: 'right',
|
|
|
+ cellRender: {
|
|
|
+ attrs: {
|
|
|
+ nameField: 'columnName',
|
|
|
+ nameTitle: '列名',
|
|
|
+ onClick: onActionClick,
|
|
|
+ },
|
|
|
+ name: 'CellAction',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ code: 'edit',
|
|
|
+ auth: ['table:edit'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'delete',
|
|
|
+ auth: ['table:delete'],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ field: 'operation',
|
|
|
fixed: 'right',
|
|
|
- slots: { default: 'action' },
|
|
|
+ headerAlign: 'center',
|
|
|
+ showOverflow: false,
|
|
|
title: '操作',
|
|
|
- width: 110,
|
|
|
+ width: 100,
|
|
|
},
|
|
|
- ],
|
|
|
- editConfig: {
|
|
|
- mode: 'row',
|
|
|
- trigger: 'click',
|
|
|
- // showStatus: true,
|
|
|
- },
|
|
|
- height: 'auto',
|
|
|
- keepSource: true,
|
|
|
- pagerConfig: {
|
|
|
- enabled: false,
|
|
|
- },
|
|
|
- dragConfig: {
|
|
|
- rowIcon: 'vxe-icon-sort',
|
|
|
- },
|
|
|
-};
|
|
|
+ ];
|
|
|
+}
|
|
|
|
|
|
-export const formColumnOptions: VbenFormProps = {
|
|
|
- commonConfig: {
|
|
|
- componentProps: {
|
|
|
- class: 'w-full',
|
|
|
- },
|
|
|
- },
|
|
|
- schema: [
|
|
|
+export const useColumnSchema = (): VbenFormSchema[] => {
|
|
|
+ return [
|
|
|
{
|
|
|
component: 'Input',
|
|
|
componentProps: {
|
|
|
@@ -253,6 +256,35 @@ export const formColumnOptions: VbenFormProps = {
|
|
|
triggerFields: ['dataType'],
|
|
|
},
|
|
|
},
|
|
|
+ ];
|
|
|
+};
|
|
|
+export const gridColumnOptions: VxeGridProps<DatabaseApi.BasicColumnRecord> = {
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ field: 'action',
|
|
|
+ fixed: 'right',
|
|
|
+ slots: { default: 'action' },
|
|
|
+ title: '操作',
|
|
|
+ width: 110,
|
|
|
+ },
|
|
|
],
|
|
|
+
|
|
|
+ height: 'auto',
|
|
|
+ keepSource: true,
|
|
|
+ pagerConfig: {
|
|
|
+ enabled: false,
|
|
|
+ },
|
|
|
+ dragConfig: {
|
|
|
+ rowIcon: 'vxe-icon-sort',
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+export const formColumnOptions: VbenFormProps = {
|
|
|
+ commonConfig: {
|
|
|
+ componentProps: {
|
|
|
+ class: 'w-full',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ schema: [],
|
|
|
wrapperClass: 'grid-cols-1',
|
|
|
};
|