浏览代码

新需求

傅行帆 5 年前
父节点
当前提交
31e4976769
共有 3 个文件被更改,包括 93 次插入5 次删除
  1. 82
    4
      src/pages/house/edit/components/HouseBatch.jsx
  2. 6
    1
      src/pages/house/edit/components/house.jsx
  3. 5
    0
      src/services/apis.js

+ 82
- 4
src/pages/house/edit/components/HouseBatch.jsx 查看文件

@@ -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
+      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
131
+      <Button onClick={() => handleCancel()}>取消</Button>
54 132
     </>
55 133
   )
56 134
 }

+ 6
- 1
src/pages/house/edit/components/house.jsx 查看文件

@@ -141,6 +141,11 @@ function House(props) {
141 141
       dataIndex: 'houseId',
142 142
       key: 'houseId',
143 143
     },
144
+    {
145
+      title: '期/区',
146
+      dataIndex: 'termName',
147
+      key: 'termName',
148
+    },
144 149
     {
145 150
       title: '楼栋',
146 151
       dataIndex: 'blockName',
@@ -264,7 +269,7 @@ function House(props) {
264 269
       <Button type="primary" onClick={() => showEdi({type: "batch"})} style={{ marginLeft: '18px'}}>批量导入房源</Button>
265 270
       <Button type="primary" onClick={() => showAparement()} style={{ marginLeft: '18px'}}>批量修改对应户型</Button>
266 271
       <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>
267
-      <Table rowSelection={rowSelection} dataSource={data.records} columns={columns} pagination={{ total: data.total, onChange: e => this.changePageNum(e) }} rowKey="House" />
272
+      <Table rowSelection={rowSelection} dataSource={data.records} columns={columns} pagination={{ total: data.total, onChange: e => changePageNum(e) }} rowKey="House" />
268 273
       <Modal
269 274
             title="批量修改对应户型"
270 275
             width={400}

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

@@ -1178,6 +1178,11 @@ export default {
1178 1178
     url: `${prefix}/house/uploadExcel`,
1179 1179
     method: 'POST',
1180 1180
     action: 'upload',
1181
+  },
1182
+  saveExcelValue: {
1183
+    url: `${prefix}/house/saveExcelValue`,
1184
+    method: 'POST',
1185
+    action: 'upload',
1181 1186
   }
1182 1187
  },
1183 1188
 }