first commit
This commit is contained in:
parent
3139834c14
commit
fb488762f5
|
@ -9,7 +9,6 @@ interface UserValue {
|
|||
const Dumbselect = (props: Store) => {
|
||||
const { usrStore } = props;
|
||||
const [value, setValue] = useState<UserValue[]>([]);
|
||||
|
||||
async function fetchUserList(username: string): Promise<UserValue[]> {
|
||||
return usrStore.serchUser(username).then((res) => {
|
||||
return res.data.record.map((item) => ({
|
||||
|
|
|
@ -1,48 +1,21 @@
|
|||
import { Button, Space, Modal, FormInstance } from "antd";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import BTable from "@/components/b_table";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import React from "react";
|
||||
import { columns } from "./role_config";
|
||||
import { columns, defaultConfig } from "./role_config";
|
||||
import "./role.less";
|
||||
|
||||
const Role = (props: Store) => {
|
||||
const { roleStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
||||
const formRef = React.useRef<FormInstance>(null);
|
||||
const [userId, setId] = useState<Number | null>(null);
|
||||
|
||||
useEffect(() => {}, []);
|
||||
|
||||
const addHandler = () => {};
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<Button type="default" onClick={() => addHandler()}>
|
||||
添加角色
|
||||
</Button>
|
||||
<BTable
|
||||
btnText="添加角色"
|
||||
store={roleStore}
|
||||
scroll={{ x: "max-content" }}
|
||||
columns={columns}
|
||||
config={defaultConfig}
|
||||
dataSource={roleStore.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>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,97 +1,56 @@
|
|||
import { FormType } from "@/components/form/interface";
|
||||
import { UserDataType } from "@/model/userModel";
|
||||
import { ColumnsType } from "antd/lib/table";
|
||||
import { Image } from "antd";
|
||||
import { getBirthDateAndGender } from "@/util/util";
|
||||
export const defaultConfig = (team, per) => [
|
||||
export const defaultConfig = [
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "角色名称",
|
||||
name: "user_name",
|
||||
name: "name",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入用户名称!" }],
|
||||
},
|
||||
|
||||
{
|
||||
type: FormType.inputNumber,
|
||||
label: "年龄",
|
||||
name: "age",
|
||||
label: "角色描述",
|
||||
name: "desc",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入年龄" }],
|
||||
rules: [{ required: true, message: "请输入角色描述" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "身份证",
|
||||
name: "id_card",
|
||||
label: "菜单权限",
|
||||
name: "menu_rights",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入身份证" }],
|
||||
rules: [{ required: true, message: "请输入菜单权限" }],
|
||||
},
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "登录账号",
|
||||
name: "account",
|
||||
label: "接口权限",
|
||||
name: "api_rights",
|
||||
value: "",
|
||||
rules: [{ required: true, message: "请输入登录账号" }],
|
||||
},
|
||||
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "联系电话",
|
||||
name: "tel",
|
||||
value: "",
|
||||
},
|
||||
|
||||
{
|
||||
type: FormType.input,
|
||||
label: "邮箱",
|
||||
name: "email",
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
type: FormType.upload,
|
||||
label: "头像",
|
||||
name: "head_img",
|
||||
value: [],
|
||||
rules: [{ required: true, message: "请输入接口权限" }],
|
||||
},
|
||||
];
|
||||
|
||||
export const columns: ColumnsType<UserDataType> = [
|
||||
{
|
||||
title: "用户名",
|
||||
dataIndex: "user_name",
|
||||
width: 200,
|
||||
title: "角色名称",
|
||||
dataIndex: "name",
|
||||
fixed: "left",
|
||||
},
|
||||
{
|
||||
title: "性别",
|
||||
width: 150,
|
||||
render: (render) => (
|
||||
<span>{getBirthDateAndGender(render.id_card)?.gender}</span>
|
||||
),
|
||||
title: "角色描述",
|
||||
dataIndex: "desc",
|
||||
},
|
||||
|
||||
{
|
||||
title: "头像",
|
||||
dataIndex: "head_img",
|
||||
width: 150,
|
||||
render: (head_img) => {
|
||||
return <Image src={head_img}></Image>;
|
||||
},
|
||||
title: "菜单权限",
|
||||
dataIndex: "menu_rights",
|
||||
},
|
||||
|
||||
{
|
||||
title: "登录账号",
|
||||
width: 150,
|
||||
dataIndex: "account",
|
||||
},
|
||||
{
|
||||
title: "身份证",
|
||||
width: 150,
|
||||
dataIndex: "id_card",
|
||||
},
|
||||
{
|
||||
title: "联系电话",
|
||||
width: 150,
|
||||
dataIndex: "tel",
|
||||
title: "接口权限",
|
||||
dataIndex: "api_rights",
|
||||
},
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue