mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-04-13 03:45:09 +00:00
add dept
This commit is contained in:
@@ -6,7 +6,8 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public enum Actions {
|
public enum Actions {
|
||||||
CREATE_USER("CREATE_USER", "创建新用户");
|
CREATE_USER("CREATE_USER", "创建用户"),
|
||||||
|
CREATE_DEPARTMENT("CREATE_DEPARTMENT", "创建部门");
|
||||||
public static final String INDEX_KEY = "action";
|
public static final String INDEX_KEY = "action";
|
||||||
private final String code;
|
private final String code;
|
||||||
private final String content;
|
private final String content;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class EmbeddingService {
|
|||||||
EmbeddingSearchRequest embeddingSearchRequest =
|
EmbeddingSearchRequest embeddingSearchRequest =
|
||||||
EmbeddingSearchRequest.builder()
|
EmbeddingSearchRequest.builder()
|
||||||
.queryEmbedding(zhipuEmbeddingModel.embed(message).content())
|
.queryEmbedding(zhipuEmbeddingModel.embed(message).content())
|
||||||
.minScore(0.9)
|
.minScore(0.89)
|
||||||
.build();
|
.build();
|
||||||
EmbeddingSearchResult<TextSegment> embeddingSearchResult =
|
EmbeddingSearchResult<TextSegment> embeddingSearchResult =
|
||||||
zhiPuEmbeddingStore.search(embeddingSearchRequest);
|
zhiPuEmbeddingStore.search(embeddingSearchRequest);
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ import { z } from "zod";
|
|||||||
import type { components } from "../api/types/schema";
|
import type { components } from "../api/types/schema";
|
||||||
import type { DepartmentUpsertModel } from "../types/department";
|
import type { DepartmentUpsertModel } from "../types/department";
|
||||||
|
|
||||||
const alertStore = useAlertStore();
|
|
||||||
|
|
||||||
const { department, availableDepartments, onSubmit } = defineProps<{
|
const { department, availableDepartments, onSubmit } = defineProps<{
|
||||||
department?: components["schemas"]["Department"];
|
department?: components["schemas"]["Department"];
|
||||||
availableDepartments?: components["schemas"]["Department"][];
|
availableDepartments?: components["schemas"]["Department"][];
|
||||||
|
|||||||
@@ -79,6 +79,11 @@
|
|||||||
userUpsertModal!.hide();
|
userUpsertModal!.hide();
|
||||||
}">
|
}">
|
||||||
</UserUpsertModal>
|
</UserUpsertModal>
|
||||||
|
<DepartmentUpsertModal :id="'department-upsert-modal'" :onSubmit="handleUpsertDepartmentSubmit" :closeModal="() => {
|
||||||
|
availableDepartments = undefined
|
||||||
|
departmentUpsertModal!.hide();
|
||||||
|
}" :availableDepartments="availableDepartments">
|
||||||
|
</DepartmentUpsertModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -90,29 +95,42 @@ import { marked } from "marked";
|
|||||||
import { nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
import { nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import Button from "../components/Button.vue";
|
import Button from "../components/Button.vue";
|
||||||
|
import DepartmentUpsertModal from "../components/DepartmentUpsertModal.vue";
|
||||||
import UserUpsertModal from "../components/UserUpsertModal.vue";
|
import UserUpsertModal from "../components/UserUpsertModal.vue";
|
||||||
import { useAiChat } from "../composables/ai/useAiChat";
|
import { useAiChat } from "../composables/ai/useAiChat";
|
||||||
import useUserStore from "../composables/store/useUserStore";
|
import useUserStore from "../composables/store/useUserStore";
|
||||||
import { useUserUpsert } from "../composables/user/useUserUpsert";
|
import { useUserUpsert } from "../composables/user/useUserUpsert";
|
||||||
import type { UserUpsertSubmitModel } from "../types/user";
|
import type { UserUpsertSubmitModel } from "../types/user";
|
||||||
|
import { useDepartmentQuery } from "@/composables/department/useDepartmentQuery";
|
||||||
|
import { useDepartmentUpsert } from "@/composables/department/useDepartmentUpsert";
|
||||||
|
import type { DepartmentUpsertModel } from "@/types/department";
|
||||||
|
|
||||||
const { messages, chat, isLoading, cancel, actionChat } = useAiChat();
|
const { messages, chat, isLoading, cancel, actionChat } = useAiChat();
|
||||||
const { user } = useUserStore();
|
const { user } = useUserStore();
|
||||||
const userUpsertModal = ref<ModalInterface>();
|
const userUpsertModal = ref<ModalInterface>();
|
||||||
|
const departmentUpsertModal = ref<ModalInterface>();
|
||||||
const inputMessage = ref("");
|
const inputMessage = ref("");
|
||||||
const chatContainer = ref<HTMLElement | null>(null);
|
const chatContainer = ref<HTMLElement | null>(null);
|
||||||
const alertStore = useAlertStore();
|
const alertStore = useAlertStore();
|
||||||
const isCommandMode = ref(false);
|
const isCommandMode = ref(false);
|
||||||
const userUpsert = useUserUpsert();
|
const userUpsert = useUserUpsert();
|
||||||
|
const departmentUpsert = useDepartmentUpsert();
|
||||||
|
|
||||||
|
const { availableDepartments,fetchAvailableDepartments } = useDepartmentQuery();
|
||||||
|
|
||||||
const commandActionMap: Record<string, () => void> = {
|
const commandActionMap: Record<string, () => void> = {
|
||||||
CREATE_USER: () => {
|
CREATE_USER: () => {
|
||||||
userUpsertModal.value?.show();
|
userUpsertModal.value?.show();
|
||||||
},
|
},
|
||||||
|
CREATE_DEPARTMENT: () => {
|
||||||
|
fetchAvailableDepartments();
|
||||||
|
departmentUpsertModal.value?.show();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const commandContentMap: Record<string, string> = {
|
const commandContentMap: Record<string, string> = {
|
||||||
CREATE_USER: "创建新用户",
|
CREATE_USER: "创建用户",
|
||||||
|
CREATE_DEPARTMENT: "创建部门",
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleMode = () => {
|
const toggleMode = () => {
|
||||||
@@ -154,6 +172,17 @@ const handleUpsertUserSubmit = async (data: UserUpsertSubmitModel) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleUpsertDepartmentSubmit = async (
|
||||||
|
department: DepartmentUpsertModel,
|
||||||
|
) => {
|
||||||
|
await departmentUpsert.upsertDepartment(department);
|
||||||
|
departmentUpsertModal.value?.hide();
|
||||||
|
alertStore.showAlert({
|
||||||
|
content: "操作成功",
|
||||||
|
level: "success",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
messages,
|
messages,
|
||||||
async () => {
|
async () => {
|
||||||
@@ -190,10 +219,10 @@ const chatByMode = async (message: string) => {
|
|||||||
|
|
||||||
const handleSendClick = async () => {
|
const handleSendClick = async () => {
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
if (isLoading.value) {
|
if (isLoading.value) {
|
||||||
abortChat();
|
abortChat();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const validInputMessage = z
|
const validInputMessage = z
|
||||||
.string({ message: "消息不能为空" })
|
.string({ message: "消息不能为空" })
|
||||||
.min(1, "消息不能为空")
|
.min(1, "消息不能为空")
|
||||||
@@ -216,6 +245,15 @@ onMounted(async () => {
|
|||||||
id: "user-upsert-modal",
|
id: "user-upsert-modal",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const $departmentUpsertModalElement: HTMLElement | null =
|
||||||
|
document.querySelector("#department-upsert-modal");
|
||||||
|
departmentUpsertModal.value = new Modal(
|
||||||
|
$departmentUpsertModalElement,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
id: "department-upsert-modal",
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ const router = useRouter();
|
|||||||
const { total, users, fetchUsersWith } = useUserQuery();
|
const { total, users, fetchUsersWith } = useUserQuery();
|
||||||
const { deleteUser } = useUserDelete();
|
const { deleteUser } = useUserDelete();
|
||||||
const userUpsert = useUserUpsert();
|
const userUpsert = useUserUpsert();
|
||||||
const { sortBy, handleSort, getSortField } = useSort();
|
const { sortBy, handleSort, getSortField } = useSort();
|
||||||
const alertStore = useAlertStore();
|
const alertStore = useAlertStore();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user