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,18 @@
|
|
|
1
|
+
import { rgba } from 'polished';
|
|
2
|
+
import { css, styled } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export const DotWrapper = styled.span<{ checked?: boolean }>`
|
|
5
|
+
display: inline-block;
|
|
6
|
+
width: 6px;
|
|
7
|
+
height: 6px;
|
|
8
|
+
border-radius: 500px;
|
|
9
|
+
background-color: ${rgba('#828c9e', 0.5)};
|
|
10
|
+
transform: translateY(32px);
|
|
11
|
+
|
|
12
|
+
${({ checked }) =>
|
|
13
|
+
checked &&
|
|
14
|
+
css`
|
|
15
|
+
width: 18px;
|
|
16
|
+
background-color: #828c9e;
|
|
17
|
+
`}
|
|
18
|
+
`;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { useHasIntersected } from '@/hooks/useHasIntersected';
|
|
2
|
+
import { IStyleProps } from '@/types';
|
|
3
|
+
import { ReactNode, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { withoutAccessErrorCodeList } from 'src/api/request';
|
|
5
|
+
import { styled } from 'styled-components';
|
|
6
|
+
|
|
7
|
+
enum DataType {
|
|
8
|
+
NONE,
|
|
9
|
+
SUCCESS,
|
|
10
|
+
ERROR,
|
|
11
|
+
NO_ACCESS,
|
|
12
|
+
NO_DATA,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface IProps<T, L> extends IStyleProps {
|
|
16
|
+
initData?: boolean;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 返回默认值
|
|
20
|
+
*/
|
|
21
|
+
defaultValue?: T;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 请求参数
|
|
25
|
+
*/
|
|
26
|
+
requestData?: L;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 获取数据异步函数
|
|
30
|
+
* @param data
|
|
31
|
+
* @param isInside
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
service: (data?: L, isInside?: boolean) => Promise<T>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 页面渲染回调
|
|
38
|
+
* @param data
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
children: (data: T) => ReactNode;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 错误提示高度
|
|
45
|
+
*/
|
|
46
|
+
errorBoxHeight?: number | string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
debounceWait?: number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 是否是内部员工登陆
|
|
55
|
+
*/
|
|
56
|
+
isInside?: boolean;
|
|
57
|
+
|
|
58
|
+
noEmptyBox?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function RequestWrapper<T, L>({
|
|
62
|
+
initData = true,
|
|
63
|
+
defaultValue,
|
|
64
|
+
requestData,
|
|
65
|
+
service,
|
|
66
|
+
children,
|
|
67
|
+
errorBoxHeight,
|
|
68
|
+
debounceWait,
|
|
69
|
+
isInside,
|
|
70
|
+
noEmptyBox,
|
|
71
|
+
...args
|
|
72
|
+
}: IProps<T, L>) {
|
|
73
|
+
const [dataType, setDataType] = useState(DataType.NONE);
|
|
74
|
+
const [data, setData] = useState(defaultValue);
|
|
75
|
+
const requestDataStr = JSON.stringify(requestData);
|
|
76
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
77
|
+
const shouldInit = useHasIntersected(ref);
|
|
78
|
+
|
|
79
|
+
const handleGetData = useCallback(async () => {
|
|
80
|
+
try {
|
|
81
|
+
setDataType(DataType.NONE);
|
|
82
|
+
setData(
|
|
83
|
+
await service(
|
|
84
|
+
{
|
|
85
|
+
...requestData,
|
|
86
|
+
requestId: undefined,
|
|
87
|
+
} as L,
|
|
88
|
+
isInside,
|
|
89
|
+
),
|
|
90
|
+
);
|
|
91
|
+
setDataType(DataType.SUCCESS);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (withoutAccessErrorCodeList.includes(error.errorCode)) {
|
|
94
|
+
// 无权限
|
|
95
|
+
setDataType(DataType.NO_ACCESS);
|
|
96
|
+
} else {
|
|
97
|
+
setDataType(DataType.ERROR);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
+
}, [requestDataStr]);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (shouldInit && initData) {
|
|
105
|
+
handleGetData();
|
|
106
|
+
}
|
|
107
|
+
}, [shouldInit, initData, handleGetData]);
|
|
108
|
+
|
|
109
|
+
const { img, remark, btn } = dataTypeMap.get(dataType) ?? {};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<DataBoxWrapper ref={ref} {...args}>
|
|
113
|
+
{dataType === DataType.SUCCESS && !!data && children(data)}
|
|
114
|
+
{!noEmptyBox &&
|
|
115
|
+
[DataType.ERROR, DataType.NO_ACCESS, DataType.NO_ACCESS].includes(
|
|
116
|
+
dataType,
|
|
117
|
+
) && (
|
|
118
|
+
<EmptyBox style={{ height: errorBoxHeight }}>
|
|
119
|
+
<img data-img src={img} alt="" />
|
|
120
|
+
<div data-msg>
|
|
121
|
+
<span data-remark>{remark}</span>
|
|
122
|
+
<span data-btn onClick={handleGetData}>
|
|
123
|
+
{btn}
|
|
124
|
+
</span>
|
|
125
|
+
</div>
|
|
126
|
+
</EmptyBox>
|
|
127
|
+
)}
|
|
128
|
+
</DataBoxWrapper>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const DataBoxWrapper = styled.div`
|
|
133
|
+
width: 100%;
|
|
134
|
+
height: 100%;
|
|
135
|
+
|
|
136
|
+
&::-webkit-scrollbar {
|
|
137
|
+
display: none;
|
|
138
|
+
}
|
|
139
|
+
`;
|
|
140
|
+
|
|
141
|
+
const EmptyBox = styled.div`
|
|
142
|
+
width: 100%;
|
|
143
|
+
height: 60%;
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
align-items: center;
|
|
147
|
+
margin: auto;
|
|
148
|
+
|
|
149
|
+
[data-img] {
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 50%;
|
|
152
|
+
margin-bottom: 12px;
|
|
153
|
+
object-fit: contain;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
[data-msg] {
|
|
157
|
+
font-size: 12px;
|
|
158
|
+
line-height: 1;
|
|
159
|
+
|
|
160
|
+
[data-remark] {
|
|
161
|
+
color: #6d7a90;
|
|
162
|
+
margin-right: 8px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
[data-btn] {
|
|
166
|
+
color: #3379ff;
|
|
167
|
+
cursor: pointer;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`;
|
|
171
|
+
|
|
172
|
+
const dataTypeMap = new Map<
|
|
173
|
+
DataType,
|
|
174
|
+
{ img?: string; remark?: string; btn?: string }
|
|
175
|
+
>()
|
|
176
|
+
.set(DataType.ERROR, {
|
|
177
|
+
img: 'https://img.alicdn.com/imgextra/i4/O1CN01vg4MQE1e6WfWTdtx4_!!6000000003822-55-tps-190-120.svg',
|
|
178
|
+
remark: '数据加载失败',
|
|
179
|
+
btn: '刷新一下~',
|
|
180
|
+
})
|
|
181
|
+
.set(DataType.NO_ACCESS, {
|
|
182
|
+
img: 'https://img.alicdn.com/imgextra/i1/O1CN01Iz7oDf1IqrBik7NYy_!!6000000000945-55-tps-190-120.svg',
|
|
183
|
+
remark: '你暂无权限',
|
|
184
|
+
btn: '',
|
|
185
|
+
})
|
|
186
|
+
.set(DataType.NO_DATA, {
|
|
187
|
+
img: 'https://img.alicdn.com/imgextra/i4/O1CN01g0QafV1rIyRHX6HA9_!!6000000005609-55-tps-190-120.svg',
|
|
188
|
+
remark: '暂无数据',
|
|
189
|
+
btn: '',
|
|
190
|
+
});
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="@rsbuild/core/types" />
|
|
2
|
+
|
|
3
|
+
declare module '*.module.css' {
|
|
4
|
+
const classes: { [key: string]: string };
|
|
5
|
+
export default classes;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare module '*.module.scss' {
|
|
9
|
+
const classes: { [key: string]: string };
|
|
10
|
+
export default classes;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module '*.module.sass' {
|
|
14
|
+
const classes: { [key: string]: string };
|
|
15
|
+
export default classes;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare module '*.module.less' {
|
|
19
|
+
const classes: { [key: string]: string };
|
|
20
|
+
export default classes;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare module '*.module.styl' {
|
|
24
|
+
const classes: { [key: string]: string };
|
|
25
|
+
export default classes;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module '@alife/dwork-cnstr-header';
|
|
29
|
+
|
|
30
|
+
interface Window {
|
|
31
|
+
MENU_LOAD: string;
|
|
32
|
+
MY_VISION_MENU_URL: string;
|
|
33
|
+
|
|
34
|
+
openHelpDrawer?: () => void;
|
|
35
|
+
|
|
36
|
+
vConsole: VConsole;
|
|
37
|
+
|
|
38
|
+
nextConePages: {
|
|
39
|
+
activePath: string;
|
|
40
|
+
title: string;
|
|
41
|
+
url: string[];
|
|
42
|
+
}[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module '@alife/micro-stark' {
|
|
46
|
+
export const isInIcestark: () => boolean;
|
|
47
|
+
export const getMountNode: () => Element;
|
|
48
|
+
export const registerAppEnter: (cb: () => unknown) => unknown;
|
|
49
|
+
export const registerAppLeave: (cb: () => unknown) => unknown;
|
|
50
|
+
export const getBasename: () => string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare module 'react/jsx-runtime';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IListItem } from '@/types';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { CardService } from 'src/services/CardService';
|
|
5
|
+
|
|
6
|
+
export const useCardOptionList = (id?: number) => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
if (id) {
|
|
13
|
+
const data = await CardService.queryOptionList(id);
|
|
14
|
+
setState(data);
|
|
15
|
+
}
|
|
16
|
+
} catch (error) {
|
|
17
|
+
CnMessage(error.message);
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
}, [id]);
|
|
21
|
+
|
|
22
|
+
return state;
|
|
23
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CostService } from '@/services/CostService';
|
|
2
|
+
import { IListItem } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useCostFiltersDicList = (name: string, isInside = false) => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
if (name) {
|
|
12
|
+
try {
|
|
13
|
+
setState(await CostService.getDicList(name, isInside));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
CnMessage.error(error.message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
}, [isInside, name]);
|
|
20
|
+
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CommonService } from '@/services/CommonService';
|
|
2
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
export const useFbiUrl = (id?: string | number) => {
|
|
6
|
+
const [state, setState] = useState<string>();
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
(async () => {
|
|
10
|
+
try {
|
|
11
|
+
if (id) {
|
|
12
|
+
const data = await CommonService.getFbiUrl(id);
|
|
13
|
+
setState(data);
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
CnMessage.error(error.message);
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
}, [id]);
|
|
20
|
+
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { atom, useRecoilValue, useSetRecoilState } from 'recoil';
|
|
4
|
+
|
|
5
|
+
const halfScreenState = atom<{
|
|
6
|
+
show: boolean;
|
|
7
|
+
src?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
}>({
|
|
10
|
+
key: 'half-screen-state',
|
|
11
|
+
default: {
|
|
12
|
+
show: false,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const useHalfScreenStateValue = () => useRecoilValue(halfScreenState);
|
|
17
|
+
export const useSetHalfScreenState = () => useSetRecoilState(halfScreenState);
|
|
18
|
+
|
|
19
|
+
export const useHalfScreenDispatch = () => {
|
|
20
|
+
const setState = useSetRecoilState(halfScreenState);
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
setState,
|
|
24
|
+
close: () => {
|
|
25
|
+
setState(() => ({
|
|
26
|
+
src: undefined,
|
|
27
|
+
title: undefined,
|
|
28
|
+
show: false,
|
|
29
|
+
}));
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const useAutoCloseHalfScreen = () => {
|
|
35
|
+
const setState = useSetRecoilState(halfScreenState);
|
|
36
|
+
const location = useLocation();
|
|
37
|
+
const refreshRef = useRef(false);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (refreshRef.current) {
|
|
41
|
+
setState(() => ({
|
|
42
|
+
src: undefined,
|
|
43
|
+
title: undefined,
|
|
44
|
+
show: false,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
refreshRef.current = true;
|
|
49
|
+
}, [location, setState]);
|
|
50
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useState, useEffect, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 元素是否进入视口过
|
|
5
|
+
* @param ref
|
|
6
|
+
* @param options
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export const useHasIntersected = <T extends Element>(
|
|
10
|
+
ref: RefObject<T>, // 接受外部传入的 ref
|
|
11
|
+
options?: IntersectionObserverInit,
|
|
12
|
+
): boolean => {
|
|
13
|
+
const [hasIntersected, setHasIntersected] = useState(false);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
// 确保传入的 ref.current 不为空
|
|
17
|
+
if (ref.current) {
|
|
18
|
+
const observer = new IntersectionObserver((entries) => {
|
|
19
|
+
// 当元素进入视口时,更新状态
|
|
20
|
+
if (entries[0].isIntersecting) {
|
|
21
|
+
setHasIntersected(true);
|
|
22
|
+
// 如果只想监听一次,可以在这里取消观察
|
|
23
|
+
observer.unobserve(ref.current!);
|
|
24
|
+
}
|
|
25
|
+
}, options);
|
|
26
|
+
|
|
27
|
+
observer.observe(ref.current);
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
observer.disconnect();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}, [ref, options]);
|
|
34
|
+
|
|
35
|
+
return hasIntersected;
|
|
36
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IndicatorService } from 'src/services/IndicatorService';
|
|
2
|
+
import { IIndicatorCardConfig } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { INDICATOR_CONFIG_BASE_URL } from 'src/utils';
|
|
6
|
+
|
|
7
|
+
export const useIndicatorCardInfo = (id?: number) => {
|
|
8
|
+
const [state, setState] = useState<Partial<IIndicatorCardConfig>>({});
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
(async () => {
|
|
12
|
+
if (id) {
|
|
13
|
+
try {
|
|
14
|
+
const data = await IndicatorService.getConfigInfo({
|
|
15
|
+
url: `${INDICATOR_CONFIG_BASE_URL}?id=${id}`,
|
|
16
|
+
});
|
|
17
|
+
setState(data);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
CnMessage(error.message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
})();
|
|
23
|
+
}, [id]);
|
|
24
|
+
|
|
25
|
+
return state;
|
|
26
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 useIndicatorCardQueryList = (id?: number | string) => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
if (id) {
|
|
12
|
+
try {
|
|
13
|
+
setState(await IndicatorService.getCardQueryList(id));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
CnMessage.error(error.message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
}, [id]);
|
|
20
|
+
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 useIndicatorClassifyList = (isFirstLevel?: boolean) => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const data = await IndicatorService.getClassifyList();
|
|
13
|
+
setState(
|
|
14
|
+
isFirstLevel
|
|
15
|
+
? data.map((item) => ({ label: item.label, value: item.value }))
|
|
16
|
+
: data,
|
|
17
|
+
);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
CnMessage(error.message);
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
}, [isFirstLevel]);
|
|
23
|
+
|
|
24
|
+
return state;
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 useIndicatorDetailsDateList = (id?: number | string) => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
if (id) {
|
|
12
|
+
try {
|
|
13
|
+
setState(await IndicatorService.getDateList(id));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
CnMessage.error(error.message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
}, [id]);
|
|
20
|
+
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IndicatorService } from '@/services/IndicatorService';
|
|
2
|
+
import { IIndicatorDetailsInfo, IIndicatorInfoQuery } from '@/types';
|
|
3
|
+
import { CnMessage } from '@cainiaofe/cn-ui';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
export const useIndicatorDetailsInfo = ({
|
|
7
|
+
subId,
|
|
8
|
+
name,
|
|
9
|
+
type,
|
|
10
|
+
indicatorDate,
|
|
11
|
+
originId,
|
|
12
|
+
}: IIndicatorInfoQuery) => {
|
|
13
|
+
const [state, setState] = useState<Partial<IIndicatorDetailsInfo>>({});
|
|
14
|
+
const [loading, setLoading] = useState(false);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
(async () => {
|
|
18
|
+
if (subId && indicatorDate) {
|
|
19
|
+
try {
|
|
20
|
+
setLoading(true);
|
|
21
|
+
if (name && type) {
|
|
22
|
+
setState(
|
|
23
|
+
await IndicatorService.getDownDetails({
|
|
24
|
+
originId,
|
|
25
|
+
subId,
|
|
26
|
+
name,
|
|
27
|
+
type,
|
|
28
|
+
indicatorDate,
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
setState(
|
|
33
|
+
await IndicatorService.getDetails({
|
|
34
|
+
subId,
|
|
35
|
+
indicatorDate,
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
CnMessage.error(error.message);
|
|
41
|
+
} finally {
|
|
42
|
+
setLoading(false);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
}, [subId, name, type, indicatorDate, originId]);
|
|
47
|
+
|
|
48
|
+
return { data: state, loading };
|
|
49
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 useIndicatorDetailsTrend = (
|
|
7
|
+
id?: string | number,
|
|
8
|
+
name?: string,
|
|
9
|
+
) => {
|
|
10
|
+
const [state, setState] = useState<IListItem<number>[]>([]);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
(async () => {
|
|
14
|
+
if (id && name) {
|
|
15
|
+
try {
|
|
16
|
+
setState(await IndicatorService.getDetailsTrend(id, name));
|
|
17
|
+
} catch (error) {
|
|
18
|
+
CnMessage.error(error.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
}, [id, name]);
|
|
23
|
+
|
|
24
|
+
return state;
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 useIndicatorDicList = (name: string) => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
if (name) {
|
|
12
|
+
try {
|
|
13
|
+
setState(await IndicatorService.getDicList(name));
|
|
14
|
+
} catch (error) {
|
|
15
|
+
CnMessage.error(error.message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
}, [name]);
|
|
20
|
+
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
@@ -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 useIndicatorLabelList = () => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
setState(await IndicatorService.getLabelList());
|
|
13
|
+
} catch (error) {
|
|
14
|
+
CnMessage.error(error.message);
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
}, []);
|
|
18
|
+
|
|
19
|
+
return state;
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 useIndicatorList = (timeSpan?: string, orgLevel?: string) => {
|
|
7
|
+
const [state, setState] = useState<IListItem<number>[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const data = await IndicatorService.queryIndicatorList(
|
|
13
|
+
timeSpan,
|
|
14
|
+
orgLevel,
|
|
15
|
+
);
|
|
16
|
+
setState(data);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
CnMessage(error.message);
|
|
19
|
+
}
|
|
20
|
+
})();
|
|
21
|
+
}, [orgLevel, timeSpan]);
|
|
22
|
+
|
|
23
|
+
return state;
|
|
24
|
+
};
|
|
@@ -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 useIndicatorRangeList = () => {
|
|
7
|
+
const [state, setState] = useState<IListItem[]>([]);
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
(async () => {
|
|
11
|
+
try {
|
|
12
|
+
setState(await IndicatorService.getRangeList());
|
|
13
|
+
} catch (error) {
|
|
14
|
+
CnMessage.error(error.message);
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
}, []);
|
|
18
|
+
|
|
19
|
+
return state;
|
|
20
|
+
};
|