优化代码

This commit is contained in:
java110 2020-09-14 23:30:16 +08:00
parent 9374f129a4
commit 67404beb1d
2 changed files with 47 additions and 4 deletions

View File

@ -48,11 +48,10 @@
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">预约房屋</label>
<div class="col-sm-10">
<input v-model="addRentingAppointmentInfo.appointmentRoomId" type="text" placeholder="选填,请填写预约房屋"
<input v-model="addRentingAppointmentInfo.appointmentRoomNum" @blur="_loadRoomInfo" type="text" placeholder="选填,请填写预约房屋 楼栋-单元-房屋 如1-1-1023"
class="form-control">
</div>
</div>

View File

@ -13,6 +13,7 @@
tenantTel: '',
appointmentTime: '',
appointmentRoomId: '',
appointmentRoomNum: '',
remark: '',
communitys: [],
communityId: '',
@ -164,7 +165,7 @@
});
},
_loadAddCommunitys: function () {
var param = {
let param = {
params: {
_uId: 'ccdd00opikookjuhyyttvhnnjuuu',
page: 1,
@ -185,6 +186,48 @@
}
);
},
_loadRoomInfo: function () {
let _appointmentRoomNum = $that.addRentingAppointmentInfo.appointmentRoomNum;
if (_appointmentRoomNum.split('-').length != 3) {
return ;
}
if($that.addRentingAppointmentInfo.communityId == ''){
vc.toast('请先选择小区');
$that.addRentingAppointmentInfo.appointmentRoomNum = '';
return ;
}
let _appointmentRoomNums = _appointmentRoomNum.split('-')
let param = {
params: {
_uId: 'ccdd00opikookjuhyyttvhnnjuuu',
page: 1,
row: 1,
floorNum: _appointmentRoomNums[0].trim(),
unitNum: _appointmentRoomNums[1].trim(),
roomNum: _appointmentRoomNums[2].trim(),
communityId: $that.addRentingAppointmentInfo.communityId
}
};
vc.http.apiGet('room.queryRooms',
param,
function (json, res) {
if (res.status == 200) {
let _rooms = JSON.parse(json).rooms;
if (_rooms.length < 1) {
vc.toast('未查询到房屋');
$that.addRentingAppointmentInfo.appointmentRoomNum = '';
return;
}
$that.addRentingAppointmentInfo.appointmentRoomId = _rooms[0].roomId;
}
}, function () {
vc.toast('未查询到房屋');
$that.addRentingAppointmentInfo.appointmentRoomNum = '';
}
);
},
clearAddRentingAppointmentInfo: function () {
let _communitys = $that.addRentingAppointmentInfo.communitys;
vc.component.addRentingAppointmentInfo = {
@ -201,7 +244,8 @@
unitNum: '',
roomId: '',
roomNum: '',
communitys: _communitys
communitys: _communitys,
appointmentRoomNum: ''
};
}
}