Commit 69df8d4f830223304ea41180fe76da20f9be4ca1

Authored by sanmu
1 parent 8b2bcc88

feat: add axios

package.json
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 "@inspir/assembly-css": "1.0.0-alpha", 17 "@inspir/assembly-css": "1.0.0-alpha",
18 "@umijs/max": "^4.0.87", 18 "@umijs/max": "^4.0.87",
19 "antd": "^5.10.2", 19 "antd": "^5.10.2",
  20 + "axios": "^1.6.1",
20 "lodash": "^4.17.21" 21 "lodash": "^4.17.21"
21 }, 22 },
22 "devDependencies": { 23 "devDependencies": {
pnpm-lock.yaml
@@ -20,6 +20,9 @@ dependencies: @@ -20,6 +20,9 @@ dependencies:
20 antd: 20 antd:
21 specifier: ^5.10.2 21 specifier: ^5.10.2
22 version: registry.npmjs.org/antd@5.10.2(react-dom@18.2.0)(react@18.2.0) 22 version: registry.npmjs.org/antd@5.10.2(react-dom@18.2.0)(react@18.2.0)
  23 + axios:
  24 + specifier: ^1.6.1
  25 + version: registry.npmjs.org/axios@1.6.1
23 lodash: 26 lodash:
24 specifier: ^4.17.21 27 specifier: ^4.17.21
25 version: registry.npmjs.org/lodash@4.17.21 28 version: registry.npmjs.org/lodash@4.17.21
@@ -5921,6 +5924,18 @@ packages: @@ -5921,6 +5924,18 @@ packages:
5921 - debug 5924 - debug
5922 dev: false 5925 dev: false
5923 5926
  5927 + registry.npmjs.org/axios@1.6.1:
  5928 + resolution: {integrity: sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/axios/-/axios-1.6.1.tgz}
  5929 + name: axios
  5930 + version: 1.6.1
  5931 + dependencies:
  5932 + follow-redirects: registry.npmjs.org/follow-redirects@1.15.3
  5933 + form-data: registry.npmjs.org/form-data@4.0.0
  5934 + proxy-from-env: registry.npmjs.org/proxy-from-env@1.1.0
  5935 + transitivePeerDependencies:
  5936 + - debug
  5937 + dev: false
  5938 +
5924 registry.npmjs.org/babel-jest@29.7.0(@babel/core@7.23.2): 5939 registry.npmjs.org/babel-jest@29.7.0(@babel/core@7.23.2):
5925 resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz} 5940 resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz}
5926 id: registry.npmjs.org/babel-jest/29.7.0 5941 id: registry.npmjs.org/babel-jest/29.7.0
@@ -7196,6 +7211,7 @@ packages: @@ -7196,6 +7211,7 @@ packages:
7196 resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/debug/-/debug-3.2.7.tgz} 7211 resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/debug/-/debug-3.2.7.tgz}
7197 name: debug 7212 name: debug
7198 version: 3.2.7 7213 version: 3.2.7
  7214 + requiresBuild: true
7199 peerDependencies: 7215 peerDependencies:
7200 supports-color: '*' 7216 supports-color: '*'
7201 peerDependenciesMeta: 7217 peerDependenciesMeta:
@@ -11061,6 +11077,7 @@ packages: @@ -11061,6 +11077,7 @@ packages:
11061 resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/ms/-/ms-2.1.3.tgz} 11077 resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/ms/-/ms-2.1.3.tgz}
11062 name: ms 11078 name: ms
11063 version: 2.1.3 11079 version: 2.1.3
  11080 + requiresBuild: true
11064 dev: false 11081 dev: false
11065 optional: true 11082 optional: true
11066 11083
@@ -12615,10 +12632,17 @@ packages: @@ -12615,10 +12632,17 @@ packages:
12615 version: 2.5.1 12632 version: 2.5.1
12616 dev: false 12633 dev: false
12617 12634
  12635 + registry.npmjs.org/proxy-from-env@1.1.0:
  12636 + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz}
  12637 + name: proxy-from-env
  12638 + version: 1.1.0
  12639 + dev: false
  12640 +
12618 registry.npmjs.org/prr@1.0.1: 12641 registry.npmjs.org/prr@1.0.1:
12619 resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/prr/-/prr-1.0.1.tgz} 12642 resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/prr/-/prr-1.0.1.tgz}
12620 name: prr 12643 name: prr
12621 version: 1.0.1 12644 version: 1.0.1
  12645 + requiresBuild: true
12622 dev: false 12646 dev: false
12623 optional: true 12647 optional: true
12624 12648
@@ -14702,6 +14726,7 @@ packages: @@ -14702,6 +14726,7 @@ packages:
14702 resolution: {integrity: sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/sax/-/sax-1.3.0.tgz} 14726 resolution: {integrity: sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/sax/-/sax-1.3.0.tgz}
14703 name: sax 14727 name: sax
14704 version: 1.3.0 14728 version: 1.3.0
  14729 + requiresBuild: true
14705 dev: false 14730 dev: false
14706 optional: true 14731 optional: true
14707 14732
src/models/user.ts
1 -import { getAdminUserList } from '@/services';  
2 import { useState } from 'react'; 1 import { useState } from 'react';
3 2
4 // src/models/userModel.ts 3 // src/models/userModel.ts
5 export default function Page() { 4 export default function Page() {
6 const [list, setList] = useState([]); 5 const [list, setList] = useState([]);
7 6
8 - const getList = async () => {  
9 - const res = await getAdminUserList({ query: { PageNum: 1, PageSize: 20 } });  
10 - setList(res.data.UserList);  
11 - }; 7 + const getList = async () => {};
12 8
13 return { list, getList }; 9 return { list, getList };
14 } 10 }
src/pages/Order/components/OrderDrawer.tsx
1 // import { PlusOutlined } from '@ant-design/icons'; 1 // import { PlusOutlined } from '@ant-design/icons';
  2 +import { postErpOrderAdd } from '@/services';
2 import { DrawerForm, ProFormText } from '@ant-design/pro-components'; 3 import { DrawerForm, ProFormText } from '@ant-design/pro-components';
3 import { Form, message } from 'antd'; 4 import { Form, message } from 'antd';
4 5
@@ -36,11 +37,7 @@ export default ({ onClose }) => { @@ -36,11 +37,7 @@ export default ({ onClose }) => {
36 }} 37 }}
37 submitTimeout={2000} 38 submitTimeout={2000}
38 onFinish={async (values) => { 39 onFinish={async (values) => {
39 - console.log(  
40 - '%c [ ]-40',  
41 - 'font-size:13px; background:pink; color:#bf2c9f;',  
42 - values,  
43 - ); 40 + await postErpOrderAdd({ values });
44 console.log(values.name); 41 console.log(values.name);
45 message.success('提交成功'); 42 message.success('提交成功');
46 // 不返回不会关闭弹框 43 // 不返回不会关闭弹框
src/pages/Order/index.tsx
  1 +import { postErpOrderListByPage } from '@/services';
1 import services from '@/services/demo'; 2 import services from '@/services/demo';
2 import { 3 import {
3 ActionType, 4 ActionType,
@@ -8,7 +9,7 @@ import { @@ -8,7 +9,7 @@ import {
8 ProTable, 9 ProTable,
9 } from '@ant-design/pro-components'; 10 } from '@ant-design/pro-components';
10 import { Button, Divider, Drawer, message } from 'antd'; 11 import { Button, Divider, Drawer, message } from 'antd';
11 -import React, { useRef, useState } from 'react'; 12 +import React, { useEffect, useRef, useState } from 'react';
12 import CreateForm from './components/CreateForm'; 13 import CreateForm from './components/CreateForm';
13 import OrderDrawer from './components/OrderDrawer'; 14 import OrderDrawer from './components/OrderDrawer';
14 import UpdateForm, { FormValueType } from './components/UpdateForm'; 15 import UpdateForm, { FormValueType } from './components/UpdateForm';
@@ -92,6 +93,10 @@ const TableList: React.FC<unknown> = () => { @@ -92,6 +93,10 @@ const TableList: React.FC<unknown> = () => {
92 const [row, setRow] = useState<API.UserInfo>(); 93 const [row, setRow] = useState<API.UserInfo>();
93 const [selectedRowsState, setSelectedRows] = useState<API.UserInfo[]>([]); 94 const [selectedRowsState, setSelectedRows] = useState<API.UserInfo[]>([]);
94 const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false); 95 const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false);
  96 +
  97 + useEffect(() => {
  98 + postErpOrderListByPage();
  99 + }, []);
95 const columns: ProDescriptionsItemProps<API.UserInfo>[] = [ 100 const columns: ProDescriptionsItemProps<API.UserInfo>[] = [
96 { 101 {
97 title: '名称', 102 title: '名称',
src/services/request.ts
@@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
2 /* tslint:disable */ 2 /* tslint:disable */
3 /** Do not modify manually. 3 /** Do not modify manually.
4 content is generated automatically by `ts-gear`. */ 4 content is generated automatically by `ts-gear`. */
5 -import { request as requester } from "umi";  
6 -import type {} from "./definition"; 5 +import requester from 'axios';
  6 +// import type {} from "./definition";
7 7
8 /** @description request parameter type for postErpOrderListByPage */ 8 /** @description request parameter type for postErpOrderListByPage */
9 export interface PostErpOrderListByPageOption { 9 export interface PostErpOrderListByPageOption {
@@ -110,10 +110,10 @@ export type PostErpOrderListByPageResponseSuccess = @@ -110,10 +110,10 @@ export type PostErpOrderListByPageResponseSuccess =
110 * @consumes application/json 110 * @consumes application/json
111 */ 111 */
112 export const postErpOrderListByPage = /* #__PURE__ */ (() => { 112 export const postErpOrderListByPage = /* #__PURE__ */ (() => {
113 - const method = "post";  
114 - const url = "/erp/order/listByPage"; 113 + const method = 'post';
  114 + const url = '/erp/order/listByPage';
115 function request( 115 function request(
116 - option?: PostErpOrderListByPageOption 116 + option?: PostErpOrderListByPageOption,
117 ): Promise<PostErpOrderListByPageResponseSuccess> { 117 ): Promise<PostErpOrderListByPageResponseSuccess> {
118 return requester(request.url, { 118 return requester(request.url, {
119 method: request.method, 119 method: request.method,
@@ -200,10 +200,10 @@ export type PostErpOrderAddResponseSuccess = PostErpOrderAddResponse[200]; @@ -200,10 +200,10 @@ export type PostErpOrderAddResponseSuccess = PostErpOrderAddResponse[200];
200 * @consumes application/json 200 * @consumes application/json
201 */ 201 */
202 export const postErpOrderAdd = /* #__PURE__ */ (() => { 202 export const postErpOrderAdd = /* #__PURE__ */ (() => {
203 - const method = "post";  
204 - const url = "/erp/order/add"; 203 + const method = 'post';
  204 + const url = '/erp/order/add';
205 function request( 205 function request(
206 - option: PostErpOrderAddOption 206 + option: PostErpOrderAddOption,
207 ): Promise<PostErpOrderAddResponseSuccess> { 207 ): Promise<PostErpOrderAddResponseSuccess> {
208 return requester(request.url, { 208 return requester(request.url, {
209 method: request.method, 209 method: request.method,
@@ -270,10 +270,10 @@ export type PostErpOrderUpdateResponseSuccess = PostErpOrderUpdateResponse[200]; @@ -270,10 +270,10 @@ export type PostErpOrderUpdateResponseSuccess = PostErpOrderUpdateResponse[200];
270 * @consumes application/json 270 * @consumes application/json
271 */ 271 */
272 export const postErpOrderUpdate = /* #__PURE__ */ (() => { 272 export const postErpOrderUpdate = /* #__PURE__ */ (() => {
273 - const method = "post";  
274 - const url = "/erp/order/update"; 273 + const method = 'post';
  274 + const url = '/erp/order/update';
275 function request( 275 function request(
276 - option?: PostErpOrderUpdateOption 276 + option?: PostErpOrderUpdateOption,
277 ): Promise<PostErpOrderUpdateResponseSuccess> { 277 ): Promise<PostErpOrderUpdateResponseSuccess> {
278 return requester(request.url, { 278 return requester(request.url, {
279 method: request.method, 279 method: request.method,