/**
|
入驻小区
|
**/
|
(function (vc) {
|
var DEFAULT_PAGE = 1;
|
var DEFAULT_ROWS = 10;
|
vc.extends({
|
data: {
|
applyRoomDiscountManageInfo: {
|
applyRoomDiscounts: [],
|
applyTypes: [],
|
total: 0,
|
records: 1,
|
moreCondition: false,
|
ardId: '',
|
states: [],
|
conditions: {
|
roomName: '',
|
applyType: '',
|
state: '',
|
communityId: ''
|
}
|
}
|
},
|
_initMethod: function () {
|
// 确保组件实例存在
|
if (!vc.component) {
|
console.error('组件实例不存在,延迟初始化');
|
// 延迟执行初始化操作
|
setTimeout(function() {
|
if (vc.component) {
|
vc.component._initMethod();
|
}
|
}, 100);
|
return;
|
}
|
|
vc.getDict('apply_room_discount', "state", function (_data) {
|
if (vc.component && vc.component.applyRoomDiscountManageInfo) {
|
// 确保states是一个数组
|
if (_data && _data.data && Array.isArray(_data.data)) {
|
vc.component.applyRoomDiscountManageInfo.states = _data.data;
|
} else if (Array.isArray(_data)) {
|
vc.component.applyRoomDiscountManageInfo.states = _data;
|
} else {
|
vc.component.applyRoomDiscountManageInfo.states = [];
|
}
|
}
|
});
|
|
if (typeof vc.component._listApplyRoomDiscounts === 'function') {
|
vc.component._listApplyRoomDiscounts(DEFAULT_PAGE, DEFAULT_ROWS);
|
}
|
|
if (typeof vc.component._listApplyRoomDiscountTypes === 'function') {
|
vc.component._listApplyRoomDiscountTypes();
|
}
|
},
|
_initEvent: function () {
|
vc.on('applyRoomDiscountManage', 'listApplyRoomDiscount', function (_param) {
|
if (vc.component && typeof vc.component._listApplyRoomDiscounts === 'function') {
|
vc.component._listApplyRoomDiscounts(DEFAULT_PAGE, DEFAULT_ROWS);
|
}
|
});
|
vc.on('pagination', 'page_event', function (_currentPage) {
|
if (vc.component && typeof vc.component._listApplyRoomDiscounts === 'function') {
|
vc.component._listApplyRoomDiscounts(_currentPage, DEFAULT_ROWS);
|
}
|
});
|
},
|
methods: {
|
_listApplyRoomDiscounts: function (_page, _rows) {
|
if (!vc.component || !vc.component.applyRoomDiscountManageInfo) {
|
console.error('组件实例不存在');
|
return;
|
}
|
|
// 验证社区信息是否存在
|
let currentCommunity = vc.getCurrentCommunity();
|
if (!currentCommunity || !currentCommunity.communityId) {
|
console.error('社区信息不存在');
|
return;
|
}
|
|
vc.component.applyRoomDiscountManageInfo.conditions.page = _page;
|
vc.component.applyRoomDiscountManageInfo.conditions.row = _rows;
|
// 小区id
|
vc.component.applyRoomDiscountManageInfo.conditions.communityId = currentCommunity.communityId;
|
var param = {
|
params: vc.component.applyRoomDiscountManageInfo.conditions
|
};
|
//发送get请求
|
vc.http.apiGet('/applyRoomDiscount/queryApplyRoomDiscount',
|
param,
|
function (json, res) {
|
if (!vc.component || !vc.component.applyRoomDiscountManageInfo) {
|
console.error('组件实例不存在');
|
return;
|
}
|
|
try {
|
let _json = JSON.parse(json);
|
vc.component.applyRoomDiscountManageInfo.total = _json.total;
|
vc.component.applyRoomDiscountManageInfo.records = _json.records;
|
vc.component.applyRoomDiscountManageInfo.applyRoomDiscounts = _json.data || [];
|
vc.emit('pagination', 'init', {
|
total: vc.component.applyRoomDiscountManageInfo.records,
|
dataCount: vc.component.applyRoomDiscountManageInfo.total,
|
currentPage: _page
|
});
|
} catch (e) {
|
console.error('处理API响应失败:', e);
|
if (vc.component && vc.component.applyRoomDiscountManageInfo) {
|
vc.component.applyRoomDiscountManageInfo.applyRoomDiscounts = [];
|
}
|
}
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
if (vc.component && vc.component.applyRoomDiscountManageInfo) {
|
vc.component.applyRoomDiscountManageInfo.applyRoomDiscounts = [];
|
}
|
}
|
);
|
},
|
_openAddApplyRoomDiscountModal: function () {
|
vc.emit('addApplyRoomDiscount', 'openAddApplyRoomDiscountModal', {});
|
},
|
//验房
|
_openEditApplyRoomDiscountModel: function (_applyRoomDiscount) {
|
_applyRoomDiscount = JSON.stringify(_applyRoomDiscount);
|
vc.emit('editApplyRoomDiscount', 'openEditApplyRoomDiscountModal', _applyRoomDiscount);
|
},
|
//跟踪记录
|
_openApplyRoomDiscountRecord: function (_applyRoomDiscount) {
|
vc.jumpToPage('/#/pages/property/listApplyRoomDiscountRecord?ardId=' + _applyRoomDiscount.ardId +
|
'&roomId=' + _applyRoomDiscount.roomId + '&roomName=' + _applyRoomDiscount.roomName +
|
'&state=' + _applyRoomDiscount.state + '&stateName=' + _applyRoomDiscount.stateName);
|
},
|
//审核
|
_openReviewApplyRoomDiscountModel: function (_applyRoomDiscount) {
|
_applyRoomDiscount = JSON.stringify(_applyRoomDiscount);
|
vc.emit('reviewApplyRoomDiscount', 'openReviewApplyRoomDiscountModal', _applyRoomDiscount);
|
},
|
//删除
|
_openDeleteApplyRoomDiscountModel: function (_applyRoomDiscount) {
|
vc.emit('deleteApplyRoomDiscount', 'openDeleteApplyRoomDiscountModal', _applyRoomDiscount);
|
},
|
//修改
|
_openEditApplyRoomDiscountRecordModel: function (_applyRoomDiscount) {
|
vc.emit('editApplyRoomDiscountRecord', 'openEditApplyRoomDiscountRecordModal', _applyRoomDiscount);
|
},
|
//查询
|
_queryApplyRoomDiscountMethod: function () {
|
if (vc.component && typeof vc.component._listApplyRoomDiscounts === 'function') {
|
vc.component._listApplyRoomDiscounts(DEFAULT_PAGE, DEFAULT_ROWS);
|
}
|
},
|
//重置
|
_resetApplyRoomDiscountMethod: function () {
|
if (!vc.component || !vc.component.applyRoomDiscountManageInfo) {
|
console.error('组件实例不存在');
|
return;
|
}
|
vc.component.applyRoomDiscountManageInfo.conditions.roomName = "";
|
vc.component.applyRoomDiscountManageInfo.conditions.applyType = "";
|
vc.component.applyRoomDiscountManageInfo.conditions.state = "";
|
if (typeof vc.component._listApplyRoomDiscounts === 'function') {
|
vc.component._listApplyRoomDiscounts(DEFAULT_PAGE, DEFAULT_ROWS);
|
}
|
},
|
_listApplyRoomDiscountTypes: function () {
|
if (!vc.component || !vc.component.applyRoomDiscountManageInfo) {
|
console.error('组件实例不存在');
|
return;
|
}
|
|
// 验证社区信息是否存在
|
let currentCommunity = vc.getCurrentCommunity();
|
if (!currentCommunity || !currentCommunity.communityId) {
|
console.error('社区信息不存在');
|
return;
|
}
|
|
let param = {
|
params: {
|
page: 1,
|
row: 50,
|
communityId: currentCommunity.communityId
|
}
|
};
|
//发送get请求
|
vc.http.apiGet('/applyRoomDiscount/queryApplyRoomDiscountType',
|
param,
|
function (json, res) {
|
if (!vc.component || !vc.component.applyRoomDiscountManageInfo) {
|
console.error('组件实例不存在');
|
return;
|
}
|
|
try {
|
let _json = JSON.parse(json);
|
vc.component.applyRoomDiscountManageInfo.applyTypes = _json.data && Array.isArray(_json.data) ? _json.data : [];
|
} catch (e) {
|
console.error('处理API响应失败:', e);
|
if (vc.component && vc.component.applyRoomDiscountManageInfo) {
|
vc.component.applyRoomDiscountManageInfo.applyTypes = [];
|
}
|
}
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
if (vc.component && vc.component.applyRoomDiscountManageInfo) {
|
vc.component.applyRoomDiscountManageInfo.applyTypes = [];
|
}
|
}
|
);
|
},
|
//导出
|
_exportApplyRoomDiscountModal: function () {
|
if (!vc.component || !vc.component.applyRoomDiscountManageInfo) {
|
console.error('组件实例不存在');
|
return;
|
}
|
|
// 验证社区信息是否存在
|
let currentCommunity = vc.getCurrentCommunity();
|
if (!currentCommunity || !currentCommunity.communityId) {
|
console.error('社区信息不存在');
|
return;
|
}
|
|
vc.component.applyRoomDiscountManageInfo.conditions.communityId = currentCommunity.communityId;
|
vc.component.applyRoomDiscountManageInfo.conditions.pagePath = 'applyRoomDiscount';
|
let param = {
|
params: vc.component.applyRoomDiscountManageInfo.conditions
|
};
|
//发送get请求
|
vc.http.apiGet('/export.exportData', param,
|
function (json, res) {
|
let _json = JSON.parse(json);
|
vc.toast(_json.msg);
|
if (_json.code == 0) {
|
vc.jumpToPage('/#/pages/property/downloadTempFile?tab=下载中心')
|
}
|
},
|
function (errInfo, error) {
|
console.log('请求失败处理');
|
});
|
},
|
_moreCondition: function () {
|
if (!vc.component || !vc.component.applyRoomDiscountManageInfo) {
|
console.error('组件实例不存在');
|
return;
|
}
|
if (vc.component.applyRoomDiscountManageInfo.moreCondition) {
|
vc.component.applyRoomDiscountManageInfo.moreCondition = false;
|
} else {
|
vc.component.applyRoomDiscountManageInfo.moreCondition = true;
|
}
|
},
|
_openDiscountType:function(){
|
vc.jumpToPage('/#/pages/fee/discountType?tab=优惠类型');
|
}
|
}
|
});
|
})(window.vc);
|