first commit
This commit is contained in:
parent
9906e9d6b5
commit
3139834c14
|
@ -1,5 +1,7 @@
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
FormInstance,
|
||||||
|
Modal,
|
||||||
Pagination,
|
Pagination,
|
||||||
PaginationProps,
|
PaginationProps,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
|
@ -8,6 +10,8 @@ import {
|
||||||
Table,
|
Table,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import SimpleForm from "./form/simple_form";
|
||||||
|
import React from "react";
|
||||||
const BTable = (props: any) => {
|
const BTable = (props: any) => {
|
||||||
const {
|
const {
|
||||||
store,
|
store,
|
||||||
|
@ -19,8 +23,13 @@ const BTable = (props: any) => {
|
||||||
actionCloumn,
|
actionCloumn,
|
||||||
onSizeChange,
|
onSizeChange,
|
||||||
onPageChange,
|
onPageChange,
|
||||||
|
config,
|
||||||
|
btnText,
|
||||||
} = props;
|
} = props;
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||||
|
const formRef = React.useRef<FormInstance>(null);
|
||||||
|
const [record, setRecord] = useState<any>(null);
|
||||||
|
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||||
const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
|
const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
|
||||||
setSelectedRowKeys(newSelectedRowKeys);
|
setSelectedRowKeys(newSelectedRowKeys);
|
||||||
selectCallback(newSelectedRowKeys);
|
selectCallback(newSelectedRowKeys);
|
||||||
|
@ -62,6 +71,8 @@ const BTable = (props: any) => {
|
||||||
type="dashed"
|
type="dashed"
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setRecord(record);
|
||||||
|
setIsModalOpen(true);
|
||||||
editCallback(record);
|
editCallback(record);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -85,8 +96,15 @@ const BTable = (props: any) => {
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
const addHandler = () => {
|
||||||
|
setRecord(null);
|
||||||
|
setIsModalOpen(true);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||||
|
<Button type="default" onClick={() => addHandler()}>
|
||||||
|
{btnText ?? "添加部门"}
|
||||||
|
</Button>
|
||||||
<Table
|
<Table
|
||||||
style={{ height: "100%", overflow: "auto" }}
|
style={{ height: "100%", overflow: "auto" }}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
|
@ -107,7 +125,32 @@ const BTable = (props: any) => {
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
<Modal
|
||||||
|
title={!record?.id ? "添加" : "编辑"}
|
||||||
|
width={800}
|
||||||
|
open={isModalOpen}
|
||||||
|
afterClose={() => formRef.current?.resetFields()}
|
||||||
|
onOk={() => formRef.current?.submit()}
|
||||||
|
okText="确定"
|
||||||
|
cancelText="取消"
|
||||||
|
onCancel={() => {
|
||||||
|
setIsModalOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SimpleForm
|
||||||
|
formName={"user_form"}
|
||||||
|
formRef={formRef}
|
||||||
|
colProps={25}
|
||||||
|
onFinish={() => {
|
||||||
|
store.add(formRef.current?.getFieldsValue());
|
||||||
|
}}
|
||||||
|
createCallback={() => {
|
||||||
|
formRef.current?.setFieldsValue(record);
|
||||||
|
}}
|
||||||
|
formDatas={config}
|
||||||
|
></SimpleForm>
|
||||||
|
</Modal>
|
||||||
|
</Space>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,66 +1,26 @@
|
||||||
import { Button, Space, Modal, FormInstance } from "antd";
|
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import BTable from "@/components/b_table";
|
import BTable from "@/components/b_table";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect } from "react";
|
||||||
import { Store } from "antd/lib/form/interface";
|
import { Store } from "antd/lib/form/interface";
|
||||||
import React from "react";
|
|
||||||
import { columns, defaultConfig } from "./dep_config";
|
import { columns, defaultConfig } from "./dep_config";
|
||||||
import "./dep.less";
|
import "./dep.less";
|
||||||
import SimpleForm from "@/components/form/simple_form";
|
|
||||||
|
|
||||||
const Dep = (props: Store) => {
|
const Dep = (props: Store) => {
|
||||||
const { depStore } = props;
|
const { depStore } = props;
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
|
||||||
const formRef = React.useRef<FormInstance>(null);
|
|
||||||
const [userId, setId] = useState<Number | null>(null);
|
|
||||||
const [record, setRecord] = useState<any>(null);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
depStore.getlist();
|
depStore.getlist();
|
||||||
}, []);
|
}, [depStore]);
|
||||||
|
|
||||||
const addHandler = () => {
|
|
||||||
setIsModalOpen(true);
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<div className="contentBox">
|
<div className="contentBox">
|
||||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
<BTable
|
||||||
<Button type="default" onClick={() => addHandler()}>
|
store={depStore}
|
||||||
添加部门
|
scroll={{ x: "max-content" }}
|
||||||
</Button>
|
columns={columns}
|
||||||
<BTable
|
config={defaultConfig}
|
||||||
store={depStore}
|
dataSource={depStore.list}
|
||||||
scroll={{ x: "max-content" }}
|
/>
|
||||||
columns={columns}
|
|
||||||
dataSource={depStore.list}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Modal
|
|
||||||
title={!userId ? "添加" : "编辑"}
|
|
||||||
width={800}
|
|
||||||
open={isModalOpen}
|
|
||||||
afterClose={() => formRef.current?.resetFields()}
|
|
||||||
onOk={() => formRef.current?.submit()}
|
|
||||||
okText="确定"
|
|
||||||
cancelText="取消"
|
|
||||||
onCancel={() => {
|
|
||||||
setId(null);
|
|
||||||
setIsModalOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SimpleForm
|
|
||||||
formName={"user_form"}
|
|
||||||
formRef={formRef}
|
|
||||||
colProps={25}
|
|
||||||
onFinish={() => {
|
|
||||||
depStore.add(formRef.current?.getFieldsValue());
|
|
||||||
}}
|
|
||||||
createCallback={() => {
|
|
||||||
formRef.current?.setFieldsValue(record);
|
|
||||||
}}
|
|
||||||
formDatas={defaultConfig}
|
|
||||||
></SimpleForm>
|
|
||||||
</Modal>
|
|
||||||
</Space>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,48 +1,27 @@
|
||||||
import { Button, Space, Modal, FormInstance } from "antd";
|
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import BTable from "@/components/b_table";
|
import BTable from "@/components/b_table";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect } from "react";
|
||||||
import { Store } from "antd/lib/form/interface";
|
import { Store } from "antd/lib/form/interface";
|
||||||
import React from "react";
|
import { columns, defaultConfig } from "./menu_config";
|
||||||
import { columns } from "./menu_config";
|
|
||||||
import "./menu.less";
|
import "./menu.less";
|
||||||
|
|
||||||
const Menu = (props: Store) => {
|
const Menu = (props: Store) => {
|
||||||
const { menuStore } = props;
|
const { menuStore } = props;
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
|
||||||
const formRef = React.useRef<FormInstance>(null);
|
|
||||||
const [userId, setId] = useState<Number | null>(null);
|
|
||||||
|
|
||||||
useEffect(() => {}, []);
|
useEffect(() => {
|
||||||
|
menuStore.getlist();
|
||||||
|
}, [menuStore]);
|
||||||
|
|
||||||
const addHandler = () => {};
|
|
||||||
return (
|
return (
|
||||||
<div className="contentBox">
|
<div className="contentBox">
|
||||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
<BTable
|
||||||
<Button type="default" onClick={() => addHandler()}>
|
btnText="添加菜单"
|
||||||
添加菜单
|
store={menuStore}
|
||||||
</Button>
|
scroll={{ x: "max-content" }}
|
||||||
<BTable
|
columns={columns}
|
||||||
store={menuStore}
|
dataSource={menuStore.list}
|
||||||
scroll={{ x: "max-content" }}
|
config={defaultConfig}
|
||||||
columns={columns}
|
/>
|
||||||
dataSource={menuStore.list}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Modal
|
|
||||||
title={!userId ? "添加菜单" : "编辑菜单"}
|
|
||||||
width={800}
|
|
||||||
open={isModalOpen}
|
|
||||||
afterClose={() => formRef.current?.resetFields()}
|
|
||||||
onOk={() => formRef.current?.submit()}
|
|
||||||
okText="确定"
|
|
||||||
cancelText="取消"
|
|
||||||
onCancel={() => {
|
|
||||||
setId(null);
|
|
||||||
setIsModalOpen(false);
|
|
||||||
}}
|
|
||||||
></Modal>
|
|
||||||
</Space>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { FormType } from "@/components/form/interface";
|
import { FormType } from "@/components/form/interface";
|
||||||
import { UserDataType } from "@/model/userModel";
|
import { UserDataType } from "@/model/userModel";
|
||||||
import { ColumnsType } from "antd/lib/table";
|
import { ColumnsType } from "antd/lib/table";
|
||||||
import { Image } from "antd";
|
|
||||||
import { getBirthDateAndGender } from "@/util/util";
|
import { getBirthDateAndGender } from "@/util/util";
|
||||||
export const defaultConfig = (team, per) => [
|
|
||||||
|
export const defaultConfig = [
|
||||||
{
|
{
|
||||||
type: FormType.input,
|
type: FormType.input,
|
||||||
label: "菜单名称",
|
label: "菜单名称",
|
||||||
|
@ -11,20 +11,50 @@ export const defaultConfig = (team, per) => [
|
||||||
value: "",
|
value: "",
|
||||||
rules: [{ required: true, message: "请输入名称!" }],
|
rules: [{ required: true, message: "请输入名称!" }],
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: FormType.inputNumber,
|
type: FormType.upload,
|
||||||
label: "icon",
|
label: "图标",
|
||||||
name: "icon",
|
name: "icon",
|
||||||
value: "",
|
value: "",
|
||||||
rules: [{ required: true, message: "请输入年龄" }],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: FormType.input,
|
type: FormType.input,
|
||||||
label: "路径",
|
label: "路由",
|
||||||
name: "id_card",
|
name: "router_path",
|
||||||
value: "",
|
value: "",
|
||||||
rules: [{ required: true, message: "请输入身份证" }],
|
rules: [{ required: true, message: "请输入路由" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "路由标题",
|
||||||
|
name: "title",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入路由" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "路由外部链接",
|
||||||
|
name: "href",
|
||||||
|
value: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "上级菜单",
|
||||||
|
name: "pid",
|
||||||
|
value: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "激活子菜单",
|
||||||
|
name: "active_menu",
|
||||||
|
value: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "本地图标",
|
||||||
|
name: "local_icon",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入路由" }],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -40,12 +70,24 @@ export const columns: ColumnsType<UserDataType> = [
|
||||||
<span>{getBirthDateAndGender(render.id_card)?.gender}</span>
|
<span>{getBirthDateAndGender(render.id_card)?.gender}</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: "路径",
|
title: "路由",
|
||||||
dataIndex: "head_img",
|
dataIndex: "router_path",
|
||||||
render: (head_img) => {
|
},
|
||||||
return <Image src={head_img}></Image>;
|
{
|
||||||
},
|
title: "路由标题",
|
||||||
|
dataIndex: "title",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "路由外部链接",
|
||||||
|
dataIndex: "href",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "指定激活子菜单",
|
||||||
|
dataIndex: "active_menu",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "本地图标",
|
||||||
|
dataIndex: "local_icon",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,20 +1,12 @@
|
||||||
import { Button, Space, Modal, FormInstance } from "antd";
|
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import BTable from "@/components/b_table";
|
import BTable from "@/components/b_table";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect } from "react";
|
||||||
import { Store } from "antd/lib/form/interface";
|
import { Store } from "antd/lib/form/interface";
|
||||||
import React from "react";
|
|
||||||
import { columns, defaultConfig } from "./user_config";
|
import { columns, defaultConfig } from "./user_config";
|
||||||
import "./user.less";
|
import "./user.less";
|
||||||
import SimpleForm from "@/components/form/simple_form";
|
|
||||||
|
|
||||||
const User = (props: Store) => {
|
const User = (props: Store) => {
|
||||||
const { usrStore } = props;
|
const { usrStore } = props;
|
||||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
|
||||||
const formRef = React.useRef<FormInstance>(null);
|
|
||||||
const [userId, setId] = useState<Number | null>(null);
|
|
||||||
const [record, setRecord] = useState<any>(null);
|
|
||||||
|
|
||||||
// 获取列表数据
|
// 获取列表数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
usrStore.getlist();
|
usrStore.getlist();
|
||||||
|
@ -22,54 +14,18 @@ const User = (props: Store) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="contentBox">
|
<div className="contentBox">
|
||||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
<BTable
|
||||||
<Button type="default" onClick={() => setIsModalOpen(true)}>
|
store={usrStore}
|
||||||
添加用户
|
scroll={{ x: "max-content" }}
|
||||||
</Button>
|
columns={columns}
|
||||||
<BTable
|
btnText="添加人员"
|
||||||
store={usrStore}
|
dataSource={usrStore.list}
|
||||||
scroll={{ x: "max-content" }}
|
deleteCallback={(record) => {
|
||||||
columns={columns}
|
usrStore.deleteItem(record);
|
||||||
dataSource={usrStore.list}
|
}}
|
||||||
deleteCallback={(record) => {
|
config={defaultConfig}
|
||||||
usrStore.deleteItem(record);
|
editCallback={(record) => {}}
|
||||||
}}
|
/>
|
||||||
editCallback={(record) => {
|
|
||||||
setIsModalOpen(true);
|
|
||||||
formRef.current?.setFieldsValue(record);
|
|
||||||
setRecord(record);
|
|
||||||
setId(record.id);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Modal
|
|
||||||
title={!userId ? "添加用户" : "编辑用户"}
|
|
||||||
width={800}
|
|
||||||
open={isModalOpen}
|
|
||||||
afterClose={() => formRef.current?.resetFields()}
|
|
||||||
onOk={() => formRef.current?.submit()}
|
|
||||||
okText="确定"
|
|
||||||
cancelText="取消"
|
|
||||||
onCancel={() => {
|
|
||||||
setId(null);
|
|
||||||
setRecord(null);
|
|
||||||
setIsModalOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SimpleForm
|
|
||||||
formName={"user_form"}
|
|
||||||
formRef={formRef}
|
|
||||||
colProps={25}
|
|
||||||
onFinish={() => {
|
|
||||||
usrStore.add(formRef.current?.getFieldsValue())
|
|
||||||
}}
|
|
||||||
createCallback={() => {
|
|
||||||
formRef.current?.setFieldsValue(record);
|
|
||||||
}}
|
|
||||||
formDatas={defaultConfig as any}
|
|
||||||
></SimpleForm>
|
|
||||||
</Modal>
|
|
||||||
</Space>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,10 +14,10 @@ class RoleConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MenuConfig {
|
class MenuConfig {
|
||||||
static ADD: string = "/role";
|
static ADD: string = "/menu";
|
||||||
static EDIT: string = "/role";
|
static EDIT: string = "/menu";
|
||||||
static LIST: string = "/role/list";
|
static LIST: string = "/menu/list";
|
||||||
static DELETE: string = "/role";
|
static DELETE: string = "/menu";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { makeObservable } from "mobx";
|
import { makeObservable } from "mobx";
|
||||||
import BaseStore from "./baseStore";
|
import BaseStore from "./baseStore";
|
||||||
import { UserDataType } from "@/model/userModel";
|
import { UserDataType } from "@/model/userModel";
|
||||||
import { RoleConfig } from "@/service/user_config";
|
import { MenuConfig } from "@/service/user_config";
|
||||||
|
|
||||||
class MenuStore extends BaseStore<UserDataType> {
|
class MenuStore extends BaseStore<UserDataType> {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(RoleConfig)
|
super(MenuConfig)
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue