diff --git a/src/pages/dashbord/index.tsx b/src/pages/dashbord/index.tsx index cd75d48..986c72c 100644 --- a/src/pages/dashbord/index.tsx +++ b/src/pages/dashbord/index.tsx @@ -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 (
+ { + setIsModalOpen(false); + }} + > + +
); }; - -export default Dashbord; +export default inject("usrStore")(observer(Dashbord)); diff --git a/src/pages/user/user.tsx b/src/pages/user/user.tsx index 5761ab3..ab14592 100644 --- a/src/pages/user/user.tsx +++ b/src/pages/user/user.tsx @@ -24,7 +24,6 @@ const User = (props: Store) => { usrStore.deleteItem(record); }} config={defaultConfig} - editCallback={(record) => {}} /> ); diff --git a/src/service/base.ts b/src/service/base.ts index 035eb9d..e718d7c 100644 --- a/src/service/base.ts +++ b/src/service/base.ts @@ -40,6 +40,7 @@ class BaseHttps { }); return res.data; }; + async post(url: string, params: any) { let res = await axios({ method: 'post', diff --git a/src/service/user_config.ts b/src/service/user_config.ts index 39751f2..9d41850 100644 --- a/src/service/user_config.ts +++ b/src/service/user_config.ts @@ -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 { diff --git a/src/store/baseStore.ts b/src/store/baseStore.ts index 4e17e07..b5de8d5 100644 --- a/src/store/baseStore.ts +++ b/src/store/baseStore.ts @@ -42,11 +42,13 @@ class BaseStore implements BaseStoreInterface { console.log(error); } } + // 分页 setPages(page: Pages) { this.page = page this.getlist() } + // 添加 async add(param: any, listParam?: any) { try { diff --git a/src/store/user.ts b/src/store/user.ts index 888293f..329de9c 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -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 { _userinfo: UserInfos = {}; // 用户信息 @@ -71,10 +72,33 @@ class UserStore extends BaseStore { 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; \ No newline at end of file