diff --git a/config/routes.ts b/config/routes.ts
index e3a3341..4825ffa 100644
--- a/config/routes.ts
+++ b/config/routes.ts
@@ -7,7 +7,13 @@ export default [
{ name: '注册', path: '/user/register', component: './User/Register' }
],
},
- { path: '/welcome', name: '欢迎', icon: 'smile', component: './Welcome' },
+
+ {
+ name: '智能分析',
+ path: '/add_chart',
+ icon: 'barChart',
+ component: './AddChart'
+ },
{
path: '/admin',
name: '管理页',
@@ -18,6 +24,6 @@ export default [
{ path: '/admin/user-manage', name: '用户管理', icon: 'smile', component: './Admin/UserManage' },
],
},
- { path: '/', redirect: '/welcome' },
+ { path: '/', redirect: '/add_chart' },
{ path: '*', layout: false, component: './404' },
];
diff --git a/src/pages/AddChart/index.tsx b/src/pages/AddChart/index.tsx
new file mode 100644
index 0000000..faf7f5e
--- /dev/null
+++ b/src/pages/AddChart/index.tsx
@@ -0,0 +1,79 @@
+import { genChartByAiUsingPOST } from '@/services/answerbi/chartController';
+import { UploadOutlined } from '@ant-design/icons';
+import { Button, Form, Input, Select, Space, Upload, message } from 'antd';
+import TextArea from 'antd/es/input/TextArea';
+import React from 'react';
+
+
+const addChart: React.FC = () => {
+
+ const onFinish = async (values: any) => {
+ //对接后端,上传数据
+ const params = {
+ ...values,
+ file: undefined,
+ };
+ try{
+ //需要取到上传的原始数据 file->file->originFileObj
+ const res = await genChartByAiUsingPOST(params, {}, values.file.file.originFileObj);
+ //正常情况下,如果没有返回值就分析失败,有就分析成功
+ if(!res?.data){
+ message.error('分析失败');
+ }else{
+ message.success('分析成功');
+ }
+ }catch(e: any){
+ //异常情况下,提示分析失败+具体失败原因
+ message.error('分析失败,' + e.message);
+ }
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }>上传EXCEL文件
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+export default addChart;
diff --git a/src/pages/Admin/UserManage/index.tsx b/src/pages/Admin/UserManage/index.tsx
index d9ce777..8ef937a 100644
--- a/src/pages/Admin/UserManage/index.tsx
+++ b/src/pages/Admin/UserManage/index.tsx
@@ -1,4 +1,4 @@
-import { listUserVOByPageUsingPOST } from '@/services/answerbi/userController';
+import { listUserByPageUsingPOST } from '@/services/answerbi/userController';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { ProTable, TableDropdown } from '@ant-design/pro-components';
import { useRef } from 'react';
@@ -14,7 +14,7 @@ export const waitTime = async (time: number = 100) => {
await waitTimePromise(time);
};
-const columns: ProColumns[] = [
+const columns: ProColumns[] = [
{
dataIndex: 'id',
valueType: 'indexBorder',
@@ -33,23 +33,31 @@ const columns: ProColumns[] = [
{
title: '头像',
dataIndex: 'userAvatar',
+ search: false,
render: (_, record) => (
-
+
)
},
{
title: '角色',
dataIndex: 'userRole',
+ valueType: 'select',
+ valueEnum :{
+ 'user': {text : '普通用户',status : 'Default'},
+ 'admin': {text:'管理员', status : 'Success'},
+ 'ban': {text:'违规被封',status:'Error'},
+ }
},
{
title: '创建时间',
+ key: 'createdTime',
dataIndex: 'createdTime',
valueType: 'dateTime',
+ sorter : true,
+ search : false,
},
-
-
{
title: '操作',
valueType: 'option',
@@ -63,9 +71,6 @@ const columns: ProColumns[] = [
>
编辑
,
-
- 查看
- ,
action?.reload()}
@@ -81,15 +86,15 @@ const columns: ProColumns[] = [
export default () => {
const actionRef = useRef();
return (
-
+
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params = {}, sort, filter) => {
console.log(sort, filter);
- const userList = await listUserVOByPageUsingPOST(params);
+ const userList = await listUserByPageUsingPOST(params);
return {
- data: userList
+ data: userList.data?.records
};
}}
editable={{
@@ -124,11 +129,11 @@ export default () => {
},
}}
pagination={{
- pageSize: 5,
+ pageSize: 10,
onChange: (page) => console.log(page),
}}
dateFormatter="string"
- headerTitle="高级表格"
+ headerTitle="用户列表"
/>
);
};
\ No newline at end of file
diff --git a/src/pages/TableList/components/UpdateForm.tsx b/src/pages/TableList/components/UpdateForm.tsx
deleted file mode 100644
index 958d8b9..0000000
--- a/src/pages/TableList/components/UpdateForm.tsx
+++ /dev/null
@@ -1,155 +0,0 @@
-import {
- ProFormDateTimePicker,
- ProFormRadio,
- ProFormSelect,
- ProFormText,
- ProFormTextArea,
- StepsForm,
-} from '@ant-design/pro-components';
-import '@umijs/max';
-import { Modal } from 'antd';
-import React from 'react';
-export type FormValueType = {
- target?: string;
- template?: string;
- type?: string;
- time?: string;
- frequency?: string;
-} & Partial;
-export type UpdateFormProps = {
- onCancel: (flag?: boolean, formVals?: FormValueType) => void;
- onSubmit: (values: FormValueType) => Promise;
- updateModalOpen: boolean;
- values: Partial;
-};
-const UpdateForm: React.FC = (props) => {
- return (
- {
- return (
- {
- props.onCancel();
- }}
- >
- {dom}
-
- );
- }}
- onFinish={props.onSubmit}
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-export default UpdateForm;
diff --git a/src/pages/TableList/index.tsx b/src/pages/TableList/index.tsx
deleted file mode 100644
index f6617b7..0000000
--- a/src/pages/TableList/index.tsx
+++ /dev/null
@@ -1,329 +0,0 @@
-import { addRule, removeRule, rule, updateRule } from '@/services/ant-design-pro/api';
-import { PlusOutlined } from '@ant-design/icons';
-import type { ActionType, ProColumns, ProDescriptionsItemProps } from '@ant-design/pro-components';
-import {
- FooterToolbar,
- ModalForm,
- PageContainer,
- ProDescriptions,
- ProFormText,
- ProFormTextArea,
- ProTable,
-} from '@ant-design/pro-components';
-import '@umijs/max';
-import { Button, Drawer, Input, message } from 'antd';
-import React, { useRef, useState } from 'react';
-import type { FormValueType } from './components/UpdateForm';
-import UpdateForm from './components/UpdateForm';
-
-/**
- * @en-US Add node
- * @zh-CN 添加节点
- * @param fields
- */
-const handleAdd = async (fields: API.RuleListItem) => {
- const hide = message.loading('正在添加');
- try {
- await addRule({
- ...fields,
- });
- hide();
- message.success('Added successfully');
- return true;
- } catch (error) {
- hide();
- message.error('Adding failed, please try again!');
- return false;
- }
-};
-
-/**
- * @en-US Update node
- * @zh-CN 更新节点
- *
- * @param fields
- */
-const handleUpdate = async (fields: FormValueType) => {
- const hide = message.loading('Configuring');
- try {
- await updateRule({
- name: fields.name,
- desc: fields.desc,
- key: fields.key,
- });
- hide();
- message.success('Configuration is successful');
- return true;
- } catch (error) {
- hide();
- message.error('Configuration failed, please try again!');
- return false;
- }
-};
-
-/**
- * Delete node
- * @zh-CN 删除节点
- *
- * @param selectedRows
- */
-const handleRemove = async (selectedRows: API.RuleListItem[]) => {
- const hide = message.loading('正在删除');
- if (!selectedRows) return true;
- try {
- await removeRule({
- key: selectedRows.map((row) => row.key),
- });
- hide();
- message.success('Deleted successfully and will refresh soon');
- return true;
- } catch (error) {
- hide();
- message.error('Delete failed, please try again');
- return false;
- }
-};
-const TableList: React.FC = () => {
- /**
- * @en-US Pop-up window of new window
- * @zh-CN 新建窗口的弹窗
- * */
- const [createModalOpen, handleModalOpen] = useState(false);
- /**
- * @en-US The pop-up window of the distribution update window
- * @zh-CN 分布更新窗口的弹窗
- * */
- const [updateModalOpen, handleUpdateModalOpen] = useState(false);
- const [showDetail, setShowDetail] = useState(false);
- const actionRef = useRef();
- const [currentRow, setCurrentRow] = useState();
- const [selectedRowsState, setSelectedRows] = useState([]);
-
- /**
- * @en-US International configuration
- * @zh-CN 国际化配置
- * */
-
- const columns: ProColumns[] = [
- {
- title: '规则名称',
- dataIndex: 'name',
- tip: 'The rule name is the unique key',
- render: (dom, entity) => {
- return (
- {
- setCurrentRow(entity);
- setShowDetail(true);
- }}
- >
- {dom}
-
- );
- },
- },
- {
- title: '描述',
- dataIndex: 'desc',
- valueType: 'textarea',
- },
- {
- title: '服务调用次数',
- dataIndex: 'callNo',
- sorter: true,
- hideInForm: true,
- renderText: (val: string) => `${val}${'万'}`,
- },
- {
- title: '状态',
- dataIndex: 'status',
- hideInForm: true,
- valueEnum: {
- 0: {
- text: '关闭',
- status: 'Default',
- },
- 1: {
- text: '运行中',
- status: 'Processing',
- },
- 2: {
- text: '已上线',
- status: 'Success',
- },
- 3: {
- text: '异常',
- status: 'Error',
- },
- },
- },
- {
- title: '上次调度时间',
- sorter: true,
- dataIndex: 'updatedAt',
- valueType: 'dateTime',
- renderFormItem: (item, { defaultRender, ...rest }, form) => {
- const status = form.getFieldValue('status');
- if (`${status}` === '0') {
- return false;
- }
- if (`${status}` === '3') {
- return ;
- }
- return defaultRender(item);
- },
- },
- {
- title: '操作',
- dataIndex: 'option',
- valueType: 'option',
- render: (_, record) => [
- {
- handleUpdateModalOpen(true);
- setCurrentRow(record);
- }}
- >
- 配置
- ,
-
- 订阅警报
- ,
- ],
- },
- ];
- return (
-
-
- headerTitle={'查询表格'}
- actionRef={actionRef}
- rowKey="key"
- search={{
- labelWidth: 120,
- }}
- toolBarRender={() => [
- ,
- ]}
- request={rule}
- columns={columns}
- rowSelection={{
- onChange: (_, selectedRows) => {
- setSelectedRows(selectedRows);
- },
- }}
- />
- {selectedRowsState?.length > 0 && (
-
- 已选择{' '}
-
- {selectedRowsState.length}
- {' '}
- 项
-
- 服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.callNo!, 0)} 万
-
-
- }
- >
-
-
-
- )}
- {
- const success = await handleAdd(value as API.RuleListItem);
- if (success) {
- handleModalOpen(false);
- if (actionRef.current) {
- actionRef.current.reload();
- }
- }
- }}
- >
-
-
-
- {
- const success = await handleUpdate(value);
- if (success) {
- handleUpdateModalOpen(false);
- setCurrentRow(undefined);
- if (actionRef.current) {
- actionRef.current.reload();
- }
- }
- }}
- onCancel={() => {
- handleUpdateModalOpen(false);
- if (!showDetail) {
- setCurrentRow(undefined);
- }
- }}
- updateModalOpen={updateModalOpen}
- values={currentRow || {}}
- />
-
- {
- setCurrentRow(undefined);
- setShowDetail(false);
- }}
- closable={false}
- >
- {currentRow?.name && (
-
- column={2}
- title={currentRow?.name}
- request={async () => ({
- data: currentRow || {},
- })}
- params={{
- id: currentRow?.name,
- }}
- columns={columns as ProDescriptionsItemProps[]}
- />
- )}
-
-
- );
-};
-export default TableList;
diff --git a/src/services/answerbi/chartController.ts b/src/services/answerbi/chartController.ts
index f552cd4..9d48118 100644
--- a/src/services/answerbi/chartController.ts
+++ b/src/services/answerbi/chartController.ts
@@ -47,6 +47,42 @@ export async function editChartUsingPOST(
});
}
+/** genChartByAi POST /api/chart/gen */
+export async function genChartByAiUsingPOST(
+ // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
+ params: API.genChartByAiUsingPOSTParams,
+ body: {},
+ file?: File,
+ options?: { [key: string]: any },
+) {
+ const formData = new FormData();
+
+ if (file) {
+ formData.append('file', file);
+ }
+
+ Object.keys(body).forEach((ele) => {
+ const item = (body as any)[ele];
+
+ if (item !== undefined && item !== null) {
+ formData.append(
+ ele,
+ typeof item === 'object' && !(item instanceof File) ? JSON.stringify(item) : item,
+ );
+ }
+ });
+
+ return request('/api/chart/gen', {
+ method: 'POST',
+ params: {
+ ...params,
+ },
+ data: formData,
+ requestType: 'form',
+ ...(options || {}),
+ });
+}
+
/** getChartById GET /api/chart/get */
export async function getChartByIdUsingGET(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
diff --git a/src/services/answerbi/typings.d.ts b/src/services/answerbi/typings.d.ts
index 8622e56..8c2bd6c 100644
--- a/src/services/answerbi/typings.d.ts
+++ b/src/services/answerbi/typings.d.ts
@@ -1,6 +1,13 @@
declare namespace API {
+ type BiResponse = {
+ chartId?: number;
+ genChart?: string;
+ genResult?: string;
+ };
+
type Chart = {
chartData?: string;
+ chartName?: string;
chartType?: string;
createdTime?: string;
deletedFlag?: number;
@@ -14,18 +21,21 @@ declare namespace API {
type ChartAddRequest = {
chartData?: string;
+ chartName?: string;
chartType?: string;
goal?: string;
};
type ChartEditRequest = {
chartData?: string;
+ chartName?: string;
chartType?: string;
goal?: string;
id?: number;
};
type ChartQueryRequest = {
+ chartName?: string;
chartType?: string;
current?: number;
goal?: string;
@@ -38,6 +48,7 @@ declare namespace API {
type ChartUpdateRequest = {
chartData?: string;
+ chartName?: string;
chartType?: string;
createdTime?: string;
deletedFlag?: number;
@@ -48,6 +59,12 @@ declare namespace API {
updatedTime?: string;
};
+ type CommonResponseBiResponse_ = {
+ code?: number;
+ data?: BiResponse;
+ message?: string;
+ };
+
type CommonResponseBoolean_ = {
code?: number;
data?: boolean;
@@ -130,6 +147,12 @@ declare namespace API {
id?: number;
};
+ type genChartByAiUsingPOSTParams = {
+ chartName?: string;
+ chartType?: string;
+ goal?: string;
+ };
+
type getChartByIdUsingGETParams = {
/** id */
id?: number;
@@ -151,9 +174,9 @@ declare namespace API {
};
type LoginUserVO = {
- createTime?: string;
+ createdTime?: string;
id?: number;
- updateTime?: string;
+ updatedTime?: string;
userAvatar?: string;
userName?: string;
userProfile?: string;
@@ -296,9 +319,9 @@ declare namespace API {
updatedTime?: string;
userAccount?: string;
userAvatar?: string;
+ userName?: string;
userPassword?: string;
userRole?: string;
- username?: string;
};
type UserAddRequest = {
@@ -316,11 +339,10 @@ declare namespace API {
type UserQueryRequest = {
current?: number;
id?: number;
- mpOpenId?: string;
pageSize?: number;
sortField?: string;
sortOrder?: string;
- unionId?: string;
+ userAccount?: string;
userName?: string;
userProfile?: string;
userRole?: string;
@@ -347,11 +369,11 @@ declare namespace API {
};
type UserVO = {
- createTime?: string;
+ createdTime?: string;
id?: number;
+ userAccount?: string;
userAvatar?: string;
userName?: string;
- userAccount?: string;
userProfile?: string;
userRole?: string;
};
diff --git a/src/services/ant-design-pro/api.ts b/src/services/ant-design-pro/api.ts
deleted file mode 100644
index cbd5961..0000000
--- a/src/services/ant-design-pro/api.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-import { request } from '@umijs/max';
-
-/** 获取当前的用户 GET /api/currentUser */
-export async function currentUser(options?: { [key: string]: any }) {
- return request<{
- data: API.CurrentUser;
- }>('/api/currentUser', {
- method: 'GET',
- ...(options || {}),
- });
-}
-
-/** 退出登录接口 POST /api/login/outLogin */
-export async function outLogin(options?: { [key: string]: any }) {
- return request>('/api/login/outLogin', {
- method: 'POST',
- ...(options || {}),
- });
-}
-
-/** 登录接口 POST /api/login/account */
-export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
- return request('/api/login/account', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- data: body,
- ...(options || {}),
- });
-}
-
-/** 此处后端没有提供注释 GET /api/notices */
-export async function getNotices(options?: { [key: string]: any }) {
- return request('/api/notices', {
- method: 'GET',
- ...(options || {}),
- });
-}
-
-/** 获取规则列表 GET /api/rule */
-export async function rule(
- params: {
- // query
- /** 当前的页码 */
- current?: number;
- /** 页面的容量 */
- pageSize?: number;
- },
- options?: { [key: string]: any },
-) {
- return request('/api/rule', {
- method: 'GET',
- params: {
- ...params,
- },
- ...(options || {}),
- });
-}
-
-/** 新建规则 PUT /api/rule */
-export async function updateRule(options?: { [key: string]: any }) {
- return request('/api/rule', {
- method: 'PUT',
- ...(options || {}),
- });
-}
-
-/** 新建规则 POST /api/rule */
-export async function addRule(options?: { [key: string]: any }) {
- return request('/api/rule', {
- method: 'POST',
- ...(options || {}),
- });
-}
-
-/** 删除规则 DELETE /api/rule */
-export async function removeRule(options?: { [key: string]: any }) {
- return request>('/api/rule', {
- method: 'DELETE',
- ...(options || {}),
- });
-}
diff --git a/src/services/ant-design-pro/index.ts b/src/services/ant-design-pro/index.ts
deleted file mode 100644
index 1ac489f..0000000
--- a/src/services/ant-design-pro/index.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-// API 更新时间:
-// API 唯一标识:
-import * as api from './api';
-import * as login from './login';
-export default {
- api,
- login,
-};
diff --git a/src/services/ant-design-pro/login.ts b/src/services/ant-design-pro/login.ts
deleted file mode 100644
index 8871ed8..0000000
--- a/src/services/ant-design-pro/login.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-import { request } from '@umijs/max';
-
-/** 发送验证码 POST /api/login/captcha */
-export async function getFakeCaptcha(
- params: {
- // query
- /** 手机号 */
- phone?: string;
- },
- options?: { [key: string]: any },
-) {
- return request('/api/login/captcha', {
- method: 'GET',
- params: {
- ...params,
- },
- ...(options || {}),
- });
-}
diff --git a/src/services/ant-design-pro/typings.d.ts b/src/services/ant-design-pro/typings.d.ts
deleted file mode 100644
index 13e5a68..0000000
--- a/src/services/ant-design-pro/typings.d.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-// @ts-ignore
-/* eslint-disable */
-
-declare namespace API {
- type CurrentUser = {
- name?: string;
- avatar?: string;
- userid?: string;
- email?: string;
- signature?: string;
- title?: string;
- group?: string;
- tags?: { key?: string; label?: string }[];
- notifyCount?: number;
- unreadCount?: number;
- country?: string;
- access?: string;
- geographic?: {
- province?: { label?: string; key?: string };
- city?: { label?: string; key?: string };
- };
- address?: string;
- phone?: string;
- };
-
- type LoginResult = {
- status?: string;
- type?: string;
- currentAuthority?: string;
- };
-
- type PageParams = {
- current?: number;
- pageSize?: number;
- };
-
- type RuleListItem = {
- key?: number;
- disabled?: boolean;
- href?: string;
- avatar?: string;
- name?: string;
- owner?: string;
- desc?: string;
- callNo?: number;
- status?: number;
- updatedAt?: string;
- createdAt?: string;
- progress?: number;
- };
-
- type RuleList = {
- data?: RuleListItem[];
- /** 列表的内容总数 */
- total?: number;
- success?: boolean;
- };
-
- type FakeCaptcha = {
- code?: number;
- status?: string;
- };
-
- type LoginParams = {
- username?: string;
- password?: string;
- autoLogin?: boolean;
- type?: string;
- };
-
- type ErrorResponse = {
- /** 业务约定的错误码 */
- errorCode: string;
- /** 业务上的错误信息 */
- errorMessage?: string;
- /** 业务上的请求是否成功 */
- success?: boolean;
- };
-
- type NoticeIconList = {
- data?: NoticeIconItem[];
- /** 列表的内容总数 */
- total?: number;
- success?: boolean;
- };
-
- type NoticeIconItemType = 'notification' | 'message' | 'event';
-
- type NoticeIconItem = {
- id?: string;
- extra?: string;
- key?: string;
- read?: boolean;
- avatar?: string;
- title?: string;
- status?: string;
- datetime?: string;
- description?: string;
- type?: NoticeIconItemType;
- };
-}