This commit is contained in:
Chuck1sn
2025-05-14 10:16:48 +08:00
commit 3cd59337e7
220 changed files with 23768 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import client from "@/api/client";
export function usePositionBind() {
const bindPosition = async (userId: number, positionIds: number[]) => {
try {
await client.POST("/iam/position/bind", {
body: {
userId,
positionIds,
},
});
return true;
} catch (error) {
console.error("Error binding positions:", error);
return false;
}
};
const unbindPosition = async (userId: number, positionIds: number[]) => {
try {
await client.POST("/iam/position/unbind", {
body: {
userId,
positionIds,
},
});
return true;
} catch (error) {
console.error("Error unbinding positions:", error);
return false;
}
};
return {
bindPosition,
unbindPosition,
};
}

View File

@@ -0,0 +1,18 @@
import client from "@/api/client";
export const usePositionDelete = () => {
const deletePosition = async (positionId: number) => {
await client.DELETE("/position", {
params: {
query: {
id: positionId,
},
},
});
};
return {
deletePosition,
};
};
export default usePositionDelete;

View File

@@ -0,0 +1,45 @@
import client from "@/api/client";
import { ref } from "vue";
import type { components } from "../../api/types/schema";
export const usePositionQuery = () => {
const total = ref<number>(0);
const positions = ref<components["schemas"]["PositionRespDto"][]>([]);
const allPositions = ref<components["schemas"]["Position"][]>([]);
const fetchAllPositions = async () => {
const { data } = await client.GET("/position/query");
allPositions.value = data ?? [];
};
const fetchPositionWith = async (
param: {
name?: string;
enable?: boolean;
userId?: number;
bindState?: "ALL" | "BIND" | "UNBIND";
},
page = 1,
size = 10,
) => {
const { data } = await client.GET("/position/page-query", {
params: {
query: {
pageRequestDto: {
page,
size,
},
positionQueryDto: param,
},
},
});
total.value = !data || !data.total ? 0 : data.total;
positions.value = data?.data ?? [];
};
return {
total,
positions,
allPositions,
fetchPositionWith,
fetchAllPositions,
};
};

View File

@@ -0,0 +1,16 @@
import client from "../../api/client";
import type { components } from "../../api/types/schema";
export const usePositionUpsert = () => {
const upsertPosition = async (
position: components["schemas"]["Position"],
) => {
await client.POST("/position", {
body: position,
});
};
return {
upsertPosition,
};
};