傅行帆 před 5 roky
rodič
revize
2c62a4f9ae

+ 5
- 0
config/config.js Zobrazit soubor

@@ -215,6 +215,11 @@ export default {
215 215
                   name: '',
216 216
                   component: './activity/editActivity',
217 217
                 },
218
+                {
219
+                  path: '/activity/SignList',
220
+                  name: '报名列表',
221
+                  component: './activity/SignList',
222
+                },
218 223
               ],
219 224
             },
220 225
             {

+ 40
- 0
src/components/SelectButton/CitySelect.jsx Zobrazit soubor

@@ -0,0 +1,40 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Select } from 'antd';
3
+
4
+import request from '../../utils/request'
5
+
6
+const { Option } = Select;
7
+
8
+/**
9
+ *
10
+ *
11
+ * @param {*} props
12
+ * @returns
13
+ */
14
+const CitySelect = (props) => {
15
+  const [ data, setData ] = useState([])
16
+
17
+  useEffect(() => {
18
+    getCityList();
19
+  },[])
20
+
21
+  const getCityList = (e) => {
22
+    request({
23
+        url: '/api/admin/buildinglist/select',
24
+        method: 'GET',
25
+        params: {pageNum: 1,pageSize: 999},
26
+    }).then((data) => {
27
+        setData(data.records)
28
+    })
29
+  }
30
+
31
+  return (
32
+      <Select value={props.value} style={{ width: '180px' }} placeholder="请选择城市" onChange={props.onChange}>
33
+          {data.map(city => (
34
+            <Option key={city.buildingId}>{city.buildingName}</Option>
35
+          ))}
36
+      </Select>
37
+  )
38
+}
39
+export default CitySelect
40
+

+ 116
- 50
src/pages/activity/ActivityList.jsx Zobrazit soubor

@@ -3,6 +3,8 @@ import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagina
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import styles from '../style/GoodsList.less';
5 5
 import router from 'umi/router';
6
+import moment from 'moment';
7
+import SelectCity from '../../components/SelectButton/CitySelect'
6 8
 
7 9
 import request from '../../utils/request'
8 10
 
@@ -52,84 +54,155 @@ const columns = [
52 54
   },
53 55
   {
54 56
     title: '活动时间',
55
-    dataIndex: 'name',
56
-    key: 'name',
57
+    dataIndex: 'startDate',
58
+    key: 'startDate',
57 59
     align: 'center',
60
+    render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>
58 61
   },
59 62
   {
60 63
     title: '已参加人数',
61
-    dataIndex: 'integral',
62
-    key: 'integral',
64
+    dataIndex: 'count',
65
+    key: 'count',
63 66
     align: 'center',
64 67
   },
65 68
   {
66 69
     title: '阅读量',
67
-    dataIndex: 'total',
68
-    key: 'total',
70
+    dataIndex: 'pvNum',
71
+    key: 'pvNum',
69 72
     align: 'center',
70 73
   },
71 74
   {
72 75
     title: '转发量',
73
-    dataIndex: 'exchanged',
74
-    key: 'exchanged',
76
+    dataIndex: 'shareNum',
77
+    key: 'shareNum',
75 78
     align: 'center',
76 79
   },
77 80
   {
78 81
     title: '收藏数',
79
-    dataIndex: 'rest',
80
-    key: 'rest',
82
+    dataIndex: 'saveNum',
83
+    key: 'saveNum',
81 84
     align: 'center',
82 85
   },
83 86
   {
84 87
     title: '状态',
85
-    dataIndex: 'state',
86
-    key: 'state',
88
+    dataIndex: 'isEnlist',
89
+    key: 'isEnlist',
87 90
     align: 'center',
91
+    render: (isEnlist)=> <><span>{isEnlist == 0 ?"未开始" : isEnlist==1 ? "进行中" : "已结束"}</span></>
88 92
   },
89 93
   {
90 94
     title: '操作',
91 95
     dataIndex: 'handle',
92 96
     key: 'handle',
93 97
     align: 'center',
94
-    render: () => <><span style={{ color: '#1990FF', marginRight: '20px' }} onClick={confirm}>下架<Icon type="shopping-cart" className={styles.shoppingCart} /></span><span style={{ color: '#FF925C' }}>编辑<Icon type="form" className={styles.edit} /></span></>,
98
+    render: (x,row) => <><span style={{ color: '#1990FF'}} onClick={getSignList.bind(this, row.dynamicId)}>{row.isEnlist == '1' || row.isEnlist == '2' ? "报名记录" : ""}<Icon type="snippets" className={styles.shoppingCart} /></span>
99
+                         <span style={{ color: '#1990FF' }} onClick={sendOrPublicDynamic.bind(this,row)}>{ row.status === 1 ? '取消发布' : '发布' }<Icon type="close-circle" className={styles.edit} /></span>
100
+                         <span style={{ color: '#1990FF' }} onClick={finishDynamic.bind(this,row)}>结束活动<Icon type="poweroff" className={styles.edit} /></span>
101
+                         <span style={{ color: '#1990FF', marginRight: '20px' }} onClick={topDynamic.bind(this,row)}>{ row.weight === 1 ? '取消置顶' : '置顶' }<Icon type="vertical-align-top" className={styles.edit} /></span>
102
+                         <span style={{ color: '#FF925C' }}>编辑<Icon type="form" className={styles.edit} /></span>
103
+                       </>
95 104
   },
96 105
 ];
97
-const confirm = () => {
98
-  Modal.confirm({
99
-    title: '确认下架该商品?',
100
-    okText: '确认',
101
-    cancelText: '取消',
102
-    onOk() {
103
-      console.log('OK');
104
-    },
105
-    onCancel() {
106
-      console.log('Cancel');
107
-    },
108
-  });
109 106
 
107
+const getSignList = (dynamicId) => {
108
+    router.push({
109
+        pathname: '/activity/SignList',
110
+        query: {
111
+            dynamicId
112
+        },
113
+      });
110 114
 }
111 115
 
112
-const header = (props) => {
113
-  const [ data, setData ] = useState({})
114
-//   const [page, changePage] = useState({})
116
+const finishDynamic = (row) => {
117
+    Modal.confirm({
118
+        title: '结束以后将无法编辑, 是否继续?',
119
+        okText: '确定',
120
+        cancelText: '取消',
121
+        onOk() {
122
+            request({
123
+                url: '/api/admin/buildingDynamic/finish',
124
+                method: 'PUT',
125
+                data: {dynamicId: row.dynamicId, top: ""},
126
+            }).then((data) => {
127
+                console.log(data)
128
+                message.info('操作成功!')
129
+                // getList()
130
+            }).catch((err) => {
131
+                console.log(err)
132
+                message.info(err.msg || err.message)
133
+            })
134
+        },
135
+      });
136
+}
115 137
 
116
-  useEffect(() => {
138
+const topDynamic = (row) => {
139
+    const weight = Math.abs(row.weight - 1)
117 140
     request({
118
-        url: '/api/admin/iBuildingDynamicList',
119
-        method: 'GET',
120
-        params: {pageNum: 1,pageSize: 10},
141
+        url: '/api/admin/buildingDynamic/weight',
142
+        method: 'PUT',
143
+        params: {dynamicId: row.dynamicId, weight},
121 144
     }).then((data) => {
122 145
         console.log(data)
123
-        setData(data)
146
+        message.info('操作成功!')
147
+        // getList()
148
+    }).catch((err) => {
149
+        console.log(err)
150
+        message.info(err.msg || err.message)
151
+    })
152
+}
153
+
154
+const sendOrPublicDynamic = (row) => {
155
+    if (row.status === 1) {
156
+        cancelDynamic(row)
157
+    } else {
158
+        sendDynamic(row)
159
+    }
160
+}
161
+
162
+// 取消活动
163
+const cancelDynamic = (row) => {
164
+    request({
165
+        url: '/api/admin/buildingDynamic/cancel/'+row.dynamicId,
166
+        method: 'PUT',
167
+    }).then((data) => {
168
+        message.info('操作成功!')
169
+        // getList()
170
+    }).catch((err) => {
171
+        console.log(err)
172
+        message.info(err.msg || err.message)
173
+    })
174
+}
175
+
176
+//发布活动
177
+const sendDynamic = (row) => {
178
+    request({
179
+        url: '/api/admin/buildingDynamic/send/'+row.dynamicId,
180
+        method: 'PUT',
181
+    }).then((data) => {
182
+        message.info('操作成功!')
183
+        // getList()
184
+    }).catch((err) => {
185
+        console.log(err)
186
+        message.info(err.msg || err.message)
124 187
     })
188
+}
189
+
190
+const header = (props) => {
191
+  const [ data, setData ] = useState({})
192
+//   const [page, changePage] = useState({})
193
+
194
+  useEffect(() => {
195
+    getList();
125 196
   },[])
126 197
 
198
+  // 查询列表
127 199
   const getList = (e) => {
128 200
     request({
129
-        url: '/api/xxx',
201
+        url: '/api/admin/iBuildingDynamicList',
130 202
         method: 'GET',
131
-        params: {},
203
+        params: {pageNum: 1,pageSize: 10},
132 204
     }).then((data) => {
205
+        console.log(data)
133 206
         setData(data)
134 207
     })
135 208
   }
@@ -141,10 +214,7 @@ const header = (props) => {
141 214
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
142 215
         <Form.Item>
143 216
           {getFieldDecorator('goodState')(
144
-            <Select style={{ width: '180px' }} placeholder="请选择城市" onChange={handleSelectChange}>
145
-              <Option value="1">上架</Option>
146
-              <Option value="0">下架</Option>
147
-            </Select>,
217
+            <SelectCity />,
148 218
           )}
149 219
         </Form.Item>
150 220
         <Form.Item>
@@ -164,16 +234,16 @@ const header = (props) => {
164 234
           )}
165 235
         </Form.Item>
166 236
         <Form.Item>
167
-          {getFieldDecorator('goodState')(
168
-            <Select style={{ width: '180px' }} placeholder="是否报名" onChange={handleSelectChange}>
169
-              <Option value="1">上架</Option>
170
-              <Option value="0">下架</Option>
171
-            </Select>,
237
+          {getFieldDecorator('min')(
238
+            <DatePicker />
172 239
           )}
173 240
         </Form.Item>
174 241
         <Form.Item>
175
-          {getFieldDecorator('min')(
176
-            <DatePicker />
242
+          {getFieldDecorator('goodState')(
243
+            <Select style={{ width: '180px' }} placeholder="是否报名" onChange={handleSelectChange}>
244
+              <Option value="1">已报名</Option>
245
+              <Option value="0">未报名</Option>
246
+            </Select>,
177 247
           )}
178 248
         </Form.Item>
179 249
         <Form.Item>
@@ -184,10 +254,6 @@ const header = (props) => {
184 254
       </Form>
185 255
       <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
186 256
       <Table dataSource={data.list} columns={columns} />
187
-      {/* 分页 */
188
-      /* <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
189
-        <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={onChange} />
190
-      </div> */}
191 257
     </>
192 258
   )
193 259
 }

+ 80
- 0
src/pages/activity/SignList.jsx Zobrazit soubor

@@ -0,0 +1,80 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal, DatePicker } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import styles from '../style/GoodsList.less';
5
+import router from 'umi/router';
6
+import moment from 'moment';
7
+
8
+import request from '../../utils/request'
9
+
10
+const { Option } = Select;
11
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
12
+
13
+
14
+
15
+// 分页
16
+function onChange(pageNumber) {
17
+  console.log('Page: ', pageNumber);
18
+}
19
+
20
+
21
+/**
22
+ *
23
+ *
24
+ * @param {*} props
25
+ * @returns
26
+ */
27
+
28
+const columns = [
29
+  {
30
+    title: '活动标题',
31
+    dataIndex: 'title',
32
+    key: 'title',
33
+    align: 'center',
34
+  },
35
+  {
36
+    title: '活动时间',
37
+    dataIndex: 'startDate',
38
+    key: 'startDate',
39
+    align: 'center',
40
+    render: (x, row) => <><span>{`${moment(row.startDate).format('YYYY-MM-DD')} —— ${moment(row.endDate).format('YYYY-MM-DD')}`}</span></>
41
+  },
42
+  {
43
+    title: '已参加人数',
44
+    dataIndex: 'count',
45
+    key: 'count',
46
+    align: 'center',
47
+  }
48
+];
49
+
50
+
51
+
52
+const header = (props) => {
53
+  const [ data, setData ] = useState({})
54
+//   const [page, changePage] = useState({})
55
+  useEffect(() => {
56
+    getSignList();
57
+  },[])
58
+
59
+  // 查询列表
60
+  const getSignList = (e) => {
61
+    request({
62
+        url: '/api/admin/SignList',
63
+        method: 'GET',
64
+        params: {pageNum: 1,pageSize: 10, dynamicId: props.location.query.dynamicId },
65
+    }).then((data) => {
66
+        console.log(data)
67
+        setData(data)
68
+    })
69
+  }
70
+
71
+  return (
72
+    <>
73
+      <Button type="primary" className={styles.addBtn}>返回</Button>
74
+      <Table dataSource={data} columns={columns} />
75
+    </>
76
+  )
77
+}
78
+const WrappedHeader = Form.create({ name: 'header' })(header);
79
+
80
+export default WrappedHeader

+ 1
- 1
src/utils/request.js Zobrazit soubor

@@ -78,7 +78,7 @@ request.interceptors.response.use(async (response, options) => {
78 78
         throw new Error(message);
79 79
       }
80 80
 
81
-      if (data.token) {
81
+      if (data && data.token) {
82 82
         window.localStorage.setItem('x-token', data.token)
83 83
       }
84 84