win-chart 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +3 -0
- package/.prettierrc.json +5 -0
- package/README.md +0 -0
- package/localhost-key.pem +28 -0
- package/localhost.pem +25 -0
- package/package.json +65 -0
- package/rsbuild.config.ts +48 -0
- package/src/api/README.md +15 -0
- package/src/api/index.js +5 -0
- package/src/api/layout/index.js +32 -0
- package/src/api/request.ts +87 -0
- package/src/api/url-map/index.js +10 -0
- package/src/api/user/index.js +12 -0
- package/src/components/FilterContext.tsx +6 -0
- package/src/components/GlobalStyle.tsx +25 -0
- package/src/components/HalfScreenBrowser.tsx +95 -0
- package/src/components/ImgBox.tsx +19 -0
- package/src/components/JumpBtn.tsx +38 -0
- package/src/components/MCardWrapper.tsx +33 -0
- package/src/components/NoContent/index.tsx +85 -0
- package/src/components/ResponsiveReactGridLayout.tsx +218 -0
- package/src/components/SliderDecoration.tsx +27 -0
- package/src/components/VisionUserConfigContext.ts +6 -0
- package/src/components/WinMenu/README.md +11 -0
- package/src/components/WinMenu/WinHeader.tsx +5 -0
- package/src/components/WinMenu/components/ExtraBox.tsx +61 -0
- package/src/components/WinMenu/components/FullMenuBox.tsx +80 -0
- package/src/components/WinMenu/components/FullMenuContainer.tsx +50 -0
- package/src/components/WinMenu/components/FullMenuItem.tsx +128 -0
- package/src/components/WinMenu/components/LangSwitch.tsx +84 -0
- package/src/components/WinMenu/components/LogoBox.tsx +29 -0
- package/src/components/WinMenu/components/PinDialog.tsx +72 -0
- package/src/components/WinMenu/components/PinnedMenuBox.tsx +183 -0
- package/src/components/WinMenu/components/UserBox.tsx +83 -0
- package/src/components/WinMenu/hooks/useUserInfo.ts +21 -0
- package/src/components/WinMenu/hooks/useUserMenu.ts +35 -0
- package/src/components/WinMenu/index.tsx +100 -0
- package/src/components/WinMenu/services/WinService.ts +79 -0
- package/src/components/WinMenu/services/request.ts +53 -0
- package/src/components/WinMenu/utils/const.ts +80 -0
- package/src/components/WinMenu/utils/enum.ts +19 -0
- package/src/components/WinMenu/utils/interface.ts +61 -0
- package/src/components/WinMenu/utils/map.ts +39 -0
- package/src/components/WinMenu/utils/tool.ts +142 -0
- package/src/components/WinMenu/utils/type.ts +1 -0
- package/src/components/hover-view.tsx +48 -0
- package/src/components/icon.tsx +44 -0
- package/src/components/indicator-remark.tsx +25 -0
- package/src/components/none-content.tsx +93 -0
- package/src/components/panel-tab.tsx +150 -0
- package/src/components/panel-title-tab.tsx +60 -0
- package/src/components/win-card/components/ChartContent.tsx +47 -0
- package/src/components/win-card/components/Indicator.tsx +42 -0
- package/src/components/win-card/components/IndicatorArea.tsx +63 -0
- package/src/components/win-card/components/IndicatorInfo.tsx +78 -0
- package/src/components/win-card/components/MatterContent.tsx +121 -0
- package/src/components/win-card/components/MatterList.tsx +141 -0
- package/src/components/win-card/components/NoticeContent.tsx +73 -0
- package/src/components/win-card/components/NoticeList.tsx +68 -0
- package/src/components/win-card/components/SelectDecoration.tsx +34 -0
- package/src/components/win-card/components/WinRankContent.tsx +102 -0
- package/src/components/win-card/index.tsx +298 -0
- package/src/components/win-card/utils/interface.ts +12 -0
- package/src/components/win-card/utils/tool.ts +11 -0
- package/src/components/win-card-mobile/components/ChartContent.tsx +47 -0
- package/src/components/win-card-mobile/components/DualLineBar.tsx +61 -0
- package/src/components/win-card-mobile/components/Indicator.tsx +42 -0
- package/src/components/win-card-mobile/components/IndicatorArea.tsx +65 -0
- package/src/components/win-card-mobile/components/IndicatorInfo.tsx +83 -0
- package/src/components/win-card-mobile/components/SelectDecoration.tsx +28 -0
- package/src/components/win-card-mobile/index.tsx +235 -0
- package/src/components/win-card-mobile/utils/interface.ts +12 -0
- package/src/components/win-card-mobile/utils/tool.ts +9 -0
- package/src/components/win-chart/components/chart-wrapper.tsx +5 -0
- package/src/components/win-chart/index.tsx +59 -0
- package/src/components/win-chart/theme/win-dark.json +372 -0
- package/src/components/win-chart/theme/win-light.json +372 -0
- package/src/components/win-chart/utils/const.ts +37 -0
- package/src/components/win-chart/utils/getAreaSpec.ts +150 -0
- package/src/components/win-chart/utils/getBarSpec.ts +60 -0
- package/src/components/win-chart/utils/getChartOptions.ts +59 -0
- package/src/components/win-chart/utils/getColumnSpec.ts +112 -0
- package/src/components/win-chart/utils/getDualSpec.ts +79 -0
- package/src/components/win-chart/utils/getFunnelSpec.ts +70 -0
- package/src/components/win-chart/utils/getLineSpec.ts +53 -0
- package/src/components/win-chart/utils/getPieSpec.ts +124 -0
- package/src/components/win-chart/utils/getRadarSpec.ts +87 -0
- package/src/components/win-chart/utils/tool.ts +163 -0
- package/src/components/win-chart/utils/type.ts +96 -0
- package/src/components/win-icon/index.tsx +97 -0
- package/src/components/win-v/components/EmptyBox.tsx +9 -0
- package/src/components/win-v/components/VDialog.tsx +173 -0
- package/src/components/win-v/components/VDialogBtn.tsx +119 -0
- package/src/components/win-v/components/VDialogMsg.tsx +325 -0
- package/src/components/win-v/components/VInput.tsx +15 -0
- package/src/components/win-v/components/VRemindMsgList.tsx +303 -0
- package/src/components/win-v/components/VRobot.tsx +97 -0
- package/src/components/win-v/hooks/useVDialogCore.ts +102 -0
- package/src/components/win-v/hooks/useVDialogOperate.ts +132 -0
- package/src/components/win-v/hooks/useVDialogState.ts +52 -0
- package/src/components/win-v/hooks/useVRemindMsgShow.ts +15 -0
- package/src/components/win-v/index.tsx +205 -0
- package/src/components/win-wrappers/card-wrapper.tsx +103 -0
- package/src/components/win-wrappers/dot-wrapper.tsx +18 -0
- package/src/components/win-wrappers/iframe-wrapper.tsx +7 -0
- package/src/components/win-wrappers/request-wrapper.tsx +190 -0
- package/src/global.d.ts +53 -0
- package/src/hooks/useCardOptionList.ts +23 -0
- package/src/hooks/useCostFiltersDicList.ts +22 -0
- package/src/hooks/useFbiUrl.ts +22 -0
- package/src/hooks/useHalfScreenState.ts +50 -0
- package/src/hooks/useHasIntersected.ts +36 -0
- package/src/hooks/useIndicatorCardInfo.ts +26 -0
- package/src/hooks/useIndicatorCardQueryList.ts +22 -0
- package/src/hooks/useIndicatorClassifyList.ts +25 -0
- package/src/hooks/useIndicatorDetailsDateList.ts +22 -0
- package/src/hooks/useIndicatorDetailsInfo.ts +49 -0
- package/src/hooks/useIndicatorDetailsTrend.ts +25 -0
- package/src/hooks/useIndicatorDicList.ts +22 -0
- package/src/hooks/useIndicatorLabelList.ts +20 -0
- package/src/hooks/useIndicatorList.ts +24 -0
- package/src/hooks/useIndicatorRangeList.ts +20 -0
- package/src/hooks/useIndicatorTypeList.ts +20 -0
- package/src/hooks/useIndicatorUnitList.ts +21 -0
- package/src/hooks/useListenQuery.ts +29 -0
- package/src/hooks/useMobile.ts +58 -0
- package/src/hooks/useNotice.ts +42 -0
- package/src/hooks/useOrgLevelList.ts +23 -0
- package/src/hooks/usePageSelection.ts +121 -0
- package/src/hooks/usePageState.ts +22 -0
- package/src/hooks/usePendingList.ts +27 -0
- package/src/hooks/usePortalPageInfo.ts +43 -0
- package/src/hooks/useRefreshByLocationChange.ts +16 -0
- package/src/hooks/useReportIndicatorList.ts +21 -0
- package/src/hooks/useReportInfo.ts +45 -0
- package/src/hooks/useReportPersonList.ts +21 -0
- package/src/hooks/useScriptLoader.ts +22 -0
- package/src/hooks/useUnreadMsgList.ts +26 -0
- package/src/hooks/useUserAvatar.ts +23 -0
- package/src/hooks/useVReportInfo.ts +50 -0
- package/src/hooks/useVisionUserConfig.ts +25 -0
- package/src/hooks/useWorkbenchOptions.ts +63 -0
- package/src/index.tsx +20 -0
- package/src/services/CardService.ts +91 -0
- package/src/services/CommonService.ts +23 -0
- package/src/services/CostService.ts +56 -0
- package/src/services/DialogService.ts +74 -0
- package/src/services/IndicatorService.ts +406 -0
- package/src/services/PageService.ts +204 -0
- package/src/services/ReportService.ts +335 -0
- package/src/services/WorkbenchService.ts +411 -0
- package/src/styles/README.md +12 -0
- package/src/styles/index.scss +9 -0
- package/src/styles/mixins/index.scss +25 -0
- package/src/styles/next-cover.scss +4 -0
- package/src/styles/normalize.scss +27 -0
- package/src/styles/utilities/index.scss +5 -0
- package/src/styles/vars/index.scss +17 -0
- package/src/types/enum-workbench.ts +29 -0
- package/src/types/enum.ts +156 -0
- package/src/types/index.ts +19 -0
- package/src/types/indicator.ts +299 -0
- package/src/types/interface.ts +303 -0
- package/src/types/portal.ts +211 -0
- package/src/types/report.ts +28 -0
- package/src/types/type.ts +11 -0
- package/src/types/user.ts +28 -0
- package/src/utils/README.md +4 -0
- package/src/utils/arms.ts +59 -0
- package/src/utils/arr.ts +123 -0
- package/src/utils/const-workbench.ts +9 -0
- package/src/utils/const.ts +18 -0
- package/src/utils/index.ts +18 -0
- package/src/utils/init.ts +5 -0
- package/src/utils/map-workbench.ts +66 -0
- package/src/utils/map.ts +377 -0
- package/src/utils/number.ts +101 -0
- package/src/utils/page.ts +81 -0
- package/src/utils/str.ts +26 -0
- package/src/utils/tools.ts +44 -0
- package/src/utils/tree.ts +145 -0
- package/src/utils/url.ts +40 -0
- package/src/utils/util.ts +99 -0
- package/src/utils/workbench.ts +25 -0
- package/tsconfig.json +33 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IndicatorService } from '@/services/IndicatorService';
|
|
2
|
+
import { IListItem } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useIndicatorTypeList = () => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
setState(await IndicatorService.getTypeList());
|
|
13
|
+
} catch (error) {
|
|
14
|
+
CnMessage.error(error.message);
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
}, []);
|
|
18
|
+
|
|
19
|
+
return state;
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IndicatorService } from 'src/services/IndicatorService';
|
|
2
|
+
import { IListItem } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useIndicatorUnitList = () => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const data = await IndicatorService.getUnitList();
|
|
13
|
+
setState(data);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
CnMessage(error.message);
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return state;
|
|
21
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useListenQuery = () => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
// 监听地址参数的变化
|
|
6
|
+
const handleParamChange = () => {
|
|
7
|
+
// 获取当前页面的参数部分
|
|
8
|
+
const currentParams = window.location.search;
|
|
9
|
+
|
|
10
|
+
// 根据需要修改参数的值或者添加新的参数
|
|
11
|
+
const newParams = `${currentParams}¶m=value`;
|
|
12
|
+
|
|
13
|
+
// 重定向到修改后的地址并刷新页面
|
|
14
|
+
window.location.href =
|
|
15
|
+
window.location.origin + window.location.pathname + newParams;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 在组件挂载时执行一次监听
|
|
19
|
+
handleParamChange();
|
|
20
|
+
|
|
21
|
+
// 监听地址参数的变化,并执行回调函数
|
|
22
|
+
window.addEventListener('popstate', handleParamChange);
|
|
23
|
+
|
|
24
|
+
// 在组件卸载时取消监听
|
|
25
|
+
return () => {
|
|
26
|
+
window.removeEventListener('popstate', handleParamChange);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isMobileDevice } from '@/utils';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { atom, useRecoilValue, useSetRecoilState } from 'recoil';
|
|
4
|
+
|
|
5
|
+
const mobileState = atom({
|
|
6
|
+
key: 'mobile-state',
|
|
7
|
+
default: isMobileDevice(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 获取 mobileState
|
|
12
|
+
* @returns 是否为移动端
|
|
13
|
+
*/
|
|
14
|
+
export const useMobileState = () => useRecoilValue(mobileState);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 监听屏幕大小变化,设置 mobileState
|
|
18
|
+
*/
|
|
19
|
+
export const useMobileStateControl = () => {
|
|
20
|
+
const setMobileState = useSetRecoilState(mobileState);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
// 定义处理屏幕大小变化的函数
|
|
24
|
+
function handleResize() {
|
|
25
|
+
setMobileState(isMobileDevice());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 监听屏幕大小变化的事件
|
|
29
|
+
window.addEventListener('resize', handleResize);
|
|
30
|
+
|
|
31
|
+
// 返回一个清理函数,以在组件卸载时移除事件监听器
|
|
32
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
33
|
+
}, [setMobileState]); // 空依赖数组确保事件监听器只被设置和清理一次
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 在移动端设置 <meta> 标签
|
|
38
|
+
*/
|
|
39
|
+
export const useMobileSetting = () => {
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
// 创建 <meta> 元素
|
|
42
|
+
const meta = document.createElement('meta');
|
|
43
|
+
meta.setAttribute('name', 'viewport');
|
|
44
|
+
meta.setAttribute(
|
|
45
|
+
'content',
|
|
46
|
+
'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// 插入 <meta> 元素到 <head> 中
|
|
50
|
+
document.head.appendChild(meta);
|
|
51
|
+
|
|
52
|
+
// 清理函数
|
|
53
|
+
return () => {
|
|
54
|
+
// 在组件卸载时移除 <meta> 元素
|
|
55
|
+
document.head.removeChild(meta);
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { INoticeInfo } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui-m';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { WorkbenchService } from 'src/services/WorkbenchService';
|
|
5
|
+
|
|
6
|
+
export const useNoticeInfo = (id?: number | string) => {
|
|
7
|
+
const [state, setState] = useState<Partial<INoticeInfo>>({});
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
if (id) {
|
|
12
|
+
try {
|
|
13
|
+
const data = await WorkbenchService.queryNoticeInfo(id);
|
|
14
|
+
setState(data);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
CnMessage(error.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
}, [id]);
|
|
21
|
+
|
|
22
|
+
return state;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const useNoticeBannerList = (init = true) => {
|
|
26
|
+
const [state, setState] = useState<INoticeInfo[]>([]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
(async () => {
|
|
30
|
+
if (init) {
|
|
31
|
+
try {
|
|
32
|
+
const data = await WorkbenchService.queryNoticeBannerList();
|
|
33
|
+
setState(data);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
CnMessage(error.message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
}, [init]);
|
|
40
|
+
|
|
41
|
+
return state;
|
|
42
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IndicatorService } from 'src/services/IndicatorService';
|
|
2
|
+
import { IListItem } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useOrgLevelList = (orgLevel?: string) => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
if (orgLevel) {
|
|
13
|
+
const data = await IndicatorService.getOrgLevelList(orgLevel);
|
|
14
|
+
setState(data);
|
|
15
|
+
}
|
|
16
|
+
} catch (error) {
|
|
17
|
+
CnMessage(error.message);
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
}, [orgLevel]);
|
|
21
|
+
|
|
22
|
+
return state;
|
|
23
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { IListItem, IListItemDataSourceMap } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { PageService } from '@/services/PageService';
|
|
5
|
+
import { filterComponentTypeList } from '@/utils';
|
|
6
|
+
|
|
7
|
+
export const usePageSelectionTypeList = () => {
|
|
8
|
+
const [state, setState] = useState<IListItem[]>(filterComponentTypeList);
|
|
9
|
+
|
|
10
|
+
// useEffect(() => {
|
|
11
|
+
// (async () => {
|
|
12
|
+
// try {
|
|
13
|
+
// const data = await PageService.getPageSelectionTypeList();
|
|
14
|
+
// setState(data);
|
|
15
|
+
// } catch (error) {
|
|
16
|
+
// CnMessage(error.message);
|
|
17
|
+
// }
|
|
18
|
+
// })();
|
|
19
|
+
// }, []);
|
|
20
|
+
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const useStructedPropertyList = (instanceId?: string | number) => {
|
|
25
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
26
|
+
|
|
27
|
+
// useEffect(() => {
|
|
28
|
+
// (async () => {
|
|
29
|
+
// try {
|
|
30
|
+
// const data = await PageService.getStructedPropertyList(instanceId);
|
|
31
|
+
// setState(data);
|
|
32
|
+
// } catch (error) {
|
|
33
|
+
// CnMessage(error.message);
|
|
34
|
+
// }
|
|
35
|
+
// })();
|
|
36
|
+
// }, [instanceId]);
|
|
37
|
+
|
|
38
|
+
return state;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const useTimeSelectionTypeList = () => {
|
|
42
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
43
|
+
|
|
44
|
+
// useEffect(() => {
|
|
45
|
+
// (async () => {
|
|
46
|
+
// try {
|
|
47
|
+
// const data = await PageService.getTimeSelectionTypeList();
|
|
48
|
+
// setState(data);
|
|
49
|
+
// } catch (error) {
|
|
50
|
+
// CnMessage(error.message);
|
|
51
|
+
// }
|
|
52
|
+
// })();
|
|
53
|
+
// }, []);
|
|
54
|
+
|
|
55
|
+
return state;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const useStructedPropertyDataSource = (
|
|
59
|
+
structedPropertyCode?: string,
|
|
60
|
+
) => {
|
|
61
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
62
|
+
|
|
63
|
+
// useEffect(() => {
|
|
64
|
+
// (async () => {
|
|
65
|
+
// if (structedPropertyCode) {
|
|
66
|
+
// try {
|
|
67
|
+
// const data = await PageService.getStructedPropertyDataSource(structedPropertyCode);
|
|
68
|
+
// setState(data);
|
|
69
|
+
// } catch (error) {
|
|
70
|
+
// CnMessage(error.message);
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
73
|
+
// })();
|
|
74
|
+
// }, [structedPropertyCode]);
|
|
75
|
+
|
|
76
|
+
return state;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const useStructedPropertyDataSourceByCodeList = (
|
|
80
|
+
structedPropertyCodeList?: string[],
|
|
81
|
+
) => {
|
|
82
|
+
const [state, setState] = useState<IListItemDataSourceMap>({});
|
|
83
|
+
|
|
84
|
+
// useEffect(() => {
|
|
85
|
+
// (async () => {
|
|
86
|
+
// if (Array.isArray(structedPropertyCodeList)) {
|
|
87
|
+
// const dataMap: IListItemDataSourceMap = {};
|
|
88
|
+
// await Promise.all(
|
|
89
|
+
// structedPropertyCodeList.map(async (code) => {
|
|
90
|
+
// try {
|
|
91
|
+
// const data = await PageService.getStructedPropertyDataSource(code);
|
|
92
|
+
// dataMap[code] = data;
|
|
93
|
+
// } catch (error) {
|
|
94
|
+
// CnMessage(error.message);
|
|
95
|
+
// }
|
|
96
|
+
// }),
|
|
97
|
+
// );
|
|
98
|
+
// setState(dataMap);
|
|
99
|
+
// }
|
|
100
|
+
// })();
|
|
101
|
+
// }, [structedPropertyCodeList]);
|
|
102
|
+
|
|
103
|
+
return state;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const useShowPropertyList = () => {
|
|
107
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
108
|
+
|
|
109
|
+
// useEffect(() => {
|
|
110
|
+
// (async () => {
|
|
111
|
+
// try {
|
|
112
|
+
// const data = await PageService.getShowPropertyList();
|
|
113
|
+
// setState(data);
|
|
114
|
+
// } catch (error) {
|
|
115
|
+
// CnMessage(error.message);
|
|
116
|
+
// }
|
|
117
|
+
// })();
|
|
118
|
+
// }, []);
|
|
119
|
+
|
|
120
|
+
return state;
|
|
121
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
atom,
|
|
3
|
+
useRecoilState,
|
|
4
|
+
useRecoilValue,
|
|
5
|
+
useSetRecoilState,
|
|
6
|
+
} from 'recoil';
|
|
7
|
+
import { getSearchParams } from '@/utils';
|
|
8
|
+
import { PageType } from '../types';
|
|
9
|
+
|
|
10
|
+
const state = atom({
|
|
11
|
+
key: 'workbench-page-context-mobile',
|
|
12
|
+
default: {
|
|
13
|
+
pageType:
|
|
14
|
+
getSearchParams().tab === PageType.MY_APPROVAL
|
|
15
|
+
? PageType.MY_APPROVAL
|
|
16
|
+
: PageType.WORKBENCH,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const usePageState = () => useRecoilState(state);
|
|
21
|
+
export const usePageStateValue = () => useRecoilValue(state);
|
|
22
|
+
export const useSetPageState = () => useSetRecoilState(state);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IMatterPendingInfo } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui-m';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { WorkbenchService } from 'src/services/WorkbenchService';
|
|
5
|
+
|
|
6
|
+
export const usePendingList = (init = true) => {
|
|
7
|
+
const [state, setState] = useState<IMatterPendingInfo[]>([
|
|
8
|
+
{ desc: '待我审批', count: '0', url: '' },
|
|
9
|
+
{ desc: '我的V信', count: '0', url: '' },
|
|
10
|
+
{ desc: '新鲜速递', count: '0', url: '' },
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
(async () => {
|
|
15
|
+
if (init) {
|
|
16
|
+
try {
|
|
17
|
+
const data = await WorkbenchService.queryPendingList();
|
|
18
|
+
setState(data);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
CnMessage(error.message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})();
|
|
24
|
+
}, [init]);
|
|
25
|
+
|
|
26
|
+
return state;
|
|
27
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { PageService } from 'src/services/PageService';
|
|
4
|
+
import { IPortalPageInfo } from 'src/types';
|
|
5
|
+
|
|
6
|
+
interface IRequestParams {
|
|
7
|
+
code?: string;
|
|
8
|
+
pageType?: string;
|
|
9
|
+
init?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const usePortalPageInfo = ({
|
|
13
|
+
pageType,
|
|
14
|
+
code,
|
|
15
|
+
init = true,
|
|
16
|
+
}: IRequestParams) => {
|
|
17
|
+
const [state, setState] = useState<Partial<IPortalPageInfo>>({});
|
|
18
|
+
|
|
19
|
+
const handleGetData = useCallback(async () => {
|
|
20
|
+
if (code || pageType) {
|
|
21
|
+
try {
|
|
22
|
+
const data = await PageService.queryIndicatorPageDetail(code, pageType);
|
|
23
|
+
|
|
24
|
+
if (data) {
|
|
25
|
+
setState(data);
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
CnMessage(error.message);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, [code, pageType]);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (init) {
|
|
35
|
+
handleGetData();
|
|
36
|
+
}
|
|
37
|
+
}, [init, handleGetData]);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
pageInfo: state,
|
|
41
|
+
refreshPageInfo: handleGetData,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
export const useRefreshByLocationChange = () => {
|
|
5
|
+
const [, setState] = useState<{}>({});
|
|
6
|
+
const location = useLocation();
|
|
7
|
+
const refreshRef = useRef(false);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (refreshRef.current) {
|
|
11
|
+
setState({});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
refreshRef.current = true;
|
|
15
|
+
}, [location]);
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReportService } from '@/services/ReportService';
|
|
2
|
+
import { IListItem } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useReportIndicatorList = () => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const data = await ReportService.getIndicatorList();
|
|
13
|
+
setState(data);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
CnMessage(error.message);
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return state;
|
|
21
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReportService } from '@/services/ReportService';
|
|
2
|
+
import { IReportContentInfo, IReportTplInfo } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui-m';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useReportTplInfo = (id?: number | string) => {
|
|
7
|
+
const [state, setState] = useState<Partial<IReportTplInfo>>({});
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
if (id) {
|
|
12
|
+
try {
|
|
13
|
+
const data = await ReportService.getTemplateDetails(id);
|
|
14
|
+
setState(data);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
CnMessage(error.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
}, [id]);
|
|
21
|
+
|
|
22
|
+
return state;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const useReportContentInfo = (
|
|
26
|
+
id?: number | string,
|
|
27
|
+
importType?: string,
|
|
28
|
+
) => {
|
|
29
|
+
const [state, setState] = useState<Partial<IReportContentInfo>>({});
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
(async () => {
|
|
33
|
+
if (id) {
|
|
34
|
+
try {
|
|
35
|
+
const data = await ReportService.getContentDetails(id, importType);
|
|
36
|
+
setState(data);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
CnMessage(error.message);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
}, [id, importType]);
|
|
43
|
+
|
|
44
|
+
return state;
|
|
45
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReportService } from '@/services/ReportService';
|
|
2
|
+
import { IListItem } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui-m';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useReportPersonList = () => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const data = await ReportService.getPersonList();
|
|
13
|
+
setState(data);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
CnMessage(error.message);
|
|
16
|
+
}
|
|
17
|
+
})();
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return state;
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export const useScriptLoader = (scriptUrl: string) => {
|
|
4
|
+
const [loaded, setLoaded] = useState(false);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (document.querySelector(`script[src="${scriptUrl}"]`)) {
|
|
8
|
+
setLoaded(true);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const script = document.createElement('script');
|
|
12
|
+
script.src = scriptUrl;
|
|
13
|
+
script.async = true;
|
|
14
|
+
script.onload = () => setLoaded(true);
|
|
15
|
+
document.body.appendChild(script);
|
|
16
|
+
return () => {
|
|
17
|
+
document.body.removeChild(script);
|
|
18
|
+
};
|
|
19
|
+
}, [scriptUrl]);
|
|
20
|
+
|
|
21
|
+
return loaded;
|
|
22
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IUnreadMsg } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { PageService } from 'src/services/PageService';
|
|
5
|
+
|
|
6
|
+
export const useUnreadMsgList = () => {
|
|
7
|
+
const [state, setState] = useState<IUnreadMsg[]>([]);
|
|
8
|
+
|
|
9
|
+
const getData = useCallback(async () => {
|
|
10
|
+
try {
|
|
11
|
+
const data = await PageService.queryUnreadMsg();
|
|
12
|
+
setState(data);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
CnMessage(error.message);
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
getData();
|
|
20
|
+
}, [getData]);
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
msgList: state,
|
|
24
|
+
handleRefreshMsgList: getData,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IUserAvatarInfo } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui-m';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { WorkbenchService } from 'src/services/WorkbenchService';
|
|
5
|
+
|
|
6
|
+
export const useUserAvatar = (init = true) => {
|
|
7
|
+
const [state, setState] = useState<IUserAvatarInfo>({});
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
if (init) {
|
|
12
|
+
try {
|
|
13
|
+
const data = await WorkbenchService.queryUserAvatar();
|
|
14
|
+
setState(data);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
CnMessage(error.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
}, [init]);
|
|
21
|
+
|
|
22
|
+
return state;
|
|
23
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { IMsgCountInfo, IVReportInfo } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui-m';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { WorkbenchService } from 'src/services/WorkbenchService';
|
|
5
|
+
|
|
6
|
+
export const useVReportInfo = () => {
|
|
7
|
+
const [state, setState] = useState<Partial<IVReportInfo> & IMsgCountInfo>({});
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const data = await WorkbenchService.queryVReportInfo();
|
|
13
|
+
const countData = await WorkbenchService.queryVReportMessageCount();
|
|
14
|
+
|
|
15
|
+
if (data && countData) {
|
|
16
|
+
setState({
|
|
17
|
+
...data,
|
|
18
|
+
...countData,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
CnMessage(error.message);
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
return state;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const useVReportMessageCount = (init = true) => {
|
|
31
|
+
const [state, setState] = useState<IMsgCountInfo>({
|
|
32
|
+
unreadCount: 0,
|
|
33
|
+
messageCount: 0,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
(async () => {
|
|
38
|
+
if (init) {
|
|
39
|
+
try {
|
|
40
|
+
const data = await WorkbenchService.queryVReportMessageCount();
|
|
41
|
+
setState(data);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
CnMessage(error.message);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
}, [init]);
|
|
48
|
+
|
|
49
|
+
return state;
|
|
50
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IVisionUserConfig } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { PageService } from 'src/services/PageService';
|
|
5
|
+
|
|
6
|
+
export const useVisionUserConfig = () => {
|
|
7
|
+
const [state, setState] = useState<IVisionUserConfig>();
|
|
8
|
+
|
|
9
|
+
const handleGetData = useCallback(async () => {
|
|
10
|
+
try {
|
|
11
|
+
setState(await PageService.getVisionUserConfig());
|
|
12
|
+
} catch (error) {
|
|
13
|
+
CnMessage.error(error.message);
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
handleGetData();
|
|
19
|
+
}, [handleGetData]);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
data: state,
|
|
23
|
+
refresh: handleGetData,
|
|
24
|
+
};
|
|
25
|
+
};
|