|
@@ -1,44 +1,141 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
+import Taro from '@tarojs/taro'
|
2
|
3
|
import withLayout from '@/layout'
|
3
|
|
-import './index.scss'
|
4
|
|
-import { ScrollView, Input } from '@tarojs/components'
|
|
4
|
+import { ScrollView, Input, Image } from '@tarojs/components'
|
|
5
|
+import Picker from '@/components/Picker'
|
|
6
|
+import { getChannelCustomerDetail } from '@/services/person'
|
|
7
|
+import { getCardList } from '@/services/card'
|
|
8
|
+import { uploadFiles, fetch } from '@/utils/request'
|
|
9
|
+import { API_MARKETING_VISIT } from '@/constants/api'
|
5
|
10
|
import '@/assets/css/iconfont.css'
|
|
11
|
+import './index.scss'
|
6
|
12
|
|
7
|
13
|
export default withLayout((props) => {
|
|
14
|
+ const { id } = props
|
|
15
|
+
|
|
16
|
+ const [loading, setLoading] = useState(false)
|
|
17
|
+ const [channelCustomer, setChannelCustomer] = useState({})
|
|
18
|
+ const [consultantList, setConsultantList] = useState([])
|
|
19
|
+ const [consultant, setConsultant] = useState()
|
|
20
|
+ const [visitDate, setVisitDate] = useState()
|
|
21
|
+ const [imageUrl, setImageUrl] = useState()
|
|
22
|
+ const [remark, setRemark] = useState()
|
|
23
|
+
|
|
24
|
+ const openAlbum = (e) => {
|
|
25
|
+ e.stopPropagation()
|
|
26
|
+
|
|
27
|
+ Taro.chooseImage({
|
|
28
|
+ count: 1,
|
|
29
|
+ sizeType: ['original', 'compressed'], //可选择原图或压缩后的图片
|
|
30
|
+ sourceType: ['album', 'camera'], //可选择性开放访问相册、相机
|
|
31
|
+ success: res => {
|
|
32
|
+ Taro.showLoading({
|
|
33
|
+ title: '加载中',
|
|
34
|
+ })
|
|
35
|
+ uploadFiles(res.tempFilePaths).then(data => {
|
|
36
|
+ setImageUrl(data[0])
|
|
37
|
+ Taro.hideLoading()
|
|
38
|
+ }).catch(() => {
|
|
39
|
+ Taro.hideLoading()
|
|
40
|
+ })
|
|
41
|
+ },
|
|
42
|
+ complete: () => {
|
|
43
|
+ Taro.hideLoading()
|
|
44
|
+ }
|
|
45
|
+ })
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ const handleSubmit = () => {
|
|
49
|
+ const payload = {
|
|
50
|
+ id,
|
|
51
|
+ type: 'report',
|
|
52
|
+ realtyConsultant: consultant,
|
|
53
|
+ customerVisit: {
|
|
54
|
+ buildingId: channelCustomer.buildingId,
|
|
55
|
+ name: channelCustomer.name,
|
|
56
|
+ recommendPerson: channelCustomer.recommendPerson,
|
|
57
|
+ realtyConsultant: consultant,
|
|
58
|
+ imageUrl,
|
|
59
|
+ visitDate: `${visitDate}T12.00.00.000Z`, // 随便造了一个时刻
|
|
60
|
+ remark,
|
|
61
|
+ channelId: channelCustomer.channelId,
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ setLoading(true)
|
|
66
|
+ fetch({ url: API_MARKETING_VISIT, payload, method: 'PUT' }).then((res) => {
|
|
67
|
+ setLoading(false)
|
|
68
|
+ Taro.showToast({
|
|
69
|
+ url: '操作成功',
|
|
70
|
+ icon: 'none'
|
|
71
|
+ })
|
|
72
|
+ const t = setTimeout(() => {
|
|
73
|
+ Taro.navigateBack({ delta: 1 })
|
|
74
|
+ clearTimeout(t)
|
|
75
|
+ }, 1500)
|
|
76
|
+ }).catch((e) => {
|
|
77
|
+ setLoading(false)
|
|
78
|
+ })
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ useEffect(() => {
|
|
82
|
+ if (id) {
|
|
83
|
+ getChannelCustomerDetail(id).then((res) => {
|
|
84
|
+ setChannelCustomer(res || {})
|
|
85
|
+
|
|
86
|
+ setConsultant(res?.realtyConsultant)
|
|
87
|
+
|
|
88
|
+ if (res?.buildingId) {
|
|
89
|
+ getCardList({
|
|
90
|
+ pageNumber: 1,
|
|
91
|
+ pageSize: 50,
|
|
92
|
+ buildingId: res.buildingId,
|
|
93
|
+ }).then((x) => {
|
|
94
|
+ const { records } = x || {}
|
|
95
|
+ setConsultantList(records || [])
|
|
96
|
+ })
|
|
97
|
+ }
|
|
98
|
+ })
|
|
99
|
+ }
|
|
100
|
+ }, [id])
|
8
|
101
|
|
9
|
102
|
// const [PageProps] = useState(props)
|
10
|
103
|
|
11
|
104
|
return (
|
12
|
105
|
<view className='Page sureVisit'>
|
13
|
106
|
|
14
|
|
- <ScrollView scroll-y={true} refresher-enabled={false} refresher-background='#fff'>
|
|
107
|
+ <ScrollView scrollY>
|
15
|
108
|
<view className='PageContent'>
|
16
|
109
|
|
17
|
110
|
<text>客户姓名</text>
|
18
|
111
|
<view className='FormLine flex-h'>
|
19
|
112
|
<view className='flex-item'>
|
20
|
|
- <Input placeholder='请输入姓名'></Input>
|
|
113
|
+ <text>{channelCustomer.name}</text>
|
|
114
|
+ {/* <Input placeholder='请输入姓名' value={channelCustomer.name}></Input> */}
|
21
|
115
|
</view>
|
22
|
116
|
</view>
|
23
|
117
|
|
24
|
118
|
<text>归属渠道</text>
|
25
|
119
|
<view className='FormLine flex-h'>
|
26
|
120
|
<view className='flex-item'>
|
27
|
|
- <Input placeholder='请输入渠道'></Input>
|
|
121
|
+ <text>{channelCustomer.channelName}</text>
|
|
122
|
+ {/* <Input placeholder='请输入渠道' value={channelCustomer.channelName}></Input> */}
|
28
|
123
|
</view>
|
29
|
124
|
</view>
|
30
|
125
|
|
31
|
126
|
<text>内场接待</text>
|
32
|
127
|
<view className='FormLine flex-h'>
|
33
|
128
|
<view className='flex-item'>
|
34
|
|
- <Input placeholder='请输入内场接待'></Input>
|
|
129
|
+ {/* <Input placeholder='请输入内场接待'></Input> */}
|
|
130
|
+ <Picker kv={['name', 'id']} value={consultant} placeholder='请输入内场接待' dicts={consultantList} onChange={setConsultant} />
|
35
|
131
|
</view>
|
36
|
132
|
</view>
|
37
|
133
|
|
38
|
134
|
<text>到访时间</text>
|
39
|
135
|
<view className='FormLine flex-h'>
|
40
|
136
|
<view className='flex-item'>
|
41
|
|
- <text>请选择</text>
|
|
137
|
+ {/* <text>请选择</text> */}
|
|
138
|
+ <Picker mode='date' value={visitDate} onChange={setVisitDate} />
|
42
|
139
|
</view>
|
43
|
140
|
<text className='iconfont icon-jiantoudown'></text>
|
44
|
141
|
</view>
|
|
@@ -46,21 +143,22 @@ export default withLayout((props) => {
|
46
|
143
|
<text>到访照片</text>
|
47
|
144
|
<view className='FormLine flex-h'>
|
48
|
145
|
<view className='flex-item'>
|
49
|
|
- <view className='UploadImg'>
|
|
146
|
+ {/* <view className='UploadImg'>
|
50
|
147
|
<text className='iconfont icon-xiangji centerLabel'></text>
|
51
|
|
- </view>
|
|
148
|
+ </view> */}
|
|
149
|
+ <Image src={imageUrl} className='UploadImg' onClick={openAlbum} mode="aspectFill"></Image>
|
52
|
150
|
</view>
|
53
|
151
|
</view>
|
54
|
152
|
|
55
|
153
|
<text>备注</text>
|
56
|
154
|
<view className='FormLine flex-h'>
|
57
|
155
|
<view className='flex-item'>
|
58
|
|
- <Input placeholder='补充说明(选填)'></Input>
|
|
156
|
+ <textarea placeholder='补充说明(选填)' value={remark} onInput={(e) => setRemark(e.detail.value)} ></textarea>
|
59
|
157
|
</view>
|
60
|
158
|
</view>
|
61
|
159
|
|
62
|
160
|
<view className='Btn'>
|
63
|
|
- <text>提交</text>
|
|
161
|
+ <button loading={loading} onClick={handleSubmit}>提交</button>
|
64
|
162
|
</view>
|
65
|
163
|
|
66
|
164
|
</view>
|