Skip to content

Commit 8a0cdca

Browse files
committed
feat: Right-click to view data
1 parent e77064c commit 8a0cdca

5 files changed

Lines changed: 32 additions & 11 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ if (__ENV__ === 'local') {
99
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
1010
@font-face {
1111
font-family: 'iconfont'; /* Project id 3633546 */
12-
src: url('//at.alicdn.com/t/c/font_3633546_0wg41yfqyqoh.woff2?t=1699018081072') format('woff2'),
13-
url('//at.alicdn.com/t/c/font_3633546_0wg41yfqyqoh.woff?t=1699018081072') format('woff'),
14-
url('//at.alicdn.com/t/c/font_3633546_0wg41yfqyqoh.ttf?t=1699018081072') format('truetype');
12+
src: url('//at.alicdn.com/t/c/font_3633546_yovsu3nzmms.woff2?t=1699021481938') format('woff2'),
13+
url('//at.alicdn.com/t/c/font_3633546_yovsu3nzmms.woff?t=1699021481938') format('woff'),
14+
url('//at.alicdn.com/t/c/font_3633546_yovsu3nzmms.ttf?t=1699021481938') format('truetype');
1515
}
1616
`;
1717
const style = document.createElement('style');

chat2db-client/src/components/SearchResult/RightClickMenu/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export enum AllSupportedMenusType {
2525
DeleteRow = 'delete-row',
2626
SetDefault = 'set-default',
2727
SetNull = 'set-null',
28+
ViewData = 'view-data',
2829
}
2930

3031
export default memo<IProps>((props) => {
@@ -76,6 +77,10 @@ export default memo<IProps>((props) => {
7677
label: <MenuLabel label={i18n('common.button.setNull')} />,
7778
key: AllSupportedMenusType.SetNull,
7879
},
80+
[AllSupportedMenusType.ViewData]: {
81+
label: <MenuLabel icon="&#xe788;" label={i18n('common.button.viewData')} />,
82+
key: AllSupportedMenusType.ViewData,
83+
},
7984
}
8085

8186
const items = useMemo(()=>{

chat2db-client/src/components/SearchResult/TableBox/index.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,10 @@ export default function TableBox(props: ITableProps) {
287287

288288
// 编辑数据失焦
289289
const editDataOnBlur = (type: 'blur' | 'set', _editingData?: string | null) => {
290-
if (type === 'blur') {
291-
setEditingCell(null);
292-
setEditingData('');
293-
}
290+
// if (type === 'blur') {
291+
// setEditingCell(null);
292+
// setEditingData('');
293+
// }
294294
// 写入的数据
295295
const value: any = type === 'blur' ? editingData : _editingData;
296296
const [colIndex, rowNo] = editingCell!;
@@ -795,6 +795,18 @@ export default function TableBox(props: ITableProps) {
795795
},
796796
};
797797

798+
const viewData = {
799+
key: AllSupportedMenusType.ViewData,
800+
callback: () => {
801+
setViewTableCellData({
802+
name: columns[editingCell![0]].name,
803+
value: editingData,
804+
colIndex: editingCell![0],
805+
rowNo: editingCell![1],
806+
});
807+
},
808+
}
809+
798810
// 表格的列配置
799811
const columns: ArtColumn[] = useMemo(() => {
800812
return (queryResultData.headerList || []).map((item, colIndex) => {
@@ -848,7 +860,7 @@ export default function TableBox(props: ITableProps) {
848860
// title: <div>{name}</div>,
849861
render: (value: any, rowData) => {
850862
const rowNo = rowData[`${preCode}0No.`];
851-
let cellRightClickMenu = [copyCell, copyRow, cloneRow, setNull, setDefault, deleteRow];
863+
let cellRightClickMenu = [viewData, copyCell, copyRow, cloneRow, setNull, setDefault, deleteRow];
852864
// 判断是否有默认值,如果没有默认值,则不显示设置默认值的菜单
853865
const hasDefaultValue = queryResultData.headerList.find((i) => i.name === name)?.defaultValue !== null;
854866
if (!hasDefaultValue) {
@@ -885,7 +897,7 @@ export default function TableBox(props: ITableProps) {
885897
) : (
886898
<>
887899
<div className={styles.tableItemContent}>{renderTableCellValue(value)}</div>
888-
<div className={styles.tableHoverBox}>
900+
{/* <div className={styles.tableHoverBox}>
889901
<Iconfont
890902
code="&#xe606;"
891903
onClick={viewTableCell.bind(null, { name: item.name, value, colIndex, rowNo })}
@@ -894,7 +906,7 @@ export default function TableBox(props: ITableProps) {
894906
code="&#xeb4e;"
895907
onClick={copyTableCell.bind(null, { name: item.name, value, colIndex, rowNo })}
896908
/>
897-
</div>
909+
</div> */}
898910
</>
899911
)}
900912
</div>
@@ -1098,7 +1110,7 @@ export default function TableBox(props: ITableProps) {
10981110
width="60vw"
10991111
maskClosable={false}
11001112
destroyOnClose={true}
1101-
footer={[
1113+
footer={queryResultData.canEdit && [
11021114
<Button key="1" type="primary" onClick={monacoEditorEditData}>
11031115
{i18n('common.button.modify')}
11041116
</Button>,
@@ -1115,7 +1127,9 @@ export default function TableBox(props: ITableProps) {
11151127
}}
11161128
options={{
11171129
lineNumbers: 'off',
1130+
readOnly: !queryResultData.canEdit,
11181131
}}
1132+
11191133
/>
11201134
</div>
11211135
</>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,5 @@ export default {
113113
'common.button.deleteRow': 'Delete row',
114114
'common.button.setNull': 'Set NULL',
115115
'common.button.setDefault': 'Set DEFAULT',
116+
'common.button.viewData': 'View/Edit Data',
116117
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,6 @@ export default {
112112
'common.button.deleteRow': '删除行',
113113
'common.button.setNull': '设置为NULL',
114114
'common.button.setDefault': '设置为默认值',
115+
'common.button.viewData': '查看/修改数据',
115116

116117
};

0 commit comments

Comments
 (0)