diff --git a/config/routes.ts b/config/routes.ts index ec8c407..8f68b38 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -247,7 +247,14 @@ export default [ { name: 'task', path: '/task', - component: 'Hidden', + routes: [ + { + name: 'task-list', + path: '/task/task-list', + component: 'Task/TaskList', + access: 'canReadMenu', + }, + ], }, { name: 'compute_power', diff --git a/src/components/Notice/index.tsx b/src/components/Notice/index.tsx index 236e479..c53b595 100644 --- a/src/components/Notice/index.tsx +++ b/src/components/Notice/index.tsx @@ -120,28 +120,28 @@ const Notice: React.FC = () => {
( - toManagePage()} style={{ cursor: "pointer" }}> - -
- 系统消息 - - 紧急 - -
-
- {item.title} -
-
{item.time}
-
- } - /> - - )} - /> + dataSource={tabsData} + renderItem={item => ( + toManagePage()} style={{ cursor: "pointer" }}> + +
+ 系统消息 + + 紧急 + +
+
+ {item.title} +
+
{item.time}
+ + } + /> +
+ )} + /> ); @@ -160,17 +160,17 @@ const Notice: React.FC = () => { width: 396, }} > - {/* */} - + {/* */} + {/* */} - - {/* */} - + + {/* */} + ); }; diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 1b1c75b..865cb29 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -6,6 +6,7 @@ * @FilePath: \general-ai-platform-web\src\locales\zh-CN.ts * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ +import * as taskZh from '@/locales/zh-CN/task'; import * as accountZh from '@/locales/zh-CN/account'; import * as noticeZh from '@/locales/zh-CN/notice'; import * as contactZh from '@/locales/zh-CN/contact'; @@ -73,4 +74,5 @@ export default { ...Object.assign({}, ...Object.values(alarmLangs)), ...Object.assign({}, ...Object.values(noticeZh)), ...Object.assign({}, ...Object.values(accountZh)), + ...Object.assign({}, ...Object.values(taskZh)), }; diff --git a/src/locales/zh-CN/task.ts b/src/locales/zh-CN/task.ts new file mode 100644 index 0000000..a5028ec --- /dev/null +++ b/src/locales/zh-CN/task.ts @@ -0,0 +1,9 @@ +export const task_list: { [key: string]: string } = { + 'task.task.table.list.id': 'ID', + 'task.task.table.list.name': '项目名称', + 'task.task.table.list.deviceGroup': '设备组', + 'task.task.table.list.state': '当前状态', + 'task.task.table.list.startTime': '开始时间', + 'task.task.table.list.runTime': '运行时长', + 'task.task.table.list.endTime': '结束时间', +}; \ No newline at end of file diff --git a/src/pages/Account/Center/index.tsx b/src/pages/Account/Center/index.tsx index 75b46a2..d77038e 100644 --- a/src/pages/Account/Center/index.tsx +++ b/src/pages/Account/Center/index.tsx @@ -131,8 +131,8 @@ const AccountCenter: React.FC = () => { setUpdateAccountModalOpen(true); setCurrentRow({}); }}> - - + +
登录密码:wangliqun @@ -143,8 +143,8 @@ const AccountCenter: React.FC = () => { setUpdatePasswordModalOpen(true); setCurrentRow({}); }}> - - + +
diff --git a/src/pages/Contact/ContactList/index.tsx b/src/pages/Contact/ContactList/index.tsx index 4b57f63..bded363 100644 --- a/src/pages/Contact/ContactList/index.tsx +++ b/src/pages/Contact/ContactList/index.tsx @@ -18,7 +18,7 @@ import { ColumnDrawer } from './components/ColumnDrawer'; // import MyCreateForm from './components/MyCreateForm'; import CreateForm from './components/CreateForm'; import UpdateForm from './components/UpdateForm'; -const ProjectList: React.FC = () => { +const ContactList: React.FC = () => { /** * @en-US Pop-up window of new window * @zh-CN 新建窗口的弹窗 @@ -314,4 +314,4 @@ const ProjectList: React.FC = () => { ); }; -export default ProjectList; +export default ContactList; diff --git a/src/pages/Notice/index.tsx b/src/pages/Notice/index.tsx index 2eb2375..141fa4b 100644 --- a/src/pages/Notice/index.tsx +++ b/src/pages/Notice/index.tsx @@ -12,7 +12,7 @@ import { FormattedMessage, useAccess, useIntl } from '@umijs/max'; import { Tag, message } from 'antd'; import React, { useRef, useState } from 'react'; import { proTableCommonOptions, proTablePaginationOptions } from '../../../config/defaultTable'; -const ProjectList: React.FC = () => { +const NoticetList: React.FC = () => { /** * @en-US Pop-up window of new window * @zh-CN 新建窗口的弹窗 @@ -207,4 +207,4 @@ const ProjectList: React.FC = () => { ); }; -export default ProjectList; +export default NoticetList; diff --git a/src/pages/Task/TaskList/index.tsx b/src/pages/Task/TaskList/index.tsx new file mode 100644 index 0000000..2ca8b21 --- /dev/null +++ b/src/pages/Task/TaskList/index.tsx @@ -0,0 +1,224 @@ +import IsBatchDelete from '@/components/BatchOperation/isBatchDelete'; +import TableActionCard from '@/components/TableActionCard'; +import IsDelete from '@/components/TableActionCard/isDelete'; +import { + deleteProjectDeleteProject, + deleteProjectDeleteProjectByIds, + postProjectGetProjectList, +} from '@/services/project/Project'; +import type { ActionType, ProColumns } from '@ant-design/pro-components'; +import { PageContainer, ProTable } from '@ant-design/pro-components'; +import { FormattedMessage, useAccess, useIntl } from '@umijs/max'; +import { Tag, message } from 'antd'; +import React, { useRef, useState } from 'react'; +import { proTableCommonOptions, proTablePaginationOptions } from '../../../../config/defaultTable'; +const TaskList: React.FC = () => { + /** + * @en-US Pop-up window of new window + * @zh-CN 新建窗口的弹窗 + * */ + const [createModalOpen, setCreateModalOpen] = useState(false); + /** + * @en-US The pop-up window of the distribution update window + * @zh-CN 分布更新窗口的弹窗 + * */ + const [updateModalOpen, setUpdateModalOpen] = useState(false); + const [showDetail, setShowDetail] = useState(false); + /** + * @en-US International configuration + * @zh-CN 国际化配置 + * */ + const intl = useIntl(); + const actionRef = useRef(); + // 动态设置每页数量 + const [currentPageSize, setCurrentPageSize] = useState(10); + const [currentRow, setCurrentRow] = useState(); + const [selectedRowsState, setSelectedRows] = useState([]); + + const handleUpdateModal = () => { + if (updateModalOpen) { + setUpdateModalOpen(false); + setCurrentRow(undefined); + } else { + setUpdateModalOpen(true); + } + }; + const handleCreateModal = () => { + if (createModalOpen) { + setCreateModalOpen(false); + setCurrentRow(undefined); + } else { + setCreateModalOpen(true); + } + }; + const handleColumnDrawer = () => { + if (showDetail) { + setShowDetail(false); + setCurrentRow(undefined); + } else { + setShowDetail(true); + } + }; + const handleDestroy = async (selectedRow: API.Project) => { + deleteProjectDeleteProject({ id: selectedRow.id }) + .then(() => { + message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '$$$' })); + actionRef.current?.reload(); + }) + .catch(() => { + message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '$$$' })); + }); + }; + + const columns: ProColumns[] = [ + { + title: , + dataIndex: 'name', + hideInSearch: false, + key: 'fixedName', + fixed: 'left', + }, + + { + title: , + dataIndex: 'info', + hideInSearch: true, + }, + + { + title: , + dataIndex: 'code', + // hideInSearch: true, + render: (dom) => { + return ( + + {dom} + + ); + }, + }, + + { + title: , + dataIndex: 'createTime', + hideInSearch: true, + valueType: 'dateTime', + }, + { + title: , + dataIndex: 'createTime', + hideInSearch: true, + valueType: 'dateTime', + }, + + { + title: , + dataIndex: 'createTime', + hideInSearch: true, + valueType: 'dateTime', + }, + + { + title: , + dataIndex: 'option', + valueType: 'option', + fixed: 'right', + render: (_, record) => [ + { + handleDestroy(record).then(() => {}); + }} + > + ), + }, + ]} + >, + ], + }, + ]; + return ( + + + headerTitle={intl.formatMessage({ + id: 'pages.searchTable.title', + defaultMessage: '$$$', + })} + scroll={{ y: proTableCommonOptions.commscrollY, x: proTableCommonOptions.commscrollX }} + options={{ fullScreen: true, setting: true, density: true, reload: true }} + actionRef={actionRef} + rowKey="key" + search={{ + labelWidth: proTableCommonOptions.searchLabelWidth, + }} + onDataSourceChange={() => {}} + pagination={{ + ...proTablePaginationOptions, + pageSize: currentPageSize, + onChange: (page, pageSize) => setCurrentPageSize(pageSize), + }} + columnsState={{ + persistenceKey: 'project_list', + persistenceType: 'localStorage', + }} + tableAlertOptionRender={() => { + return ( + <> + {selectedRowsState?.length > 0 && ( + { + // TODO 需要;联调删除接口 + deleteProjectDeleteProjectByIds({ + ids: selectedRowsState.map((v: API.Project) => { + return v.id as number; + }), + }).then(() => { + actionRef.current?.reloadAndRest?.(); + }); + }} + /> + )} + + ); + }} + request={async (params = {}, sort) => { + const { current, ...rest } = params; + const reqParams = { + page: current, + desc: false, + orderKey: '', + ...rest, + }; + if (sort && Object.keys(sort).length) { + reqParams.orderKey = Object.keys(sort)[0]; + let sort_select = sort[reqParams.orderKey]; + reqParams.desc = sort_select === 'descend'; + } + let resp = await postProjectGetProjectList({ ...reqParams }); + return { + data: resp.data.list.map((v: API.Project) => { + return { ...v, key: v.id }; + }), + success: resp.success, + total: resp.data.total, + current: resp.data.page, + pageSize: resp.data.pageSize, + }; + }} + columns={columns} + // rowSelection={{ + // onChange: (_, selectedRows) => { + // setSelectedRows(selectedRows); + // }, + // }} + /> + + ); +}; + +export default TaskList;