256 lines
9.9 KiB
JavaScript
256 lines
9.9 KiB
JavaScript
(function (vc, vm) {
|
|
vc.extends({
|
|
data: {
|
|
editRoomUnits: [],
|
|
editRoomInfo: {
|
|
roomId: '',
|
|
unitId: '',
|
|
roomNum: '',
|
|
layer: '',
|
|
section: '0',
|
|
apartment: '',
|
|
apartment1: '',
|
|
apartment2: '',
|
|
builtUpArea: '',
|
|
feeCoefficient: '1.00',
|
|
state: '',
|
|
remark: '',
|
|
communityId: '',
|
|
attrs: [],
|
|
roomSubType: '110',
|
|
roomArea: '',
|
|
roomRent: '0',
|
|
roomSubTypes: []
|
|
}
|
|
},
|
|
_initMethod: function () {
|
|
$that._loadRoomAttrSpec();
|
|
},
|
|
_initEvent: function () {
|
|
vc.on('editRoom', 'openEditRoomModal', function (_room) {
|
|
$that.refreshEditRoomInfo();
|
|
//与字典表关联
|
|
vc.getDict('building_room', "room_sub_type", function (_data) {
|
|
$that.editRoomInfo.roomSubTypes = _data;
|
|
});
|
|
vc.copyObject(_room, $that.editRoomInfo);
|
|
$that.loadUnitsFromEditRoom(_room.floorId);
|
|
$('#editRoomModel').modal('show');
|
|
$that.editRoomInfo.floorId = _room.floorId;
|
|
$that.editRoomInfo.communityId = vc.getCurrentCommunity().communityId;
|
|
if (_room.hasOwnProperty('roomAttrDto')) {
|
|
let _roomAttrDtos = _room.roomAttrDto;
|
|
_roomAttrDtos.forEach(item => {
|
|
$that.editRoomInfo.attrs.forEach(attrItem => {
|
|
if (item.specCd == attrItem.specCd) {
|
|
attrItem.attrId = item.attrId;
|
|
attrItem.value = item.value;
|
|
}
|
|
})
|
|
})
|
|
}
|
|
});
|
|
},
|
|
methods: {
|
|
/**
|
|
根据楼ID加载房屋
|
|
**/
|
|
loadUnitsFromEditRoom: function (_floorId) {
|
|
$that.editRoomUnits = [];
|
|
var param = {
|
|
params: {
|
|
floorId: _floorId,
|
|
communityId: vc.getCurrentCommunity().communityId
|
|
}
|
|
}
|
|
vc.http.apiGet(
|
|
'/unit.queryUnits',
|
|
param,
|
|
function (json, res) {
|
|
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
|
if (res.status == 200) {
|
|
var tmpUnits = JSON.parse(json);
|
|
$that.editRoomUnits = tmpUnits;
|
|
|
|
$that.editRoomInfo.apartment1 = $that.editRoomInfo.apartment.substr(0, 2);
|
|
$that.editRoomInfo.apartment2 = $that.editRoomInfo.apartment.substr(2, 5);
|
|
return;
|
|
}
|
|
vc.toast(json);
|
|
},
|
|
function (errInfo, error) {
|
|
console.log('请求失败处理');
|
|
vc.toast(errInfo);
|
|
});
|
|
},
|
|
_loadRoomAttrSpec: function () {
|
|
$that.editRoomInfo.attrs = [];
|
|
vc.getAttrSpec('building_room_attr', function (data) {
|
|
data.forEach(item => {
|
|
item.value = '';
|
|
item.values = [];
|
|
$that._loadAttrValue(item.specCd, item.values);
|
|
if (item.specShow == 'Y') {
|
|
$that.editRoomInfo.attrs.push(item);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
_loadAttrValue: function (_specCd, _values) {
|
|
vc.getAttrValue(_specCd, function (data) {
|
|
data.forEach(item => {
|
|
if (item.valueShow == 'Y') {
|
|
_values.push(item);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
editRoomValidate: function () {
|
|
return vc.validate.validate({
|
|
editRoomInfo: $that.editRoomInfo
|
|
}, {
|
|
'editRoomInfo.unitId': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "小区楼房屋不能为空"
|
|
}],
|
|
'editRoomInfo.roomNum': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "房屋编号不能为空"
|
|
},
|
|
{
|
|
limit: "maxLength",
|
|
param: "12",
|
|
errInfo: "房屋编号长度不能超过12位"
|
|
},
|
|
],
|
|
'editRoomInfo.layer': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "房屋楼层高度不能为空"
|
|
}],
|
|
'editRoomInfo.state': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "房间状态不能为空"
|
|
}],
|
|
'editRoomInfo.apartment': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "户型不能为空"
|
|
}],
|
|
'editRoomInfo.builtUpArea': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "建筑面积不能为空"
|
|
},
|
|
{
|
|
limit: "money",
|
|
param: "",
|
|
errInfo: "建筑面积错误,如 300.00"
|
|
},
|
|
{
|
|
limit: "maxLength",
|
|
param: "12",
|
|
errInfo: "建筑面积数字长度不能超过6位"
|
|
}
|
|
],
|
|
'editRoomInfo.roomArea': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "室内面积不能为空"
|
|
},
|
|
{
|
|
limit: "money",
|
|
param: "",
|
|
errInfo: "室内面积错误,如 300.00"
|
|
},
|
|
],
|
|
'editRoomInfo.feeCoefficient': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "算费系数不能为空"
|
|
},
|
|
{
|
|
limit: "money",
|
|
param: "",
|
|
errInfo: "算费系数错误,如 300.00"
|
|
}
|
|
],
|
|
'editRoomInfo.roomSubType': [{
|
|
limit: "required",
|
|
param: "",
|
|
errInfo: "房屋类型不能为空"
|
|
}],
|
|
'editRoomInfo.remark': [{
|
|
limit: "maxLength",
|
|
param: "200",
|
|
errInfo: "备注长度不能超过200位"
|
|
}]
|
|
});
|
|
},
|
|
editRoom: function () {
|
|
if (!$that.editRoomValidate()) {
|
|
vc.toast(vc.validate.errInfo);
|
|
return;
|
|
}
|
|
$that.editRoomInfo.apartment = $that.editRoomInfo.apartment1 + $that.editRoomInfo.apartment2;
|
|
if ('' == $that.editRoomInfo.unitPrice || null == $that.editRoomInfo.unitPrice) {
|
|
$that.editRoomInfo.unitPrice = '0';
|
|
}
|
|
vc.http.apiPost(
|
|
'/room.updateRoom',
|
|
JSON.stringify($that.editRoomInfo), {
|
|
emulateJSON: true
|
|
},
|
|
function (json, res) {
|
|
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
|
let _json = JSON.parse(json);
|
|
if (_json.code == 0) {
|
|
//关闭model
|
|
$('#editRoomModel').modal('hide');
|
|
vc.emit('room', 'loadData', {
|
|
floorId: $that.editRoomInfo.floorId
|
|
});
|
|
vc.toast("修改成功");
|
|
return;
|
|
} else {
|
|
vc.toast(_json.msg);
|
|
}
|
|
},
|
|
function (errInfo, error) {
|
|
console.log('请求失败处理');
|
|
vc.toast(errInfo);
|
|
});
|
|
},
|
|
refreshEditRoomInfo: function () {
|
|
let _attrs = $that.editRoomInfo.attrs;
|
|
_attrs.forEach(_item => {
|
|
_item.attrId = '';
|
|
_item.value = '';
|
|
});
|
|
$that.editRoomInfo = {
|
|
roomId: '',
|
|
unitId: '',
|
|
roomNum: '',
|
|
layer: '',
|
|
section: '0',
|
|
apartment: '',
|
|
apartment1: '',
|
|
apartment2: '',
|
|
builtUpArea: '',
|
|
feeCoefficient: '1.00',
|
|
state: '',
|
|
remark: '',
|
|
communityId: '',
|
|
attrs: _attrs,
|
|
roomSubType: '110',
|
|
roomArea: '',
|
|
roomRent: '0',
|
|
roomSubTypes: []
|
|
}
|
|
}
|
|
}
|
|
});
|
|
})(window.vc, window.$that); |