소스 검색

新需求

傅行帆 5 년 전
부모
커밋
bffd30c84b
3개의 변경된 파일163개의 추가작업 그리고 2개의 파일을 삭제
  1. 6
    0
      config/routes.js
  2. 148
    0
      src/pages/house/add/HouseBatchAdd.jsx
  3. 9
    2
      src/pages/house/add/index.jsx

+ 6
- 0
config/routes.js 파일 보기

@@ -537,6 +537,12 @@ export default [
537 537
                 hideInMenu: true,
538 538
                 component: './house/add/index',
539 539
               },
540
+              {
541
+                path: '/house/batch',
542
+                name: '批量上传', 
543
+                hideInMenu: true,
544
+                component: './house/add/HouseBatchAdd',
545
+              },
540 546
               {
541 547
                 path: '/house/edit',
542 548
                 name: '编辑', 

+ 148
- 0
src/pages/house/add/HouseBatchAdd.jsx 파일 보기

@@ -0,0 +1,148 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload, Table } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import moment from 'moment';
5
+import router from 'umi/router';
6
+import { fetch } from '../../../utils/request';
7
+import apis from '../../../services/apis';
8
+import XForm, { FieldTypes } from '../../../components/XForm';
9
+import ApartmentSelect from '../../../components/HouseSelect/ApartmentSelect';
10
+import request from '@/utils/request';
11
+
12
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
13
+const { TextArea } = Input;
14
+
15
+function HouseBatchAdd(props) {
16
+
17
+const [data, setData] = useState({list: [], total: 0})
18
+
19
+const [uploadFile, setUploadFile] = useState(null)
20
+
21
+const uploadExcel = fetch(apis.house.uploadExcel)
22
+
23
+const uploaderProps = {
24
+  name: 'file',
25
+  accept: '.xls, .xlsx',
26
+  showUploadList: false,
27
+  customRequest({
28
+    action,
29
+    file,
30
+    headers,
31
+    onError,
32
+    onProgress,
33
+    onSuccess,
34
+    withCredentials,
35
+  }) {
36
+     
37
+    const data = new FormData()
38
+    data.append('file', file)
39
+    data.append('salesBatchId', props.location.query.salesBatchId)
40
+    data.append('buildingId', props.location.query.buildingId)
41
+
42
+    setUploadFile(file)
43
+
44
+    uploadExcel({ data }).then((res) => {
45
+      setData(res)
46
+      onSuccess(res, file);
47
+    }).catch(onError);
48
+
49
+    return {
50
+      abort() {
51
+        console.log('upload progress is aborted.');
52
+      },
53
+    };
54
+  },
55
+}
56
+
57
+//取消
58
+function handleCancel(){
59
+  router.push({
60
+    pathname: '/house/edit',
61
+    query: {
62
+      id: props.location.query.salesBatchId,
63
+      buildingId: props.location.query.buildingId,
64
+    },
65
+  });
66
+}
67
+
68
+function batchSaveHouse() {
69
+  const uploadData = new FormData()
70
+  uploadData.append('file', uploadFile)
71
+  uploadData.append('salesBatchId', props.location.query.salesBatchId)
72
+  uploadData.append('buildingId', props.location.query.buildingId)
73
+
74
+  request({ ...apis.house.saveExcelValue, data: uploadData,headers: "content-type=multipart/form-data" }).then(res => {
75
+    message.info('新增房源成功!请确认全部数据正常,然后在房源详情页 销售批次栏 选择 发布状态 为“是” 将房源 发布到小程序。如需要置业顾问或用户分享,请在房源详情中配套海报图和分享图。')
76
+    router.push({
77
+      pathname: '/house/edit',
78
+      query: {
79
+        id: props.location.query.salesBatchId,
80
+        buildingId: props.location.query.buildingId,
81
+      },
82
+    });
83
+  }).catch(err => {
84
+    // openNotificationWithIcon('error', err.message)
85
+  })
86
+}
87
+
88
+const columns = [
89
+  {
90
+    title: '期/区',
91
+    dataIndex: 'termName',
92
+    key: 'termName',
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: 'heat',
122
+    key: 'heat',
123
+  },
124
+  {
125
+    title: '发布状态',
126
+    dataIndex: 'status',
127
+    key: 'status',
128
+    render: status => <><span>{status == 0 ? '否' : status == 1 ? '是' : ''}</span></>,
129
+  },
130
+]
131
+
132
+  return (
133
+    <>
134
+      <span>1.导入房源先下载模板--></span><Button type="primary" htmlType="submit">下载模板</Button><br/>
135
+      <span>2.使用excel打开模板文件,编辑房源数据并保存</span><br/>
136
+      <span>3.将编辑好的文件上传--></span><Upload {...uploaderProps}><Button type="primary" htmlType="submit">上传</Button></Upload><br/>
137
+      <span>4.检查导入的数据是否正常 ↓,不正常则重新编辑保存再次上传,请仔细阅读模板中的编辑规则</span>
138
+      <Table dataSource={data.list} columns={columns} pagination={{ total: data.total}}  rowKey="House" />
139
+      
140
+      <span>5.全部正常请点击提交</span>
141
+      <Button type="primary" onClick={() => batchSaveHouse()}>提交</Button>
142
+      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
143
+      <span>暂时未确定房源?  --></span><Button onClick={() => handleCancel()}>以后处理</Button>
144
+    </>
145
+  )
146
+}
147
+const WrappedHouseBatchAdd = Form.create({ name: 'house_batch' })(HouseBatchAdd);
148
+export default WrappedHouseBatchAdd

+ 9
- 2
src/pages/house/add/index.jsx 파일 보기

@@ -59,8 +59,15 @@ const header = props => {
59 59
         // getList({ pageNum: pageNumber, pageSize: 10, ...submitValue })
60 60
         console.log(submitValue)
61 61
         request({ ...apis.house.addTaSalesBatch, data: { ...submitValue },}).then((data) => {
62
-          message.info("保存成功")
63
-          cancelPage()
62
+          message.info("保存成功,请上传房源")
63
+          console.log(data,"datattttttt")
64
+          router.push({
65
+            pathname: '/house/batch',
66
+            query: {
67
+              salesBatchId: data.salesBatchId,
68
+              buildingId: data.buildingId,
69
+            },
70
+          });
64 71
         }).catch((err) => {
65 72
           message.info(err.msg || err.message)
66 73
         })