Commit c1d9386f475af0577f619ec949f4aa5f4d737956
1 parent
24d321bc
feat: update
Showing
8 changed files
with
32 additions
and
14 deletions
.umirc.ts
src/access.ts
1 | 1 | export default (initialState: API.UserInfo) => { |
2 | 2 | // 在这里按照初始化数据定义项目中的权限,统一管理 |
3 | 3 | // 参考文档 https://umijs.org/docs/max/access |
4 | - const canSeeAdmin = !!( | |
5 | - initialState && initialState.name !== 'dontHaveAccess' | |
6 | - ); | |
4 | + const { roleSmallVO } = initialState; | |
5 | + | |
6 | + console.log(roleSmallVO.code === 'admin'); | |
7 | 7 | return { |
8 | - canSeeAdmin, | |
8 | + canReadAdmin: roleSmallVO.code === 'admin', | |
9 | 9 | }; |
10 | 10 | }; | ... | ... |
src/app.ts
... | ... | @@ -7,12 +7,12 @@ import { message } from 'antd'; |
7 | 7 | import { RESPONSE_CODE } from './constants/enum'; |
8 | 8 | |
9 | 9 | import './style/global.css'; |
10 | +import { getUserInfo } from './utils'; | |
10 | 11 | |
11 | 12 | // 全局初始化数据配置,用于 Layout 用户信息和权限初始化 |
12 | 13 | // 更多信息见文档:https://umijs.org/docs/api/runtime-config#getinitialstate |
13 | -export async function getInitialState(): Promise<{ name: string }> { | |
14 | - // getUserInfo(); | |
15 | - return { name: '' }; | |
14 | +export async function getInitialState() { | |
15 | + return getUserInfo(); | |
16 | 16 | } |
17 | 17 | |
18 | 18 | export const layout = () => { | ... | ... |
src/pages/Login/index.tsx
... | ... | @@ -9,7 +9,7 @@ import { |
9 | 9 | ProConfigProvider, |
10 | 10 | ProFormText, |
11 | 11 | } from '@ant-design/pro-components'; |
12 | -import { history, useModel } from '@umijs/max'; | |
12 | +import { useModel } from '@umijs/max'; | |
13 | 13 | import { Button, theme } from 'antd'; |
14 | 14 | import { useEffect, useState } from 'react'; |
15 | 15 | |
... | ... | @@ -27,6 +27,7 @@ export default () => { |
27 | 27 | useEffect(() => { |
28 | 28 | fetchCode(); |
29 | 29 | }, []); |
30 | + | |
30 | 31 | return ( |
31 | 32 | <ProConfigProvider hashed={false}> |
32 | 33 | <div |
... | ... | @@ -43,7 +44,10 @@ export default () => { |
43 | 44 | |
44 | 45 | if (res.result === RESPONSE_CODE.SUCCESS) { |
45 | 46 | setUserLocalInfo(res.data.token, res.data?.user); |
46 | - history.push('/order'); | |
47 | + /** | |
48 | + * 使用history.push或者history.replace会导致菜单路由无法更新,需要再次刷新页面 | |
49 | + */ | |
50 | + window.location.href = '/order'; | |
47 | 51 | } else { |
48 | 52 | fetchCode(); |
49 | 53 | } | ... | ... |
src/pages/Order/index.tsx
... | ... | @@ -6,6 +6,7 @@ import { |
6 | 6 | } from '@/services'; |
7 | 7 | import { orderExport } from '@/services/order'; |
8 | 8 | import { enumValueToLabel, formatDateTime } from '@/utils'; |
9 | +import { getUserInfo } from '@/utils/user'; | |
9 | 10 | import { |
10 | 11 | ClockCircleTwoTone, |
11 | 12 | ContainerTwoTone, |
... | ... | @@ -90,7 +91,7 @@ const OrderPage = () => { |
90 | 91 | const [orderRow, setOrderRow] = useState<Partial<OrderType>>({}); |
91 | 92 | const [mainOrderAllItemKeys, setMainOrderAllItemKeys] = useState([]); |
92 | 93 | const [rolePath, setRolePath] = useState([]); //当前角色权限(新增跟打印按钮) |
93 | - const userInfo = JSON.parse(localStorage.getItem('userInfo')); | |
94 | + const userInfo = getUserInfo(); | |
94 | 95 | // const [tableHeight, setTableHeight] = useState(200); |
95 | 96 | const [selectedRows, setSelectedRows] = useState({}); |
96 | 97 | const [selectedRowObj, setSelectedRowObj] = useState({}); | ... | ... |
src/pages/OrderReport/components/OrderDualAxes.tsx
1 | 1 | import { DualAxes } from '@ant-design/charts'; |
2 | 2 | |
3 | -const OrderDualAxes = ({ data }) => { | |
3 | +const OrderDualAxes = ({ data, statisticMethod }) => { | |
4 | + let yFiledString = ''; | |
5 | + if (statisticMethod === 'MONTH_STATISTICS') { | |
6 | + yFiledString = 'curTime'; | |
7 | + } else { | |
8 | + yFiledString = 'curMonth'; | |
9 | + } | |
4 | 10 | const config = { |
5 | 11 | data: [ |
6 | 12 | data.targetAndTotalPaymentDtoList === undefined |
... | ... | @@ -8,7 +14,7 @@ const OrderDualAxes = ({ data }) => { |
8 | 14 | : data.targetAndTotalPaymentDtoList, |
9 | 15 | data.orderNumberDtoList === undefined ? [] : data.orderNumberDtoList, |
10 | 16 | ], |
11 | - xField: 'curTime', | |
17 | + xField: yFiledString, | |
12 | 18 | yField: ['curDayTotalPayment', 'curDayTotalOrderNumber'], |
13 | 19 | geometryOptions: [ |
14 | 20 | { | ... | ... |
src/pages/OrderReport/index.tsx
1 | 1 | import { postServiceOrderQueryReportFormsInformation } from '@/services'; |
2 | 2 | import { enumToSelect } from '@/utils'; |
3 | +import { getUserInfo } from '@/utils/user'; | |
3 | 4 | import { EllipsisOutlined } from '@ant-design/icons'; |
4 | 5 | import { |
5 | 6 | PageContainer, |
... | ... | @@ -28,7 +29,7 @@ import { |
28 | 29 | import OrderDualAxes from './components/OrderDualAxes'; |
29 | 30 | import OrderStatisticCard from './components/OrderStatisticCard'; |
30 | 31 | import './index.less'; |
31 | -const userInfo = JSON.parse(localStorage.getItem('userInfo')); | |
32 | +const userInfo = getUserInfo(); | |
32 | 33 | |
33 | 34 | const OrderReportPage = () => { |
34 | 35 | const [form] = Form.useForm<{ |
... | ... | @@ -181,7 +182,10 @@ const OrderReportPage = () => { |
181 | 182 | bordered |
182 | 183 | > |
183 | 184 | <Spin spinning={loading}> |
184 | - <OrderDualAxes data={statisticData} /> | |
185 | + <OrderDualAxes | |
186 | + data={statisticData} | |
187 | + statisticMethod={statisticsMethod} | |
188 | + /> | |
185 | 189 | </Spin> |
186 | 190 | </ProCard> |
187 | 191 | </Space> | ... | ... |
src/services/demo/typings.d.ts