|
@@ -0,0 +1,112 @@
|
|
|
+import { Avatar, Button, Card, PageHeader, Space, Table } from "ant-design-vue";
|
|
|
+import { defineComponent, onMounted } from "vue";
|
|
|
+import { useRouter } from "vue-router";
|
|
|
+
|
|
|
+import loading from "@/components/Provider/Loading";
|
|
|
+import Modal from "@/components/Provider/Modal";
|
|
|
+import { useAuth } from "@/modules";
|
|
|
+import OperationModal from "./components/OperationModal";
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ setup() {
|
|
|
+ const router = useRouter();
|
|
|
+
|
|
|
+ const authStore = useAuth();
|
|
|
+
|
|
|
+ const columns = [
|
|
|
+ // {
|
|
|
+ // title: "头像",
|
|
|
+ // dataIndex: "avatar",
|
|
|
+ // customRender: ({ text }: any) => {
|
|
|
+ // return <Avatar src={text} />;
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ title: "登录名",
|
|
|
+ dataIndex: "loginName",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "姓名",
|
|
|
+ dataIndex: "name",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "手机号",
|
|
|
+ dataIndex: "phone",
|
|
|
+ customRender: ({ text }: any) => <div>{text || "-"}</div>,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "操作",
|
|
|
+ dataIndex: "actions",
|
|
|
+ customRender: ({ record }: any) => {
|
|
|
+ const editDisabled =
|
|
|
+ record.loginName == "admin" &&
|
|
|
+ authStore.userInfo.loginName !== "admin";
|
|
|
+
|
|
|
+ const DeleteDisabled =
|
|
|
+ record.loginName == "admin" ||
|
|
|
+ record.loginName == authStore.userInfo.loginName;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Space>
|
|
|
+ <Button
|
|
|
+ disabled={editDisabled}
|
|
|
+ type="link"
|
|
|
+ onClick={() => showModal(record)}
|
|
|
+ >
|
|
|
+ 编辑
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type="link"
|
|
|
+ danger
|
|
|
+ disabled={DeleteDisabled}
|
|
|
+ onClick={() => authStore.deleteUser(record)}
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </Button>
|
|
|
+ </Space>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const initList = async () => {
|
|
|
+ loading.show("");
|
|
|
+ await authStore.userListController.loadPage(1);
|
|
|
+ loading.hidden();
|
|
|
+ };
|
|
|
+
|
|
|
+ const showModal = async (item?: any) => {
|
|
|
+ const itemData: any = await Modal.show(<OperationModal data={item} />, {
|
|
|
+ title: item._id ? `编辑用户` : `添加用户`,
|
|
|
+ width: "500px",
|
|
|
+ });
|
|
|
+ authStore.addOrUpdateUser(itemData);
|
|
|
+ };
|
|
|
+
|
|
|
+ onMounted(() => initList());
|
|
|
+
|
|
|
+ return () => (
|
|
|
+ <Card>
|
|
|
+ <PageHeader title="用户管理">
|
|
|
+ {{
|
|
|
+ extra: () => (
|
|
|
+ <Button type="primary" onClick={showModal}>
|
|
|
+ + 添加用户
|
|
|
+ </Button>
|
|
|
+ ),
|
|
|
+ }}
|
|
|
+ </PageHeader>
|
|
|
+ <Table
|
|
|
+ bordered
|
|
|
+ columns={columns}
|
|
|
+ dataSource={authStore.userListController.state.list}
|
|
|
+ pagination={{
|
|
|
+ pageSize: authStore.userListController.state.size,
|
|
|
+ total: authStore.userListController.state.total,
|
|
|
+ onChange: (v) => authStore.userListController.loadPage(v),
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Card>
|
|
|
+ );
|
|
|
+ },
|
|
|
+});
|