/** 入驻小区 **/ (function (vc) { var DEFAULT_PAGE = 1; var DEFAULT_ROWS = 10; vc.extends({ data: { simplifyRoomFeeInfo: { total: 0, records: 1, fees: [], monthFees: [], roomId: '', roomName: '', name: '', floorNum: '', unitNum: '', roomNum: '', feeConfigs: [], configId: '', feeTypeCds: [], feeTypeCd: '', state: '2008001', totalAmount: 0.0, roomType: '', ownerFee: 'N', ownerId: '', showFlag: 'DEFAULT' } }, _initMethod: function () { vc.popover('popover-show'); vc.popover('popover-show-endTime'); vc.popover('popover-show-deadlineTime'); }, _initEvent: function () { //切换 至费用页面 vc.on('simplifyRoomFee', 'switch', function (_param) { console.log('Received switch event with room info:', _param); $that.clearSimplifyRoomFeeInfo(); if (!_param.roomId) { console.error('No roomId provided in switch event:', _param); return; } // 先复制所有参数到组件数据 vc.copyObject(_param, $that.simplifyRoomFeeInfo); console.log('After copying room info:', $that.simplifyRoomFeeInfo); // 先获取字典数据 vc.getDict('pay_fee_config', "fee_type_cd", function (_data) { $that.simplifyRoomFeeInfo.feeTypeCds = _data; console.log('Fetched fee type CDs:', _data); // 再加载费用数据 console.log('Loading fee data for roomId:', $that.simplifyRoomFeeInfo.roomId); $that._listSimplifyRoomFee(DEFAULT_PAGE, DEFAULT_ROWS); }); }); vc.on('simplifyRoomFee', 'notify', function () { $that._listSimplifyRoomFee(DEFAULT_PAGE, DEFAULT_ROWS); }); vc.on('simplifyRoomFee', 'paginationPlus', 'page_event', function (_currentPage) { $that._listSimplifyRoomFee(_currentPage, DEFAULT_ROWS); }); }, methods: { getOnePrice1: function (fee) { let _price = fee.mwPrice; if (!_price) { return fee.squarePrice; } if (parseFloat(_price) > 0) { return _price; } return fee.squarePrice; }, _listSimplifyRoomFee: function (_page, _row) { let param = { params: { page: _page, row: _row, communityId: vc.getCurrentCommunity().communityId, payerObjId: $that.simplifyRoomFeeInfo.roomId, payerObjType: '3333', configId: $that.simplifyRoomFeeInfo.configId, state: $that.simplifyRoomFeeInfo.state, feeTypeCd: $that.simplifyRoomFeeInfo.feeTypeCd, } }; //按业主查询 if ($that.simplifyRoomFeeInfo.ownerFee == 'Y') { param.params.payerObjId = ''; param.params.ownerId = $that.simplifyRoomFeeInfo.ownerId; } //发送get请求 vc.http.apiGet('/fee.listFee', param, function (json, res) { console.log('Fee API response:', json); console.log('Response status:', res.status); try { let _feeConfigInfo = JSON.parse(json); console.log('Parsed fee config info:', _feeConfigInfo); // 处理不同的数据格式 let feeData = []; let total = 0; let records = 0; // 检查数据格式 if (_feeConfigInfo.fees && Array.isArray(_feeConfigInfo.fees)) { // 格式1: { fees: [...], total: 10, records: 10 } feeData = _feeConfigInfo.fees; total = _feeConfigInfo.total || feeData.length; records = _feeConfigInfo.records || feeData.length; } else if (Array.isArray(_feeConfigInfo)) { // 格式2: [...]直接返回数组 feeData = _feeConfigInfo; total = feeData.length; records = feeData.length; } else if (_feeConfigInfo.data && Array.isArray(_feeConfigInfo.data)) { // 格式3: { data: [...], total: 10, records: 10 } feeData = _feeConfigInfo.data; total = _feeConfigInfo.total || feeData.length; records = _feeConfigInfo.records || feeData.length; } else { // 其他格式 console.error('Unknown fee data format:', _feeConfigInfo); feeData = []; total = 0; records = 0; } console.log('Processed fee data:', { feeData: feeData, total: total, records: records, feeCount: feeData.length }); // 直接更新组件数据,不使用sort,避免排序问题 $that.simplifyRoomFeeInfo.total = total; $that.simplifyRoomFeeInfo.records = records; let _totalAmount = 0.0; feeData.forEach(item => { if (item && item.amountOwed) { _totalAmount += parseFloat(item.amountOwed); } }); $that.simplifyRoomFeeInfo.totalAmount = _totalAmount.toFixed(2); // 直接赋值,不排序,避免排序问题 $that.simplifyRoomFeeInfo.fees = feeData; console.log('Assigned fees to component:', $that.simplifyRoomFeeInfo.fees); console.log('Fees length:', $that.simplifyRoomFeeInfo.fees.length); // 确保showFlag设置正确 if ($that.simplifyRoomFeeInfo.showFlag !== 'DEFAULT') { $that.simplifyRoomFeeInfo.showFlag = 'DEFAULT'; console.log('Reset showFlag to DEFAULT'); } // 初始化分页 vc.emit('simplifyRoomFee', 'paginationPlus', 'init', { total: records, dataCount: total, currentPage: _page }); console.log('Component data after update:', { feesLength: $that.simplifyRoomFeeInfo.fees.length, total: $that.simplifyRoomFeeInfo.total, records: $that.simplifyRoomFeeInfo.records, totalAmount: $that.simplifyRoomFeeInfo.totalAmount, showFlag: $that.simplifyRoomFeeInfo.showFlag }); } catch (error) { console.error('Error processing fee data:', error); // 出错时重置数据 $that.simplifyRoomFeeInfo.fees = []; $that.simplifyRoomFeeInfo.total = 0; $that.simplifyRoomFeeInfo.records = 0; $that.simplifyRoomFeeInfo.totalAmount = '0.00'; } }, function (errInfo, error) { console.error('请求失败处理:', errInfo, error); // 出错时重置数据 $that.simplifyRoomFeeInfo.fees = []; $that.simplifyRoomFeeInfo.total = 0; $that.simplifyRoomFeeInfo.records = 0; $that.simplifyRoomFeeInfo.totalAmount = '0.00'; } ); }, _roomFeeCompare: function (a, b) { // 添加安全检查,避免字段不存在导致的错误 if (!a || !b) { return 0; } var val1 = a.payerObjName || ''; var val2 = b.payerObjName || ''; if (val1 < val2) { return -1; } else if (val1 > val2) { return 1; } else { return 0; } }, _toOwnerPayFee: function () { vc.jumpToPage('/#/pages/property/owePayFeeOrder?payObjId=' + $that.simplifyRoomFeeInfo.roomId + "&payObjType=3333&roomName=" + $that.simplifyRoomFeeInfo.roomName); }, _openRoomCreateFeeAddModal: function () { $that.simplifyRoomFeeInfo.ownerName = $that.simplifyRoomFeeInfo.name; vc.emit('roomCreateFeeAdd', 'openRoomCreateFeeAddModal', { isMore: false, room: $that.simplifyRoomFeeInfo, ownerName: $that.simplifyRoomFeeInfo.name }); }, _openAddMeterWaterSimplifyModal: function () { vc.emit('addMeterWater', 'openAddMeterWaterModal', { roomId: $that.simplifyRoomFeeInfo.roomId, roomName: $that.simplifyRoomFeeInfo.roomName, ownerName: $that.simplifyRoomFeeInfo.name }); }, _getAttrValue: function (_attrs, _specCd) { let _value = ""; _attrs.forEach(item => { if (item.specCd == _specCd) { _value = item.value; return; } }); return _value; }, _getDeadlineTime: function (_fee) { if (_fee.amountOwed == 0 && _fee.endTime == _fee.maxEndTime) { return "-"; } if (_fee.state == '2009001') { return "-"; } return vc.dateFormat(_fee.maxEndTime); }, _getEndTime: function (_fee) { if (_fee.state == '2009001') { return "-"; } return vc.dateFormat(_fee.endTime); }, _openProxyFeeModal: function () { //创建代收费用 vc.emit('addProxyFee', 'openAddProxyFeeModal', { roomId: $that.simplifyRoomFeeInfo.roomId, roomName: $that.simplifyRoomFeeInfo.roomName, ownerName: $that.simplifyRoomFeeInfo.name }); }, _payFee: function (_fee) { _fee.roomName = $that.simplifyRoomFeeInfo.roomName; _fee.builtUpArea = $that.simplifyRoomFeeInfo.builtUpArea; // vc.jumpToPage('/#/pages/property/payFeeOrder?' + vc.objToGetParam(_fee)); vc.jumpToPage('/#/pages/property/payFeeOrder?feeId=' + _fee.feeId + '&monthCount=' + _fee.monthCount ); }, _editFee: function (_fee) { // 计费结束时间 _fee.maxEndTime = $that._getAttrValue(_fee.feeAttrs, '390010'); vc.emit('editFee', 'openEditFeeModal', _fee); }, _payFeeHis: function (_fee) { _fee.builtUpArea = $that.simplifyRoomFeeInfo.builtUpArea; vc.jumpToPage('/#/pages/property/propertyFee?' + vc.objToGetParam(_fee)); }, _deleteFee: function (_fee) { vc.emit('deleteFee', 'openDeleteFeeModal', { communityId: vc.getCurrentCommunity().communityId, feeId: _fee.feeId }); }, _finishFee: function (_fee) { vc.emit('finishFee', 'openFinishFeeModal', { communityId: vc.getCurrentCommunity().communityId, feeId: _fee.feeId }); // console.log("触发了结束费用模态框的事件"); }, _openTempImportRoomFeeModal: function () { vc.emit('tempImportRoomFee', 'openImportRoomFeeModal', { roomId: $that.simplifyRoomFeeInfo.roomId, roomName: $that.simplifyRoomFeeInfo.roomName, ownerName: $that.simplifyRoomFeeInfo.name }) }, clearSimplifyRoomFeeInfo: function () { let _feeConfigs = []; if ($that.roomCreateFeeAddInfo && $that.roomCreateFeeAddInfo.feeTypeCds) { _feeConfigs = $that.roomCreateFeeAddInfo.feeTypeCds; } $that.simplifyRoomFeeInfo = { total: 0, records: 1, fees: [], monthFees: [], accounts: [], roomId: '', name: '', roomName: '', floorNum: '', unitNum: '', roomNum: '', feeConfigs: _feeConfigs, feeTypeCd: '', configId: '', state: '2008001', totalAmount: 0.0, roomType: '', ownerFee: 'N', ownerId: '', showFlag: 'DEFAULT' } }, _changeSimplifyRoomFeeFeeTypeCd: function (_feeTypeCd) { $that.simplifyRoomFeeInfo.configId = ''; vc.emit('simplifyRoomFee', 'notify', {}); var param = { params: { page: 1, row: 50, communityId: vc.getCurrentCommunity().communityId, feeTypeCd: _feeTypeCd, isDefault: '', valid: '1' } }; //发送get请求 vc.http.apiGet('/feeConfig.listFeeConfigs', param, function (json, res) { var _feeConfigManageInfo = JSON.parse(json); $that.simplifyRoomFeeInfo.feeConfigs = _feeConfigManageInfo.feeConfigs; }, function (errInfo, error) { console.log('请求失败处理'); }); }, _changeSimplifyRoomConfigId: function () { vc.emit('simplifyRoomFee', 'notify', {}); }, _simplifyRoomGetFeeOwnerInfo: function (attrs) { let ownerName = $that._getAttrValue(attrs, '390008'); let ownerLink = $that._getAttrValue(attrs, '390009'); return '业主:' + ownerName + ',电话:' + ownerLink; }, _getSimplifyRoomFeeRoomName: function (fee) { if ($that.simplifyRoomFeeInfo.ownerFee != 'Y') { return ''; } let _feeName = '' fee.feeAttrs.forEach(item => { if (item.specCd == '390012') { _feeName = '(' + item.value + ')'; } }) return _feeName; }, _openBatchPayRoomFeeModal: function () { vc.jumpToPage('/#/pages/property/batchPayFeeOrder?ownerId=' + $that.simplifyRoomFeeInfo.ownerId + "&payerObjType=3333") }, _openMonthPayRoomFeeModal: function () { vc.jumpToPage('/#/pages/property/payFeeMonthOrder?payerObjId=' + $that.simplifyRoomFeeInfo.roomId + "&payerObjType=3333"); }, _openRoomCreateFeeComboModal: function () { vc.jumpToPage('/#/pages/property/createFeeByCombo?payerObjId=' + $that.simplifyRoomFeeInfo.roomId + "&payerObjName=" + $that.simplifyRoomFeeInfo.roomName + "&payerObjType=3333") }, _viewRoomFeeConfig: function (_fee) { let param = { params: { page: 1, row: 1, communityId: vc.getCurrentCommunity().communityId, configId: _fee.configId } }; //发送get请求 vc.http.apiGet('/feeConfig.listFeeConfigs', param, function (json, res) { let _feeConfigManageInfo = JSON.parse(json); let _feeConfig = _feeConfigManageInfo.feeConfigs[0]; vc.emit('viewData', 'openViewDataModal', { title: _fee.feeName + " 费用项", data: { "费用项ID": _feeConfig.configId, "费用类型": _feeConfig.feeTypeCdName, "收费项目": _feeConfig.feeName, "费用标识": _feeConfig.feeFlagName, "催缴类型": _feeConfig.billTypeName, "付费类型": _feeConfig.paymentCd == '1200' ? '预付费' : '后付费', "缴费周期": _feeConfig.paymentCycle, "应收开始时间": _feeConfig.startTime, "应收结束时间": _feeConfig.endTime, "公式": _feeConfig.computingFormulaName, "计费单价": _feeConfig.computingFormula == '2002' ? '-' : _feeConfig.squarePrice, "附加/固定费用": _feeConfig.additionalAmount, } }) }, function (errInfo, error) { console.log('请求失败处理'); } ); }, _viewRoomFee: function (_fee) { let _data = { "费用ID": _fee.feeId, "费用标识": _fee.feeFlagName, "费用类型": _fee.feeTypeCdName, "付费对象": _fee.payerObjName, "费用项": _fee.feeName, "费用状态": _fee.stateName, "建账时间": _fee.startTime, "应收开始时间": $that._getEndTime(_fee), "应收结束时间": $that._getDeadlineTime(_fee), "批次": _fee.batchId, }; _fee.feeAttrs.forEach(attr => { _data[attr.specCdName] = attr.value; }) vc.emit('viewData', 'openViewDataModal', { title: _fee.feeName + " 详情", data: _data }); }, _changeSimplifyRoomShowFlag: function () { if ($that.simplifyRoomFeeInfo.showFlag == 'MONTH') { $that._listSimplifyRoomMonthFee(DEFAULT_PAGE, DEFAULT_ROWS) } else { $that._listSimplifyRoomFee(DEFAULT_PAGE, DEFAULT_ROWS); } }, _listSimplifyRoomMonthFee: function (_page, _row) { let param = { params: { page: 1, row: 100, communityId: vc.getCurrentCommunity().communityId, objId: $that.simplifyRoomFeeInfo.roomId, payerObjType: '3333', configId: $that.simplifyRoomFeeInfo.configId, feeTypeCd: $that.simplifyRoomFeeInfo.feeTypeCd, detailId: '-1', feeState: '2008001' } }; //按业主查询 if ($that.simplifyRoomFeeInfo.ownerFee == 'Y') { param.params.payerObjId = ''; param.params.ownerId = $that.simplifyRoomFeeInfo.ownerId; } //发送get请求 vc.http.apiGet('/fee.listMonthFee', param, function (json) { let _feeConfigInfo = JSON.parse(json); $that.simplifyRoomFeeInfo.total = _feeConfigInfo.total; $that.simplifyRoomFeeInfo.records = _feeConfigInfo.records; let _totalAmount = 0.0; _feeConfigInfo.data.forEach(item => { _totalAmount += parseFloat(item.receivableAmount); }) $that.simplifyRoomFeeInfo.totalAmount = _totalAmount.toFixed(2); $that.simplifyRoomFeeInfo.monthFees = _feeConfigInfo.data; }, function () { console.log('请求失败处理'); } ); }, } }); })(window.vc);