fix(bug)
This commit is contained in:
parent
e1ec20882e
commit
3c81498378
|
@ -1,8 +1,15 @@
|
|||
import { Space } from "antd";
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
import { Checkbox, Modal, Space } from "antd";
|
||||
import { Store } from "antd/lib/form/interface";
|
||||
import "./index.less";
|
||||
import ReactECharts from 'echarts-for-react';
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { useEffect, useState } from "react";
|
||||
const Dashbord = (props: Store) => {
|
||||
const { usrStore } = props;
|
||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
||||
const [plainOptions, setOption] = useState();
|
||||
const [check, setCheck] = useState([])
|
||||
const options = {
|
||||
grid: { top: 8, right: 8, bottom: 24, left: 36 },
|
||||
xAxis: {
|
||||
|
@ -23,13 +30,59 @@ const Dashbord = (props: Store) => {
|
|||
trigger: 'axis',
|
||||
},
|
||||
};
|
||||
useEffect(() => {
|
||||
getColumn()
|
||||
getHead()
|
||||
}, [])
|
||||
|
||||
const getHead = async () => {
|
||||
const res = await usrStore.getHead()
|
||||
if (res.length > 0) {
|
||||
res.forEach((element) => {
|
||||
element.label = element.data_name;
|
||||
element.value = element.identity;
|
||||
element.editable = true;
|
||||
});
|
||||
setOption(res)
|
||||
}
|
||||
}
|
||||
|
||||
const getColumn = async () => {
|
||||
const res = await usrStore.getUsed()
|
||||
if (res.length === 0) {
|
||||
console.log(res)
|
||||
setIsModalOpen(true)
|
||||
}
|
||||
}
|
||||
|
||||
const onChange = (checkedValues) => {
|
||||
setCheck(checkedValues)
|
||||
};
|
||||
|
||||
const handleOk = async () => {
|
||||
const res = await usrStore.setUsed({ identitys: check })
|
||||
console.log(res)
|
||||
}
|
||||
return (
|
||||
<div className="contentBox">
|
||||
<Space direction="vertical" size="middle" style={{ display: "flex" }}>
|
||||
<ReactECharts option={options} />
|
||||
</Space>
|
||||
<Modal
|
||||
title={"常用列设置"}
|
||||
width={600}
|
||||
height={600}
|
||||
open={isModalOpen}
|
||||
onOk={handleOk}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
onCancel={() => {
|
||||
setIsModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<Checkbox.Group options={plainOptions} defaultValue={[]} onChange={onChange} />
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Dashbord;
|
||||
export default inject("usrStore")(observer(Dashbord));
|
||||
|
|
|
@ -24,7 +24,6 @@ const User = (props: Store) => {
|
|||
usrStore.deleteItem(record);
|
||||
}}
|
||||
config={defaultConfig}
|
||||
editCallback={(record) => {}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -40,6 +40,7 @@ class BaseHttps {
|
|||
});
|
||||
return res.data;
|
||||
};
|
||||
|
||||
async post(url: string, params: any) {
|
||||
let res = await axios({
|
||||
method: 'post',
|
||||
|
|
|
@ -5,6 +5,8 @@ class UserConfig {
|
|||
static LIST: string = "/user/list";
|
||||
static DELETE: string = "/user";
|
||||
static menu: string = "/user/menu";
|
||||
static used: string = "/user/used";
|
||||
|
||||
}
|
||||
|
||||
class RoleConfig {
|
||||
|
|
|
@ -42,11 +42,13 @@ class BaseStore<B> implements BaseStoreInterface<B> {
|
|||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 分页
|
||||
setPages(page: Pages) {
|
||||
this.page = page
|
||||
this.getlist()
|
||||
}
|
||||
|
||||
// 添加
|
||||
async add(param: any, listParam?: any) {
|
||||
try {
|
||||
|
|
|
@ -4,6 +4,7 @@ import BaseStore from "./baseStore";
|
|||
import { UserDataType, UserInfos } from "@/model/userModel";
|
||||
import { message } from "antd";
|
||||
import { UserConfig } from "@/service/user_config";
|
||||
import SourceConfig from "@/service/source_config";
|
||||
|
||||
class UserStore extends BaseStore<UserDataType> {
|
||||
_userinfo: UserInfos = {}; // 用户信息
|
||||
|
@ -71,10 +72,33 @@ class UserStore extends BaseStore<UserDataType> {
|
|||
setUserDetaul(data) {
|
||||
this.userDetail = data
|
||||
}
|
||||
|
||||
// 获取菜单
|
||||
async getMenu() {
|
||||
let res = await base.get(UserConfig.menu, {})
|
||||
return res.data.record
|
||||
}
|
||||
|
||||
// 获取常用表头
|
||||
async getUsed() {
|
||||
let res = await base.get(UserConfig.used, {})
|
||||
return res.data.record
|
||||
}
|
||||
|
||||
// 设置常用表头
|
||||
async setUsed(params) {
|
||||
await base.post(UserConfig.used, params)
|
||||
}
|
||||
|
||||
// 获取全部表头
|
||||
async getHead() {
|
||||
let res = await base.get(SourceConfig.Headers, {})
|
||||
if (res.code !== 200) {
|
||||
message.error(res.msg)
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const userStore = new UserStore();
|
||||
export default userStore;
|
Loading…
Reference in New Issue