fix(bug)
This commit is contained in:
parent
992ce27014
commit
0c63810c25
|
@ -126,7 +126,7 @@ const SimpleForm = (props: SimpleFormData) => {
|
||||||
>
|
>
|
||||||
<TextArea
|
<TextArea
|
||||||
value={v.name}
|
value={v.name}
|
||||||
placeholder="Controlled autosize"
|
placeholder={v.label}
|
||||||
autoSize={{ minRows: 3, maxRows: 5 }}
|
autoSize={{ minRows: 3, maxRows: 5 }}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
|
@ -31,6 +31,8 @@ const LayOut = (props: Store) => {
|
||||||
const { usrStore } = props;
|
const { usrStore } = props;
|
||||||
const [collapsed, setCollapsed] = useState(false);
|
const [collapsed, setCollapsed] = useState(false);
|
||||||
const nav = useNavigate();
|
const nav = useNavigate();
|
||||||
|
const [muens, setMenus] = useState([])
|
||||||
|
|
||||||
const {
|
const {
|
||||||
token: { colorBgContainer, borderRadiusLG },
|
token: { colorBgContainer, borderRadiusLG },
|
||||||
} = theme.useToken();
|
} = theme.useToken();
|
||||||
|
@ -54,11 +56,24 @@ const LayOut = (props: Store) => {
|
||||||
];
|
];
|
||||||
const [stateOpenKeys, setStateOpenKeys] = useState(['2', '23']);
|
const [stateOpenKeys, setStateOpenKeys] = useState(['2', '23']);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// if (usrStore.isNeedLogin) {
|
usrStore.getMenu().then((res) => {
|
||||||
// nav("/login");
|
const men: any = [...res];
|
||||||
// }
|
men.forEach(element => {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
element.label = element.name;
|
||||||
}, [usrStore.isNeedLogin]);
|
element.key = element.router_path;
|
||||||
|
if (element.children?.length > 0) {
|
||||||
|
element.children?.forEach((i) => {
|
||||||
|
i.label = i.name;
|
||||||
|
i.key = i.router_path;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (element.children?.length === 0) {
|
||||||
|
element.children = null
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setMenus(men)
|
||||||
|
})
|
||||||
|
}, [usrStore, usrStore.isNeedLogin]);
|
||||||
const onOpenChange: MenuProps['onOpenChange'] = (openKeys) => {
|
const onOpenChange: MenuProps['onOpenChange'] = (openKeys) => {
|
||||||
const currentOpenKey = openKeys.find((key) => stateOpenKeys.indexOf(key) === -1);
|
const currentOpenKey = openKeys.find((key) => stateOpenKeys.indexOf(key) === -1);
|
||||||
// open
|
// open
|
||||||
|
@ -109,7 +124,7 @@ const LayOut = (props: Store) => {
|
||||||
openKeys={stateOpenKeys}
|
openKeys={stateOpenKeys}
|
||||||
style={{ height: "100%", borderRight: 0 }}
|
style={{ height: "100%", borderRight: 0 }}
|
||||||
onOpenChange={onOpenChange}
|
onOpenChange={onOpenChange}
|
||||||
items={items}
|
items={muens}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
nav(e.key);
|
nav(e.key);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
import { Space } from "antd";
|
import { Space } from "antd";
|
||||||
import { inject, observer } from "mobx-react";
|
|
||||||
import { Store } from "antd/lib/form/interface";
|
import { Store } from "antd/lib/form/interface";
|
||||||
import React, { useEffect } from "react";
|
|
||||||
import "./index.less";
|
import "./index.less";
|
||||||
import ReactECharts from 'echarts-for-react';
|
import ReactECharts from 'echarts-for-react';
|
||||||
const Dashbord = (props: Store) => {
|
const Dashbord = (props: Store) => {
|
||||||
const { usrStore } = props;
|
|
||||||
useEffect(() => {
|
|
||||||
usrStore.getMenu()
|
|
||||||
}, [])
|
|
||||||
const options = {
|
const options = {
|
||||||
grid: { top: 8, right: 8, bottom: 24, left: 36 },
|
grid: { top: 8, right: 8, bottom: 24, left: 36 },
|
||||||
xAxis: {
|
xAxis: {
|
||||||
|
@ -38,4 +32,4 @@ const Dashbord = (props: Store) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default inject("usrStore")(observer(Dashbord));
|
export default Dashbord;
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
import { FormType } from "@/components/form/interface";
|
||||||
|
import { UserDataType } from "@/model/userModel";
|
||||||
|
import { ColumnsType } from "antd/es/table";
|
||||||
|
|
||||||
|
export const defaultConfig = [
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "事件名称",
|
||||||
|
name: "name",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入事件名称!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "事件描述",
|
||||||
|
name: "desc",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入事件描述!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.textarea,
|
||||||
|
label: "事件内容",
|
||||||
|
name: "content",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入事件内容!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "事件地点",
|
||||||
|
name: "address",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入事件地点!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "事件开始时间",
|
||||||
|
name: "start_time",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入事件开始时间!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "事件开始时间",
|
||||||
|
name: "end_time",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入事件开始时间!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "造成的影响",
|
||||||
|
name: "effect",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入影响!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "负责人名称",
|
||||||
|
name: "director",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入负责人名称!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "负责人电话",
|
||||||
|
name: "tel",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入负责人电话!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.input,
|
||||||
|
label: "负责人身份证",
|
||||||
|
name: "id_card",
|
||||||
|
value: "",
|
||||||
|
rules: [{ required: true, message: "请输入负责人身份证!" }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FormType.select,
|
||||||
|
label: "事件等级",
|
||||||
|
name: "level",
|
||||||
|
value: 1,
|
||||||
|
selectList: [
|
||||||
|
{
|
||||||
|
name: "普通",
|
||||||
|
id: 1,
|
||||||
|
}, {
|
||||||
|
name: "紧急",
|
||||||
|
id: 2,
|
||||||
|
}, {
|
||||||
|
name: "特级",
|
||||||
|
id: 3,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
rules: [{ required: true, message: "请输入事件等级!" }],
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
type: FormType.upload,
|
||||||
|
label: "现场拍摄",
|
||||||
|
name: "images",
|
||||||
|
value: [],
|
||||||
|
rules: [{ required: true, message: "现场图片不能为空!" }],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
export const columns: ColumnsType<UserDataType> = [
|
||||||
|
{
|
||||||
|
title: "事件名称",
|
||||||
|
dataIndex: "name",
|
||||||
|
fixed: "left",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: "事件描述",
|
||||||
|
dataIndex: "desc",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "事件内容",
|
||||||
|
dataIndex: "content",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "事件地点",
|
||||||
|
dataIndex: "address",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "事件开始时间",
|
||||||
|
dataIndex: "start_time",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "事件结束时间",
|
||||||
|
dataIndex: "end_time",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "影响",
|
||||||
|
dataIndex: "effect",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "负责人名称",
|
||||||
|
dataIndex: "director",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "电话",
|
||||||
|
dataIndex: "tel",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "负责人身份证",
|
||||||
|
dataIndex: "id_card",
|
||||||
|
},
|
||||||
|
];
|
|
@ -1,6 +1,25 @@
|
||||||
const Event = () => {
|
import BTable from "@/components/b_table";
|
||||||
return <div>dev
|
import { Store } from "antd/es/form/interface";
|
||||||
|
import { inject, observer } from "mobx-react";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import { columns, defaultConfig } from "./config";
|
||||||
|
|
||||||
|
const Event = (props: Store) => {
|
||||||
|
const { thingStore } = props;
|
||||||
|
useEffect(() => {
|
||||||
|
thingStore.getlist();
|
||||||
|
}, [thingStore]);
|
||||||
|
|
||||||
|
return <div className="contentBox">
|
||||||
|
<BTable
|
||||||
|
btnText="添加事件"
|
||||||
|
store={thingStore}
|
||||||
|
scroll={{ x: "max-content" }}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={thingStore.list??[]}
|
||||||
|
config={defaultConfig}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Event;
|
export default inject("thingStore")(observer(Event));
|
|
@ -71,7 +71,6 @@ export const defaultConfig = [
|
||||||
name: "head_img",
|
name: "head_img",
|
||||||
value: [],
|
value: [],
|
||||||
},
|
},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const columns: ColumnsType<UserDataType> = [
|
export const columns: ColumnsType<UserDataType> = [
|
||||||
|
@ -100,17 +99,26 @@ export const columns: ColumnsType<UserDataType> = [
|
||||||
|
|
||||||
{
|
{
|
||||||
title: "登录账号",
|
title: "登录账号",
|
||||||
width: 150,
|
|
||||||
dataIndex: "account",
|
dataIndex: "account",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "身份证",
|
title: "身份证",
|
||||||
width: 150,
|
|
||||||
dataIndex: "id_card",
|
dataIndex: "id_card",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "联系电话",
|
title: "联系电话",
|
||||||
width: 150,
|
|
||||||
dataIndex: "tel",
|
dataIndex: "tel",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "所属部门",
|
||||||
|
dataIndex: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "所属单位",
|
||||||
|
dataIndex: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "角色",
|
||||||
|
dataIndex: "",
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -37,4 +37,12 @@ class CompanyConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { RoleConfig, UserConfig, MenuConfig, DepConfig, CompanyConfig };
|
class EventConfig {
|
||||||
|
static ADD: string = "/thing";
|
||||||
|
static EDIT: string = "/thing";
|
||||||
|
static LIST: string = "/thing/list";
|
||||||
|
static DELETE: string = "/thing";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export { RoleConfig, UserConfig, MenuConfig, DepConfig, CompanyConfig,EventConfig };
|
|
@ -4,6 +4,7 @@ import roleStore from './role';
|
||||||
import menuStore from './menu';
|
import menuStore from './menu';
|
||||||
import depStore from './dep';
|
import depStore from './dep';
|
||||||
import companyStore from './company';
|
import companyStore from './company';
|
||||||
|
import thingStore from './thing';
|
||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
usrStore,
|
usrStore,
|
||||||
|
@ -11,7 +12,8 @@ const store = {
|
||||||
roleStore,
|
roleStore,
|
||||||
menuStore,
|
menuStore,
|
||||||
depStore,
|
depStore,
|
||||||
companyStore
|
companyStore,
|
||||||
|
thingStore,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default store;
|
export default store;
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { makeObservable } from "mobx";
|
||||||
|
import BaseStore from "./baseStore";
|
||||||
|
import { UserDataType } from "@/model/userModel";
|
||||||
|
import { EventConfig } from "@/service/user_config";
|
||||||
|
|
||||||
|
class ThingStore extends BaseStore<UserDataType> {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(EventConfig)
|
||||||
|
makeObservable(this, {
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const thingStore = new ThingStore();
|
||||||
|
export default thingStore;
|
|
@ -71,8 +71,8 @@ class UserStore extends BaseStore<UserDataType> {
|
||||||
this.userDetail = data
|
this.userDetail = data
|
||||||
}
|
}
|
||||||
async getMenu() {
|
async getMenu() {
|
||||||
let data = await base.get(UserConfig.menu, {})
|
let res = await base.get(UserConfig.menu, {})
|
||||||
console.log(data)
|
return res.data.record
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const userStore = new UserStore();
|
const userStore = new UserStore();
|
||||||
|
|
Loading…
Reference in New Issue