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,10 +279,9 @@ function remove(item: ClViewGroup.Item) {
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
function next(params: any) {
|
||||
config.service
|
||||
.delete({
|
||||
ids: [item.id]
|
||||
})
|
||||
.delete(params)
|
||||
.then(async () => {
|
||||
ElMessage.success("删除成功");
|
||||
|
||||
@ -297,6 +296,14 @@ function remove(item: ClViewGroup.Item) {
|
||||
.catch((err) => {
|
||||
ElMessage.error(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
// 删除事件
|
||||
if (config.onDelete) {
|
||||
config.onDelete(item, { next });
|
||||
} else {
|
||||
next({ ids: [item.id] });
|
||||
}
|
||||
})
|
||||
.catch(() => null);
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@ export default (): ModuleConfig => {
|
||||
label: "视图组件",
|
||||
description: "左右侧布局、顶部详情等",
|
||||
author: "COOL",
|
||||
version: "1.0.3",
|
||||
updateTime: "2024-03-23",
|
||||
version: "1.0.4",
|
||||
updateTime: "2024-03-25",
|
||||
demo: [
|
||||
{
|
||||
name: "左右侧布局",
|
||||
|
||||
@ -2,8 +2,8 @@ import { provide, ref } from "vue";
|
||||
import { useParent } from "/@/cool";
|
||||
import type { ClViewGroup } from "../types";
|
||||
|
||||
export function useViewGroup(options?: DeepPartial<ClViewGroup.Options>) {
|
||||
const ViewGroup = ref<ClViewGroup.Ref>();
|
||||
export function useViewGroup<T = ClViewGroup.Item>(options?: DeepPartial<ClViewGroup.Options<T>>) {
|
||||
const ViewGroup = ref<ClViewGroup.Ref<T>>();
|
||||
useParent("cl-view-group", ViewGroup);
|
||||
|
||||
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 {
|
||||
id: any;
|
||||
name: string;
|
||||
children: Item[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface Ref {
|
||||
selected: Item | undefined;
|
||||
type M<T> = T & Item;
|
||||
|
||||
interface Ref<T = Item> {
|
||||
selected: M<T> | undefined;
|
||||
isExpand: boolean;
|
||||
select(data?: any): void;
|
||||
expand(value?: boolean): void;
|
||||
edit(item?: Item): void;
|
||||
remove(item: Item): void;
|
||||
edit(item?: M<T>): void;
|
||||
remove(item: M<T>): void;
|
||||
refresh(params?: any): void;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
interface Options<T = Item> {
|
||||
label: string;
|
||||
title: string;
|
||||
leftWidth: string;
|
||||
@ -57,9 +60,10 @@ export declare namespace ClViewGroup {
|
||||
enableAdd?: boolean;
|
||||
enableRefresh?: boolean;
|
||||
custom?: boolean;
|
||||
onSelect?(item: Item): void;
|
||||
onEdit?(item?: Item): DeepPartial<ClForm.Options>;
|
||||
onContextMenu?(item: Item): ClContextMenu.Options;
|
||||
onData?(list: any[]): any[];
|
||||
onSelect?(item: M<T>): void;
|
||||
onEdit?(item?: M<T>): DeepPartial<ClForm.Options>;
|
||||
onContextMenu?(item: M<T>): ClContextMenu.Options;
|
||||
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