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