+ {this.create &&
}
{this.pluginer?.actions && (
{this.pluginer.actions.map(Action => (
@@ -218,7 +219,7 @@ export const AnTable = defineComponent({
)}
-
+
{this.pluginer?.widgets && this.pluginer.widgets?.map(Widget => )}
diff --git a/src/components/AnTable/extra/column.tsx b/src/components/AnTable/extra/column.tsx
new file mode 100644
index 0000000..c00bb02
--- /dev/null
+++ b/src/components/AnTable/extra/column.tsx
@@ -0,0 +1,34 @@
+import { dayjs } from '@/libs/dayjs';
+import { TableColumn } from '../hooks/useTableColumn';
+
+export function useUpdateColumn(): TableColumn {
+ return {
+ title: '更新用户',
+ dataIndex: 'createdAt',
+ width: 190,
+ render({ record }) {
+ return (
+
+ {record.updatedBy ?? '无'}
+ {dayjs(record.updatedAt).format()}
+
+ );
+ },
+ };
+}
+
+export function useCreateColumn(): TableColumn {
+ return {
+ title: '创建用户',
+ dataIndex: 'createdAt',
+ width: 190,
+ render({ record }) {
+ return (
+
+ {record.createdBy ?? '无'}
+ {dayjs(record.createdAt).format()}
+
+ );
+ },
+ };
+}
diff --git a/src/components/AnTable/hooks/useModiyForm.tsx b/src/components/AnTable/hooks/useModiyForm.tsx
index dc6e35d..611681d 100644
--- a/src/components/AnTable/hooks/useModiyForm.tsx
+++ b/src/components/AnTable/hooks/useModiyForm.tsx
@@ -1,10 +1,10 @@
-import { cloneDeep, merge } from "lodash-es";
-import { IAnFormItem } from "../../AnForm/components/FormItem";
-import { FormModalProps } from "../../AnForm/components/FormModal";
-import { FormModalUseOptions } from "../../AnForm/hooks/useFormModal";
-import { ExtendFormItem } from "./useSearchForm";
+import { FormItem } from '@/components/AnForm/hooks/useItems';
+import { merge } from 'lodash-es';
+import { FormModalUseOptions } from '../../AnForm/hooks/useFormModal';
+import { ExtendFormItem } from './useSearchForm';
+import { TableUseOptions } from './useTable';
-export type ModifyForm = Omit
& {
+export type ModifyForm = Omit & {
/**
* 是否继承新建弹窗
*/
@@ -15,19 +15,28 @@ export type ModifyForm = Omit & {
items?: ExtendFormItem[];
};
-export function useModifyForm(form: ModifyForm, create: FormModalProps) {
- const { extend, items, ...rest } = form;
+export function useModifyForm(options: TableUseOptions) {
+ const { create, modify } = options;
+ if (!modify) {
+ return null;
+ }
+ const { extend, items, ...rest } = modify;
let result = {};
- if (extend) {
- cloneDeep(create ?? {});
- const createItems = create.items;
- const modifyItems = form.items;
- if (modifyItems && createItems) {
+ if (extend && create) {
+ const { items: createItems, ...createRest } = create;
+ const createItemMap = createItems.reduce((map, value) => {
+ map[value.field] = value;
+ return map;
+ }, {} as Record);
+ const modified: any = merge({}, createRest, rest);
+ const modifyItems = items;
+ if (modifyItems) {
for (let i = 0; i < modifyItems.length; i++) {
if (modifyItems[i].extend) {
- modifyItems[i] = merge({}, createItems[i], modifyItems[i]);
+ modifyItems[i] = merge({}, createItemMap[modifyItems[i].field!], modifyItems[i]);
}
}
}
+ modified.items = modifyItems;
}
}
diff --git a/src/components/AnTable/hooks/useSearchForm.tsx b/src/components/AnTable/hooks/useSearchForm.tsx
index a06faf7..0516b50 100644
--- a/src/components/AnTable/hooks/useSearchForm.tsx
+++ b/src/components/AnTable/hooks/useSearchForm.tsx
@@ -66,7 +66,7 @@ export function useSearchForm(search?: SearchForm, extendItems: IAnFormItem[] =
setterProps: {},
};
- const items: any[] = [];
+ const items: IAnFormItem[] = [];
for (const _item of _items) {
const { searchable, enterable, field, extend, ...itemRest } = _item;
if ((field || extend) === 'submit' && hideSearch) {
@@ -80,10 +80,10 @@ export function useSearchForm(search?: SearchForm, extendItems: IAnFormItem[] =
}
}
if (searchable) {
- (item as any).nodeProps.onSearch = () => null;
+ (item as any).setterProps.onSearch = () => null;
}
if (enterable) {
- (item as any).nodeProps.onPressEnter = () => null;
+ (item as any).setterProps.onPressEnter = () => null;
}
if (item.setterProps) {
(item.setterProps as any).placeholder = (item.setterProps as any).placeholder ?? item.label;
diff --git a/src/components/AnTable/hooks/useTable.tsx b/src/components/AnTable/hooks/useTable.tsx
index 56125c1..693bfa1 100644
--- a/src/components/AnTable/hooks/useTable.tsx
+++ b/src/components/AnTable/hooks/useTable.tsx
@@ -1,6 +1,6 @@
-import { FormModalUseOptions, useFormModal } from '../../AnForm/hooks/useFormModal';
+import { FormModalUseOptions, useFormModalProps } from '../../AnForm/hooks/useFormModal';
import { AnTable, TableProps } from '../components/Table';
-import { ModifyForm } from './useModiyForm';
+import { ModifyForm, useModifyForm } from './useModiyForm';
import { SearchForm, useSearchForm } from './useSearchForm';
import { TableColumn, useTableColumns } from './useTableColumn';
import { AnTablePlugin, PluginContainer } from './useTablePlugin';
@@ -71,18 +71,35 @@ export interface TableUseOptions extends Pick | null>(null);
+ const pluginer = new PluginContainer(options.plugins ?? []);
options = pluginer.callOptionsHook(options);
const { columns } = useTableColumns(options.columns ?? []);
const data = ref(options.data);
const pagination = ref({ hide: false, showTotal: true, showPageSize: true, ...(options.paging ?? {}) });
const tableProps = ref(options.tableProps ?? {});
- const tableRef = ref | null>(null);
const searchProps = useSearchForm(options.search);
- // const create = options.create && useFormModal(options.create);
+ const create = options.create && useFormModalProps(options.create);
const AnTabler = () => (
);
diff --git a/src/components/AnTable/hooks/useTableColumn.tsx b/src/components/AnTable/hooks/useTableColumn.tsx
index a6a933f..4e0d2f6 100644
--- a/src/components/AnTable/hooks/useTableColumn.tsx
+++ b/src/components/AnTable/hooks/useTableColumn.tsx
@@ -23,6 +23,8 @@ interface TableColumnButton {
* ```
*/
type?: 'modify' | 'delete';
+
+ confirm?: string;
/**
* 按钮文本
* @example
diff --git a/src/pages/home/home.vue b/src/pages/home/home.vue
index b942e35..f8054e1 100644
--- a/src/pages/home/home.vue
+++ b/src/pages/home/home.vue
@@ -1,21 +1,18 @@
-
{{ formatModel(emodel) }}
-
diff --git a/src/types/auto-component.d.ts b/src/types/auto-component.d.ts
index fa220c6..baf1506 100644
--- a/src/types/auto-component.d.ts
+++ b/src/types/auto-component.d.ts
@@ -7,22 +7,24 @@ export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
+ AAutoComplete: typeof import('@arco-design/web-vue')['AutoComplete']
AAvatar: typeof import('@arco-design/web-vue')['Avatar']
ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb']
ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem']
AButton: typeof import('@arco-design/web-vue')['Button']
- ACard: typeof import('@arco-design/web-vue')['Card']
ACheckbox: typeof import('@arco-design/web-vue')['Checkbox']
AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider']
ADivider: typeof import('@arco-design/web-vue')['Divider']
ADoption: typeof import('@arco-design/web-vue')['Doption']
ADrawer: typeof import('@arco-design/web-vue')['Drawer']
ADropdown: typeof import('@arco-design/web-vue')['Dropdown']
+ ADropdownButton: typeof import('@arco-design/web-vue')['DropdownButton']
AEmpty: typeof import('@arco-design/web-vue')['Empty']
AForm: typeof import('@arco-design/web-vue')['Form']
AFormItem: typeof import('@arco-design/web-vue')['FormItem']
- AImage: typeof import('@arco-design/web-vue')['Image']
+ AImagePreview: typeof import('@arco-design/web-vue')['ImagePreview']
AInput: typeof import('@arco-design/web-vue')['Input']
+ AInputNumber: typeof import('@arco-design/web-vue')['InputNumber']
AInputPassword: typeof import('@arco-design/web-vue')['InputPassword']
AInputSearch: typeof import('@arco-design/web-vue')['InputSearch']
ALayout: typeof import('@arco-design/web-vue')['Layout']
@@ -30,20 +32,23 @@ declare module '@vue/runtime-core' {
ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader']
ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider']
ALink: typeof import('@arco-design/web-vue')['Link']
- AList: typeof import('@arco-design/web-vue')['List']
- AListItem: typeof import('@arco-design/web-vue')['ListItem']
- AListItemMeta: typeof import('@arco-design/web-vue')['ListItemMeta']
AMenu: typeof import('@arco-design/web-vue')['Menu']
AMenuItem: typeof import('@arco-design/web-vue')['MenuItem']
AModal: typeof import('@arco-design/web-vue')['Modal']
AniEmpty: typeof import('./../components/empty/AniEmpty.vue')['default']
APagination: typeof import('@arco-design/web-vue')['Pagination']
+ APopover: typeof import('@arco-design/web-vue')['Popover']
+ AProgress: typeof import('@arco-design/web-vue')['Progress']
+ ARadio: typeof import('@arco-design/web-vue')['Radio']
+ ARadioGroup: typeof import('@arco-design/web-vue')['RadioGroup']
AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar']
+ ASelect: typeof import('@arco-design/web-vue')['Select']
ASpace: typeof import('@arco-design/web-vue')['Space']
ASpin: typeof import('@arco-design/web-vue')['Spin']
+ ASwitch: typeof import('@arco-design/web-vue')['Switch']
ATag: typeof import('@arco-design/web-vue')['Tag']
+ ATextarea: typeof import('@arco-design/web-vue')['Textarea']
ATooltip: typeof import('@arco-design/web-vue')['Tooltip']
- ATree: typeof import('@arco-design/web-vue')['Tree']
AUpload: typeof import('@arco-design/web-vue')['Upload']
BaseOption: typeof import('./../components/editor/components/BaseOption.vue')['default']
BreadCrumb: typeof import('./../components/breadcrumb/bread-crumb.vue')['default']