瀏覽代碼

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

# Conflicts:
#	src/pages/house/edit/index.jsx
傅行帆 5 年之前
父節點
當前提交
b869a227bc

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

@@ -0,0 +1,64 @@
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 ApartmentSelect = props => {
23
+  const [data, setData] = useState([])
24
+  const [value, setValue] = useState([])
25
+  useEffect(() => {
26
+    getList();
27
+  }, [props.value])
28
+
29
+
30
+  const getList = e => {
31
+    request({ ...apis.house.apartmentList, params: { pageNum: 1, pageSize: 999, buildingId: props.buildingId} }).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(apartment => (
59
+            <Option key={apartment.apartmentId} value={apartment.apartmentId}>{apartment.apartmentName}</Option>
60
+          ))}
61
+      </Select>
62
+  )
63
+}
64
+export default ApartmentSelect

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

@@ -25,16 +25,14 @@ const Poster = props => {
25 25
   const [posterId, setPosterId] = useState('')
26 26
 
27 27
   const [building, setBuilding] = useState({ buildingImg: [{ url: '' }] })
28
-  const { buildingId } = props.building
29
-   // ============这边改造下就可以饿============================
30
-  if (buildingId) {
28
+  const { salesBatchId } = props.salesBatchId
29
+  if (salesBatchId) {
31 30
     // eslint-disable-next-line react-hooks/rules-of-hooks
32 31
     useEffect(() => {
33 32
       request({
34 33
         ...apis.activity.poster,
35
-        params: { targetId: buildingId, targetType: 'building' },
34
+        params: { targetId: salesBatchId, targetType: 'house' },
36 35
       }).then(data => {
37
-        console.log(data, '2222')
38 36
         if (data.length > 0) {
39 37
           setPosterId(data[0].posterId)
40 38
           changeImg(data[0].posterImg)
@@ -45,7 +43,7 @@ const Poster = props => {
45 43
         message.info(err.msg || err.message)
46 44
       })
47 45
 
48
-      getById(buildingId)
46
+      // getById(salesBatchId)
49 47
       getMiniappName()
50 48
     }, [])
51 49
   }
@@ -70,7 +68,7 @@ const Poster = props => {
70 68
   }
71 69
 
72 70
   const submitPoster = () => {
73
-    if (buildingId) {
71
+    if (salesBatchId) {
74 72
       if (!imgValue) {
75 73
         message.error('请选择海报图片')
76 74
         return
@@ -80,7 +78,7 @@ const Poster = props => {
80 78
         request({
81 79
           ...apis.activity.updatePoster,
82 80
           urlData: { id: posterId },
83
-          data: { targetId: buildingId, targetType: 'building', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue },
81
+          data: { targetId: salesBatchId, targetType: 'house', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue },
84 82
         }).then(() => {
85 83
           message.info('保存成功')
86 84
         }).catch(err => {
@@ -89,7 +87,7 @@ const Poster = props => {
89 87
       } else {
90 88
         request({
91 89
           ...apis.activity.addPoster,
92
-          data: { targetId: buildingId, targetType: 'building', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue },
90
+          data: { targetId: salesBatchId, targetType: 'house', posterImg: imgValue, posterTitle: inputValue, posterDescription: textAreaValue },
93 91
         }).then(data => {
94 92
           setPosterId(data.posterId)
95 93
           message.info('保存成功')

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

@@ -19,14 +19,13 @@ const Share = props => {
19 19
   const [inputValue, changeInput] = useState('')
20 20
   const [imgValue, changeImg] = useState('')
21 21
   const [shareContentId, setShareContentId] = useState('')
22
-// ============这边改造下就可以饿============================
23
-  const { buildingId } = props.building
24
-  if (buildingId) {
22
+  const { salesBatchId } = props.salesBatchId
23
+  if (salesBatchId) {
25 24
     // eslint-disable-next-line react-hooks/rules-of-hooks
26 25
     useEffect(() => {
27 26
       request({
28 27
         ...apis.activity.shareContent,
29
-        params: { targetId: buildingId, targetType: 'building' },
28
+        params: { targetId: salesBatchId, targetType: 'house' },
30 29
       }).then(data => {
31 30
         if (data.length > 0) {
32 31
           setShareContentId(data[0].shareContentId)
@@ -40,12 +39,12 @@ const Share = props => {
40 39
   }
41 40
 
42 41
   const submitShare = () => {
43
-    if (buildingId) {
42
+    if (salesBatchId) {
44 43
       if (shareContentId) {
45 44
         request({
46 45
           ...apis.activity.updateShareContent,
47 46
           urlData: { id: shareContentId },
48
-          data: { targetId: buildingId, shareContentType: 'building', shareContentImg: imgValue,shareContentTitle: inputValue },
47
+          data: { targetId: salesBatchId, shareContentType: 'house', shareContentImg: imgValue,shareContentTitle: inputValue },
49 48
         }).then(data => {
50 49
           message.info('保存成功')
51 50
         }).catch(err => {
@@ -54,7 +53,7 @@ const Share = props => {
54 53
        } else {
55 54
         request({
56 55
           ...apis.activity.addShareContent,
57
-          data: { targetId: buildingId, shareContentType: 'building', shareContentImg: imgValue,shareContentTitle: inputValue },
56
+          data: { targetId: salesBatchId, shareContentType: 'house', shareContentImg: imgValue,shareContentTitle: inputValue },
58 57
         }).then(data => {
59 58
           setShareContentId(data.shareContentId)
60 59
           message.info('保存成功')

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

@@ -40,7 +40,7 @@ function openNotificationWithIcon(type, message) {
40 40
 function EditHouse(props) {
41 41
   const {salesBatchId} = props.location.query.id;
42 42
   console.log(props.location.query.id)
43
-  const [tab, setTab] = useState('house')
43
+  const [tab, setTab] = useState('base')
44 44
   const [salesBatchData, setSalesBatchData] = useState({ salesBatchId: undefined })
45 45
 
46 46
   function tabsCallback(e) {
@@ -67,8 +67,8 @@ function EditHouse(props) {
67 67
       <div style={{ marginTop: '20px' }}>
68 68
         { (tab === 'base' && <Base salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }} onSuccess={e => buildingOnSuccess(e)}/>)} 
69 69
         { (tab === 'house' && <HouseTab salesBatchId={props.location.query.id} buildingId={props.location.query.buildingId}/>)}
70
-        { (tab === 'poster' && <Poster />)}
71
-        { (tab === 'share' && <Share />)}
70
+        { (tab === 'poster' && <Poster salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
71
+        { (tab === 'share' && <Share salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
72 72
         { (tab === 'preselectionImg' && <PreselectionImg />)}
73 73
         { (tab === 'preselectionRecord' && <PreselectionRecord />)}
74 74
         { (tab === 'shareRecord' && <ShareRecord />)}