mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-19 01:36:38 +08:00
feat(ui):用户
This commit is contained in:
parent
960286a350
commit
aba8f57279
@ -0,0 +1,39 @@
|
|||||||
|
import usePopup from "./usePopup";
|
||||||
|
import { Message } from "@arco-design/web-vue";
|
||||||
|
import type { Component } from "vue";
|
||||||
|
import type { BaseResponse } from "@gpt-vue/packages/type";
|
||||||
|
interface Arg {
|
||||||
|
reload?: () => void;
|
||||||
|
record?: Record<string, any>;
|
||||||
|
}
|
||||||
|
export default function (
|
||||||
|
node: Component,
|
||||||
|
api: (params?: any) => Promise<BaseResponse<any>>
|
||||||
|
): (arg: Arg) => void {
|
||||||
|
const nodeProps = (arg: Arg[]) => {
|
||||||
|
return {
|
||||||
|
data: arg[0].record || {},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const popupProps = (arg: Arg[], getExposed) => {
|
||||||
|
return {
|
||||||
|
width: 700,
|
||||||
|
onBeforeOk: async () => {
|
||||||
|
const exposed = getExposed();
|
||||||
|
const validateRes = await exposed?.formRef.value.validate();
|
||||||
|
if (validateRes) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const { code } = await api(exposed?.form.value);
|
||||||
|
if (code === 0) {
|
||||||
|
Message.success("操作成功");
|
||||||
|
}
|
||||||
|
arg[0]?.reload?.();
|
||||||
|
return code === 0;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return usePopup(node, { nodeProps, popupProps });
|
||||||
|
}
|
@ -3,11 +3,10 @@ import SearchTable from "@/components/SearchTable/SearchTable.vue";
|
|||||||
import type { SearchTableColumns } from "@/components/SearchTable/type";
|
import type { SearchTableColumns } from "@/components/SearchTable/type";
|
||||||
import { getList, save as saveApi, deletApi, resetPassword } from "./api";
|
import { getList, save as saveApi, deletApi, resetPassword } from "./api";
|
||||||
import UserForm from "./UserForm.vue";
|
import UserForm from "./UserForm.vue";
|
||||||
import { ref } from "vue";
|
|
||||||
import { Message } from "@arco-design/web-vue";
|
import { Message } from "@arco-design/web-vue";
|
||||||
import { dateFormat } from "@gpt-vue/packages/utils";
|
import { dateFormat } from "@gpt-vue/packages/utils";
|
||||||
import usePopup from "@/composables/usePopup";
|
|
||||||
import UserPassword from "./UserPassword.vue";
|
import UserPassword from "./UserPassword.vue";
|
||||||
|
import useCustomFormPopup from "@/composables/useCustomFormPopup";
|
||||||
const columns: SearchTableColumns[] = [
|
const columns: SearchTableColumns[] = [
|
||||||
{
|
{
|
||||||
title: "账号",
|
title: "账号",
|
||||||
@ -56,38 +55,8 @@ const columns: SearchTableColumns[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
//弹窗
|
//弹窗
|
||||||
|
const editModal = useCustomFormPopup(UserForm, saveApi);
|
||||||
const popup = (node, api) => {
|
const password = useCustomFormPopup(UserPassword, resetPassword);
|
||||||
const nodeProps = (arg) => {
|
|
||||||
return {
|
|
||||||
data: arg[0].record,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const popupProps = (arg, getExposed) => {
|
|
||||||
return {
|
|
||||||
width: 700,
|
|
||||||
onBeforeOk: async () => {
|
|
||||||
const exposed = getExposed();
|
|
||||||
const validateRes = await exposed?.formRef.value.validate();
|
|
||||||
if (validateRes) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const res = await api(exposed?.form.value);
|
|
||||||
if (res.code === 0) {
|
|
||||||
Message.success("操作成功");
|
|
||||||
}
|
|
||||||
arg[0].reload();
|
|
||||||
return res.code === 0;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
return usePopup(node, { nodeProps, popupProps });
|
|
||||||
};
|
|
||||||
|
|
||||||
const editModal = popup(UserForm, saveApi);
|
|
||||||
const password = popup(UserPassword, resetPassword);
|
|
||||||
|
|
||||||
const handleDelete = async ({ id }: { id: string }, reload) => {
|
const handleDelete = async ({ id }: { id: string }, reload) => {
|
||||||
const res = await deletApi(id);
|
const res = await deletApi(id);
|
||||||
|
@ -79,7 +79,6 @@ const props = defineProps({
|
|||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const form = ref({
|
const form = ref({
|
||||||
id: "",
|
|
||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
calls: "",
|
calls: "",
|
||||||
|
Loading…
Reference in New Issue
Block a user