瀏覽代碼

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

# Conflicts:
#	src/pages/house/edit/index.jsx
weichaochao 5 年之前
父節點
當前提交
8340395bd0

+ 64
- 0
src/components/HouseSelect/BlockSelect.jsx 查看文件

1
+import React, { useState, useEffect, useRef } from 'react';
2
+import { Select } from 'antd';
3
+import apis from '../../services/apis';
4
+import request from '../../utils/request'
5
+
6
+const { Option } = Select;
7
+
8
+function usePrevious(props) {
9
+  const ref = useRef();
10
+  useEffect(() => {
11
+    ref.current = props;
12
+  });
13
+  return ref.current;
14
+}
15
+
16
+/**
17
+ *
18
+ *
19
+ * @param {*} props
20
+ * @returns
21
+ */
22
+const BuildingSelect = props => {
23
+  const [data, setData] = useState([])
24
+  const [value, setValue] = useState([])
25
+  useEffect(() => {
26
+    getBuildList();
27
+  }, [props.value])
28
+
29
+
30
+  const getBuildList = e => {
31
+    request({ ...apis.building.buildingSelect, params: { pageNum: 1, pageSize: 999 } }).then(data => {
32
+        setData(data.records)
33
+        checkValue(data.records)
34
+        // 默认选中第一个
35
+    })
36
+  }
37
+
38
+
39
+  const checkValue = (data) => {
40
+    if (props.value) {
41
+      const tempData = data.filter(f => f.buildingId == props.value)
42
+      const va = (tempData.length > 0) ? props.value : '项目已下线,请重新选择项目'
43
+      props.onChange(va)
44
+
45
+    }
46
+  }
47
+
48
+  return (
49
+      <Select
50
+      showSearch
51
+      value={props.value}
52
+      style={{ width: '300px' }}
53
+      placeholder="请选择项目"
54
+      onChange={props.onChange}
55
+      filterOption={(input, option) =>
56
+        option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
57
+      }>
58
+          {data.map(building => (
59
+            <Option key={building.buildingId} value={building.buildingId}>{building.buildingName}</Option>
60
+          ))}
61
+      </Select>
62
+  )
63
+}
64
+export default BuildingSelect

+ 196
- 9
src/pages/house/edit/components/house.jsx 查看文件

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload } from 'antd';
3
-import { FormattedMessage } from 'umi-plugin-react/locale';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, Table, notification, Modal } from 'antd';
4
 import moment from 'moment';
3
 import moment from 'moment';
5
-import router from 'umi/router';
4
+import request from '../../../../utils/request';
6
 import apis from '../../../../services/apis';
5
 import apis from '../../../../services/apis';
6
+import Styles from './style.less';
7
+import { router } from 'umi';
7
 
8
 
8
-const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
9
-const { TextArea } = Input;
9
+/**
10
+ *图片设置
11
+ *
12
+ * @param {*} props
13
+ * @returns
14
+ */
15
+function House(props) {
16
+  // eslint-disable-next-line react-hooks/rules-of-hooks
17
+  const [data, setData] = useState([])
10
 
18
 
11
-const House = props => {
12
-  return <div><span>房源信息</span></div>
13
-}
19
+  useEffect(() => {
20
+    getList()
21
+  }, [])
22
+
23
+  function openNotificationWithIcon(type, message) {
24
+    notification[type]({
25
+      message,
26
+      description:
27
+        '',
28
+    });
29
+  }
30
+
31
+  function getList(params) {
32
+    // 网路请求
33
+    request({ ...apis.house.taHousingResources, params: { ...params,salesBatchId: props.salesBatchId,buildingId: props.buildingId } }).then(res => {
34
+      console.log(res,"resresres")
35
+      setData(res)
36
+    }).catch(err => {
37
+      openNotificationWithIcon('error', err.message)
38
+    })
39
+  }
40
+
41
+    // 重置搜索
42
+    function handleReset () {
43
+      props.form.resetFields();
44
+      getList({ pageNumber: 1, pageSize: 10 })
45
+    }
46
+
47
+      // 分页
48
+  function changePageNum(pageNumber) {
49
+    // eslint-disable-next-line react-hooks/rules-of-hooks
50
+    getList({ pageNumber: pageNumber, pageSize: 10})
51
+  }
14
 
52
 
15
-export default House
53
+  const rowSelection = {
54
+    onChange: (selectedRowKeys, selectedRows) => {
55
+      console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
56
+    },
57
+  };
58
+
59
+  function showEdi() {
60
+    window.location.href = "/house/add";
61
+  }
62
+
63
+  /**
64
+   * 删除
65
+   *
66
+   * @param {*} record
67
+   */
68
+  function deleteApartment(record) {
69
+    confirm({
70
+      title: '确认删除当前数据?',
71
+      content: '确定后成功删除,点击取消则放弃当前操作',
72
+      okText: '确定',
73
+      cancelText: '取消',
74
+      onOk() {
75
+        // 网路请求
76
+        request({ ...apis.building.buildingApartmentDelete, urlData: { id: record.apartmentId } }).then(res => {
77
+          getList()
78
+          openNotificationWithIcon('success', '操作成功')
79
+        }).catch(err => {
80
+          // openNotificationWithIcon('error', err.message)
81
+        })
82
+      },
83
+      onCancel() {},
84
+    });
85
+  }
86
+
87
+
88
+  const columns = [
89
+    {
90
+      title: '房源编号',
91
+      dataIndex: 'houseId',
92
+      key: 'houseId',
93
+    },
94
+    {
95
+      title: '楼栋',
96
+      dataIndex: 'blockName',
97
+      key: 'blockName',
98
+    },
99
+    {
100
+      title: '单元',
101
+      dataIndex: 'unitName',
102
+      key: 'unitName',
103
+    },
104
+    {
105
+      title: '层',
106
+      dataIndex: 'floorName',
107
+      key: 'floorName',
108
+    },
109
+    {
110
+      title: '房号',
111
+      dataIndex: 'roomName',
112
+      key: 'roomName',
113
+    },
114
+    {
115
+      title: '价格(万元)',
116
+      dataIndex: 'price',
117
+      key: 'price',
118
+    },
119
+    {
120
+      title: '对应户型',
121
+      dataIndex: 'apartmentName',
122
+      key: 'apartmentName',
123
+    },
124
+    {
125
+      title: '预选基础热度',
126
+      dataIndex: 'heat',
127
+      key: 'heat',
128
+    },
129
+    {
130
+      title: '预选实际热度',
131
+      dataIndex: 'realHeat',
132
+      key: 'realHeat',
133
+    },
134
+    {
135
+      title: '发布状态',
136
+      dataIndex: 'status',
137
+      key: 'status',
138
+    },
139
+    {
140
+      title: '最后修改人',
141
+      dataIndex: 'updateName',
142
+      key: 'updateName',
143
+    },
144
+    {
145
+      title: '操作',
146
+      dataIndex: 'apartmentId',
147
+      key: 'apartmentId',
148
+      render: (_, record) => (
149
+        <>
150
+          <Button type="link" style={{ color: 'red' }} onClick={() => showEdi(record)}>编辑</Button>
151
+          <Button type="link" style={{ color: 'red' }} onClick={() => deleteApartment(record)}>删除</Button>
152
+        </>
153
+      ),
154
+    },
155
+  ]
156
+  const { getFieldDecorator } = props.form
157
+  return (
158
+    <>
159
+    <Form layout="inline" onSubmit={e => handleSubmit(e)}>
160
+        <Form.Item>
161
+          {getFieldDecorator('cityId')(
162
+            <Input
163
+            prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
164
+            placeholder="请输入标题"
165
+          />,
166
+          )}
167
+        </Form.Item>
168
+        <Form.Item>
169
+          {getFieldDecorator('buildingId')(
170
+            <Input
171
+            prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
172
+            placeholder="请输入标题"
173
+          />,
174
+          )}
175
+        </Form.Item>
176
+        <Form.Item>
177
+          {getFieldDecorator('title')(
178
+            <Input
179
+              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
180
+              placeholder="请输入标题"
181
+            />,
182
+          )}
183
+        </Form.Item>
184
+        <Form.Item>
185
+          <Button type="primary" htmlType="submit" >
186
+            搜索
187
+          </Button>
188
+          <Button style={{ marginLeft: 8 }} onClick={handleReset}>
189
+            重置
190
+            </Button>
191
+        </Form.Item>
192
+      </Form>
193
+      <Button type="primary" onClick={() => showEdi()}>新增房源</Button>
194
+      <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量导入房源</Button>
195
+      <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量修改对应户型</Button>
196
+      <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>
197
+      <Table rowSelection={rowSelection} dataSource={data.records} columns={columns} pagination={{ total: data.total, onChange: e => this.changePageNum(e) }} rowKey="House" />
198
+    </>
199
+  )
200
+}
201
+const WrappedHeader = Form.create({ name: 'House' })(House);
202
+export default WrappedHeader

+ 47
- 0
src/pages/house/edit/components/houseTab.jsx 查看文件

1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, notification } from 'antd';
3
+import moment from 'moment';
4
+import request from '../../../../utils/request';
5
+import apis from '../../../../services/apis';
6
+import { router } from 'umi';
7
+
8
+import House from './house'
9
+
10
+const { Option } = Select
11
+const { TabPane } = Tabs;
12
+
13
+const formItemLayout = {
14
+  labelCol: {
15
+    xs: { span: 24 },
16
+    sm: { span: 2 },
17
+  },
18
+  wrapperCol: {
19
+    xs: { span: 24 },
20
+    sm: { span: 16 },
21
+  },
22
+};
23
+
24
+function openNotificationWithIcon(type, message) {
25
+  notification[type]({
26
+    message,
27
+    description:
28
+      '',
29
+  });
30
+}
31
+
32
+function EditHouse(props) {
33
+
34
+  const [tab, setTab] = useState('house')
35
+
36
+  return (
37
+    <>
38
+      <div style={{ marginTop: '20px' }}>
39
+        { (tab === 'house' && <House salesBatchId="1" buildingId="1" />)} 
40
+      </div>
41
+    </>
42
+  )
43
+}
44
+
45
+const WrappedEditHouseForm = Form.create({ name: 'editHouse' })(EditHouse);
46
+
47
+export default WrappedEditHouseForm

+ 4
- 2
src/pages/house/edit/index.jsx 查看文件

6
 import { router } from 'umi';
6
 import { router } from 'umi';
7
 
7
 
8
 import Base from './components/base'
8
 import Base from './components/base'
9
-import House from './components/house'
9
+import HouseTab from './components/houseTab'
10
 import Poster from './components/poster'
10
 import Poster from './components/poster'
11
 import Share from './components/share'
11
 import Share from './components/share'
12
 import PreselectionImg from './components/preselectionImg'
12
 import PreselectionImg from './components/preselectionImg'
42
   console.log(props.location.query.id)
42
   console.log(props.location.query.id)
43
   const [tab, setTab] = useState('base')
43
   const [tab, setTab] = useState('base')
44
   const [salesBatchData, setSalesBatchData] = useState({ salesBatchId: undefined })
44
   const [salesBatchData, setSalesBatchData] = useState({ salesBatchId: undefined })
45
+
46
+  // const [tab, setTab] = useState('house')
45
   
47
   
46
   function tabsCallback(e) {
48
   function tabsCallback(e) {
47
     setTab(e.target.value)
49
     setTab(e.target.value)
66
       </Radio.Group>
68
       </Radio.Group>
67
       <div style={{ marginTop: '20px' }}>
69
       <div style={{ marginTop: '20px' }}>
68
         { (tab === 'base' && <Base salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }} onSuccess={e => buildingOnSuccess(e)}/>)} 
70
         { (tab === 'base' && <Base salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }} onSuccess={e => buildingOnSuccess(e)}/>)} 
69
-        { (tab === 'house' && <House />)}
71
+        { (tab === 'house' && <HouseTab salesBatchId="1" buildingId="1"/>)}
70
         { (tab === 'poster' && <Poster />)}
72
         { (tab === 'poster' && <Poster />)}
71
         { (tab === 'share' && <Share />)}
73
         { (tab === 'share' && <Share />)}
72
         { (tab === 'preselectionImg' && <PreselectionImg />)}
74
         { (tab === 'preselectionImg' && <PreselectionImg />)}

+ 5
- 0
src/services/apis.js 查看文件

1094
     url: `${prefix}/iBuildingDynamicList`,
1094
     url: `${prefix}/iBuildingDynamicList`,
1095
     action: 'admin.iBuildingDynamicList.get',
1095
     action: 'admin.iBuildingDynamicList.get',
1096
   },
1096
   },
1097
+  taHousingResources: {
1098
+    method: 'GET',
1099
+    url: `${prefix}/taHousingResources`,
1100
+    action: 'admin.taHousingResources.id.get',
1101
+  }
1097
  },
1102
  },
1098
 }
1103
 }