|
@@ -1,10 +1,12 @@
|
1
|
1
|
import withLayout from '@/layouts'
|
2
|
2
|
import Taro from '@tarojs/taro'
|
3
|
3
|
import CustomNav from '@/components/CustomNav'
|
4
|
|
-import { View, Text, Image, Input, Button, Label } from '@tarojs/components';
|
|
4
|
+import { View, Input, Button, Label, Textarea } from '@tarojs/components';
|
5
|
5
|
import { useEffect, useState } from "react"
|
6
|
6
|
import { saveRoom, getRoomDetail, updateRoom } from '@/services/landlord'
|
7
|
7
|
import { getExtendContent } from "@/services/home";
|
|
8
|
+import { saveExtend } from '@/services/landlord'
|
|
9
|
+import Popup from '@/components/Popup'
|
8
|
10
|
import Extend from "../../components/Extend";
|
9
|
11
|
import './addRoom.less'
|
10
|
12
|
|
|
@@ -58,20 +60,52 @@ export default withLayout((props) => {
|
58
|
60
|
}
|
59
|
61
|
}
|
60
|
62
|
const [extend, setExtend] = useState([]);
|
61
|
|
-
|
62
|
63
|
useEffect(() => {
|
63
|
64
|
if (roomId) {
|
64
|
65
|
getRoomDetail(roomId).then((res) => {
|
65
|
66
|
setRoomModel(res)
|
66
|
67
|
})
|
67
|
|
- getExtendContent('room', roomId).then((res) => {
|
|
68
|
+ }
|
|
69
|
+ }, [roomId])//这个地方写这个单词的目的是 因为编辑时roomId有可能还没加载成功
|
|
70
|
+ const [reset, setReset] = useState(false)
|
|
71
|
+ useEffect(() => {
|
|
72
|
+ if (roomId) {
|
|
73
|
+ getExtendContent('room', roomId, { pageSize: 999 }).then((res) => {
|
68
|
74
|
setExtend(res.records || []);
|
69
|
75
|
})
|
|
76
|
+ setReset(false)
|
70
|
77
|
}
|
71
|
|
- }, [roomId])//这个地方写这个单词的目的是 因为编辑时roomId有可能还没加载成功
|
72
|
|
-
|
73
|
|
-
|
|
78
|
+ }, [reset])
|
74
|
79
|
|
|
80
|
+ //新增文字
|
|
81
|
+ const [showCutover, setShowCutover] = useState(false)
|
|
82
|
+ const [cont,setcont]=useState()
|
|
83
|
+ const onClose = () => {
|
|
84
|
+ setShowCutover(false)
|
|
85
|
+ setReset(true)
|
|
86
|
+ setcont()
|
|
87
|
+ }
|
|
88
|
+ const handelAdd = () => {
|
|
89
|
+ var content = document.getElementById('content').value
|
|
90
|
+ if (content === '') {
|
|
91
|
+ Taro.showToast({
|
|
92
|
+ title: '您还没有添加文字哦',
|
|
93
|
+ icon: 'none'
|
|
94
|
+ })
|
|
95
|
+ return;
|
|
96
|
+ }
|
|
97
|
+ const date = {
|
|
98
|
+ targetId: roomId,
|
|
99
|
+ targetType: 'room',
|
|
100
|
+ content,
|
|
101
|
+ contentType: 'text'
|
|
102
|
+ }
|
|
103
|
+ saveExtend(date)
|
|
104
|
+ onClose()
|
|
105
|
+ }
|
|
106
|
+ const showText = () => {
|
|
107
|
+ setShowCutover(true)
|
|
108
|
+ }
|
75
|
109
|
return (
|
76
|
110
|
<view className='page-index'>
|
77
|
111
|
<view className="index-navbar">
|
|
@@ -79,16 +113,32 @@ export default withLayout((props) => {
|
79
|
113
|
</view>
|
80
|
114
|
<view className='roomDetail' style={{ height: '100%', overflow: "hidden", }} >
|
81
|
115
|
<scroll-view scrollY style={{ height: '100%' }}>
|
|
116
|
+ <View id='det'>
|
|
117
|
+ <Popup show={showCutover} onClose={onClose}>
|
|
118
|
+ <View className='editword'>
|
|
119
|
+ <View style={{ marginBottom: '25px' }}>
|
|
120
|
+ <View className='rzline' /><Label className='srl mg'>新增文字</Label><View className='rzline' />
|
|
121
|
+ </View>
|
|
122
|
+ <View>
|
|
123
|
+ <Textarea className='storezn' id='content' value={cont} placeholder='请输入准备新增的文字' />
|
|
124
|
+ </View>
|
|
125
|
+ <View>
|
|
126
|
+ <Button className='cancel' onClick={onClose}>取消</Button>
|
|
127
|
+ <Button className='btn' onClick={handelAdd}>确认修改</Button>
|
|
128
|
+ </View>
|
|
129
|
+ </View>
|
|
130
|
+ </Popup>
|
|
131
|
+ </View>
|
82
|
132
|
<mp-form models={roomModel} >
|
83
|
133
|
<mp-cells title='房屋名称' footer='' ext-class='cells' >
|
84
|
134
|
<mp-cell>
|
85
|
|
- <Input style={{fontWeight:'bold'}} onInput={(e) => setRoomModel({ ...roomModel, roomName: e.detail.value })} value={roomModel.roomName} placeholder='请输入房屋名称(必填)' />
|
|
135
|
+ <Input style={{ fontWeight: 'bold' }} onInput={(e) => setRoomModel({ ...roomModel, roomName: e.detail.value })} value={roomModel.roomName} placeholder='请输入房屋名称(必填)' />
|
86
|
136
|
</mp-cell>
|
87
|
137
|
</mp-cells>
|
88
|
138
|
<mp-cells title='房屋位置'>
|
89
|
139
|
<mp-cell>
|
90
|
|
- <Input style={{color:'#000',fontWeight:'bold',marginBottom:'13px'}} onInput={(e) => setRoomModel({ ...roomModel, address: e.detail.value })} value={roomModel.address} placeholder='请输入房屋位置(必填)' />
|
91
|
|
- <Label style={{ color: '#666'}} onClick={onRoomMap}>{roomModel.location == '' ? '房间定位(必填)' : roomModel.location}</Label>
|
|
140
|
+ <Input style={{ color: '#000', fontWeight: 'bold', marginBottom: '13px' }} onInput={(e) => setRoomModel({ ...roomModel, address: e.detail.value })} value={roomModel.address} placeholder='请输入房屋位置(必填)' />
|
|
141
|
+ <Label style={{ color: '#666' }} onClick={onRoomMap}>{roomModel.location == '' ? '房间定位(必填)' : roomModel.location}</Label>
|
92
|
142
|
</mp-cell>
|
93
|
143
|
</mp-cells>
|
94
|
144
|
<mp-cells title='停车场位置'>
|
|
@@ -99,29 +149,28 @@ export default withLayout((props) => {
|
99
|
149
|
</mp-cells>
|
100
|
150
|
<mp-cells title='WiFi信息'>
|
101
|
151
|
<mp-cell>
|
102
|
|
- <View style={{color:'#666'}}>
|
103
|
|
- <Input style={{display:'inline-block',background:'#fff',width:'20%'}} value='名称:' disabled/><Input style={{display:'inline-block',width:'80%'}} onInput={(e) => setRoomModel({ ...roomModel, wifiName: e.detail.value })} value={roomModel.wifiName} placeholder='请输入wifi名称' />
|
104
|
|
- <Input style={{display:'inline-block',background:'#fff',width:'20%'}} value='密码:' disabled/><Input style={{display:'inline-block',width:'80%'}} onInput={(e) => setRoomModel({ ...roomModel, wifiPassword: e.detail.value })} value={roomModel.wifiPassword} placeholder='请输入wifi密码' />
|
105
|
|
- </View>
|
|
152
|
+ <View style={{ color: '#666' }}>
|
|
153
|
+ <Input style={{ display: 'inline-block', background: '#fff', width: '20%' }} value='名称:' disabled /><Input style={{ display: 'inline-block', width: '80%' }} onInput={(e) => setRoomModel({ ...roomModel, wifiName: e.detail.value })} value={roomModel.wifiName} placeholder='请输入wifi名称' />
|
|
154
|
+ <Input style={{ display: 'inline-block', background: '#fff', width: '20%' }} value='密码:' disabled /><Input style={{ display: 'inline-block', width: '80%' }} onInput={(e) => setRoomModel({ ...roomModel, wifiPassword: e.detail.value })} value={roomModel.wifiPassword} placeholder='请输入wifi密码' />
|
|
155
|
+ </View>
|
106
|
156
|
</mp-cell>
|
107
|
157
|
</mp-cells>
|
108
|
158
|
<mp-cells title='权重'>
|
109
|
159
|
<mp-cell>
|
110
|
160
|
<input type='number' value={roomModel.weight} onInput={(e) => setRoomModel({ ...roomModel, weight: e.detail.value })} placeholder='请输入权重(必填)' />
|
111
|
161
|
</mp-cell>
|
112
|
|
-
|
113
|
162
|
</mp-cells>
|
114
|
163
|
<mp-cells title='其他指引'>
|
115
|
164
|
{
|
116
|
165
|
extend == '' ? null :
|
117
|
166
|
<mp-cell >
|
118
|
167
|
{extend.map((item) => (
|
119
|
|
- <Extend key={item.extId} item={item} />
|
|
168
|
+ <Extend key={item.extId} item={item} setReset={setReset} />
|
120
|
169
|
))}
|
121
|
170
|
</mp-cell>
|
122
|
171
|
}
|
123
|
172
|
<mp-cell extClass='adds'>
|
124
|
|
- <Button className='add'>增加文字</Button><Button className='add'>增加图片</Button>
|
|
173
|
+ <Button className='add' onClick={showText}>增加文字</Button><Button className='add'>增加图片</Button>
|
125
|
174
|
<Button className='button-OK' onClick={sumbit}>确定</Button>
|
126
|
175
|
</mp-cell>
|
127
|
176
|
</mp-cells>
|