Просмотр исходного кода

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

# Conflicts:
#	src/pages/house/edit/index.jsx
傅行帆 5 лет назад
Родитель
Сommit
b869a227bc

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

+ 6
- 7
src/pages/house/edit/components/share.jsx Просмотреть файл

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

+ 3
- 3
src/pages/house/edit/index.jsx Просмотреть файл

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