prod-test-chat-sdk 0.0.1
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/.prettierrc.js +24 -0
- package/README.md +46 -0
- package/config/env.js +104 -0
- package/config/getHttpsConfig.js +66 -0
- package/config/jest/babelTransform.js +29 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +134 -0
- package/config/paths.js +77 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +785 -0
- package/config/webpackDevServer.config.js +127 -0
- package/dist/Chat/AgentList/index.d.ts +9 -0
- package/dist/Chat/ChatFooter/index.d.ts +17 -0
- package/dist/Chat/Conversation/index.d.ts +11 -0
- package/dist/Chat/MessageContainer/index.d.ts +19 -0
- package/dist/Chat/MobileAgents/index.d.ts +11 -0
- package/dist/Chat/components/AgentTip/index.d.ts +8 -0
- package/dist/Chat/components/ConversationModal/index.d.ts +10 -0
- package/dist/Chat/components/CopilotAvatar/index.d.ts +2 -0
- package/dist/Chat/components/Message.d.ts +10 -0
- package/dist/Chat/components/RecommendQuestions/index.d.ts +6 -0
- package/dist/Chat/components/Text.d.ts +9 -0
- package/dist/Chat/constants.d.ts +19 -0
- package/dist/Chat/index.d.ts +17 -0
- package/dist/Chat/service.d.ts +11 -0
- package/dist/Chat/type.d.ts +97 -0
- package/dist/Copilot/constants.d.ts +11 -0
- package/dist/Copilot/index.d.ts +13 -0
- package/dist/ShowCase/index.d.ts +8 -0
- package/dist/ShowCase/service.d.ts +2 -0
- package/dist/ShowCase/type.d.ts +11 -0
- package/dist/common/constants.d.ts +58 -0
- package/dist/common/env.d.ts +3 -0
- package/dist/common/type.d.ts +247 -0
- package/dist/components/ChatItem/ExecuteItem.d.ts +25 -0
- package/dist/components/ChatItem/ExpandParseTip.d.ts +20 -0
- package/dist/components/ChatItem/FilterItem.d.ts +17 -0
- package/dist/components/ChatItem/Loading.d.ts +2 -0
- package/dist/components/ChatItem/ParseTip.d.ts +26 -0
- package/dist/components/ChatItem/ParseTipUtils.d.ts +10 -0
- package/dist/components/ChatItem/SimilarQuestionItem.d.ts +10 -0
- package/dist/components/ChatItem/SqlItem.d.ts +17 -0
- package/dist/components/ChatItem/SwitchEntity.d.ts +9 -0
- package/dist/components/ChatItem/Text.d.ts +6 -0
- package/dist/components/ChatItem/Typing.d.ts +2 -0
- package/dist/components/ChatItem/index.d.ts +33 -0
- package/dist/components/ChatMsg/ApplyAuth/index.d.ts +7 -0
- package/dist/components/ChatMsg/Bar/index.d.ts +13 -0
- package/dist/components/ChatMsg/DateOptions/index.d.ts +9 -0
- package/dist/components/ChatMsg/FilterSection/index.d.ts +8 -0
- package/dist/components/ChatMsg/MarkDown/index.d.ts +10 -0
- package/dist/components/ChatMsg/Message/index.d.ts +18 -0
- package/dist/components/ChatMsg/MetricCard/PeriodCompareItem.d.ts +7 -0
- package/dist/components/ChatMsg/MetricCard/index.d.ts +10 -0
- package/dist/components/ChatMsg/MetricTrend/MetricInfo.d.ts +8 -0
- package/dist/components/ChatMsg/MetricTrend/MetricTrendChart.d.ts +14 -0
- package/dist/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.d.ts +12 -0
- package/dist/components/ChatMsg/MetricTrend/index.d.ts +16 -0
- package/dist/components/ChatMsg/NoPermissionChart/index.d.ts +8 -0
- package/dist/components/ChatMsg/Pie/PieChart.d.ts +11 -0
- package/dist/components/ChatMsg/Pie/index.d.ts +14 -0
- package/dist/components/ChatMsg/Table/index.d.ts +12 -0
- package/dist/components/ChatMsg/Text/index.d.ts +9 -0
- package/dist/components/ChatMsg/WebPage/index.d.ts +8 -0
- package/dist/components/ChatMsg/index.d.ts +15 -0
- package/dist/components/DrillDownDimensions/DimensionSection.d.ts +11 -0
- package/dist/components/DrillDownDimensions/index.d.ts +13 -0
- package/dist/components/IconFont/index.d.ts +3 -0
- package/dist/components/MetricOptions/index.d.ts +11 -0
- package/dist/components/RecommendOptions/index.d.ts +9 -0
- package/dist/components/Tools/FeedbackModal.d.ts +9 -0
- package/dist/components/Tools/index.d.ts +12 -0
- package/dist/demo/Chat.d.ts +2 -0
- package/dist/demo/ChatDemo.d.ts +4 -0
- package/dist/demo/CopilotDemo.d.ts +2 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useComposing.d.ts +5 -0
- package/dist/hooks/useExportByEcharts.d.ts +10 -0
- package/dist/hooks/useMethodRegister.d.ts +4 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.es.js +1 -0
- package/dist/service/axiosInstance.d.ts +3 -0
- package/dist/service/index.d.ts +25 -0
- package/dist/utils/utils.d.ts +45 -0
- package/package.json +214 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/manifest.json +15 -0
- package/public/robots.txt +3 -0
- package/rollup/rollup.config.mjs +37 -0
- package/rollup/rollup.esm.config.mjs +21 -0
- package/rollup/rollup.umd.config.mjs +30 -0
- package/scripts/build.js +217 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +52 -0
- package/src/Chat/AgentList/index.tsx +52 -0
- package/src/Chat/AgentList/style.module.less +83 -0
- package/src/Chat/ChatFooter/index.tsx +423 -0
- package/src/Chat/ChatFooter/style.module.less +225 -0
- package/src/Chat/Conversation/index.tsx +236 -0
- package/src/Chat/Conversation/style.module.less +171 -0
- package/src/Chat/MessageContainer/index.tsx +145 -0
- package/src/Chat/MessageContainer/style.module.less +53 -0
- package/src/Chat/MobileAgents/index.tsx +62 -0
- package/src/Chat/MobileAgents/style.module.less +55 -0
- package/src/Chat/components/AgentTip/index.tsx +48 -0
- package/src/Chat/components/AgentTip/style.module.less +44 -0
- package/src/Chat/components/ConversationModal/index.tsx +65 -0
- package/src/Chat/components/CopilotAvatar/index.tsx +8 -0
- package/src/Chat/components/CopilotAvatar/style.module.less +13 -0
- package/src/Chat/components/Message.tsx +38 -0
- package/src/Chat/components/RecommendQuestions/index.tsx +64 -0
- package/src/Chat/components/RecommendQuestions/style.module.less +36 -0
- package/src/Chat/components/Text.tsx +42 -0
- package/src/Chat/components/style.module.less +311 -0
- package/src/Chat/constants.ts +37 -0
- package/src/Chat/index.tsx +526 -0
- package/src/Chat/service.ts +49 -0
- package/src/Chat/style.module.less +119 -0
- package/src/Chat/type.ts +107 -0
- package/src/Copilot/constants.ts +11 -0
- package/src/Copilot/index.tsx +149 -0
- package/src/Copilot/style.module.less +151 -0
- package/src/ShowCase/index.tsx +120 -0
- package/src/ShowCase/service.ts +12 -0
- package/src/ShowCase/style.module.less +46 -0
- package/src/ShowCase/type.ts +14 -0
- package/src/common/constants.ts +93 -0
- package/src/common/env.ts +5 -0
- package/src/common/type.ts +270 -0
- package/src/components/ChatItem/ExecuteItem.tsx +211 -0
- package/src/components/ChatItem/ExpandParseTip.tsx +333 -0
- package/src/components/ChatItem/FilterItem.tsx +209 -0
- package/src/components/ChatItem/Loading.tsx +14 -0
- package/src/components/ChatItem/ParseTip.tsx +322 -0
- package/src/components/ChatItem/ParseTipUtils.tsx +205 -0
- package/src/components/ChatItem/SimilarQuestionItem.tsx +84 -0
- package/src/components/ChatItem/SqlItem.tsx +410 -0
- package/src/components/ChatItem/SwitchEntity.tsx +52 -0
- package/src/components/ChatItem/Text.tsx +17 -0
- package/src/components/ChatItem/Typing.tsx +19 -0
- package/src/components/ChatItem/index.tsx +843 -0
- package/src/components/ChatItem/style.less +670 -0
- package/src/components/ChatMsg/ApplyAuth/index.tsx +30 -0
- package/src/components/ChatMsg/ApplyAuth/style.less +13 -0
- package/src/components/ChatMsg/Bar/index.tsx +223 -0
- package/src/components/ChatMsg/Bar/style.less +60 -0
- package/src/components/ChatMsg/DateOptions/index.tsx +46 -0
- package/src/components/ChatMsg/DateOptions/style.less +43 -0
- package/src/components/ChatMsg/FilterSection/index.tsx +42 -0
- package/src/components/ChatMsg/FilterSection/style.less +37 -0
- package/src/components/ChatMsg/MarkDown/index.tsx +26 -0
- package/src/components/ChatMsg/MarkDown/style.less +9 -0
- package/src/components/ChatMsg/Message/index.tsx +105 -0
- package/src/components/ChatMsg/Message/style.less +119 -0
- package/src/components/ChatMsg/MetricCard/PeriodCompareItem.tsx +29 -0
- package/src/components/ChatMsg/MetricCard/index.tsx +80 -0
- package/src/components/ChatMsg/MetricCard/style.less +126 -0
- package/src/components/ChatMsg/MetricTrend/MetricInfo.tsx +60 -0
- package/src/components/ChatMsg/MetricTrend/MetricTrendChart.tsx +235 -0
- package/src/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.tsx +162 -0
- package/src/components/ChatMsg/MetricTrend/index.tsx +127 -0
- package/src/components/ChatMsg/MetricTrend/style.less +195 -0
- package/src/components/ChatMsg/NoPermissionChart/index.tsx +28 -0
- package/src/components/ChatMsg/NoPermissionChart/style.less +26 -0
- package/src/components/ChatMsg/Pie/PieChart.tsx +134 -0
- package/src/components/ChatMsg/Pie/index.tsx +88 -0
- package/src/components/ChatMsg/Pie/style.less +43 -0
- package/src/components/ChatMsg/Table/index.tsx +105 -0
- package/src/components/ChatMsg/Table/style.less +131 -0
- package/src/components/ChatMsg/Text/index.tsx +70 -0
- package/src/components/ChatMsg/Text/style.less +38 -0
- package/src/components/ChatMsg/WebPage/index.tsx +125 -0
- package/src/components/ChatMsg/index.tsx +428 -0
- package/src/components/ChatMsg/style.less +28 -0
- package/src/components/DrillDownDimensions/DimensionSection.tsx +99 -0
- package/src/components/DrillDownDimensions/index.tsx +76 -0
- package/src/components/DrillDownDimensions/style.less +64 -0
- package/src/components/IconFont/index.tsx +7 -0
- package/src/components/MetricOptions/index.tsx +75 -0
- package/src/components/MetricOptions/style.less +69 -0
- package/src/components/RecommendOptions/index.tsx +126 -0
- package/src/components/RecommendOptions/style.less +24 -0
- package/src/components/Tools/FeedbackModal.tsx +55 -0
- package/src/components/Tools/index.tsx +126 -0
- package/src/components/Tools/style.less +67 -0
- package/src/demo/Chat.tsx +73 -0
- package/src/demo/ChatDemo.tsx +14 -0
- package/src/demo/CopilotDemo.tsx +43 -0
- package/src/demo/style.module.less +19 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useComposing.ts +31 -0
- package/src/hooks/useExportByEcharts.ts +41 -0
- package/src/hooks/useMethodRegister.ts +25 -0
- package/src/index.tsx +44 -0
- package/src/service/axiosInstance.ts +58 -0
- package/src/service/index.ts +174 -0
- package/src/setupProxy.js +18 -0
- package/src/setupTests.ts +5 -0
- package/src/styles/global.less +52 -0
- package/src/styles/index.less +39 -0
- package/src/styles/reboot.less +14 -0
- package/src/styles/variables.less +80 -0
- package/src/typings.d.ts +179 -0
- package/src/utils/utils.ts +346 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { PREFIX_CLS } from '../../../common/constants';
|
|
2
|
+
import { MsgDataType } from '../../../common/type';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import NoPermissionChart from '../NoPermissionChart';
|
|
5
|
+
import { ColumnType } from '../../../common/type';
|
|
6
|
+
import { Spin, Select } from 'antd';
|
|
7
|
+
import PieChart from './PieChart';
|
|
8
|
+
import Bar from '../Bar';
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
data: MsgDataType;
|
|
12
|
+
question: string;
|
|
13
|
+
triggerResize?: boolean;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
metricField: ColumnType;
|
|
16
|
+
categoryField: ColumnType;
|
|
17
|
+
onApplyAuth?: (model: string) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const metricChartSelectOptions = [
|
|
21
|
+
{
|
|
22
|
+
value: 'pie',
|
|
23
|
+
label: '饼图',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
value: 'bar',
|
|
27
|
+
label: '柱状图',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const Pie: React.FC<Props> = ({
|
|
32
|
+
data,
|
|
33
|
+
question,
|
|
34
|
+
triggerResize,
|
|
35
|
+
loading,
|
|
36
|
+
metricField,
|
|
37
|
+
categoryField,
|
|
38
|
+
onApplyAuth,
|
|
39
|
+
}) => {
|
|
40
|
+
const [chartType, setChartType] = useState('pie');
|
|
41
|
+
const { entityInfo } = data;
|
|
42
|
+
|
|
43
|
+
if (metricField && !metricField?.authorized) {
|
|
44
|
+
return (
|
|
45
|
+
<NoPermissionChart
|
|
46
|
+
model={entityInfo?.dataSetInfo?.name || ''}
|
|
47
|
+
chartType="pieChart"
|
|
48
|
+
onApplyAuth={onApplyAuth}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const prefixCls = `${PREFIX_CLS}-pie`;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className={prefixCls}>
|
|
57
|
+
<div className={`${prefixCls}-metric-fields ${prefixCls}-metric-field-single`}>
|
|
58
|
+
{question}
|
|
59
|
+
</div>
|
|
60
|
+
<div className={`${prefixCls}-select-options`}>
|
|
61
|
+
<Select
|
|
62
|
+
defaultValue="pie"
|
|
63
|
+
bordered={false}
|
|
64
|
+
options={metricChartSelectOptions}
|
|
65
|
+
onChange={(value: string) => setChartType(value)}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
{chartType === 'pie' ? (
|
|
69
|
+
<PieChart
|
|
70
|
+
data={data}
|
|
71
|
+
metricField={metricField}
|
|
72
|
+
categoryField={categoryField}
|
|
73
|
+
triggerResize={triggerResize}
|
|
74
|
+
/>
|
|
75
|
+
) : (
|
|
76
|
+
<Bar
|
|
77
|
+
data={data}
|
|
78
|
+
triggerResize={triggerResize}
|
|
79
|
+
loading={loading}
|
|
80
|
+
metricField={metricField}
|
|
81
|
+
onApplyAuth={onApplyAuth}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default Pie;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@pie-prefix-cls: ~'@{prefix-cls}-pie';
|
|
4
|
+
|
|
5
|
+
.@{pie-prefix-cls} {
|
|
6
|
+
&-select-options {
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: flex-end;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&-chart {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 400px;
|
|
14
|
+
min-height: 400px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&-metric-fields {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: baseline;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
column-gap: 8px;
|
|
22
|
+
row-gap: 12px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-metric-field-single {
|
|
26
|
+
padding-left: 0;
|
|
27
|
+
font-weight: 500;
|
|
28
|
+
cursor: default;
|
|
29
|
+
font-size: 15px;
|
|
30
|
+
color: var(--text-color);
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
color: var(--text-color);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-indicator-name {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
color: var(--text-color);
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
margin-top: 2px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { formatByDataFormatType, formatByThousandSeperator } from '../../../utils/utils';
|
|
2
|
+
import { Table as AntTable } from 'antd';
|
|
3
|
+
import { MsgDataType } from '../../../common/type';
|
|
4
|
+
import { CLS_PREFIX } from '../../../common/constants';
|
|
5
|
+
import ApplyAuth from '../ApplyAuth';
|
|
6
|
+
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
7
|
+
import moment from 'moment';
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
data: MsgDataType;
|
|
11
|
+
size?: SizeType;
|
|
12
|
+
question?: string;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
onApplyAuth?: (model: string) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const Table: React.FC<Props> = ({ data, size, loading, question, onApplyAuth }) => {
|
|
18
|
+
const { entityInfo, queryColumns, queryResults } = data;
|
|
19
|
+
|
|
20
|
+
const prefixCls = `${CLS_PREFIX}-table`;
|
|
21
|
+
const tableColumns: any[] = queryColumns.map(
|
|
22
|
+
({ name, bizName, showType, dataFormatType, dataFormat, authorized }) => {
|
|
23
|
+
return {
|
|
24
|
+
dataIndex: bizName,
|
|
25
|
+
key: bizName,
|
|
26
|
+
title: name || bizName,
|
|
27
|
+
sorter:
|
|
28
|
+
showType === 'NUMBER'
|
|
29
|
+
? (a, b) => {
|
|
30
|
+
return a[bizName] - b[bizName];
|
|
31
|
+
}
|
|
32
|
+
: undefined,
|
|
33
|
+
render: (value: string | number) => {
|
|
34
|
+
if (!authorized) {
|
|
35
|
+
return (
|
|
36
|
+
<ApplyAuth model={entityInfo?.dataSetInfo.name || ''} onApplyAuth={onApplyAuth} />
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (dataFormatType === 'percent') {
|
|
40
|
+
return (
|
|
41
|
+
<div className={`${prefixCls}-formatted-value`}>
|
|
42
|
+
{`${
|
|
43
|
+
value
|
|
44
|
+
? formatByDataFormatType(value, dataFormatType, dataFormat)
|
|
45
|
+
: '0%'
|
|
46
|
+
}`}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (showType === 'NUMBER') {
|
|
51
|
+
return (
|
|
52
|
+
<div className={`${prefixCls}-formatted-value`}>
|
|
53
|
+
{/* {getFormattedValue(value as number)} */}
|
|
54
|
+
{formatByThousandSeperator(value)}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (bizName.includes('photo')) {
|
|
59
|
+
return (
|
|
60
|
+
<div className={`${prefixCls}-photo`}>
|
|
61
|
+
<img width={40} height={40} src={value as string} alt="" />
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const getRowClassName = (_: any, index: number) => {
|
|
72
|
+
return index % 2 !== 0 ? `${prefixCls}-even-row` : '';
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const dateColumn = queryColumns.find(column => column.type === 'DATE' || column.showType === 'DATE');
|
|
76
|
+
const dataSource = dateColumn
|
|
77
|
+
? queryResults.sort((a, b) => moment(a[dateColumn.bizName]).diff(moment(b[dateColumn.bizName])))
|
|
78
|
+
: queryResults;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className={prefixCls}>
|
|
82
|
+
{question && (
|
|
83
|
+
<div className={`${prefixCls}-top-bar`}>
|
|
84
|
+
<div className={`${prefixCls}-indicator-name`}>{question}</div>
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
<AntTable
|
|
89
|
+
pagination={
|
|
90
|
+
queryResults.length <= 10 ? false : { defaultPageSize: 10, position: ['bottomCenter'] }
|
|
91
|
+
}
|
|
92
|
+
columns={tableColumns}
|
|
93
|
+
dataSource={dataSource}
|
|
94
|
+
style={{ width: '100%', overflowX: 'auto', overflowY: 'hidden' }}
|
|
95
|
+
rowClassName={getRowClassName}
|
|
96
|
+
size={size}
|
|
97
|
+
loading={loading}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default Table;
|
|
104
|
+
|
|
105
|
+
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@table-prefix-cls: ~'@{supersonic-chat-prefix}-table';
|
|
4
|
+
|
|
5
|
+
.@{table-prefix-cls} {
|
|
6
|
+
margin-top: 6px;
|
|
7
|
+
|
|
8
|
+
&-photo {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&-filter-section-wrapper {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
color: var(--text-color-third);
|
|
18
|
+
margin-bottom: 12px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&-filter-section {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
font-size: 13px;
|
|
25
|
+
column-gap: 12px;
|
|
26
|
+
color: var(--text-color-third);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-top-bar {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: baseline;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
column-gap: 8px;
|
|
34
|
+
row-gap: 12px;
|
|
35
|
+
font-style: italic;
|
|
36
|
+
margin-bottom: 15px;
|
|
37
|
+
}
|
|
38
|
+
&-indicator-name {
|
|
39
|
+
font-size: 14px;
|
|
40
|
+
color: var(--text-color);
|
|
41
|
+
font-weight: 500;
|
|
42
|
+
margin-top: 2px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&-filter-item {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&-filter-item-label {
|
|
51
|
+
color: var(--text-color-third);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&-filter-item-value {
|
|
55
|
+
color: var(--text-color);
|
|
56
|
+
font-weight: 500;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&-drill-down-dimensions {
|
|
60
|
+
margin-top: 12px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
table {
|
|
64
|
+
width: 100%;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&-even-row {
|
|
68
|
+
background-color: #fbfbfb;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ant-table-container table > thead > tr:first-child th:first-child {
|
|
72
|
+
border-top-left-radius: 12px !important;
|
|
73
|
+
border-bottom-left-radius: 12px !important;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ant-table-container table > thead > tr:first-child th:last-child {
|
|
77
|
+
border-top-right-radius: 12px !important;
|
|
78
|
+
border-bottom-right-radius: 12px !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ant-table-tbody > tr.ant-table-row:hover > td {
|
|
82
|
+
background-color: #fafafa !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.ant-table-cell { // 更新修改,解决表格内容太长导致显示的问题
|
|
86
|
+
white-space: nowrap;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
text-overflow: ellipsis;
|
|
89
|
+
max-width: 250px;
|
|
90
|
+
text-align: center !important;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.ant-table-thead {
|
|
94
|
+
.ant-table-cell {
|
|
95
|
+
padding-top: 10px;
|
|
96
|
+
padding-bottom: 10px;
|
|
97
|
+
color: #666;
|
|
98
|
+
font-size: 13px;
|
|
99
|
+
background: #f0f2f5;
|
|
100
|
+
|
|
101
|
+
&::before {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.@{table-prefix-cls}-formatted-value {
|
|
108
|
+
font-weight: 500;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.ant-table-thead .ant-table-cell {
|
|
112
|
+
padding-top: 8.5px;
|
|
113
|
+
padding-bottom: 8.5px;
|
|
114
|
+
color: #737b7b;
|
|
115
|
+
font-weight: 500;
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
background-color: #edf2f2;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.ant-table-tbody {
|
|
121
|
+
.ant-table-cell {
|
|
122
|
+
padding: 12px 2px;
|
|
123
|
+
color: var(--text-color);
|
|
124
|
+
font-size: 14px;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.ant-table-pagination.ant-pagination {
|
|
129
|
+
margin-bottom: 0;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { UpOutlined, DownOutlined } from '@ant-design/icons';
|
|
3
|
+
import { CLS_PREFIX } from '../../../common/constants';
|
|
4
|
+
import { ColumnType } from '../../../common/type';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
columns: ColumnType[];
|
|
8
|
+
referenceColumn?: ColumnType;
|
|
9
|
+
dataSource: any[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Text: React.FC<Props> = ({ columns, referenceColumn, dataSource }) => {
|
|
13
|
+
const [text, setText] = useState<string>();
|
|
14
|
+
const [referenceExpanded, setRederenceExpanded] = useState(false);
|
|
15
|
+
const [referenceData, setReferenceData] = useState<any[]>([]);
|
|
16
|
+
|
|
17
|
+
const prefixCls = `${CLS_PREFIX}-text`;
|
|
18
|
+
|
|
19
|
+
const initData = () => {
|
|
20
|
+
let textValue = dataSource[0][columns[0].bizName];
|
|
21
|
+
setText(textValue === undefined ? '暂无数据' : textValue);
|
|
22
|
+
if (referenceColumn) {
|
|
23
|
+
const referenceDataValue = dataSource[0][referenceColumn.bizName];
|
|
24
|
+
setReferenceData(referenceDataValue || []);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
initData();
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
const onToggleMore = () => {
|
|
33
|
+
setRederenceExpanded(!referenceExpanded);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
style={{
|
|
39
|
+
lineHeight: '24px',
|
|
40
|
+
width: 'fit-content',
|
|
41
|
+
maxWidth: '100%',
|
|
42
|
+
overflowX: 'hidden',
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
{text}
|
|
46
|
+
{referenceData.length > 0 && (
|
|
47
|
+
<span className={`${prefixCls}-check-more`} onClick={onToggleMore}>
|
|
48
|
+
{referenceExpanded ? '收起' : '查看'}更多
|
|
49
|
+
{referenceExpanded ? (
|
|
50
|
+
<UpOutlined className={`${prefixCls}-arrow-icon`} />
|
|
51
|
+
) : (
|
|
52
|
+
<DownOutlined className={`${prefixCls}-arrow-icon`} />
|
|
53
|
+
)}
|
|
54
|
+
</span>
|
|
55
|
+
)}
|
|
56
|
+
{referenceData.length > 0 && referenceExpanded && (
|
|
57
|
+
<div className={`${prefixCls}-reference-data`}>
|
|
58
|
+
{referenceData.map(item => (
|
|
59
|
+
<div className={`${prefixCls}-reference-item`} key={item.doc_title}>
|
|
60
|
+
<div className={`${prefixCls}-reference-item-title`}>{item.doc_title}</div>
|
|
61
|
+
<div className={`${prefixCls}-reference-item-value`}>{item.doc_chunk}</div>
|
|
62
|
+
</div>
|
|
63
|
+
))}
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default Text;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@text-prefix-cls: ~'@{supersonic-chat-prefix}-text';
|
|
4
|
+
|
|
5
|
+
.@{text-prefix-cls} {
|
|
6
|
+
&-check-more {
|
|
7
|
+
margin-left: 12px;
|
|
8
|
+
font-size: 13px;
|
|
9
|
+
color: var(--chat-blue);
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&-arrow-icon {
|
|
14
|
+
margin-left: 2px;
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-reference-data {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
row-gap: 10px;
|
|
22
|
+
margin-top: 10px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-reference-item {
|
|
26
|
+
font-size: 13px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&-reference-item-title {
|
|
30
|
+
color: var(--text-color);
|
|
31
|
+
font-weight: 500;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&-reference-item-value {
|
|
35
|
+
color: var(--text-color-secondary);
|
|
36
|
+
margin-top: 4px;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { MsgDataType } from '../../../common/type';
|
|
3
|
+
import { getToken, isMobile, isProd } from '../../../utils/utils';
|
|
4
|
+
import { webPageHost } from '../../../common/env';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
id: string | number;
|
|
8
|
+
data: MsgDataType;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const DEFAULT_HEIGHT = 800;
|
|
12
|
+
|
|
13
|
+
const WebPage: React.FC<Props> = ({ id, data }) => {
|
|
14
|
+
const [pluginUrl, setPluginUrl] = useState('');
|
|
15
|
+
const [height, setHeight] = useState(DEFAULT_HEIGHT);
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
name,
|
|
19
|
+
webPage: { url, params },
|
|
20
|
+
} = data.response || {};
|
|
21
|
+
|
|
22
|
+
const handleMessage = useCallback((event: MessageEvent) => {
|
|
23
|
+
const messageData = event.data;
|
|
24
|
+
const { type, payload } = messageData;
|
|
25
|
+
if (type === 'changeMiniProgramContainerSize') {
|
|
26
|
+
const { msgId, height } = payload;
|
|
27
|
+
if (`${msgId}` === `${id}`) {
|
|
28
|
+
setHeight(height);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (messageData === 'storyResize') {
|
|
33
|
+
const ifr: any = document.getElementById(`reportIframe_${id}`);
|
|
34
|
+
const iDoc = ifr.contentDocument || ifr.document || ifr.contentWindow;
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
setHeight(isProd() ? calcPageHeight(iDoc) : DEFAULT_HEIGHT);
|
|
37
|
+
}, 200);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
window.addEventListener('message', handleMessage);
|
|
44
|
+
return () => {
|
|
45
|
+
window.removeEventListener('message', handleMessage);
|
|
46
|
+
};
|
|
47
|
+
}, [handleMessage]);
|
|
48
|
+
|
|
49
|
+
function calcPageHeight(doc: any) {
|
|
50
|
+
const titleAreaEl = doc.getElementById('titleArea');
|
|
51
|
+
const titleAreaHeight = Math.max(
|
|
52
|
+
titleAreaEl?.clientHeight || 0,
|
|
53
|
+
titleAreaEl?.scrollHeight || 0
|
|
54
|
+
);
|
|
55
|
+
const dashboardGridEl = doc.getElementsByClassName('dashboardGrid')?.[0];
|
|
56
|
+
const dashboardGridHeight = Math.max(
|
|
57
|
+
dashboardGridEl?.clientHeight || 0,
|
|
58
|
+
dashboardGridEl?.scrollHeight || 0
|
|
59
|
+
);
|
|
60
|
+
return Math.max(titleAreaHeight + dashboardGridHeight + 10, DEFAULT_HEIGHT);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const initData = () => {
|
|
64
|
+
const heightValue =
|
|
65
|
+
params?.find((option: any) => option.paramType === 'FORWARD' && option.key === 'height')
|
|
66
|
+
?.value || DEFAULT_HEIGHT;
|
|
67
|
+
setHeight(heightValue);
|
|
68
|
+
let urlValue = url;
|
|
69
|
+
const valueParams = (params || [])
|
|
70
|
+
.filter((option: any) => option.paramType !== 'FORWARD')
|
|
71
|
+
.reduce((result: any, item: any) => {
|
|
72
|
+
result[item.key] = item.value;
|
|
73
|
+
return result;
|
|
74
|
+
}, {});
|
|
75
|
+
if (urlValue.includes('?type=dashboard') || urlValue.includes('?type=widget')) {
|
|
76
|
+
const filterData = encodeURIComponent(
|
|
77
|
+
JSON.stringify(
|
|
78
|
+
urlValue.includes('dashboard')
|
|
79
|
+
? {
|
|
80
|
+
global: valueParams,
|
|
81
|
+
}
|
|
82
|
+
: {
|
|
83
|
+
local: valueParams,
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
urlValue = urlValue.replace(
|
|
88
|
+
'?',
|
|
89
|
+
`?token=${getToken()}&miniProgram=true&reportName=${name}&filterData=${filterData}&`
|
|
90
|
+
);
|
|
91
|
+
urlValue = `${webPageHost}${urlValue}`;
|
|
92
|
+
} else {
|
|
93
|
+
const params = Object.keys(valueParams || {}).map(key => `${key}=${valueParams[key]}`);
|
|
94
|
+
if (params.length > 0) {
|
|
95
|
+
if (url.includes('?')) {
|
|
96
|
+
urlValue = urlValue.replace('?', `?${params.join('&')}&`);
|
|
97
|
+
} else {
|
|
98
|
+
urlValue = `${urlValue}?${params.join('&')}`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
setPluginUrl(urlValue);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
initData();
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<iframe
|
|
111
|
+
id={`reportIframe_${id}`}
|
|
112
|
+
name={`reportIframe_${id}`}
|
|
113
|
+
src={pluginUrl}
|
|
114
|
+
style={{
|
|
115
|
+
width: isMobile ? 'calc(100vw - 20px)' : 'calc(100vw - 410px)',
|
|
116
|
+
height,
|
|
117
|
+
border: 'none',
|
|
118
|
+
}}
|
|
119
|
+
title="reportIframe"
|
|
120
|
+
allowFullScreen
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default WebPage;
|