Przeglądaj źródła

项目编辑页,还在画

魏熙美 5 lat temu
rodzic
commit
01eb8abaa4

+ 5
- 0
config/config.js Wyświetl plik

@@ -122,6 +122,11 @@ export default {
122 122
                   name: '项目列表',
123 123
                   component: './building/list/index',
124 124
                 },
125
+                {
126
+                  path: '/building/list/add',
127
+                  name: '', // 项目添加
128
+                  component: './building/list/add/index',
129
+                },
125 130
                 {
126 131
                   path: '/building/type',
127 132
                   name: '项目类型',

+ 217
- 0
src/pages/building/list/add/components/base.jsx Wyświetl plik

@@ -0,0 +1,217 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs } 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
+import { router } from 'umi';
8
+import ImageUpload from '../../../../../components/XForm/ImageUpload'
9
+import Wangedit from '../../../../../components/Wangedit/Wangedit'
10
+import TagGroup from './tags'
11
+
12
+const { Option } = Select
13
+const { TabPane } = Tabs;
14
+
15
+const formItemLayout = {
16
+  labelCol: {
17
+    xs: { span: 24 },
18
+    sm: { span: 2 },
19
+  },
20
+  wrapperCol: {
21
+    xs: { span: 24 },
22
+    sm: { span: 16 },
23
+  },
24
+};
25
+
26
+function AddBuilding(props) {
27
+  // eslint-disable-next-line react-hooks/rules-of-hooks
28
+  const [dataSource, setDataSource] = useState({ records: [] })
29
+
30
+  const [buildingAreaTags, setBuildingAreaTags] = useState({ tags: ['Unremovable', 'Tag 2', 'Tag 3'], inputVisible: false, inputValue: '' })
31
+
32
+
33
+  const { getFieldDecorator } = props.form;
34
+
35
+  function handleSubmit(e) {
36
+    e.preventDefault();
37
+    props.form.validateFieldsAndScroll((err, values) => {
38
+      if (!err) {
39
+        console.log('Received values of form: ', values);
40
+      }
41
+    });
42
+  }
43
+
44
+  return (
45
+        <Form {...formItemLayout} onSubmit={handleSubmit}>
46
+          <Form.Item label="楼盘编号">
47
+            {getFieldDecorator('code')(<Input />)}
48
+          </Form.Item>
49
+          <Form.Item label="楼盘名称" hasFeedback>
50
+            {getFieldDecorator('buildingName')(<Input />)}
51
+          </Form.Item>
52
+          <Form.Item label="别名" hasFeedback>
53
+            {getFieldDecorator('name')(<Input />)}
54
+          </Form.Item>
55
+          <Form.Item label="项目类型" hasFeedback>
56
+            {getFieldDecorator('name')(<Input />)}
57
+          </Form.Item>
58
+          <Form.Item label="均价" hasFeedback>
59
+            {getFieldDecorator('price')(<Input />)}
60
+          </Form.Item>
61
+          <Form.Item label="开盘时间" hasFeedback>
62
+            {getFieldDecorator('openingDate')(<DatePicker />)}
63
+          </Form.Item>
64
+          <Form.Item label="电话" hasFeedback>
65
+            {getFieldDecorator('tel')(<Input />)}
66
+          </Form.Item>
67
+          <Form.Item label="项目动态" hasFeedback>
68
+            {getFieldDecorator('dynamic')(<Input />)}
69
+          </Form.Item>
70
+          <Form.Item label="物业类型" hasFeedback>
71
+            {getFieldDecorator('buildingProperty')(
72
+              <Select mode="multiple" placeholder="物业类型" style={{ width: '1016px' }}>
73
+                <Option value="未知">未知</Option>
74
+              </Select>,
75
+            )}
76
+          </Form.Item>
77
+          <Form.Item label="销售状态" hasFeedback>
78
+            {getFieldDecorator('marketStatus')(<Input />)}
79
+          </Form.Item>
80
+          <Form.Item label="标签" hasFeedback>
81
+            {getFieldDecorator('tags')(
82
+              <Select mode="multiple" placeholder="标签" style={{ width: '1016px' }}>
83
+              <Option value="未知">未知</Option>
84
+              </Select>,
85
+            )}
86
+          </Form.Item>
87
+          <Form.Item label="项目主图" hasFeedback>
88
+            {getFieldDecorator('tags')(
89
+              <ImageUpload />,
90
+            )}
91
+          </Form.Item>
92
+          <Form.Item label="地址图片" hasFeedback>
93
+            {getFieldDecorator('tags')(
94
+              <ImageUpload />,
95
+            )}
96
+          </Form.Item>
97
+          <Form.Item label="海报底图" hasFeedback>
98
+            {getFieldDecorator('tags')(
99
+              <ImageUpload />,
100
+            )}
101
+          </Form.Item>
102
+          <Form.Item label="排序" hasFeedback>
103
+            {getFieldDecorator('orderNo')(<Input />)}
104
+          </Form.Item>
105
+          <Form.Item label="优惠信息" hasFeedback>
106
+            {getFieldDecorator('discount')(<Input />)}
107
+          </Form.Item>
108
+          <Form.Item label="首页推荐" hasFeedback>
109
+            {getFieldDecorator('isMain')(
110
+            <Radio.Group>
111
+              <Radio value={1}>是</Radio>
112
+              <Radio value={2}>否</Radio>
113
+            </Radio.Group>,
114
+            )}
115
+          </Form.Item>
116
+          <Form.Item label="所在城市" hasFeedback>
117
+            {getFieldDecorator('cityId')(
118
+              <Select placeholder="选择城市" style={{ width: '200px' }}>
119
+                <Option value="red">Red</Option>
120
+              </Select>,
121
+            )}
122
+          </Form.Item>
123
+          <Form.Item label="楼盘区域" hasFeedback>
124
+            {getFieldDecorator('buildingArea')(<Input />)}
125
+          </Form.Item>
126
+          <Form.Item label="项目地址" hasFeedback>
127
+            {getFieldDecorator('address')(<Input />)}
128
+          </Form.Item>
129
+          <Form.Item label="项目坐标" hasFeedback>
130
+            {getFieldDecorator('coordinate')(<Input disabled />)}
131
+          </Form.Item>
132
+          <Form.Item label="项目地址" hasFeedback>
133
+            {getFieldDecorator('coordinate')(<Input />)}
134
+          </Form.Item>
135
+          <Form.Item label="周边交通" hasFeedback>
136
+            {getFieldDecorator('buildingArea')(
137
+              <TagGroup />,
138
+            )}
139
+          </Form.Item>
140
+          <Form.Item label="周边交通" hasFeedback>
141
+            {getFieldDecorator('buildingMall')(
142
+              <TagGroup />,
143
+            )}
144
+          </Form.Item>
145
+          <Form.Item label="周边学校" hasFeedback>
146
+            {getFieldDecorator('buildingEdu')(
147
+              <TagGroup />,
148
+            )}
149
+          </Form.Item>
150
+          <Form.Item label="周边医院" hasFeedback>
151
+            {getFieldDecorator('buildingHospital')(
152
+              <TagGroup />,
153
+            )}
154
+          </Form.Item>
155
+          <Form.Item label="周边银行" hasFeedback>
156
+            {getFieldDecorator('buildingBank')(
157
+              <TagGroup />,
158
+            )}
159
+          </Form.Item>
160
+          <Form.Item label="周边餐饮" hasFeedback>
161
+            {getFieldDecorator('buildingRestaurant')(
162
+              <TagGroup />,
163
+            )}
164
+          </Form.Item>
165
+          <Form.Item label="绿化率" hasFeedback>
166
+            {getFieldDecorator('greeningRate')(<Input />)}
167
+          </Form.Item>
168
+          <Form.Item label="容积率" hasFeedback>
169
+            {getFieldDecorator('volumeRate')(<Input />)}
170
+          </Form.Item>
171
+          <Form.Item label="车位比" hasFeedback>
172
+            {getFieldDecorator('parkingRate')(<Input />)}
173
+          </Form.Item>
174
+          <Form.Item label="规划户数" hasFeedback>
175
+            {getFieldDecorator('familyNum')(<Input />)}
176
+          </Form.Item>
177
+          <Form.Item label="物业公司" hasFeedback>
178
+            {getFieldDecorator('serviceCompany')(<Input />)}
179
+          </Form.Item>
180
+          <Form.Item label="物业费" hasFeedback>
181
+            {getFieldDecorator('serviceFee')(<Input />)}
182
+          </Form.Item>
183
+          <Form.Item label="装修标准" hasFeedback>
184
+            {getFieldDecorator('decoration')(<Input />)}
185
+          </Form.Item>
186
+          <Form.Item label="交房时间" hasFeedback>
187
+            {getFieldDecorator('receivedDate')(<DatePicker />)}
188
+          </Form.Item>
189
+          <Form.Item label="产权年限" hasFeedback>
190
+            {getFieldDecorator('rightsYear')(<Input />)}
191
+          </Form.Item>
192
+          <Form.Item label="预售许可证" hasFeedback>
193
+            {getFieldDecorator('decoration')(
194
+              <ImageUpload />,
195
+            )}
196
+          </Form.Item>
197
+          <Form.Item label="项目备注" hasFeedback>
198
+            {getFieldDecorator('remark')(
199
+              <Wangedit />,
200
+            )}
201
+          </Form.Item>
202
+          <Form.Item style={{ width: '400px', margin: 'auto', display: 'flex', justifyContent: 'space-between' }}>
203
+            <Button type="primary" htmlType="submit">
204
+                确定
205
+            </Button>
206
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
207
+            <Button onClick={() => router.go(-1)}>
208
+                取消
209
+            </Button>
210
+          </Form.Item>
211
+        </Form>
212
+  )
213
+}
214
+
215
+const WrappedAddBuildingForm = Form.create({ name: 'addBuilding' })(AddBuilding);
216
+
217
+export default WrappedAddBuildingForm

+ 112
- 0
src/pages/building/list/add/components/imageSet.jsx Wyświetl plik

@@ -0,0 +1,112 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, Table, notification } 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
+import { router } from 'umi';
8
+
9
+
10
+const saleType = [
11
+  {
12
+    id: 1,
13
+    name: '待定',
14
+  },
15
+  {
16
+    id: 2,
17
+    name: '售罄',
18
+  },
19
+  {
20
+    id: 3,
21
+    name: '在售',
22
+  },
23
+]
24
+
25
+/**
26
+ *图片设置
27
+ *
28
+ * @param {*} props
29
+ * @returns
30
+ */
31
+function imageSet(props) {
32
+  // eslint-disable-next-line react-hooks/rules-of-hooks
33
+  const [data, setData] = useState([])
34
+
35
+  // eslint-disable-next-line react-hooks/rules-of-hooks
36
+  useEffect(() => {
37
+    getList()
38
+  }, [])
39
+
40
+  function openNotificationWithIcon(type, message) {
41
+    notification[type]({
42
+      message,
43
+      description:
44
+        '',
45
+    });
46
+  }
47
+
48
+  function getList(params) {
49
+    console.log(props)
50
+    // 网路请求
51
+    const { url, method } = apis.building.buildingApartment
52
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(props.building.buildingId)
53
+
54
+    request({ url: tempUrl, method, params: { ...params } }).then(res => {
55
+      setData(res)
56
+    }).catch(err => {
57
+      openNotificationWithIcon('error', err)
58
+    })
59
+  }
60
+
61
+
62
+  const columns = [
63
+    {
64
+      title: '名称',
65
+      dataIndex: 'apartmentName',
66
+      key: 'apartmentName',
67
+    },
68
+    {
69
+      title: '类型',
70
+      dataIndex: 'apartmentType',
71
+      key: 'apartmentType',
72
+      render: (_, record) => <span>{ record.apartmentType === 'apart' ? '户型' : '相册' }</span>,
73
+    },
74
+    {
75
+      title: '销售状态',
76
+      dataIndex: 'marketStatus',
77
+      key: 'marketStatus',
78
+      render: (_, record) => <span>{ (saleType.filter(x => x.id == record.marketStatus)[0] || {}).name }</span>,
79
+    },
80
+    {
81
+      title: '备注',
82
+      dataIndex: 'remark',
83
+      key: 'remark',
84
+    },
85
+    {
86
+      title: '创建时间',
87
+      dataIndex: 'createDate',
88
+      key: 'createDate',
89
+      render: (_, record) => <span>{ moment(record.createDate).format('YYYY-MM-DD') }</span>,
90
+    },
91
+    {
92
+      title: '操作',
93
+      dataIndex: 'apartmentId',
94
+      key: 'apartmentId',
95
+      render: (_, record) => (
96
+        <>
97
+          <Button type="link" style={{ color: 'red' }}>编辑</Button>
98
+          <Button type="link" style={{ color: 'red' }}>删除</Button>
99
+        </>
100
+      ),
101
+    },
102
+  ]
103
+
104
+  return (
105
+    <>
106
+      <Button type="primary">新增图片库</Button>
107
+      <Table dataSource={data} columns={columns} pagination={false} />
108
+    </>
109
+  )
110
+}
111
+
112
+export default imageSet

+ 82
- 0
src/pages/building/list/add/components/tags.jsx Wyświetl plik

@@ -0,0 +1,82 @@
1
+import React from 'react'
2
+import { Tag, Input, Tooltip, Icon } from 'antd';
3
+
4
+class EditableTagGroup extends React.Component {
5
+  state = {
6
+    tags: [],
7
+    inputVisible: false,
8
+    inputValue: '',
9
+  };
10
+
11
+  handleClose = removedTag => {
12
+    const tags = this.state.tags.filter(tag => tag !== removedTag);
13
+    console.log(tags);
14
+    this.setState({ tags });
15
+  };
16
+
17
+  showInput = () => {
18
+    this.setState({ inputVisible: true }, () => this.input.focus());
19
+  };
20
+
21
+  handleInputChange = e => {
22
+    this.setState({ inputValue: e.target.value });
23
+  };
24
+
25
+  handleInputConfirm = () => {
26
+    const { inputValue } = this.state;
27
+    let { tags } = this.state;
28
+    if (inputValue && tags.indexOf(inputValue) === -1) {
29
+      tags = [...tags, inputValue];
30
+    }
31
+    console.log(tags);
32
+    this.setState({
33
+      tags,
34
+      inputVisible: false,
35
+      inputValue: '',
36
+    });
37
+  };
38
+
39
+  saveInputRef = input => (this.input = input);
40
+
41
+  render() {
42
+    const { tags, inputVisible, inputValue } = this.state;
43
+    return (
44
+      <div>
45
+        {tags.map((tag, index) => {
46
+          const isLongTag = tag.length > 20;
47
+          const tagElem = (
48
+            <Tag key={tag} closable={index !== 0} onClose={() => this.handleClose(tag)}>
49
+              {isLongTag ? `${tag.slice(0, 20)}...` : tag}
50
+            </Tag>
51
+          );
52
+          return isLongTag ? (
53
+            <Tooltip title={tag} key={tag}>
54
+              {tagElem}
55
+            </Tooltip>
56
+          ) : (
57
+            tagElem
58
+          );
59
+        })}
60
+        {inputVisible && (
61
+          <Input
62
+            ref={this.saveInputRef}
63
+            type="text"
64
+            size="small"
65
+            style={{ width: 78 }}
66
+            value={inputValue}
67
+            onChange={this.handleInputChange}
68
+            onBlur={this.handleInputConfirm}
69
+            onPressEnter={this.handleInputConfirm}
70
+          />
71
+        )}
72
+        {!inputVisible && (
73
+          <Tag onClick={this.showInput} style={{ background: '#fff', borderStyle: 'dashed' }}>
74
+            <Icon type="plus" /> 新建
75
+          </Tag>
76
+        )}
77
+      </div>
78
+    );
79
+  }
80
+}
81
+
82
+export default EditableTagGroup

+ 67
- 0
src/pages/building/list/add/index.jsx Wyświetl plik

@@ -0,0 +1,67 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs } 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
+import { router } from 'umi';
8
+
9
+
10
+import ImageUpload from '../../../../components/XForm/ImageUpload'
11
+import Wangedit from '../../../../components/Wangedit/Wangedit'
12
+import TagGroup from './components/tags'
13
+import Base from './components/base'
14
+import ImageSet from './components/imageSet'
15
+
16
+
17
+const { Option } = Select
18
+const { TabPane } = Tabs;
19
+
20
+const formItemLayout = {
21
+  labelCol: {
22
+    xs: { span: 24 },
23
+    sm: { span: 2 },
24
+  },
25
+  wrapperCol: {
26
+    xs: { span: 24 },
27
+    sm: { span: 16 },
28
+  },
29
+};
30
+
31
+function AddBuilding(props) {
32
+  // eslint-disable-next-line react-hooks/rules-of-hooks
33
+  const [dataSource, setDataSource] = useState({ records: [] })
34
+
35
+  const [buildingAreaTags, setBuildingAreaTags] = useState({ tags: ['Unremovable', 'Tag 2', 'Tag 3'], inputVisible: false, inputValue: '' })
36
+
37
+
38
+  const { getFieldDecorator } = props.form;
39
+
40
+  function handleSubmit(e) {
41
+    e.preventDefault();
42
+    props.form.validateFieldsAndScroll((err, values) => {
43
+      if (!err) {
44
+        console.log('Received values of form: ', values);
45
+      }
46
+    });
47
+  }
48
+
49
+  function tabsCallback(key) {
50
+    console.log(key);
51
+  }
52
+
53
+  return (
54
+    <Tabs defaultActiveKey="1" onChange={tabsCallback}>
55
+      <TabPane tab="基本信息" key="1">
56
+        <Base />
57
+      </TabPane>
58
+      <TabPane tab="图片" key="2">
59
+        <ImageSet building={{ buildingId: '159fd19bb973b6972c10fbebf07ddeb1' }} />
60
+      </TabPane>
61
+    </Tabs>
62
+  )
63
+}
64
+
65
+const WrappedAddBuildingForm = Form.create({ name: 'addBuilding' })(AddBuilding);
66
+
67
+export default WrappedAddBuildingForm

+ 0
- 0
src/pages/building/list/add/style.less Wyświetl plik


+ 7
- 1
src/pages/building/list/index.jsx Wyświetl plik

@@ -4,6 +4,7 @@ import moment from 'moment';
4 4
 import request from '../../../utils/request';
5 5
 import apis from '../../../services/apis';
6 6
 import Styles from './style.less';
7
+import { router } from 'umi';
7 8
 
8 9
 
9 10
 const { Option } = Select;
@@ -137,6 +138,11 @@ function body(props) {
137 138
     console.log(value, dateString)
138 139
   }
139 140
 
141
+
142
+  function toAdd() {
143
+    router.push({ pathname: '/building/list/add' })
144
+  }
145
+
140 146
   return (
141 147
     <>
142 148
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
@@ -200,7 +206,7 @@ function body(props) {
200 206
           </Button>
201 207
         </Form.Item>
202 208
       </Form>
203
-      <Button type="primary" className={Styles.addButton}>
209
+      <Button type="primary" className={Styles.addButton} onClick={() => toAdd()}>
204 210
         新增楼盘
205 211
       </Button>
206 212
 

+ 11
- 10
src/pages/customer/independentList/index.jsx Wyświetl plik

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar } from 'antd';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Table, Avatar, notification } from 'antd';
3 3
 import moment from 'moment';
4 4
 import request from '../../../utils/request';
5 5
 import apis from '../../../services/apis';
@@ -28,20 +28,21 @@ function body(props) {
28 28
     getList({ pageNumber: 1, pageSize: 10 })
29 29
   }, [])
30 30
 
31
+
32
+  function openNotificationWithIcon(type, message) {
33
+    notification[type]({
34
+      message,
35
+      description:
36
+        '',
37
+    });
38
+  }
39
+
31 40
   function getList(params) {
32 41
     // 网路请求
33 42
     request({ ...apis.customer.agents, params: { ...params } }).then(res => {
34 43
       setDataSource(res)
35 44
     }).catch(err => {
36
-      // eslint-disable-next-line no-unused-expressions
37
-      <Alert
38
-        style={{
39
-          marginBottom: 24,
40
-        }}
41
-        message={err}
42
-        type="error"
43
-        showIcon
44
-      />
45
+      openNotificationWithIcon('error', err)
45 46
     })
46 47
   }
47 48
 

+ 1
- 1
src/pages/customer/recommendCustomer/index.jsx Wyświetl plik

@@ -115,7 +115,7 @@ function body(props) {
115 115
       title: '推荐时间',
116 116
       dataIndex: 'createDate',
117 117
       key: 'createDate',
118
-      render: (_, record) => <><sapn>{ moment(record.createDate).format('YYYY-MM-DD') }</sapn></>,
118
+      render: (_, record) => <><sapn>{ record.createDate && moment(record.createDate).format('YYYY-MM-DD') }</sapn></>,
119 119
     },
120 120
     {
121 121
       title: '状态',

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

@@ -22,6 +22,10 @@ export default {
22 22
       method: 'GET',
23 23
       url: `${prefix}/buildinglist`,
24 24
     },
25
+    buildingApartment: {
26
+      method: 'GET',
27
+      url: `${prefix}/buildingApartment/buildingId/id`,
28
+    },
25 29
   },
26 30
   buildingType: {
27 31
     getList: {