Przeglądaj źródła

Merge branch 'master' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager

许静 5 lat temu
rodzic
commit
70a0efda95

+ 1
- 1
config/config.js Wyświetl plik

@@ -264,7 +264,7 @@ export default {
264 264
                 },
265 265
                 {
266 266
                   path: '/activity/SignList',
267
-                  name: '报名列表',
267
+                  name: '',
268 268
                   component: './activity/SignList',
269 269
                 },
270 270
               ],

+ 19
- 9
src/components/XForm/ImageUpload.jsx Wyświetl plik

@@ -1,10 +1,14 @@
1 1
 import React from 'react';
2 2
 import { Upload, Icon, message } from 'antd';
3 3
 import './style.less';
4
+import { uploaderProps } from '../../utils/upload';
5
+
6
+
4 7
 
5 8
 class ImageUpload extends React.Component {
6 9
   state = {
7
-    loading: false
10
+    loading: false,
11
+    imageUrl: undefined,
8 12
   };
9 13
 
10 14
   handleChange = info => {
@@ -14,13 +18,19 @@ class ImageUpload extends React.Component {
14 18
     }
15 19
 
16 20
     if (info.file.status === "done") {
17
-      const imageUrl = info.response.url
18
-
19 21
       this.setState({
20
-        loading: false
22
+        loading: false,
21 23
       })
22 24
 
23
-      this.props.onChange(imageUrl)
25
+      if (info.file.response && info.file.response.url) {
26
+        this.setState({
27
+          imageUrl: info.file.response.thumbUrl,
28
+        });
29
+
30
+        if (typeof this.props.onChange === 'function') {
31
+          this.props.onChange(info.file.response.url);
32
+        }
33
+      }
24 34
     }
25 35
   };
26 36
 
@@ -35,16 +45,16 @@ class ImageUpload extends React.Component {
35 45
 
36 46
     return (
37 47
       <Upload
38
-        name="avatar"
39 48
         listType="picture-card"
40 49
         className="avatar-uploader"
41 50
         showUploadList={false}
42
-        action={this.props.action}
43 51
         beforeUpload={this.props.beforeUpload}
44 52
         onChange={this.handleChange}
53
+
54
+        {...uploaderProps}
45 55
       >
46
-        {value ? (
47
-          <img src={value} alt="avatar" style={{ width: "100%" }} />
56
+        {(this.state.imageUrl || value) ? (
57
+          <img src={this.state.imageUrl || value} alt="avatar" style={{ width: "100%" }} />
48 58
         ) : (
49 59
           uploadButton
50 60
         )}

+ 107
- 26
src/pages/activity/editActivity.jsx Wyświetl plik

@@ -1,10 +1,15 @@
1
-import React, { useState } from 'react';
2
-import { Form, Input, Button, Icon, Select, Tabs, Radio } from 'antd';
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker,message } from 'antd';
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import styles from '../style/GoodsList.less';
5
+import moment from 'moment';
6
+import router from 'umi/router';
7
+import BuildSelect from '../../components/SelectButton/BuildSelect'
5 8
 import XForm, { FieldTypes } from '../../components/XForm';
6 9
 import Wangedit from '../../components/Wangedit/Wangedit'
10
+import request from '../../utils/request'
7 11
 
12
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
8 13
 /**
9 14
  *
10 15
  *
@@ -12,69 +17,145 @@ import Wangedit from '../../components/Wangedit/Wangedit'
12 17
  * @returns
13 18
  */
14 19
  const Edit = (props) => {
15
-  const [ tab, changeTab ] = useState('basic');
20
+  const [ tab, changeTab ] = useState('basic')
16 21
   const dynamicId = props.location.query.dynamicId
17
-  console.log(dynamicId)
22
+  const [ dynamicData, setDynamicData ] = useState({})
23
+  if(dynamicId){
24
+    useEffect(() => {
25
+      getDynamicData(dynamicId);
26
+    },[])
27
+
28
+  // 查询列表
29
+  const getDynamicData = (dynamicId) => {
30
+    request({
31
+        url: '/api/admin/buildingDynamic/Details',
32
+        method: 'GET',
33
+        params: { dynamicId },
34
+    }).then((data) => {
35
+        console.log(data)
36
+        setDynamicData(data)
37
+    })
38
+  }
39
+  }
40
+
41
+  const cancelPage = () =>{
42
+    router.push({
43
+      pathname: '/activity/ActivityList',
44
+    });
45
+  }
18 46
 
19 47
   const Basic = (props) => {
20 48
     const fields = [
21 49
       {
22 50
         label: '所属项目',
23
-        name: 'org_id',
24
-        type: FieldTypes.Text
51
+        name: 'buildingId',
52
+        render: <BuildSelect />,
53
+        value: dynamicData.buildingId,
54
+        rules: [
55
+          {required: true, message: '请选择所属项目'},
56
+        ]
25 57
       },
26 58
       {
27 59
         label: '主图',
28
-        name: 'city_id',
60
+        name: 'imgUrl',
29 61
         type: FieldTypes.ImageUploader,
62
+        value: dynamicData.imgUrl,
30 63
       },
31 64
       {
32 65
         label: '活动标题',
33
-        name: 'share_num',
66
+        name: 'title',
34 67
         type: FieldTypes.Text,
35
-        placeholder: '不填, 默认使用手机号'
68
+        value: dynamicData.title,
69
+        rules: [
70
+          {required: true, message: '请输入活动标题'},
71
+        ]
36 72
       },
37 73
       {
38 74
         label: '活动时间',
39
-        name: 'save_num',
40
-        type: FieldTypes.Text,
75
+        name: 'activityTime',
76
+        type: FieldTypes.RangePicker,
77
+        value: dynamicData.startDate != null ?  [moment(dynamicData.startDate,'YYYY-MM-DD'),moment(dynamicData.endDate,'YYYY-MM-DD')] : null,
41 78
         rules: [
42
-          {required: true, message: '请填写手机号'}
79
+          {required: true, message: '请选择活动时间'},
43 80
         ]
44 81
       },
45 82
       {
46 83
         label: '活动地点',
47
-        name: 'pv_num',
48
-        type: FieldTypes.ImageUploader,
49
-        extra: '建议图片大小 128 * 128'
84
+        name: 'address',
85
+        type: FieldTypes.Text,
86
+        value: dynamicData.address,
87
+        rules: [
88
+          {required: true, message: '请输入活动地点'},
89
+        ]
50 90
       },
51 91
       {
52 92
         label: '活动人数',
53
-        name: 'favor_num',
54
-        type: FieldTypes.DatePicker,
93
+        name: 'enlistNum',
94
+        type: FieldTypes.Text,
95
+        value: dynamicData.enlistNum,
96
+        rules: [
97
+          {required: true, message: '请输入活动人数'},
98
+        ]
55 99
       },
56 100
       {
57 101
         label: '活动详情',
58
-        name: 'expDate',
102
+        name: 'desc',
59 103
         render: <Wangedit />,
60
-        value: "222222",
104
+        value: dynamicData.desc,
61 105
       },
62 106
       {
63 107
         label: '是否需要报名',
64
-        name: 'volume_rate',
65
-        type: FieldTypes.DatePicker,
108
+        name: 'isEnlist',
109
+        render: <Radio.Group name="radiogroup">
110
+                  <Radio value={1}>是</Radio>
111
+                  <Radio value={0}>否</Radio>
112
+                </Radio.Group>,
113
+        value: dynamicData.isEnlist != null ? dynamicData.isEnlist-0 : 1,
66 114
       },
67 115
       {
68 116
         label: '报名时间',
69
-        name: 'parking_rate',
70
-        type: FieldTypes.DatePicker,
117
+        name: 'signupTime',
118
+        type: FieldTypes.RangePicker,
119
+        value: dynamicData.enlistStart != null ?  [moment(dynamicData.enlistStart,'YYYY-MM-DD'),moment(dynamicData.enlistEnd,'YYYY-MM-DD')] : null,
120
+        rules: [
121
+          {required: true, message: '请选择报名时间'},
122
+        ]
71 123
       },
72 124
     ]
73 125
   
74
-    const handleSubmit = val => {
75
-      window.console.log('submit data --->', val)
126
+    const handleSubmit = val => { 
127
+      let {activityTime,signupTime, ...submitValue} = val
128
+      const [startDate, endDate] = activityTime
129
+      submitValue.startDate = moment(startDate).format('YYYY-MM-DD');
130
+      submitValue.endDate = moment(endDate).format('YYYY-MM-DD');
131
+      const [enlistStart, enlistEnd] = signupTime
132
+      submitValue.enlistStart = moment(enlistStart).format('YYYY-MM-DD');
133
+      submitValue.enlistEnd = moment(enlistEnd).format('YYYY-MM-DD');
134
+      console.log('submit data --->', submitValue)
135
+      if(dynamicId){
136
+        submitValue.dynamicId = dynamicId
137
+        request({
138
+          url: '/api/admin/buildingDynamic/update',
139
+          method: 'PUT',
140
+          data: submitValue,
141
+        }).then((data) => {
142
+          cancelPage()
143
+        }).catch((err) => {
144
+          message.info(err.msg || err.message)
145
+        })
146
+      }else{
147
+        request({
148
+          url: '/api/admin/buildingDynamic/add',
149
+          method: 'POST',
150
+          data: submitValue,
151
+        }).then((data) => {
152
+          cancelPage()
153
+        }).catch((err) => {
154
+          message.info(err.msg || err.message)
155
+        })
156
+      }
76 157
     }
77
-    return <XForm onSubmit={handleSubmit} fields={fields}></XForm>
158
+    return <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
78 159
   }
79 160
   
80 161
   const Poster = (props) => {

+ 210
- 0
src/pages/news/list/NewsList.jsx Wyświetl plik

@@ -0,0 +1,210 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert } from 'antd';
3
+import moment from 'moment';
4
+import request from '../../../utils/request';
5
+import apis from '../../../services/apis';
6
+import Styles from './style.less';
7
+
8
+
9
+const { Option } = Select;
10
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
11
+const { Meta } = Card;
12
+
13
+const tempDate = [{ code: 's101' }]
14
+
15
+/**
16
+ *卡片
17
+ *
18
+ * @returns
19
+ */
20
+function CartBody(props) {
21
+  const { data } = props
22
+  console.log(props);
23
+  return (
24
+          <Card
25
+            hoverable
26
+            style={{ minWidth: '400px', borderRadius: '12px', margin: '10px', boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)' }}
27
+            cover={<img alt="example" src={ data.newsImg } style={{ borderRadius: '12px 12px 0 0', width: '100%', height: '14vw' }}></img>}
28
+            bodyStyle={{ padding: '10px 20px' }}
29
+          >
30
+            <p className={Styles.cardText}>
31
+              <span className={Styles.title}>资讯类型</span>
32
+              <span >:{ data.newsType.newsTypeName }</span>
33
+              <span className={Styles.ediText}>
34
+                编辑
35
+                <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
36
+              </span>
37
+            </p>
38
+            <p className={Styles.cardText}>
39
+              <span className={Styles.title}>状态</span>
40
+              <span >:{ data.status == '0' ? "已发布" : "未发布" }</span>
41
+            </p>
42
+            <p className={Styles.cardItem}>
43
+              <span className={Styles.title}>阅读数量</span>
44
+              <span > :{ data.pvNum }</span>
45
+            </p>
46
+            <p className={Styles.cardItem}>
47
+              <span className={Styles.title}>转发数量</span>
48
+              <span className={ Styles.address }>:{ data.shareNum }</span>
49
+            </p>
50
+            <p className={Styles.cardItem}>
51
+              <span className={Styles.title}>点赞数量</span>     
52
+              <span >:{ data.favorNum }</span>         
53
+            </p>
54
+            <p className={Styles.cardItem}>
55
+              <span className={Styles.title}>收藏数量</span>
56
+              <span >:{ data.saveNum }</span>
57
+            </p>
58
+            <p className={Styles.cardItem}>
59
+              <span className={Styles.title}>录入时间</span>
60
+              <span >:{ data.createDate }</span>
61
+            </p>
62
+            <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
63
+              <span style={{ color: '#1990FF' }}>
64
+                取消发布
65
+                <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
66
+              </span>
67
+              <span style={{
68
+                color: '#FF4A4A', position: 'absolute', right: '0',
69
+              }} >
70
+                删除
71
+                <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
72
+              </span>
73
+            </p>
74
+          </Card>
75
+  )
76
+}
77
+
78
+/**
79
+ *
80
+ *
81
+ * @param {*} props
82
+ * @returns
83
+ */
84
+function body(props) {
85
+  const { getFieldDecorator } = props.form
86
+
87
+  // eslint-disable-next-line react-hooks/rules-of-hooks
88
+  const [dataSource, setDataSource] = useState({ records: [] })
89
+
90
+  // eslint-disable-next-line react-hooks/rules-of-hooks
91
+  useEffect(() => {
92
+    getList({ pageNum: 1, pageSize: 6 })
93
+  }, [])
94
+
95
+  function getList(params) {
96
+    // 网路请求
97
+    request({ ...apis.news.getList, params: { ...params } }).then(res => {
98
+      setDataSource(res)
99
+    }).catch(err => {
100
+      // eslint-disable-next-line no-unused-expressions
101
+      <Alert
102
+        style={{
103
+          marginBottom: 24,
104
+        }}
105
+        message={err}
106
+        type="error"
107
+        showIcon
108
+      />
109
+    })
110
+  }
111
+
112
+  // 提交事件
113
+  function handleSubmit(e) {
114
+    e.preventDefault();
115
+    props.form.validateFields((err, values) => {
116
+      if (!err) {
117
+        // eslint-disable-next-line no-console
118
+        console.log('提交数据: ', values)
119
+        const { startDate } = values
120
+        getList({ pageNum: 1, pageSize: 9, ...values })
121
+      }
122
+    });
123
+  }
124
+
125
+  // Change 事件
126
+  function handleSelectChange(e) {
127
+    // eslint-disable-next-line no-console
128
+    console.log(e)
129
+  }
130
+
131
+  // 分页
132
+  function onChange(pageNumber) {
133
+    // eslint-disable-next-line react-hooks/rules-of-hooks
134
+      getList({ pageNum: pageNumber, pageSize: 9 })
135
+  }
136
+
137
+  function getDate(value, dateString) {
138
+    // moment(value).format('YYYY-MM-DD HH:mm:ss')
139
+    console.log(value, dateString)
140
+  }
141
+
142
+  return (
143
+    <>
144
+      <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
145
+
146
+        <Form.Item>
147
+          {getFieldDecorator('city')(
148
+            <Select style={{ width: '180px' }} placeholder="请选择城市" onChange={handleSelectChange}>
149
+            </Select>,
150
+          )}
151
+        </Form.Item>
152
+
153
+        <Form.Item>
154
+          {getFieldDecorator('project')(
155
+            <Select style={{ width: '180px' }} placeholder="请选择项目" onChange={handleSelectChange}>
156
+            </Select>,
157
+          )}
158
+        </Form.Item>
159
+        <Form.Item>
160
+          {getFieldDecorator('title')(
161
+            <Input
162
+              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
163
+              placeholder="请输入标题"
164
+            />,
165
+          )}
166
+        </Form.Item>
167
+        <Form.Item>
168
+          {getFieldDecorator('type')(
169
+            <Select style={{ width: '180px' }} placeholder="咨询类型" onChange={handleSelectChange}>
170
+            </Select>,
171
+          )}
172
+        </Form.Item>       
173
+        <Form.Item>
174
+          {getFieldDecorator('newsStatus')(
175
+            <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
176
+              <Option value="1">已发布</Option>
177
+              <Option value="0">未发布</Option>
178
+            </Select>,
179
+          )}
180
+        </Form.Item>
181
+        <Form.Item>
182
+          <Button type="primary" htmlType="submit" className={Styles.SubmitButton}>
183
+            搜索
184
+          </Button>
185
+        </Form.Item>
186
+      </Form>
187
+      <Button type="primary" className={Styles.addButton}>
188
+        新增
189
+      </Button>
190
+
191
+      {/* 卡片内容,显示楼盘项目  */}
192
+      <Row style={{ padding: ' 0 10px' }}>
193
+        {
194
+          dataSource.records.map((item, index) => (
195
+              <Col span={8}>
196
+                <CartBody data={item} key={item.buildingId}/>
197
+              </Col>
198
+            ))
199
+        }
200
+      </Row>
201
+      {/* 分页 */}
202
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
203
+        <Pagination showQuickJumper defaultCurrent={1} total={dataSource.total} onChange={onChange} />
204
+      </div>
205
+    </>
206
+  );
207
+}
208
+const WrappedBody = Form.create({ name: 'body' })(body);
209
+
210
+export default WrappedBody

+ 58
- 0
src/pages/news/list/style.less Wyświetl plik

@@ -0,0 +1,58 @@
1
+.SubmitButton {
2
+    background: #3a91d5;
3
+    border-radius: 7px;
4
+    border: 0px;
5
+  }
6
+  .SelectFrom {
7
+    width: 180px;
8
+    background: #ffffff;
9
+    border-radius: 7px;
10
+    border: 1px solid #dbdbdb;
11
+  }
12
+  .addButton {
13
+    background: #50be00;
14
+    border-radius: 4px;
15
+    border: 0px;
16
+    margin: 10px 0px;
17
+  }
18
+  .cardText {
19
+    font-size: 18px;
20
+    color: #333;
21
+    line-height: 24px;
22
+    display: flex;
23
+    align-items: center;
24
+    position: relative;
25
+  
26
+  }
27
+  .cardItem{
28
+    font-size: 18px;
29
+    font-weight: 400;
30
+    color: #666;
31
+    line-height: 24px;
32
+    display: flex;
33
+    align-items: center;  
34
+  }
35
+  .ediText {
36
+    font-size: 18px;
37
+    color: #ff925c;
38
+    line-height: 24px;
39
+    position: absolute;
40
+    right: 0;
41
+  }
42
+  .title{
43
+    display: inline-block;
44
+    width: 84px;
45
+    justify-content: space-between;
46
+    text-align: justify;
47
+    text-align-last:justify
48
+  }
49
+  
50
+  .address { 
51
+    width: 400px;
52
+    height: 24px; 
53
+    text-overflow: ellipsis; 
54
+    white-space: nowrap;
55
+    overflow: hidden;
56
+  }
57
+  
58
+  

+ 1
- 1
src/pages/news/type/NewsType.jsx Wyświetl plik

@@ -59,7 +59,7 @@ const columns = [
59 59
     title: '类型图片',
60 60
     dataIndex: 'img',
61 61
     key: 'img',
62
-    align: 'center',
62
+    align: 'left',
63 63
     render: (text, record) => <img src={record.img} className={styles.touxiang} />,
64 64
   },
65 65
   {

+ 12
- 0
src/services/apis.js Wyświetl plik

@@ -1,6 +1,12 @@
1 1
 const prefix = '/api/admin'
2 2
 
3 3
 export default {
4
+  image: {
5
+    upload: {
6
+      url: `${prefix}/antd/image`,
7
+      method: 'POST',
8
+    }
9
+  },
4 10
   user: {
5 11
     current: {
6 12
       method: 'GET',
@@ -39,6 +45,12 @@ export default {
39 45
       url: `${prefix}/tdBuildingType/id`,
40 46
     },
41 47
   },
48
+  news: {
49
+    getList: {
50
+      method: 'GET',
51
+      url: `${prefix}/taNews`,
52
+    },
53
+  },
42 54
   customer: {
43 55
     drift: {
44 56
       method: 'GET',

+ 12
- 0
src/services/news.js Wyświetl plik

@@ -0,0 +1,12 @@
1
+import request from '@/utils/request';
2
+
3
+/**
4
+ * 项目
5
+ */
6
+
7
+/**
8
+ * 获取列表
9
+ */
10
+export async function getList() {
11
+  return request('/api/admin/taNews')
12
+}

+ 11
- 0
src/utils/upload.js Wyświetl plik

@@ -0,0 +1,11 @@
1
+import apis from '../services/apis';
2
+
3
+const uploaderProps = {
4
+  name: 'file',
5
+  action: apis.image.upload.url,
6
+  headers: {
7
+    Authorization: `Bearer ${window.localStorage.getItem('x-token')}`
8
+  }
9
+}
10
+
11
+export { uploaderProps }