傅行帆 5 年前
父节点
当前提交
1a6b08b0fd
共有 6 个文件被更改,包括 421 次插入12 次删除
  1. 1
    1
      config/config.js
  2. 24
    11
      config/routes.js
  3. 176
    0
      src/pages/sample/demand/index.jsx
  4. 22
    0
      src/pages/sample/demand/style.less
  5. 176
    0
      src/pages/sample/h5/index.jsx
  6. 22
    0
      src/pages/sample/h5/style.less

+ 1
- 1
config/config.js 查看文件

133
 
133
 
134
   proxy: {
134
   proxy: {
135
     '/api': {
135
     '/api': {
136
-      target: 'https://dev.pawoma.cn',
136
+      target: 'http://localhost:8080',
137
       changeOrigin: true,
137
       changeOrigin: true,
138
       // pathRewrite: { '^/server': '' },
138
       // pathRewrite: { '^/server': '' },
139
     },
139
     },

+ 24
- 11
config/routes.js 查看文件

21
         routes: [
21
         routes: [
22
           {
22
           {
23
             path: '/',
23
             path: '/',
24
-            redirect: '/welcome',
25
-          },
26
-          {
27
-            path: '/welcome',
28
-            name: '首页',
29
-            component: './Welcome',
24
+            redirect: '/channel',
30
           },
25
           },
26
+          // {
27
+          //   path: '/welcome',
28
+          //   name: '首页',
29
+          //   component: './Welcome',
30
+          // },
31
           {
31
           {
32
             path: '/channel',
32
             path: '/channel',
33
             name: '渠道列表',
33
             name: '渠道列表',
36
           {
36
           {
37
             path: '/channel/edit',
37
             path: '/channel/edit',
38
             name: '渠道列表',
38
             name: '渠道列表',
39
+            hideInMenu: true,
39
             component: './channel/edit',
40
             component: './channel/edit',
40
           },
41
           },
42
+          {
43
+            path: '/sample',
44
+            name: 'H5样例管理',
45
+            component: '../layouts/BlankLayout',
46
+            routes: [
47
+              {
48
+                path: '/sample/h5/list',
49
+                name: 'H5样例',
50
+                component: './sample/h5/index',
51
+              },
52
+              {
53
+                path: '/sample/demand/list',
54
+                name: 'H5需求单',
55
+                component: './sample/demand/index',
56
+              },
57
+            ],
58
+          },
41
           {
59
           {
42
             path: '/resource',
60
             path: '/resource',
43
             name: '资源管理',
61
             name: '资源管理',
44
             component: './resource',
62
             component: './resource',
45
           },
63
           },
46
-          // {
47
-          //   path: '/channel/edit',
48
-          //   name: '渠道列表',
49
-          //   component: './channel/edit',
50
-          // },
51
           {
64
           {
52
             component: './404',
65
             component: './404',
53
           },
66
           },

+ 176
- 0
src/pages/sample/demand/index.jsx 查看文件

1
+import React, { useState, useEffect } from 'react';
2
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
3
+import { Form, Pagination, Card, Button, Icon, Tooltip, message,   notification, Modal, Table } from 'antd';
4
+import router from 'umi/router';
5
+import moment from 'moment';
6
+import className from 'classnames';
7
+import Cell from '../../../components/Cell';
8
+import styles from './style.less';
9
+import { fetch, apis } from '../../../utils/request';
10
+import request from '../../../utils/request';
11
+import AuthButton from '@/components/AuthButton';
12
+
13
+
14
+
15
+function header(props) {
16
+  // 获取初始化数据
17
+  const [ data, setData ] = useState({})
18
+
19
+  useEffect(() => {
20
+    getList({ pageNum: 1, pageSize: 10 });
21
+  },[])
22
+
23
+  // 查询列表
24
+  const getList = (params) => {
25
+    request({ ...apis.channel.list, params: { ...params } }).then((data) => {
26
+        console.log(data)
27
+        setData(data)
28
+    })
29
+  }
30
+
31
+  
32
+  // 提交事件
33
+  const handleSubmit = (e, props) => {
34
+    e.preventDefault();
35
+    props.form.validateFields((err, values) => {
36
+      if (!err) {
37
+        getList({ pageNum: 1, pageSize: 10, ...values })
38
+      }
39
+    });
40
+  }
41
+
42
+  const changePageNum = (pageNumber) => {
43
+    getList({ pageNum: pageNumber, pageSize: 10 })
44
+  }
45
+
46
+
47
+  // 跳转到编辑资讯
48
+  const toEditNews = (id) => () => {
49
+    router.push({
50
+      pathname: '/channel/edit',
51
+      query: {
52
+        id
53
+      },
54
+    });
55
+  }
56
+
57
+  
58
+  const changeNewsStatus = (row, newsId) => () => {
59
+    const title = row.status === 0 ? '确定启用吗': '停用后,此账号将无法登录渠道代理商后台'
60
+    Modal.confirm({
61
+      title: title,
62
+      okText: '确认',
63
+      cancelText: '取消',
64
+      onOk() {
65
+        if(row.status === 0){
66
+          request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 1 } }).then((data) => {
67
+            message.info('操作成功!')
68
+            getList({ pageNum: 1, pageSize: 10 });
69
+          }).catch((err) => {
70
+            console.log(err)
71
+            message.info(err.msg || err.message)
72
+          })
73
+        }else{
74
+          request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 0 } }).then((data) => {
75
+            message.info('操作成功!')
76
+            getList({ pageNum: 1, pageSize: 10 });
77
+          }).catch((err) => {
78
+            console.log(err)
79
+            message.info(err.msg || err.message)
80
+          })
81
+        }
82
+        
83
+      }
84
+    });
85
+  }
86
+  /**
87
+   *
88
+   *
89
+   * @param {*} props
90
+   * @returns
91
+   */
92
+  const columns = [
93
+    {
94
+      title: '渠道代理',
95
+      dataIndex: 'channelProxyName',
96
+      key: 'channelProxyName',
97
+      align: 'center',
98
+    },
99
+    {
100
+      title: '账号名',
101
+      dataIndex: 'userName',
102
+      key: 'userName',
103
+      align: 'center',
104
+      render: (x, row) => <span>{row.userName === null || row.userName === '' ? row.channelTel : row.userName}</span>,
105
+    },
106
+    {
107
+      title: '小程序总数',
108
+      dataIndex: 'appMaxNum',
109
+      key: 'appMaxNum',
110
+      align: 'center',
111
+
112
+    },
113
+    {
114
+      title: '现有小程序',
115
+      dataIndex: 'appCurrentNum',
116
+      key: 'appCurrentNum',
117
+      align: 'center',
118
+      render: (appCurrentNum) => <span>{appCurrentNum === 0 || appCurrentNum == null ? 0 : appCurrentNum}</span>,
119
+    },
120
+    {
121
+      title: '服务到期时间',
122
+      dataIndex: 'expireDate',
123
+      key: 'expireDate',
124
+      align: 'center',
125
+      render: (x, row) => <><span>{`${moment(row.expireDate).format('YYYY-MM-DD')}`}</span></>,
126
+    },
127
+    {
128
+      title: '状态',
129
+      dataIndex: 'status',
130
+      key: 'status',
131
+      align: 'center',
132
+      render: (status) => <span>{status === 1 ? '启动' : '停用'}</span>,
133
+    },
134
+    {
135
+      title: '操作',
136
+      dataIndex: 'handle',
137
+      key: 'handle',
138
+      align: 'center',
139
+      render: (x, row) => (
140
+        <>
141
+          <AuthButton name="admin.taNewsType.id.delete" noRight={null}>
142
+            <span style={{ color: '#EF273A', marginRight: '20px', cursor: 'pointer' }} onClick={changeNewsStatus(row, row.channelId)}>
143
+              {row.status == 1 ? '停用' : '启用'}<Icon type="shopping-cart" className={styles.shoppingCart} />
144
+            </span>
145
+          </AuthButton>
146
+          <AuthButton name="admin.taNewsType.id.put" noRight={null}>
147
+            <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditNews(row.channelId)}>
148
+              编辑<Icon type="form" className={styles.edit} />
149
+            </span>
150
+          </AuthButton>
151
+        </>
152
+      ),
153
+    },
154
+  ];
155
+  function handleReset() {
156
+    props.form.resetFields();
157
+    getList({ pageNum: 1, pageSize: 10 })
158
+  }
159
+
160
+  const { getFieldDecorator } = props.form
161
+  return (
162
+
163
+    <>
164
+      <AuthButton name="admin.taNewsType.post" noRight={null}>
165
+        <Button type="danger" className={styles.addBtn} onClick={toEditNews()}>新增</Button>
166
+      </AuthButton>
167
+      <Table rowKey="newsType" dataSource={data.records} columns={columns} pagination={false} />
168
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
169
+        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
170
+      </div>
171
+    </>
172
+  )
173
+}
174
+const WrappedHeader = Form.create({ name: 'header' })(header);
175
+
176
+export default WrappedHeader

+ 22
- 0
src/pages/sample/demand/style.less 查看文件

1
+.flex-box {
2
+  display: flex;
3
+  flex-wrap: wrap;
4
+
5
+  .flex-item {
6
+    flex: none;
7
+  }
8
+
9
+  .flex-auto {
10
+    flex: auto;
11
+  }
12
+}
13
+
14
+.member {
15
+  margin-bottom: 36px;
16
+  margin-right: 24px;
17
+}
18
+
19
+.square {
20
+  height: 0;
21
+  padding-bottom : 80%;
22
+}

+ 176
- 0
src/pages/sample/h5/index.jsx 查看文件

1
+import React, { useState, useEffect } from 'react';
2
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
3
+import { Form, Pagination, Card, Button, Icon, Tooltip, message,   notification, Modal, Table } from 'antd';
4
+import router from 'umi/router';
5
+import moment from 'moment';
6
+import className from 'classnames';
7
+import Cell from '../../../components/Cell';
8
+import styles from './style.less';
9
+import { fetch, apis } from '../../../utils/request';
10
+import request from '../../../utils/request';
11
+import AuthButton from '@/components/AuthButton';
12
+
13
+
14
+
15
+function header(props) {
16
+  // 获取初始化数据
17
+  const [ data, setData ] = useState({})
18
+
19
+  useEffect(() => {
20
+    getList({ pageNum: 1, pageSize: 10 });
21
+  },[])
22
+
23
+  // 查询列表
24
+  const getList = (params) => {
25
+    request({ ...apis.channel.list, params: { ...params } }).then((data) => {
26
+        console.log(data)
27
+        setData(data)
28
+    })
29
+  }
30
+
31
+  
32
+  // 提交事件
33
+  const handleSubmit = (e, props) => {
34
+    e.preventDefault();
35
+    props.form.validateFields((err, values) => {
36
+      if (!err) {
37
+        getList({ pageNum: 1, pageSize: 10, ...values })
38
+      }
39
+    });
40
+  }
41
+
42
+  const changePageNum = (pageNumber) => {
43
+    getList({ pageNum: pageNumber, pageSize: 10 })
44
+  }
45
+
46
+
47
+  // 跳转到编辑资讯
48
+  const toEditNews = (id) => () => {
49
+    router.push({
50
+      pathname: '/channel/edit',
51
+      query: {
52
+        id
53
+      },
54
+    });
55
+  }
56
+
57
+  
58
+  const changeNewsStatus = (row, newsId) => () => {
59
+    const title = row.status === 0 ? '确定启用吗': '停用后,此账号将无法登录渠道代理商后台'
60
+    Modal.confirm({
61
+      title: title,
62
+      okText: '确认',
63
+      cancelText: '取消',
64
+      onOk() {
65
+        if(row.status === 0){
66
+          request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 1 } }).then((data) => {
67
+            message.info('操作成功!')
68
+            getList({ pageNum: 1, pageSize: 10 });
69
+          }).catch((err) => {
70
+            console.log(err)
71
+            message.info(err.msg || err.message)
72
+          })
73
+        }else{
74
+          request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 0 } }).then((data) => {
75
+            message.info('操作成功!')
76
+            getList({ pageNum: 1, pageSize: 10 });
77
+          }).catch((err) => {
78
+            console.log(err)
79
+            message.info(err.msg || err.message)
80
+          })
81
+        }
82
+        
83
+      }
84
+    });
85
+  }
86
+  /**
87
+   *
88
+   *
89
+   * @param {*} props
90
+   * @returns
91
+   */
92
+  const columns = [
93
+    {
94
+      title: '渠道代理',
95
+      dataIndex: 'channelProxyName',
96
+      key: 'channelProxyName',
97
+      align: 'center',
98
+    },
99
+    {
100
+      title: '账号名',
101
+      dataIndex: 'userName',
102
+      key: 'userName',
103
+      align: 'center',
104
+      render: (x, row) => <span>{row.userName === null || row.userName === '' ? row.channelTel : row.userName}</span>,
105
+    },
106
+    {
107
+      title: '小程序总数',
108
+      dataIndex: 'appMaxNum',
109
+      key: 'appMaxNum',
110
+      align: 'center',
111
+
112
+    },
113
+    {
114
+      title: '现有小程序',
115
+      dataIndex: 'appCurrentNum',
116
+      key: 'appCurrentNum',
117
+      align: 'center',
118
+      render: (appCurrentNum) => <span>{appCurrentNum === 0 || appCurrentNum == null ? 0 : appCurrentNum}</span>,
119
+    },
120
+    {
121
+      title: '服务到期时间',
122
+      dataIndex: 'expireDate',
123
+      key: 'expireDate',
124
+      align: 'center',
125
+      render: (x, row) => <><span>{`${moment(row.expireDate).format('YYYY-MM-DD')}`}</span></>,
126
+    },
127
+    {
128
+      title: '状态',
129
+      dataIndex: 'status',
130
+      key: 'status',
131
+      align: 'center',
132
+      render: (status) => <span>{status === 1 ? '启动' : '停用'}</span>,
133
+    },
134
+    {
135
+      title: '操作',
136
+      dataIndex: 'handle',
137
+      key: 'handle',
138
+      align: 'center',
139
+      render: (x, row) => (
140
+        <>
141
+          <AuthButton name="admin.taNewsType.id.delete" noRight={null}>
142
+            <span style={{ color: '#EF273A', marginRight: '20px', cursor: 'pointer' }} onClick={changeNewsStatus(row, row.channelId)}>
143
+              {row.status == 1 ? '停用' : '启用'}<Icon type="shopping-cart" className={styles.shoppingCart} />
144
+            </span>
145
+          </AuthButton>
146
+          <AuthButton name="admin.taNewsType.id.put" noRight={null}>
147
+            <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditNews(row.channelId)}>
148
+              编辑<Icon type="form" className={styles.edit} />
149
+            </span>
150
+          </AuthButton>
151
+        </>
152
+      ),
153
+    },
154
+  ];
155
+  function handleReset() {
156
+    props.form.resetFields();
157
+    getList({ pageNum: 1, pageSize: 10 })
158
+  }
159
+
160
+  const { getFieldDecorator } = props.form
161
+  return (
162
+
163
+    <>
164
+      <AuthButton name="admin.taNewsType.post" noRight={null}>
165
+        <Button type="danger" className={styles.addBtn} onClick={toEditNews()}>新增</Button>
166
+      </AuthButton>
167
+      <Table rowKey="newsType" dataSource={data.records} columns={columns} pagination={false} />
168
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
169
+        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
170
+      </div>
171
+    </>
172
+  )
173
+}
174
+const WrappedHeader = Form.create({ name: 'header' })(header);
175
+
176
+export default WrappedHeader

+ 22
- 0
src/pages/sample/h5/style.less 查看文件

1
+.flex-box {
2
+  display: flex;
3
+  flex-wrap: wrap;
4
+
5
+  .flex-item {
6
+    flex: none;
7
+  }
8
+
9
+  .flex-auto {
10
+    flex: auto;
11
+  }
12
+}
13
+
14
+.member {
15
+  margin-bottom: 36px;
16
+  margin-right: 24px;
17
+}
18
+
19
+.square {
20
+  height: 0;
21
+  padding-bottom : 80%;
22
+}