|
@@ -0,0 +1,151 @@
|
|
|
+import { message, Tooltip, Radio } from 'antd';
|
|
|
+import React, { useRef, useState } from 'react';
|
|
|
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
|
|
+import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
|
|
|
+import { SorterResult } from 'antd/es/table/interface';
|
|
|
+import { TableListItem } from './data.d';
|
|
|
+import service from './service';
|
|
|
+import styles from './index.less'
|
|
|
+
|
|
|
+/**
|
|
|
+ * 更新节点
|
|
|
+ * @param fields
|
|
|
+ */
|
|
|
+const handleUpdate = async (fields: TableListItem) => {
|
|
|
+ const hide = message.loading('正在配置');
|
|
|
+ try {
|
|
|
+ const data = await service.forceUpdateModel(fields);
|
|
|
+ hide();
|
|
|
+ message.success('配置成功');
|
|
|
+ return data.success;
|
|
|
+ } catch (error) {
|
|
|
+ hide();
|
|
|
+ message.error('配置失败请重试!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const TableList: React.FC<{}> = () => {
|
|
|
+ const [sorter, setSorter] = useState<string>('');
|
|
|
+ const actionRef = useRef<ActionType>();
|
|
|
+
|
|
|
+ const columns: ProColumns<TableListItem>[] = [
|
|
|
+ {
|
|
|
+ title: '服务IP',
|
|
|
+ dataIndex: 'serviceIp',
|
|
|
+ width: 150,
|
|
|
+ copyable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '模型名称',
|
|
|
+ dataIndex: 'modelName',
|
|
|
+ width: 150,
|
|
|
+ copyable: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '模型版本',
|
|
|
+ dataIndex: 'modelVersion',
|
|
|
+ valueType: 'dateTime',
|
|
|
+ width: 200,
|
|
|
+ hideInSearch: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '当前版本',
|
|
|
+ dataIndex: 'currentVersion',
|
|
|
+ valueType: 'dateTime',
|
|
|
+ width: 220,
|
|
|
+ hideInSearch: true,
|
|
|
+ render: (text, row)=>{
|
|
|
+ if (row.currentVersion < row.modelVersion) {
|
|
|
+ return (<div className={styles.red}>{text} :待更新</div>)
|
|
|
+ }
|
|
|
+ return (<div>{text}</div>)
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '启动状态',
|
|
|
+ dataIndex: 'success',
|
|
|
+ copyable: true,
|
|
|
+ width: 100,
|
|
|
+ renderFormItem: () => {
|
|
|
+ return (
|
|
|
+ <Radio.Group>
|
|
|
+ <Radio value="成功">成功</Radio>
|
|
|
+ <Radio value="失败">失败</Radio>
|
|
|
+ </Radio.Group>
|
|
|
+ );
|
|
|
+ },
|
|
|
+ valueEnum: {
|
|
|
+ "成功": { text: "成功", status: 'Success' },
|
|
|
+ "失败": { text: "失败", status: 'Error' }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '启动信息',
|
|
|
+ dataIndex: 'msg',
|
|
|
+ hideInSearch: true,
|
|
|
+ valueType: 'text',
|
|
|
+ width: 200,
|
|
|
+ render: (text, row) => {
|
|
|
+ if (!text) {
|
|
|
+ row.msg = '';
|
|
|
+ }
|
|
|
+
|
|
|
+ return (<>
|
|
|
+ <Tooltip title={row.msg}>
|
|
|
+ <span>{row.msg.substring(0, 10)}</span>
|
|
|
+ </Tooltip>
|
|
|
+ </>);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'option',
|
|
|
+ width: 100,
|
|
|
+ valueType: 'option',
|
|
|
+ render: (_, record,index,action) => (
|
|
|
+ <>
|
|
|
+ <a
|
|
|
+ onClick={async () => {
|
|
|
+ const success = await handleUpdate(record);
|
|
|
+ if (success) {
|
|
|
+ await action.reload();
|
|
|
+ }
|
|
|
+ console.log(record);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 强制更新
|
|
|
+ </a>
|
|
|
+ </>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ return (
|
|
|
+ <PageHeaderWrapper>
|
|
|
+ <ProTable<TableListItem>
|
|
|
+ headerTitle="查询表格"
|
|
|
+ actionRef={actionRef}
|
|
|
+ rowKey="id"
|
|
|
+ onChange={(_, _filter, _sorter) => {
|
|
|
+ const sorterResult = _sorter as SorterResult<TableListItem>;
|
|
|
+ if (sorterResult.field) {
|
|
|
+ setSorter(`${sorterResult.field}_${sorterResult.order}`);
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ pagination={{
|
|
|
+ defaultPageSize: 10,
|
|
|
+ }}
|
|
|
+ params={{
|
|
|
+ sorter,
|
|
|
+ }}
|
|
|
+ request={(params) => service.queryList(params)}
|
|
|
+ columns={columns}
|
|
|
+ rowSelection={{}}
|
|
|
+ />
|
|
|
+ </PageHeaderWrapper>
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export default TableList;
|