李志伟 3 年前
父节点
当前提交
f332f4a68d

+ 1
- 0
.npmrc 查看文件

1
+registry=https://registry.npmmirror.com

+ 33
- 10
config/routes.js 查看文件

43
     ],
43
     ],
44
   },
44
   },
45
   {
45
   {
46
-    path: '/',
46
+    path: '/PlatformMessageManagement',
47
     name: '消息管理',
47
     name: '消息管理',
48
     icon: 'crown',
48
     icon: 'crown',
49
     component: '../layouts/BasicLayout',
49
     component: '../layouts/BasicLayout',
58
         path: '/PlatformMessageManagement/MessageEdit',
58
         path: '/PlatformMessageManagement/MessageEdit',
59
         name: '消息查看',
59
         name: '消息查看',
60
         component: './PlatformMessageManagement/MessageEdit',
60
         component: './PlatformMessageManagement/MessageEdit',
61
-        hideInMenu: true
61
+        hideInMenu: true,
62
       },
62
       },
63
+    ],
64
+  },
63
 
65
 
66
+  {
67
+    path: '/OrderManage',
68
+    name: '订单调度',
69
+    icon: 'InsertRowLeftOutlined',
70
+    component: '../layouts/BasicLayout',
71
+    routes: [
72
+      {
73
+        path: '/OrderManage',
74
+        name: '订单调度',
75
+        component: './OrderManage',
76
+      },
77
+    ],
78
+  },
79
+  {
80
+    path: '/Finance',
81
+    name: '财务管理',
82
+    icon: 'InsertRowLeftOutlined',
83
+    component: '../layouts/BasicLayout',
84
+    routes: [
85
+      {
86
+        path: '/Finance/AccountLog',
87
+        name: '平台流水',
88
+        component: './Finance/AccountLog',
89
+      },
90
+      {
91
+        path: '/Finance/Withdrawal',
92
+        name: '提现管理',
93
+        component: './Finance/Withdrawal',
94
+      },
64
     ],
95
     ],
65
   },
96
   },
66
   {
97
   {
97
         component: './SystemManagement/Agreement',
128
         component: './SystemManagement/Agreement',
98
         // hideInMenu: true
129
         // hideInMenu: true
99
       },
130
       },
100
-
101
     ],
131
     ],
102
   },
132
   },
103
-
104
-  {
105
-    name: 'list.table-list',
106
-    icon: 'table',
107
-    path: '/list',
108
-    component: './TableList',
109
-  },
110
   {
133
   {
111
     path: '/',
134
     path: '/',
112
     redirect: '/welcome',
135
     redirect: '/welcome',

+ 1
- 1
package.json 查看文件

57
     "antd": "^4.17.0",
57
     "antd": "^4.17.0",
58
     "classnames": "^2.3.0",
58
     "classnames": "^2.3.0",
59
     "lodash": "^4.17.0",
59
     "lodash": "^4.17.0",
60
-    "moment": "^2.29.0",
60
+    "moment": "^2.29.1",
61
     "omit.js": "^2.0.2",
61
     "omit.js": "^2.0.2",
62
     "rc-menu": "^9.1.0",
62
     "rc-menu": "^9.1.0",
63
     "rc-util": "^5.16.0",
63
     "rc-util": "^5.16.0",

+ 0
- 16
src/app.jsx 查看文件

4
 import RightContent from '@/components/RightContent';
4
 import RightContent from '@/components/RightContent';
5
 import Footer from '@/components/Footer';
5
 import Footer from '@/components/Footer';
6
 import { currentUser as queryCurrentUser } from './services/ant-design-pro/api';
6
 import { currentUser as queryCurrentUser } from './services/ant-design-pro/api';
7
-import { BookOutlined, LinkOutlined } from '@ant-design/icons';
8
 import defaultSettings from '../config/defaultSettings';
7
 import defaultSettings from '../config/defaultSettings';
9
 const isDev = process.env.NODE_ENV === 'development';
8
 const isDev = process.env.NODE_ENV === 'development';
10
 const loginPath = '/user/login';
9
 const loginPath = '/user/login';
48
   return {
47
   return {
49
     rightContentRender: () => <RightContent />,
48
     rightContentRender: () => <RightContent />,
50
     disableContentMargin: false,
49
     disableContentMargin: false,
51
-    waterMarkProps: {
52
-      content: initialState?.currentUser?.name,
53
-    },
54
     footerRender: () => <Footer />,
50
     footerRender: () => <Footer />,
55
     onPageChange: () => {
51
     onPageChange: () => {
56
       const { location } = history; // 如果没有登录,重定向到 login
52
       const { location } = history; // 如果没有登录,重定向到 login
59
         history.push(loginPath);
55
         history.push(loginPath);
60
       }
56
       }
61
     },
57
     },
62
-    links: isDev
63
-      ? [
64
-          <Link to="/umi/plugin/openapi" target="_blank">
65
-            <LinkOutlined />
66
-            <span>OpenAPI 文档</span>
67
-          </Link>,
68
-          <Link to="/~docs">
69
-            <BookOutlined />
70
-            <span>业务组件文档</span>
71
-          </Link>,
72
-        ]
73
-      : [],
74
     menuHeaderRender: undefined,
58
     menuHeaderRender: undefined,
75
     // 自定义 403 页面
59
     // 自定义 403 页面
76
     // unAccessible: <div>unAccessible</div>,
60
     // unAccessible: <div>unAccessible</div>,

+ 53
- 0
src/components/PageTable/index.jsx 查看文件

1
+import React, { useState, useCallback, useRef } from 'react';
2
+import { Button } from 'antd';
3
+import { UploadOutlined } from '@ant-design/icons';
4
+import ProTable from '@ant-design/pro-table';
5
+import { queryTable } from '@/utils/request';
6
+import useExport from '@/utils/hooks/useExport';
7
+
8
+export default (props) => {
9
+  const { formRef, request, expfunc, params = {}, toolBarRender, ...leftProps } = props;
10
+
11
+  // 如果 formRef 未设置, 则使用 fmRef 去代理
12
+  const fmRef = useRef();
13
+  const ref = formRef || fmRef;
14
+
15
+  // 自动封装查询函数
16
+  const getList = useCallback(queryTable(request), [request]);
17
+
18
+  // 获取导出函数
19
+  const [exporting, exportFunc] = useExport(expfunc);
20
+
21
+  const handleExport = useCallback(() => {
22
+    const formData = ref.current ? ref.current.getFieldsValue() : {};
23
+    exportFunc({ ...formData, ...params });
24
+  }, [exportFunc, params]);
25
+
26
+  // 添加导出按钮
27
+  const renderToolbar = useCallback(() => {
28
+    const acts = [];
29
+    if (toolBarRender) {
30
+      acts.push(...toolBarRender());
31
+    }
32
+
33
+    if (typeof expfunc === 'function') {
34
+      acts.push(
35
+        <Button loading={exporting} key="export" icon={<UploadOutlined />} onClick={handleExport}>
36
+          导出
37
+        </Button>,
38
+      );
39
+    }
40
+
41
+    return acts;
42
+  }, [toolBarRender, exporting, handleExport, expfunc]);
43
+
44
+  return (
45
+    <ProTable
46
+      {...leftProps}
47
+      params={params}
48
+      formRef={ref}
49
+      // request={getList}
50
+      toolBarRender={renderToolbar}
51
+    />
52
+  );
53
+};

+ 89
- 0
src/pages/Finance/AccountLog/index.jsx 查看文件

1
+import React from 'react';
2
+// import { getPersonList, exportPersonList } from '@/services/person';
3
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
4
+import moment from 'moment';
5
+import PageTable from '@/components/PageTable';
6
+
7
+const formatterTime = (val) => {
8
+  return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
9
+};
10
+
11
+export default (props) => {
12
+  const columns = [
13
+    {
14
+      title: '流水号',
15
+      dataIndex: 'log_id',
16
+      key: 'log_id',
17
+    },
18
+    {
19
+      title: '订单号',
20
+      dataIndex: 'orderId',
21
+      key: 'orderId',
22
+    },
23
+    {
24
+      title: '用户Id',
25
+      dataIndex: 'userId',
26
+      key: 'userId',
27
+    },
28
+    {
29
+      title: '收款人',
30
+      dataIndex: 'name',
31
+      key: 'name',
32
+    },
33
+    {
34
+      title: '手机号码',
35
+      dataIndex: 'phone',
36
+      key: 'phone',
37
+    },
38
+    {
39
+      title: '用户类型',
40
+      dataIndex: 'type',
41
+      key: 'type',
42
+      valueType: 'select',
43
+      valueEnum: {
44
+        '': { text: '不限', status: 'Default' },
45
+        1: { text: '押金' },
46
+        2: { text: '人工费' },
47
+      },
48
+    },
49
+    {
50
+      title: '支付方式',
51
+      dataIndex: 'payType',
52
+      key: 'payType',
53
+      valueType: 'select',
54
+      search: false,
55
+      valueEnum: {
56
+        '': { text: '不限', status: 'Default' },
57
+        1: { text: '微信' },
58
+        2: { text: '支付宝' },
59
+      },
60
+    },
61
+    {
62
+      title: '流水金额',
63
+      dataIndex: 'money',
64
+      key: 'money',
65
+      search: false,
66
+    },
67
+    {
68
+      title: '发生时间',
69
+      dataIndex: 'createDate',
70
+      key: 'createDate',
71
+      search: false,
72
+      render: (t) => formatterTime(t),
73
+      width: 200,
74
+    },
75
+  ];
76
+
77
+  return (
78
+    <PageHeaderWrapper>
79
+      <PageTable
80
+        // request={getPersonList}
81
+        // expfunc={exportPersonList}
82
+        columns={columns}
83
+        rowKey="logId"
84
+        options={false}
85
+        scroll={{ x: 1000 }}
86
+      />
87
+    </PageHeaderWrapper>
88
+  );
89
+};

+ 89
- 0
src/pages/Finance/Withdrawal/index.jsx 查看文件

1
+import React from 'react';
2
+// import { getPersonList, exportPersonList } from '@/services/person';
3
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
4
+import moment from 'moment';
5
+import PageTable from '@/components/PageTable';
6
+
7
+const formatterTime = (val) => {
8
+  return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
9
+};
10
+
11
+export default (props) => {
12
+  const columns = [
13
+    {
14
+      title: '序号',
15
+      dataIndex: 'sortId',
16
+      key: 'sortId',
17
+      search: false,
18
+    },
19
+    {
20
+      title: '用户账号',
21
+      dataIndex: 'account_id',
22
+      key: 'account_id',
23
+    },
24
+    {
25
+      title: '收款人',
26
+      dataIndex: 'name',
27
+      key: 'name',
28
+    },
29
+    {
30
+      title: '手机号码',
31
+      dataIndex: 'phone',
32
+      key: 'phone',
33
+    },
34
+    {
35
+      title: '提现金额',
36
+      dataIndex: 'money',
37
+      key: 'money',
38
+      search: false,
39
+    },
40
+    {
41
+      title: '账号类型',
42
+      dataIndex: 'payType',
43
+      key: 'payType',
44
+      valueType: 'select',
45
+      valueEnum: {
46
+        '': { text: '不限', status: 'Default' },
47
+        1: { text: '微信' },
48
+        2: { text: '支付宝' },
49
+      },
50
+      search: false,
51
+    },
52
+    {
53
+      title: '提现账号',
54
+      dataIndex: 'withfrawalNum',
55
+      key: 'withfrawalNum',
56
+      search: false,
57
+    },
58
+
59
+    {
60
+      title: '申请时间',
61
+      dataIndex: 'createDate',
62
+      key: 'createDate',
63
+      search: false,
64
+      render: (t) => formatterTime(t),
65
+      search: false,
66
+    },
67
+    {
68
+      title: '更新时间',
69
+      dataIndex: 'updateDate',
70
+      key: 'updateDate',
71
+      valueType: 'date',
72
+      render: (t) => formatterTime(t),
73
+      width: 200,
74
+    },
75
+  ];
76
+
77
+  return (
78
+    <PageHeaderWrapper>
79
+      <PageTable
80
+        // request={getPersonList}
81
+        // expfunc={exportPersonList}
82
+        columns={columns}
83
+        rowKey="withdrawalId"
84
+        options={false}
85
+        scroll={{ x: 1000 }}
86
+      />
87
+    </PageHeaderWrapper>
88
+  );
89
+};

+ 95
- 0
src/pages/OrderManage/index.jsx 查看文件

1
+import React from 'react';
2
+// import { getPersonList, exportPersonList } from '@/services/person';
3
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
4
+import moment from 'moment';
5
+import PageTable from '@/components/PageTable';
6
+
7
+const formatterTime = (val) => {
8
+  return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
9
+};
10
+
11
+export default (props) => {
12
+  const columns = [
13
+    {
14
+      title: '订单编号',
15
+      dataIndex: 'orderNum',
16
+      key: 'orderNum',
17
+    },
18
+    {
19
+      title: '农机名',
20
+      dataIndex: 'machineryName',
21
+      key: 'machineryName',
22
+    },
23
+    {
24
+      title: '农机型号',
25
+      dataIndex: 'type',
26
+      key: 'type',
27
+    },
28
+    {
29
+      title: '农机数量',
30
+      dataIndex: 'machineryNum',
31
+      key: 'machineryNum',
32
+    },
33
+    {
34
+      title: '需求时间',
35
+      dataIndex: 'appointment_date',
36
+      key: 'appointment_date',
37
+    },
38
+    {
39
+      title: '农机价格',
40
+      dataIndex: 'price',
41
+      key: 'price',
42
+    },
43
+    {
44
+      title: '押金',
45
+      dataIndex: 'deposit',
46
+      key: 'deposit',
47
+    },
48
+    {
49
+      title: '费用',
50
+      dataIndex: 'laborCost',
51
+      key: 'laborCost',
52
+    },
53
+    {
54
+      title: '状态',
55
+      dataIndex: 'state',
56
+      key: 'state',
57
+      valueType: 'select',
58
+      valueEnum: {
59
+        '': { text: '不限', status: 'Default' },
60
+        1: { text: '未付款' },
61
+        2: { text: '已付款' },
62
+        3: { text: '待确认' },
63
+        4: { text: '进行中' },
64
+        5: { text: '待评价' },
65
+        6: { text: '已评价' },
66
+        7: { text: '申请退款' },
67
+        8: { text: '已退款' },
68
+      },
69
+    },
70
+    {
71
+      title: '下单时间',
72
+      dataIndex: 'createDate',
73
+      key: 'createDate',
74
+      search: false,
75
+      render: (t) => formatterTime(t),
76
+      width: 200,
77
+    },
78
+    //操作如果是需求多台机器则需调度 状态为待确认时 状态栏显示调度按钮跳到调度页面
79
+    // 如果是申请退款 则出现处理按钮 显示需求时间 如果未到则退款并且改变已分配农机手状态和农机状态
80
+    // 如果已经服务过了 则可以打电话给农户咨询具体情况看是否退部分款项
81
+  ];
82
+
83
+  return (
84
+    <PageHeaderWrapper>
85
+      <PageTable
86
+        // request={getPersonList}
87
+        // expfunc={exportPersonList}
88
+        columns={columns}
89
+        rowKey="orderId"
90
+        options={false}
91
+        scroll={{ x: 1000 }}
92
+      />
93
+    </PageHeaderWrapper>
94
+  );
95
+};

+ 35
- 24
src/pages/PlatformMessageManagement/MessageManageList/index.jsx 查看文件

5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
 import ProTable from '@ant-design/pro-table';
6
 import ProTable from '@ant-design/pro-table';
7
 
7
 
8
-
9
-
10
 export default (props) => {
8
 export default (props) => {
11
   const dataSource = [
9
   const dataSource = [
12
     {
10
     {
11
+      id: 9,
13
       key: '1',
12
       key: '1',
14
       name: '胡彦斌',
13
       name: '胡彦斌',
15
       age: 32,
14
       age: 32,
16
       address: '西湖区湖底公园1号',
15
       address: '西湖区湖底公园1号',
17
     },
16
     },
18
     {
17
     {
18
+      id: 10,
19
       key: '2',
19
       key: '2',
20
       name: '胡彦祖',
20
       name: '胡彦祖',
21
       age: 42,
21
       age: 42,
24
   ];
24
   ];
25
 
25
 
26
   const actions = () => [
26
   const actions = () => [
27
-    <Button key='add' type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>新增商户</Button>,
28
-  ]
27
+    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>
28
+      新增商户
29
+    </Button>,
30
+  ];
29
   const columns = [
31
   const columns = [
30
     {
32
     {
31
       title: '消息ID',
33
       title: '消息ID',
34
       dataIndex: 'id',
36
       dataIndex: 'id',
35
       search: false,
37
       search: false,
36
 
38
 
37
-      render: (t, record) => <Link key={1} to={`./edit?id=${record.shopId}`}>{record.shopName}</Link>,
38
-
39
+      render: (t, record) => (
40
+        <Link key={1} to={`./edit?id=${record.shopId}`}>
41
+          {record.shopName}
42
+        </Link>
43
+      ),
39
     },
44
     },
40
 
45
 
41
     {
46
     {
42
       title: '消息标题',
47
       title: '消息标题',
43
-      dataIndex: 'packageNum',
44
-      render: (t, record) => <Link key={1} to={`./package?shopId=${record.shopId}`}>{record?.packageNum}</Link>,
48
+      key: 'title',
49
+      dataIndex: 'title',
50
+      render: (t, record) => (
51
+        <Link key={1} to={`./package?shopId=${record.shopId}`}>
52
+          {record?.packageNum}
53
+        </Link>
54
+      ),
45
     },
55
     },
46
 
56
 
47
     {
57
     {
48
       title: '推送对象',
58
       title: '推送对象',
59
+      key: 'pushPerson',
49
       search: false,
60
       search: false,
50
-      dataIndex: 'packageNum',
51
-      render: (t, record) => record.status === 1 ? '农机手' : '农户',
52
-
61
+      dataIndex: 'pushPerson',
62
+      render: (t, record) => (record.pushPerson === 1 ? '农机手' : '农户'),
53
     },
63
     },
54
 
64
 
55
-
56
     {
65
     {
57
       title: '推送方式',
66
       title: '推送方式',
58
       key: 'status',
67
       key: 'status',
61
       formItemProps: { label: '推送方式' },
70
       formItemProps: { label: '推送方式' },
62
       valueType: 'select',
71
       valueType: 'select',
63
       valueEnum: {
72
       valueEnum: {
64
-        0: { text: '通知栏推送', },
65
-        1: { text: 'APP内消息中心推送', },
66
-        2: { text: '短信推送', },
67
-      }
73
+        0: { text: '通知栏推送' },
74
+        1: { text: 'APP内消息中心推送' },
75
+        2: { text: '短信推送' },
76
+      },
68
     },
77
     },
69
 
78
 
70
     {
79
     {
71
       title: (
80
       title: (
72
         <>
81
         <>
73
           创建时间
82
           创建时间
74
-          <Tooltip placement="top" >
83
+          <Tooltip placement="top">
75
             <QuestionCircleOutlined style={{ marginLeft: 4 }} />
84
             <QuestionCircleOutlined style={{ marginLeft: 4 }} />
76
           </Tooltip>
85
           </Tooltip>
77
         </>
86
         </>
78
       ),
87
       ),
79
       width: 140,
88
       width: 140,
80
-      key: 'since',
89
+      key: 'createdAt',
81
       dataIndex: 'createdAt',
90
       dataIndex: 'createdAt',
82
       valueType: 'date',
91
       valueType: 'date',
83
       // render: (t) => formatterTime(t),
92
       // render: (t) => formatterTime(t),
89
       valueType: 'option',
98
       valueType: 'option',
90
       width: '300px',
99
       width: '300px',
91
       render: (_, record) => [
100
       render: (_, record) => [
92
-        <Link key={2} to={`./MessageEdit`}>查看</Link>,
101
+        <Link key={2} to={`./MessageEdit`}>
102
+          查看
103
+        </Link>,
93
         <Popconfirm
104
         <Popconfirm
94
           key={3}
105
           key={3}
95
           title="您是否确认删除 ?"
106
           title="您是否确认删除 ?"
99
         >
110
         >
100
           <a href="#">删除</a>
111
           <a href="#">删除</a>
101
         </Popconfirm>,
112
         </Popconfirm>,
102
-      ]
113
+      ],
103
     },
114
     },
104
-  ]
115
+  ];
105
 
116
 
106
   return (
117
   return (
107
     <PageHeaderWrapper>
118
     <PageHeaderWrapper>
109
         dataSource={dataSource}
120
         dataSource={dataSource}
110
         columns={columns}
121
         columns={columns}
111
         // request={getList}
122
         // request={getList}
112
-        rowKey="shopId"
123
+        rowKey="id"
113
         options={false}
124
         options={false}
114
         toolBarRender={actions}
125
         toolBarRender={actions}
115
         scroll={{ x: 1000 }}
126
         scroll={{ x: 1000 }}
116
       />
127
       />
117
     </PageHeaderWrapper>
128
     </PageHeaderWrapper>
118
-  )
119
-}
129
+  );
130
+};

+ 0
- 196
src/pages/TableList/components/UpdateForm.jsx 查看文件

1
-import React from 'react';
2
-import { Modal } from 'antd';
3
-import {
4
-  ProFormSelect,
5
-  ProFormText,
6
-  ProFormTextArea,
7
-  StepsForm,
8
-  ProFormRadio,
9
-  ProFormDateTimePicker,
10
-} from '@ant-design/pro-form';
11
-import { useIntl, FormattedMessage } from 'umi';
12
-
13
-const UpdateForm = (props) => {
14
-  const intl = useIntl();
15
-  return (
16
-    <StepsForm
17
-      stepsProps={{
18
-        size: 'small',
19
-      }}
20
-      stepsFormRender={(dom, submitter) => {
21
-        return (
22
-          <Modal
23
-            width={640}
24
-            bodyStyle={{
25
-              padding: '32px 40px 48px',
26
-            }}
27
-            destroyOnClose
28
-            title={intl.formatMessage({
29
-              id: 'pages.searchTable.updateForm.ruleConfig',
30
-              defaultMessage: '规则配置',
31
-            })}
32
-            visible={props.updateModalVisible}
33
-            footer={submitter}
34
-            onCancel={() => {
35
-              props.onCancel();
36
-            }}
37
-          >
38
-            {dom}
39
-          </Modal>
40
-        );
41
-      }}
42
-      onFinish={props.onSubmit}
43
-    >
44
-      <StepsForm.StepForm
45
-        initialValues={{
46
-          name: props.values.name,
47
-          desc: props.values.desc,
48
-        }}
49
-        title={intl.formatMessage({
50
-          id: 'pages.searchTable.updateForm.basicConfig',
51
-          defaultMessage: '基本信息',
52
-        })}
53
-      >
54
-        <ProFormText
55
-          name="name"
56
-          label={intl.formatMessage({
57
-            id: 'pages.searchTable.updateForm.ruleName.nameLabel',
58
-            defaultMessage: '规则名称',
59
-          })}
60
-          width="md"
61
-          rules={[
62
-            {
63
-              required: true,
64
-              message: (
65
-                <FormattedMessage
66
-                  id="pages.searchTable.updateForm.ruleName.nameRules"
67
-                  defaultMessage="请输入规则名称!"
68
-                />
69
-              ),
70
-            },
71
-          ]}
72
-        />
73
-        <ProFormTextArea
74
-          name="desc"
75
-          width="md"
76
-          label={intl.formatMessage({
77
-            id: 'pages.searchTable.updateForm.ruleDesc.descLabel',
78
-            defaultMessage: '规则描述',
79
-          })}
80
-          placeholder={intl.formatMessage({
81
-            id: 'pages.searchTable.updateForm.ruleDesc.descPlaceholder',
82
-            defaultMessage: '请输入至少五个字符',
83
-          })}
84
-          rules={[
85
-            {
86
-              required: true,
87
-              message: (
88
-                <FormattedMessage
89
-                  id="pages.searchTable.updateForm.ruleDesc.descRules"
90
-                  defaultMessage="请输入至少五个字符的规则描述!"
91
-                />
92
-              ),
93
-              min: 5,
94
-            },
95
-          ]}
96
-        />
97
-      </StepsForm.StepForm>
98
-      <StepsForm.StepForm
99
-        initialValues={{
100
-          target: '0',
101
-          template: '0',
102
-        }}
103
-        title={intl.formatMessage({
104
-          id: 'pages.searchTable.updateForm.ruleProps.title',
105
-          defaultMessage: '配置规则属性',
106
-        })}
107
-      >
108
-        <ProFormSelect
109
-          name="target"
110
-          width="md"
111
-          label={intl.formatMessage({
112
-            id: 'pages.searchTable.updateForm.object',
113
-            defaultMessage: '监控对象',
114
-          })}
115
-          valueEnum={{
116
-            0: '表一',
117
-            1: '表二',
118
-          }}
119
-        />
120
-        <ProFormSelect
121
-          name="template"
122
-          width="md"
123
-          label={intl.formatMessage({
124
-            id: 'pages.searchTable.updateForm.ruleProps.templateLabel',
125
-            defaultMessage: '规则模板',
126
-          })}
127
-          valueEnum={{
128
-            0: '规则模板一',
129
-            1: '规则模板二',
130
-          }}
131
-        />
132
-        <ProFormRadio.Group
133
-          name="type"
134
-          label={intl.formatMessage({
135
-            id: 'pages.searchTable.updateForm.ruleProps.typeLabel',
136
-            defaultMessage: '规则类型',
137
-          })}
138
-          options={[
139
-            {
140
-              value: '0',
141
-              label: '强',
142
-            },
143
-            {
144
-              value: '1',
145
-              label: '弱',
146
-            },
147
-          ]}
148
-        />
149
-      </StepsForm.StepForm>
150
-      <StepsForm.StepForm
151
-        initialValues={{
152
-          type: '1',
153
-          frequency: 'month',
154
-        }}
155
-        title={intl.formatMessage({
156
-          id: 'pages.searchTable.updateForm.schedulingPeriod.title',
157
-          defaultMessage: '设定调度周期',
158
-        })}
159
-      >
160
-        <ProFormDateTimePicker
161
-          name="time"
162
-          width="md"
163
-          label={intl.formatMessage({
164
-            id: 'pages.searchTable.updateForm.schedulingPeriod.timeLabel',
165
-            defaultMessage: '开始时间',
166
-          })}
167
-          rules={[
168
-            {
169
-              required: true,
170
-              message: (
171
-                <FormattedMessage
172
-                  id="pages.searchTable.updateForm.schedulingPeriod.timeRules"
173
-                  defaultMessage="请选择开始时间!"
174
-                />
175
-              ),
176
-            },
177
-          ]}
178
-        />
179
-        <ProFormSelect
180
-          name="frequency"
181
-          label={intl.formatMessage({
182
-            id: 'pages.searchTable.updateForm.object',
183
-            defaultMessage: '监控对象',
184
-          })}
185
-          width="md"
186
-          valueEnum={{
187
-            month: '月',
188
-            week: '周',
189
-          }}
190
-        />
191
-      </StepsForm.StepForm>
192
-    </StepsForm>
193
-  );
194
-};
195
-
196
-export default UpdateForm;

+ 0
- 403
src/pages/TableList/index.jsx 查看文件

1
-import { PlusOutlined } from '@ant-design/icons';
2
-import { Button, message, Input, Drawer } from 'antd';
3
-import React, { useState, useRef } from 'react';
4
-import { useIntl, FormattedMessage } from 'umi';
5
-import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
6
-import ProTable from '@ant-design/pro-table';
7
-import { ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form';
8
-import ProDescriptions from '@ant-design/pro-descriptions';
9
-import UpdateForm from './components/UpdateForm';
10
-import { rule, addRule, updateRule, removeRule } from '@/services/ant-design-pro/api';
11
-/**
12
- * @en-US Add node
13
- * @zh-CN 添加节点
14
- * @param fields
15
- */
16
-
17
-const handleAdd = async (fields) => {
18
-  const hide = message.loading('正在添加');
19
-
20
-  try {
21
-    await addRule({ ...fields });
22
-    hide();
23
-    message.success('Added successfully');
24
-    return true;
25
-  } catch (error) {
26
-    hide();
27
-    message.error('Adding failed, please try again!');
28
-    return false;
29
-  }
30
-};
31
-/**
32
- * @en-US Update node
33
- * @zh-CN 更新节点
34
- *
35
- * @param fields
36
- */
37
-
38
-const handleUpdate = async (fields) => {
39
-  const hide = message.loading('Configuring');
40
-
41
-  try {
42
-    await updateRule({
43
-      name: fields.name,
44
-      desc: fields.desc,
45
-      key: fields.key,
46
-    });
47
-    hide();
48
-    message.success('Configuration is successful');
49
-    return true;
50
-  } catch (error) {
51
-    hide();
52
-    message.error('Configuration failed, please try again!');
53
-    return false;
54
-  }
55
-};
56
-/**
57
- *  Delete node
58
- * @zh-CN 删除节点
59
- *
60
- * @param selectedRows
61
- */
62
-
63
-const handleRemove = async (selectedRows) => {
64
-  const hide = message.loading('正在删除');
65
-  if (!selectedRows) return true;
66
-
67
-  try {
68
-    await removeRule({
69
-      key: selectedRows.map((row) => row.key),
70
-    });
71
-    hide();
72
-    message.success('Deleted successfully and will refresh soon');
73
-    return true;
74
-  } catch (error) {
75
-    hide();
76
-    message.error('Delete failed, please try again');
77
-    return false;
78
-  }
79
-};
80
-
81
-const TableList = () => {
82
-  /**
83
-   * @en-US Pop-up window of new window
84
-   * @zh-CN 新建窗口的弹窗
85
-   *  */
86
-  const [createModalVisible, handleModalVisible] = useState(false);
87
-  /**
88
-   * @en-US The pop-up window of the distribution update window
89
-   * @zh-CN 分布更新窗口的弹窗
90
-   * */
91
-
92
-  const [updateModalVisible, handleUpdateModalVisible] = useState(false);
93
-  const [showDetail, setShowDetail] = useState(false);
94
-  const actionRef = useRef();
95
-  const [currentRow, setCurrentRow] = useState();
96
-  const [selectedRowsState, setSelectedRows] = useState([]);
97
-  /**
98
-   * @en-US International configuration
99
-   * @zh-CN 国际化配置
100
-   * */
101
-
102
-  const intl = useIntl();
103
-  const columns = [
104
-    {
105
-      title: (
106
-        <FormattedMessage
107
-          id="pages.searchTable.updateForm.ruleName.nameLabel"
108
-          defaultMessage="Rule name"
109
-        />
110
-      ),
111
-      dataIndex: 'name',
112
-      tip: 'The rule name is the unique key',
113
-      render: (dom, entity) => {
114
-        return (
115
-          <a
116
-            onClick={() => {
117
-              setCurrentRow(entity);
118
-              setShowDetail(true);
119
-            }}
120
-          >
121
-            {dom}
122
-          </a>
123
-        );
124
-      },
125
-    },
126
-    {
127
-      title: <FormattedMessage id="pages.searchTable.titleDesc" defaultMessage="Description" />,
128
-      dataIndex: 'desc',
129
-      valueType: 'textarea',
130
-    },
131
-    {
132
-      title: (
133
-        <FormattedMessage
134
-          id="pages.searchTable.titleCallNo"
135
-          defaultMessage="Number of service calls"
136
-        />
137
-      ),
138
-      dataIndex: 'callNo',
139
-      sorter: true,
140
-      hideInForm: true,
141
-      renderText: (val) =>
142
-        `${val}${intl.formatMessage({
143
-          id: 'pages.searchTable.tenThousand',
144
-          defaultMessage: ' 万 ',
145
-        })}`,
146
-    },
147
-    {
148
-      title: <FormattedMessage id="pages.searchTable.titleStatus" defaultMessage="Status" />,
149
-      dataIndex: 'status',
150
-      hideInForm: true,
151
-      valueEnum: {
152
-        0: {
153
-          text: (
154
-            <FormattedMessage
155
-              id="pages.searchTable.nameStatus.default"
156
-              defaultMessage="Shut down"
157
-            />
158
-          ),
159
-          status: 'Default',
160
-        },
161
-        1: {
162
-          text: (
163
-            <FormattedMessage id="pages.searchTable.nameStatus.running" defaultMessage="Running" />
164
-          ),
165
-          status: 'Processing',
166
-        },
167
-        2: {
168
-          text: (
169
-            <FormattedMessage id="pages.searchTable.nameStatus.online" defaultMessage="Online" />
170
-          ),
171
-          status: 'Success',
172
-        },
173
-        3: {
174
-          text: (
175
-            <FormattedMessage
176
-              id="pages.searchTable.nameStatus.abnormal"
177
-              defaultMessage="Abnormal"
178
-            />
179
-          ),
180
-          status: 'Error',
181
-        },
182
-      },
183
-    },
184
-    {
185
-      title: (
186
-        <FormattedMessage
187
-          id="pages.searchTable.titleUpdatedAt"
188
-          defaultMessage="Last scheduled time"
189
-        />
190
-      ),
191
-      sorter: true,
192
-      dataIndex: 'updatedAt',
193
-      valueType: 'dateTime',
194
-      renderFormItem: (item, { defaultRender, ...rest }, form) => {
195
-        const status = form.getFieldValue('status');
196
-
197
-        if (`${status}` === '0') {
198
-          return false;
199
-        }
200
-
201
-        if (`${status}` === '3') {
202
-          return (
203
-            <Input
204
-              {...rest}
205
-              placeholder={intl.formatMessage({
206
-                id: 'pages.searchTable.exception',
207
-                defaultMessage: 'Please enter the reason for the exception!',
208
-              })}
209
-            />
210
-          );
211
-        }
212
-
213
-        return defaultRender(item);
214
-      },
215
-    },
216
-    {
217
-      title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="Operating" />,
218
-      dataIndex: 'option',
219
-      valueType: 'option',
220
-      render: (_, record) => [
221
-        <a
222
-          key="config"
223
-          onClick={() => {
224
-            handleUpdateModalVisible(true);
225
-            setCurrentRow(record);
226
-          }}
227
-        >
228
-          <FormattedMessage id="pages.searchTable.config" defaultMessage="Configuration" />
229
-        </a>,
230
-        <a key="subscribeAlert" href="https://procomponents.ant.design/">
231
-          <FormattedMessage
232
-            id="pages.searchTable.subscribeAlert"
233
-            defaultMessage="Subscribe to alerts"
234
-          />
235
-        </a>,
236
-      ],
237
-    },
238
-  ];
239
-  return (
240
-    <PageContainer>
241
-      <ProTable
242
-        headerTitle={intl.formatMessage({
243
-          id: 'pages.searchTable.title',
244
-          defaultMessage: 'Enquiry form',
245
-        })}
246
-        actionRef={actionRef}
247
-        rowKey="key"
248
-        search={{
249
-          labelWidth: 120,
250
-        }}
251
-        toolBarRender={() => [
252
-          <Button
253
-            type="primary"
254
-            key="primary"
255
-            onClick={() => {
256
-              handleModalVisible(true);
257
-            }}
258
-          >
259
-            <PlusOutlined /> <FormattedMessage id="pages.searchTable.new" defaultMessage="New" />
260
-          </Button>,
261
-        ]}
262
-        request={rule}
263
-        columns={columns}
264
-        rowSelection={{
265
-          onChange: (_, selectedRows) => {
266
-            setSelectedRows(selectedRows);
267
-          },
268
-        }}
269
-      />
270
-      {selectedRowsState?.length > 0 && (
271
-        <FooterToolbar
272
-          extra={
273
-            <div>
274
-              <FormattedMessage id="pages.searchTable.chosen" defaultMessage="Chosen" />{' '}
275
-              <a
276
-                style={{
277
-                  fontWeight: 600,
278
-                }}
279
-              >
280
-                {selectedRowsState.length}
281
-              </a>{' '}
282
-              <FormattedMessage id="pages.searchTable.item" defaultMessage="项" />
283
-              &nbsp;&nbsp;
284
-              <span>
285
-                <FormattedMessage
286
-                  id="pages.searchTable.totalServiceCalls"
287
-                  defaultMessage="Total number of service calls"
288
-                />{' '}
289
-                {selectedRowsState.reduce((pre, item) => pre + item.callNo, 0)}{' '}
290
-                <FormattedMessage id="pages.searchTable.tenThousand" defaultMessage="万" />
291
-              </span>
292
-            </div>
293
-          }
294
-        >
295
-          <Button
296
-            onClick={async () => {
297
-              await handleRemove(selectedRowsState);
298
-              setSelectedRows([]);
299
-              actionRef.current?.reloadAndRest?.();
300
-            }}
301
-          >
302
-            <FormattedMessage
303
-              id="pages.searchTable.batchDeletion"
304
-              defaultMessage="Batch deletion"
305
-            />
306
-          </Button>
307
-          <Button type="primary">
308
-            <FormattedMessage
309
-              id="pages.searchTable.batchApproval"
310
-              defaultMessage="Batch approval"
311
-            />
312
-          </Button>
313
-        </FooterToolbar>
314
-      )}
315
-      <ModalForm
316
-        title={intl.formatMessage({
317
-          id: 'pages.searchTable.createForm.newRule',
318
-          defaultMessage: 'New rule',
319
-        })}
320
-        width="400px"
321
-        visible={createModalVisible}
322
-        onVisibleChange={handleModalVisible}
323
-        onFinish={async (value) => {
324
-          const success = await handleAdd(value);
325
-
326
-          if (success) {
327
-            handleModalVisible(false);
328
-
329
-            if (actionRef.current) {
330
-              actionRef.current.reload();
331
-            }
332
-          }
333
-        }}
334
-      >
335
-        <ProFormText
336
-          rules={[
337
-            {
338
-              required: true,
339
-              message: (
340
-                <FormattedMessage
341
-                  id="pages.searchTable.ruleName"
342
-                  defaultMessage="Rule name is required"
343
-                />
344
-              ),
345
-            },
346
-          ]}
347
-          width="md"
348
-          name="name"
349
-        />
350
-        <ProFormTextArea width="md" name="desc" />
351
-      </ModalForm>
352
-      <UpdateForm
353
-        onSubmit={async (value) => {
354
-          const success = await handleUpdate(value);
355
-
356
-          if (success) {
357
-            handleUpdateModalVisible(false);
358
-            setCurrentRow(undefined);
359
-
360
-            if (actionRef.current) {
361
-              actionRef.current.reload();
362
-            }
363
-          }
364
-        }}
365
-        onCancel={() => {
366
-          handleUpdateModalVisible(false);
367
-
368
-          if (!showDetail) {
369
-            setCurrentRow(undefined);
370
-          }
371
-        }}
372
-        updateModalVisible={updateModalVisible}
373
-        values={currentRow || {}}
374
-      />
375
-
376
-      <Drawer
377
-        width={600}
378
-        visible={showDetail}
379
-        onClose={() => {
380
-          setCurrentRow(undefined);
381
-          setShowDetail(false);
382
-        }}
383
-        closable={false}
384
-      >
385
-        {currentRow?.name && (
386
-          <ProDescriptions
387
-            column={2}
388
-            title={currentRow?.name}
389
-            request={async () => ({
390
-              data: currentRow || {},
391
-            })}
392
-            params={{
393
-              id: currentRow?.name,
394
-            }}
395
-            columns={columns}
396
-          />
397
-        )}
398
-      </Drawer>
399
-    </PageContainer>
400
-  );
401
-};
402
-
403
-export default TableList;

+ 16
- 0
src/utils/download.js 查看文件

1
+export function fetchBlob(url) {
2
+  return window.fetch(url).then((response) => response.blob());
3
+}
4
+
5
+export function downloadBlob(blob, fileName) {
6
+  const url = window.URL.createObjectURL(blob);
7
+  const link = document.createElement('a');
8
+  link.href = url;
9
+  link.setAttribute('download', fileName);
10
+  link.click();
11
+  window.URL.revokeObjectURL(url);
12
+}
13
+
14
+export function downloadUrl(url, fileName) {
15
+  return fetchBlob(url).then((blob) => downloadBlob(blob, fileName));
16
+}

+ 23
- 0
src/utils/hooks/useExport.js 查看文件

1
+import { useState, useCallback } from 'react';
2
+
3
+export default (expFunc) => {
4
+  const [loading, setLoading] = useState(false);
5
+
6
+  const fn = useCallback(
7
+    (...args) => {
8
+      if (typeof expFunc === 'function') {
9
+        setLoading(true);
10
+        expFunc(...args)
11
+          .then(() => {
12
+            setLoading(false);
13
+          })
14
+          .catch(() => {
15
+            setLoading(false);
16
+          });
17
+      }
18
+    },
19
+    [setLoading, expFunc],
20
+  );
21
+
22
+  return [loading, fn];
23
+};

+ 85
- 0
src/utils/request.js 查看文件

1
+import { request } from 'umi';
2
+import { downloadBlob } from './download';
3
+
4
+function requestInterceptor(url, options) {
5
+  const headers = options.headers || {};
6
+  const token = localStorage.getItem('token')
7
+    ? { 'X-Authorization-JWT': localStorage.getItem('token') }
8
+    : {};
9
+  const prefix =
10
+    process.env.NODE_ENV === 'production' ? 'http://sgl-v2.njyunzhi.com/api/admin' : '/api/admin';
11
+
12
+  return {
13
+    url: `${prefix}${url}`,
14
+    options: {
15
+      ...options,
16
+      headers: {
17
+        ...headers,
18
+        ...token,
19
+      },
20
+    },
21
+  };
22
+}
23
+
24
+async function responseInterceptor(response) {
25
+  const contextType = response.headers.get('content-type');
26
+  if (contextType.indexOf('json') > -1) {
27
+    const result = await response.clone().json();
28
+    if (result?.token || result?.data?.token) {
29
+      localStorage.setItem('token', result?.token || result?.data?.token);
30
+    }
31
+
32
+    if (result.code === 1000) {
33
+      return result;
34
+    }
35
+    return Promise.reject(result);
36
+  }
37
+
38
+  if (contextType.indexOf('application/vnd.ms-excel') > -1) {
39
+    const data = await response.clone().blob();
40
+    const content = response.headers.get('content-disposition');
41
+    const fileName = content.replace('attachment;filename=', '');
42
+    downloadBlob(data, decodeURIComponent(fileName));
43
+  }
44
+
45
+  return response;
46
+}
47
+
48
+// https://umijs.org/plugins/plugin-request
49
+export const requestConfig = {
50
+  errorConfig: {
51
+    adaptor: (resData) => {
52
+      return {
53
+        ...resData,
54
+        success: resData.code === 1000,
55
+        errorMessage: resData.message,
56
+        showType: 0, // 静默处理错误
57
+      };
58
+    },
59
+  },
60
+  requestInterceptors: [requestInterceptor],
61
+  responseInterceptors: [responseInterceptor],
62
+};
63
+
64
+export default (...args) => request(...args).then((r) => r.data);
65
+
66
+export function queryTable(apiRequest) {
67
+  return function (params) {
68
+    return apiRequest({
69
+      ...params,
70
+      pageNum: params.current,
71
+    })
72
+      .then((res) => {
73
+        return {
74
+          data: res.records,
75
+          success: true,
76
+          total: res.total,
77
+        };
78
+      })
79
+      .catch((err) => {
80
+        return {
81
+          success: false,
82
+        };
83
+      });
84
+  };
85
+}