mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-12 13:42:50 +00:00
cl-view-group 添加泛型
This commit is contained in:
parent
7754e14bf4
commit
ad841ac140
@ -279,24 +279,31 @@ function remove(item: ClViewGroup.Item) {
|
|||||||
type: "warning"
|
type: "warning"
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
config.service
|
function next(params: any) {
|
||||||
.delete({
|
config.service
|
||||||
ids: [item.id]
|
.delete(params)
|
||||||
})
|
.then(async () => {
|
||||||
.then(async () => {
|
ElMessage.success("删除成功");
|
||||||
ElMessage.success("删除成功");
|
|
||||||
|
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
await refresh();
|
await refresh();
|
||||||
|
|
||||||
// 删除当前
|
// 删除当前
|
||||||
if (selected.value?.id == item.id) {
|
if (selected.value?.id == item.id) {
|
||||||
select();
|
select();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
ElMessage.error(err.message);
|
ElMessage.error(err.message);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除事件
|
||||||
|
if (config.onDelete) {
|
||||||
|
config.onDelete(item, { next });
|
||||||
|
} else {
|
||||||
|
next({ ids: [item.id] });
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,8 +5,8 @@ export default (): ModuleConfig => {
|
|||||||
label: "视图组件",
|
label: "视图组件",
|
||||||
description: "左右侧布局、顶部详情等",
|
description: "左右侧布局、顶部详情等",
|
||||||
author: "COOL",
|
author: "COOL",
|
||||||
version: "1.0.3",
|
version: "1.0.4",
|
||||||
updateTime: "2024-03-23",
|
updateTime: "2024-03-25",
|
||||||
demo: [
|
demo: [
|
||||||
{
|
{
|
||||||
name: "左右侧布局",
|
name: "左右侧布局",
|
||||||
|
|||||||
@ -2,8 +2,8 @@ import { provide, ref } from "vue";
|
|||||||
import { useParent } from "/@/cool";
|
import { useParent } from "/@/cool";
|
||||||
import type { ClViewGroup } from "../types";
|
import type { ClViewGroup } from "../types";
|
||||||
|
|
||||||
export function useViewGroup(options?: DeepPartial<ClViewGroup.Options>) {
|
export function useViewGroup<T = ClViewGroup.Item>(options?: DeepPartial<ClViewGroup.Options<T>>) {
|
||||||
const ViewGroup = ref<ClViewGroup.Ref>();
|
const ViewGroup = ref<ClViewGroup.Ref<T>>();
|
||||||
useParent("cl-view-group", ViewGroup);
|
useParent("cl-view-group", ViewGroup);
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
|
|||||||
22
src/plugins/view/types/index.d.ts
vendored
22
src/plugins/view/types/index.d.ts
vendored
@ -5,20 +5,23 @@ export declare namespace ClViewGroup {
|
|||||||
interface Item {
|
interface Item {
|
||||||
id: any;
|
id: any;
|
||||||
name: string;
|
name: string;
|
||||||
|
children: Item[];
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Ref {
|
type M<T> = T & Item;
|
||||||
selected: Item | undefined;
|
|
||||||
|
interface Ref<T = Item> {
|
||||||
|
selected: M<T> | undefined;
|
||||||
isExpand: boolean;
|
isExpand: boolean;
|
||||||
select(data?: any): void;
|
select(data?: any): void;
|
||||||
expand(value?: boolean): void;
|
expand(value?: boolean): void;
|
||||||
edit(item?: Item): void;
|
edit(item?: M<T>): void;
|
||||||
remove(item: Item): void;
|
remove(item: M<T>): void;
|
||||||
refresh(params?: any): void;
|
refresh(params?: any): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Options {
|
interface Options<T = Item> {
|
||||||
label: string;
|
label: string;
|
||||||
title: string;
|
title: string;
|
||||||
leftWidth: string;
|
leftWidth: string;
|
||||||
@ -57,9 +60,10 @@ export declare namespace ClViewGroup {
|
|||||||
enableAdd?: boolean;
|
enableAdd?: boolean;
|
||||||
enableRefresh?: boolean;
|
enableRefresh?: boolean;
|
||||||
custom?: boolean;
|
custom?: boolean;
|
||||||
onSelect?(item: Item): void;
|
onSelect?(item: M<T>): void;
|
||||||
onEdit?(item?: Item): DeepPartial<ClForm.Options>;
|
onEdit?(item?: M<T>): DeepPartial<ClForm.Options>;
|
||||||
onContextMenu?(item: Item): ClContextMenu.Options;
|
onContextMenu?(item: M<T>): ClContextMenu.Options;
|
||||||
onData?(list: any[]): any[];
|
onData?(list: M<T>[]): any[];
|
||||||
|
onDelete?(item: M<T>, { next }: { next(params: any): void }): Promise<void> | void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user