diff --git a/chat2db-client/src/components/SearchResult/components/TableBox/index.tsx b/chat2db-client/src/components/SearchResult/components/TableBox/index.tsx index dc24967c6..af0d23d9f 100644 --- a/chat2db-client/src/components/SearchResult/components/TableBox/index.tsx +++ b/chat2db-client/src/components/SearchResult/components/TableBox/index.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useMemo, useState } from 'react'; -import { Dropdown, Input, MenuProps, message, Modal, Space, Popover, Spin, Button } from 'antd'; +import { Dropdown, Input, MenuProps, message, Modal, Space, Popover, Spin, Button, DatePicker } from 'antd'; import { BaseTable, ArtColumn, useTablePipeline, features, SortItem } from 'ali-react-table'; import styled from 'styled-components'; import classnames from 'classnames'; @@ -15,7 +15,7 @@ import styles from './index.less'; // 工具函数 import { compareStrings } from '@/utils/sort'; import { downloadFile } from '@/utils/file'; -import { transformInputValue } from '../../utils'; +import { transformInputValue, transformDateTimeValue } from '../../utils'; // 类型定义 import { CRUD } from '@/constants'; @@ -72,6 +72,10 @@ export enum USER_FILLED_VALUE { DEFAULT = 'CHAT2DB_UPDATE_TABLE_DATA_USER_FILLED_DEFAULT', } +export enum DATE_TIME { + DATEFORMAT = 'YYYY-MM-DD HH:mm:ss', +} + const SupportBaseTable: any = styled(BaseTable)` &.supportBaseTable { --bgcolor: var(--color-bg-base); @@ -605,6 +609,7 @@ export default function TableBox(props: ITableProps) { const isNumber = dataType === TableDataType.NUMERIC; const isNumericalOrder = dataType === TableDataType.CHAT2DB_ROW_NUMBER; const colId = `${preCode}${colIndex}${name}`; + const isDateTime = dataType === TableDataType.DATETIME; if (isNumericalOrder) { return { @@ -652,6 +657,50 @@ export default function TableBox(props: ITableProps) { }; } + if (isDateTime) { + return { + code: colId, + name: name, + key: name, + render: (value: any, rowData) => { + const rowId = rowData[colNoCode]; + const content = renderTableCellValue(value); + return ( +
+ {editingCell?.[0] === colId && editingCell?.[1] === rowId && editingCell?.[2] ? + + ( + { + setEditingData(String(dateString)); + }} + onBlur={() => { + setEditingCell([editingCell![0], editingCell![1], false]); + updateTableData('setCell', editingData); + }} + /> + ) : ( + <> +
{content}
+
{content}
+ + )} +
+ ); + } + }; + } return { code: colId, name: name, diff --git a/chat2db-client/src/components/SearchResult/utils.tsx b/chat2db-client/src/components/SearchResult/utils.tsx index 039cff13c..ad91aa124 100644 --- a/chat2db-client/src/components/SearchResult/utils.tsx +++ b/chat2db-client/src/components/SearchResult/utils.tsx @@ -1,4 +1,5 @@ -import { USER_FILLED_VALUE } from './components/TableBox/index'; +import { USER_FILLED_VALUE, DATE_TIME } from './components/TableBox/index'; +import dayjs from 'dayjs'; // 在input中把USER_FILLED_VALUE转换为null export const transformInputValue = (value: string) => { @@ -7,3 +8,7 @@ export const transformInputValue = (value: string) => { } return value; }; + +export const transformDateTimeValue = (value: string) => { + return dayjs(value, DATE_TIME.DATEFORMAT); +}; diff --git a/chat2db-client/src/layouts/GlobalLayout/index.tsx b/chat2db-client/src/layouts/GlobalLayout/index.tsx index a7aa2503d..1d0fe7876 100644 --- a/chat2db-client/src/layouts/GlobalLayout/index.tsx +++ b/chat2db-client/src/layouts/GlobalLayout/index.tsx @@ -1,9 +1,11 @@ import React, { useEffect, useLayoutEffect, useState } from 'react'; import usePollRequestService, { ServiceStatus } from '@/hooks/usePollRequestService'; -import i18n, { isEn } from '@/i18n'; +import i18n, { isZH, isTR, isJA } from '@/i18n'; import { Button, ConfigProvider, Spin, Tooltip } from 'antd'; import antdEnUS from 'antd/locale/en_US'; import antdZhCN from 'antd/locale/zh_CN'; +import antdJaJP from 'antd/locale/ja_JP'; +import antdTrTR from 'antd/locale/tr_TR'; import service from '@/service/misc'; import useCopyFocusData from '@/hooks/useFocusData'; import { useTheme } from '@/hooks/useTheme'; @@ -93,8 +95,15 @@ const GlobalLayout = () => { ); } + const activeLang = () => { + if (isZH) return antdZhCN; + if (isJA) return antdJaJP; + if (isTR) return antdTrTR; + return antdEnUS; + }; + return ( - +