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