Skip to content

Commit 43b3b56

Browse files
committed
集成导出功能
1 parent 5a80da6 commit 43b3b56

6 files changed

Lines changed: 246 additions & 194 deletions

File tree

chat2db-client/src/components/Iconfont/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import styles from './index.less';
55

66
// 只有本地开发时使用cdn,发布线上时要下载iconfont到 /assets/font
77
if (__ENV__ === 'local') {
8-
let container = `
8+
const container = `
99
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
1010
@font-face {
1111
font-family: 'iconfont'; /* Project id 3633546 */
12-
src: url('//at.alicdn.com/t/c/font_3633546_73vqnzklicw.woff2?t=1693730048111') format('woff2'),
13-
url('//at.alicdn.com/t/c/font_3633546_73vqnzklicw.woff?t=1693730048111') format('woff'),
14-
url('//at.alicdn.com/t/c/font_3633546_73vqnzklicw.ttf?t=1693730048111') format('truetype');
12+
src: url('//at.alicdn.com/t/c/font_3633546_xr1m2ndzj4j.woff2?t=1695475278282') format('woff2'),
13+
url('//at.alicdn.com/t/c/font_3633546_xr1m2ndzj4j.woff?t=1695475278282') format('woff'),
14+
url('//at.alicdn.com/t/c/font_3633546_xr1m2ndzj4j.ttf?t=1695475278282') format('truetype');
1515
}
1616
`;
17-
let style = document.createElement('style');
17+
const style = document.createElement('style');
1818
style.type = 'text/css';
1919
document.head.appendChild(style);
2020
style.appendChild(document.createTextNode(container));

chat2db-client/src/i18n/en-us/editTable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default {
1212
'editTable.label.indexType': 'Index type',
1313
'editTable.label.includeColumn': 'Include column',
1414
'editTable.button.createTable': 'Create table',
15+
'editTable.button.importTable': 'Import table',
1516
'editTable.label.index': 'Index',
1617
'editTable.label.columnName': 'Name',
1718
'editTable.label.columnSize': 'Size',

chat2db-client/src/i18n/zh-cn/editTable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default {
1212
'editTable.label.indexType': '索引类型',
1313
'editTable.label.includeColumn': '包含列',
1414
'editTable.button.createTable': '新建表',
15+
'editTable.button.importTable': '导出表',
1516
'editTable.label.index': '序号',
1617
'editTable.label.columnName': '列名',
1718
'editTable.label.columnSize': '长度',

chat2db-client/src/pages/main/workspace/components/TableList/index.less

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,21 @@
6969
}
7070
}
7171
}
72+
73+
.operationItem {
74+
display: flex;
75+
align-items: center;
76+
.operationIconRight {
77+
margin-left: 10px;
78+
}
79+
.operationTitle {
80+
margin-left: 6px;
81+
}
82+
}
83+
84+
:global {
85+
.ant-dropdown-menu-submenu-title {
86+
display: flex;
87+
align-items: center;
88+
}
89+
}

chat2db-client/src/pages/main/workspace/components/TableList/index.tsx

Lines changed: 88 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, useMemo } from 'react';
22
import classnames from 'classnames';
33
import i18n from '@/i18n';
44
import { connect } from 'umi';
5-
import { Input, Cascader, Button, Space, Dropdown, MenuProps } from 'antd';
5+
import { Input, Cascader, Dropdown, MenuProps } from 'antd';
66
import Iconfont from '@/components/Iconfont';
77
import LoadingContent from '@/components/Loading/LoadingContent';
88
import { IConnectionModelType } from '@/models/connection';
@@ -15,7 +15,6 @@ import { useUpdateEffect } from '@/hooks/useUpdateEffect';
1515
import { v4 as uuidV4 } from 'uuid';
1616
import { ITreeNode } from '@/typings';
1717
import styles from './index.less';
18-
import { DownOutlined } from '@ant-design/icons';
1918
import { ExportTypeEnum } from '@/typings/resultTable';
2019

2120
interface IOption {
@@ -64,44 +63,95 @@ const TableList = dvaModel((props: any) => {
6463
const items: MenuProps['items'] = useMemo(
6564
() => [
6665
{
67-
label: i18n('common.button.exportWord'),
68-
key: '1',
69-
// icon: <UserOutlined />,
70-
onClick: () => {
71-
handleExport(ExportTypeEnum.WORD);
72-
},
73-
},
74-
{
75-
label: i18n('common.button.exportExcel'),
76-
key: '2',
77-
// icon: <UserOutlined />,
78-
onClick: () => {
79-
handleExport(ExportTypeEnum.EXCEL);
80-
},
81-
},
82-
{
83-
label: i18n('common.button.exportHtml'),
84-
key: '3',
85-
// icon: <UserOutlined />,
86-
onClick: () => {
87-
handleExport(ExportTypeEnum.HTML);
88-
},
89-
},
90-
{
91-
label: i18n('common.button.exportMarkdown'),
92-
key: '4',
93-
// icon: <UserOutlined />,
66+
label: (
67+
<div className={styles.operationItem}>
68+
<Iconfont className={styles.operationIcon} code="&#xe6b6;" />
69+
<div className={styles.operationTitle}>{i18n('editTable.button.createTable')}</div>
70+
</div>
71+
),
72+
key: 'createTable',
9473
onClick: () => {
95-
handleExport(ExportTypeEnum.MARKDOWN);
74+
dispatch({
75+
type: 'workspace/setCreateConsoleIntro',
76+
payload: {
77+
id: uuidV4(),
78+
type: WorkspaceTabType.EditTable,
79+
title: 'create-table',
80+
uniqueData: {},
81+
},
82+
});
9683
},
9784
},
9885
{
99-
label: i18n('common.button.exportPdf'),
100-
key: '5',
101-
// icon: <UserOutlined />,
102-
onClick: () => {
103-
handleExport(ExportTypeEnum.PDF);
104-
},
86+
label: (
87+
<div className={styles.operationItem}>
88+
<Iconfont className={styles.operationIcon} code="&#xe613;" />
89+
<div className={styles.operationTitle}>{i18n('editTable.button.importTable')}</div>
90+
</div>
91+
),
92+
key: 'importTable',
93+
children: [
94+
{
95+
label: (
96+
<div className={styles.operationItem}>
97+
<Iconfont className={styles.operationIcon} code="&#xe7ba;" />
98+
<div className={styles.operationTitle}>{i18n('common.button.exportWord')}</div>
99+
</div>
100+
),
101+
key: '1',
102+
onClick: () => {
103+
handleExport(ExportTypeEnum.WORD);
104+
},
105+
},
106+
{
107+
label: (
108+
<div className={styles.operationItem}>
109+
<Iconfont className={styles.operationIcon} code="&#xe7b7;" />
110+
<div className={styles.operationTitle}>{i18n('common.button.exportExcel')}</div>
111+
</div>
112+
),
113+
key: '2',
114+
onClick: () => {
115+
handleExport(ExportTypeEnum.EXCEL);
116+
},
117+
},
118+
{
119+
label: (
120+
<div className={styles.operationItem}>
121+
<Iconfont className={styles.operationIcon} code="&#xe87d;" />
122+
<div className={styles.operationTitle}>{i18n('common.button.exportHtml')}</div>
123+
</div>
124+
),
125+
key: '3',
126+
onClick: () => {
127+
handleExport(ExportTypeEnum.HTML);
128+
},
129+
},
130+
{
131+
label: (
132+
<div className={styles.operationItem}>
133+
<Iconfont className={styles.operationIcon} code="&#xe7b8;" />
134+
<div className={styles.operationTitle}>{i18n('common.button.exportMarkdown')}</div>
135+
</div>
136+
),
137+
key: '4',
138+
onClick: () => {
139+
handleExport(ExportTypeEnum.MARKDOWN);
140+
},
141+
},
142+
{
143+
label: (
144+
<div className={styles.operationItem}>
145+
<Iconfont className={styles.operationIcon} code="&#xe67a;" />
146+
<div className={styles.operationTitle}>{i18n('common.button.exportPdf')}</div>
147+
</div>
148+
),
149+
key: '5',
150+
onClick: () => {
151+
handleExport(ExportTypeEnum.PDF);
152+
},
153+
},
154+
],
105155
},
106156
],
107157
[curWorkspaceParams],
@@ -175,25 +225,6 @@ const TableList = dvaModel((props: any) => {
175225
setCurType(selectedOptions[0]);
176226
}
177227

178-
const cascaderOnChange: any = () => {
179-
dispatch({
180-
type: 'workspace/setCreateConsoleIntro',
181-
payload: {
182-
id: uuidV4(),
183-
type: WorkspaceTabType.EditTable,
184-
title: 'create-table',
185-
uniqueData: {},
186-
},
187-
});
188-
};
189-
190-
const options = [
191-
{
192-
value: 'createTable',
193-
label: i18n('editTable.button.createTable'),
194-
},
195-
];
196-
197228
return (
198229
<div className={styles.tableModule}>
199230
<div className={styles.leftModuleTitle}>
@@ -223,26 +254,18 @@ const TableList = dvaModel((props: any) => {
223254
</div>
224255
</Cascader>
225256
<div className={styles.iconBox}>
226-
<Dropdown menu={{ items }}>
227-
<Button>
228-
<Space>
229-
{i18n('common.text.export')}
230-
<DownOutlined />
231-
</Space>
232-
</Button>
233-
</Dropdown>
234257
<div className={classnames(styles.refreshIcon, styles.itemIcon)} onClick={() => refreshTableList()}>
235258
<Iconfont code="&#xec08;" />
236259
</div>
237260
<div className={classnames(styles.searchIcon, styles.itemIcon)} onClick={() => openSearch()}>
238261
<Iconfont code="&#xe600;" />
239262
</div>
240263
{curType.value === TreeNodeType.TABLES && (
241-
<Cascader options={options} onChange={cascaderOnChange}>
264+
<Dropdown menu={{ items }}>
242265
<div className={classnames(styles.moreIcon, styles.itemIcon)}>
243266
<Iconfont code="&#xe601;" />
244267
</div>
245-
</Cascader>
268+
</Dropdown>
246269
)}
247270
</div>
248271
</div>

0 commit comments

Comments
 (0)