|
@@ -1,5 +1,5 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
|
-import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload } from 'antd';
|
|
2
|
+import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload, Table } from 'antd';
|
3
|
3
|
import { FormattedMessage } from 'umi-plugin-react/locale';
|
4
|
4
|
import moment from 'moment';
|
5
|
5
|
import router from 'umi/router';
|
|
@@ -12,6 +12,12 @@ import request from '@/utils/request';
|
12
|
12
|
const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
13
|
13
|
const { TextArea } = Input;
|
14
|
14
|
|
|
15
|
+function HouseBatch(props) {
|
|
16
|
+
|
|
17
|
+const [data, setData] = useState({list: [], total: 0})
|
|
18
|
+
|
|
19
|
+const [uploadFile, setUploadFile] = useState(null)
|
|
20
|
+
|
15
|
21
|
const uploadExcel = fetch(apis.house.uploadExcel)
|
16
|
22
|
|
17
|
23
|
const uploaderProps = {
|
|
@@ -27,12 +33,16 @@ const uploaderProps = {
|
27
|
33
|
onSuccess,
|
28
|
34
|
withCredentials,
|
29
|
35
|
}) {
|
30
|
|
- console.log(uploadExcel,"11")
|
|
36
|
+
|
31
|
37
|
const data = new FormData()
|
32
|
38
|
data.append('file', file)
|
|
39
|
+ data.append('salesBatchId', props.salesBatchId)
|
|
40
|
+ data.append('buildingId', props.buildingId)
|
|
41
|
+
|
|
42
|
+ setUploadFile(file)
|
33
|
43
|
|
34
|
44
|
uploadExcel({ data }).then((res) => {
|
35
|
|
- console.log(res,"fileuda");
|
|
45
|
+ setData(res)
|
36
|
46
|
onSuccess(res, file);
|
37
|
47
|
}).catch(onError);
|
38
|
48
|
|
|
@@ -44,13 +54,81 @@ const uploaderProps = {
|
44
|
54
|
},
|
45
|
55
|
}
|
46
|
56
|
|
47
|
|
-function HouseBatch(props) {
|
|
57
|
+//取消
|
|
58
|
+function handleCancel(){
|
|
59
|
+ props.onSuccess({type: "house"})
|
|
60
|
+}
|
|
61
|
+
|
|
62
|
+function batchSaveHouse() {
|
|
63
|
+ const uploadData = new FormData()
|
|
64
|
+ uploadData.append('file', uploadFile)
|
|
65
|
+ uploadData.append('salesBatchId', props.salesBatchId)
|
|
66
|
+ uploadData.append('buildingId', props.buildingId)
|
|
67
|
+
|
|
68
|
+ request({ ...apis.house.saveExcelValue, data: uploadData,headers: "content-type=multipart/form-data" }).then(res => {
|
|
69
|
+ message.info('上传成功')
|
|
70
|
+ props.onSuccess({type: "house"})
|
|
71
|
+ }).catch(err => {
|
|
72
|
+ // openNotificationWithIcon('error', err.message)
|
|
73
|
+ })
|
|
74
|
+}
|
|
75
|
+
|
|
76
|
+const columns = [
|
|
77
|
+ {
|
|
78
|
+ title: '期/区',
|
|
79
|
+ dataIndex: 'termName',
|
|
80
|
+ key: 'termName',
|
|
81
|
+ },
|
|
82
|
+ {
|
|
83
|
+ title: '楼栋',
|
|
84
|
+ dataIndex: 'blockName',
|
|
85
|
+ key: 'blockName',
|
|
86
|
+ },
|
|
87
|
+ {
|
|
88
|
+ title: '单元',
|
|
89
|
+ dataIndex: 'unitName',
|
|
90
|
+ key: 'unitName',
|
|
91
|
+ },
|
|
92
|
+ {
|
|
93
|
+ title: '层',
|
|
94
|
+ dataIndex: 'floorName',
|
|
95
|
+ key: 'floorName',
|
|
96
|
+ },
|
|
97
|
+ {
|
|
98
|
+ title: '房号',
|
|
99
|
+ dataIndex: 'roomName',
|
|
100
|
+ key: 'roomName',
|
|
101
|
+ },
|
|
102
|
+ {
|
|
103
|
+ title: '价格(万元)',
|
|
104
|
+ dataIndex: 'price',
|
|
105
|
+ key: 'price',
|
|
106
|
+ },
|
|
107
|
+ {
|
|
108
|
+ title: '预选基础热度',
|
|
109
|
+ dataIndex: 'heat',
|
|
110
|
+ key: 'heat',
|
|
111
|
+ },
|
|
112
|
+ {
|
|
113
|
+ title: '发布状态',
|
|
114
|
+ dataIndex: 'status',
|
|
115
|
+ key: 'status',
|
|
116
|
+ render: status => <><span>{status == 0 ? '否' : status == 1 ? '是' : ''}</span></>,
|
|
117
|
+ },
|
|
118
|
+]
|
|
119
|
+
|
48
|
120
|
return (
|
49
|
121
|
<>
|
50
|
122
|
<span>1.导入房源先下载模板--></span><Button type="primary" htmlType="submit">下载模板</Button><br/>
|
51
|
123
|
<span>2.使用excel打开模板文件,编辑房源数据并保存</span><br/>
|
52
|
124
|
<span>3.将编辑好的文件上传--></span><Upload {...uploaderProps}><Button type="primary" htmlType="submit">上传</Button></Upload><br/>
|
53
|
125
|
<span>4.检查导入的数据是否正常 ↓,不正常则重新编辑保存再次上传,请仔细阅读模板中的编辑规则</span>
|
|
126
|
+ <Table dataSource={data.list} columns={columns} pagination={{ total: data.total}} rowKey="House" />
|
|
127
|
+
|
|
128
|
+ <span>5.全部正常请点击提交</span>
|
|
129
|
+ <Button type="primary" onClick={() => batchSaveHouse()}>提交</Button>
|
|
130
|
+
|
|
131
|
+ <Button onClick={() => handleCancel()}>取消</Button>
|
54
|
132
|
</>
|
55
|
133
|
)
|
56
|
134
|
}
|