| | |
| | | data: { |
| | | costDetailInfo: { |
| | | costDetails: [], |
| | | communityList: [], |
| | | paginationInfo: { |
| | | currentPage: 1, |
| | | rows: DEFAULT_ROWS, |
| | |
| | | conditions: { |
| | | date: '', |
| | | communityName: '', |
| | | communityCode: '' |
| | | communityCode: '', |
| | | communityId: vc.getCurrentCommunity().communityId, |
| | | flowNumber: '', |
| | | projectCode: '', |
| | | year: '', |
| | | projectName: '', |
| | | _communityName: vc.getCurrentCommunity().name |
| | | } |
| | | } |
| | | }, |
| | | _initMethod: function () { |
| | | $that = vc.component; |
| | | $that._injectStyles(); |
| | | $that._listCostDetails(DEFAULT_PAGE, DEFAULT_ROWS); |
| | | $that.costDetailInfo.conditions.communityId = vc.getCurrentCommunity().communityId; |
| | | $that.costDetailInfo.conditions._communityName = vc.getCurrentCommunity().name; |
| | | $that._loadCommunityList(); |
| | | $that._initDate(); |
| | | }, |
| | | _initEvent: function () { |
| | |
| | | }, |
| | | methods: { |
| | | _initDate: function () { |
| | | $(".queryDate").datetimepicker({ |
| | | language: 'zh-CN', |
| | | fontAwesome: 'fa', |
| | | format: 'yyyy-mm-dd hh:ii:ss', |
| | | initTime: true, |
| | | initialDate: new Date(), |
| | | autoClose: 1, |
| | | todayBtn: true |
| | | }); |
| | | $('.queryDate').datetimepicker() |
| | | .on('changeDate', function (ev) { |
| | | var value = $(".queryDate").val(); |
| | | $that.costDetailInfo.conditions.date = value; |
| | | }); |
| | | //防止多次点击时间插件失去焦点 |
| | | var queryDateElements = document.getElementsByClassName('form-control queryDate'); |
| | | if (queryDateElements.length > 0) { |
| | | queryDateElements[0].addEventListener('click', function(e) { |
| | | e.currentTarget.blur(); |
| | | }); |
| | | }, |
| | | _loadCommunityList: function () { |
| | | var communityInfos = vc.getCommunitys(); |
| | | if (communityInfos && Array.isArray(communityInfos) && communityInfos.length > 0) { |
| | | $that.costDetailInfo.communityList = communityInfos; |
| | | $that.costDetailInfo.conditions.communityName = communityInfos[0].name; |
| | | } else { |
| | | var currentCommunity = vc.getCurrentCommunity(); |
| | | if (currentCommunity && currentCommunity.name) { |
| | | $that.costDetailInfo.communityList = [currentCommunity]; |
| | | $that.costDetailInfo.conditions.communityName = currentCommunity.name; |
| | | } |
| | | } |
| | | $that._listCostDetails(DEFAULT_PAGE, DEFAULT_ROWS); |
| | | }, |
| | | _listCostDetails: function (_page, _rows) { |
| | | $that.costDetailInfo.conditions.page = _page; |
| | | $that.costDetailInfo.conditions.row = _rows; |
| | | $that.costDetailInfo.conditions.communityId = vc.getCurrentCommunity().communityId; |
| | | var param = { |
| | | params: $that.costDetailInfo.conditions |
| | | var selectedCommunityName = $that.costDetailInfo.conditions.communityName || vc.getCurrentCommunity().name; |
| | | var params = { |
| | | communityName: selectedCommunityName, |
| | | page: _page, |
| | | row: _rows |
| | | }; |
| | | //发送get请求 |
| | | vc.http.apiGet('/costDetail/queryCostDetail', |
| | | |
| | | if ($that.costDetailInfo.conditions.flowNumber) { |
| | | params.flowNumber = $that.costDetailInfo.conditions.flowNumber; |
| | | } |
| | | if ($that.costDetailInfo.conditions.projectCode) { |
| | | params.projectCode = $that.costDetailInfo.conditions.projectCode; |
| | | } |
| | | if ($that.costDetailInfo.conditions.year) { |
| | | params.year = parseInt($that.costDetailInfo.conditions.year); |
| | | } |
| | | if ($that.costDetailInfo.conditions.projectName) { |
| | | params.projectName = $that.costDetailInfo.conditions.projectName; |
| | | } |
| | | |
| | | var param = { |
| | | params: params |
| | | }; |
| | | |
| | | vc.http.apiGet('/maintenancePayment/queryMaintenancePayment', |
| | | param, |
| | | function (json, res) { |
| | | var _json = JSON.parse(json); |
| | | $that.costDetailInfo.paginationInfo.dataCount = _json.total || 0; |
| | | $that.costDetailInfo.paginationInfo.total = _json.records || 1; |
| | | $that.costDetailInfo.costDetails = _json.data || []; |
| | | $that.costDetailInfo.paginationInfo.currentPage = _page; |
| | | $that._freshPageList(); |
| | | try { |
| | | var _json = JSON.parse(json); |
| | | |
| | | if (_json.code === 0 && _json.data) { |
| | | var records = Array.isArray(_json.data) ? _json.data : []; |
| | | |
| | | var mappedRecords = records.map(function (item) { |
| | | var dateStr = ''; |
| | | if (item.date) { |
| | | dateStr = item.date.substring(0, 7); |
| | | } else if (item.year && item.month) { |
| | | var monthStr = item.month < 10 ? '0' + item.month : String(item.month); |
| | | dateStr = item.year + '-' + monthStr; |
| | | } |
| | | |
| | | return { |
| | | flowCode: item.flowNumber || '--', |
| | | communityCode: item.projectCode || '--', |
| | | communityName: item.projectName || '--', |
| | | date: dateStr, |
| | | projectContent: item.projectContent || '--', |
| | | managementAmount: item.managementOfficeAmount || '--', |
| | | managementStamped: item.managementOfficeSeal === '是' ? '1' : '0', |
| | | committeeAmount: item.ownersCommitteeAmount || '--', |
| | | appraisalAmount: item.auditAmount || '--', |
| | | committeeStamped: item.ownersCommitteeSeal === '是' ? '1' : '0', |
| | | approvalDepartment: item.reportDepartment || '--', |
| | | fundTypeLevel1: item.fundTypeLevel1 || '--', |
| | | fundTypeLevel2: item.fundTypeLevel2 || '--', |
| | | buildingType: item.buildingOrAll || '--', |
| | | maintenanceType: item.maintenanceType || '--', |
| | | costDetailId: item.id, |
| | | _originalData: item |
| | | }; |
| | | }); |
| | | |
| | | var total = _json.total || 0; |
| | | var totalPages = _json.records || 1; |
| | | |
| | | $that.costDetailInfo.paginationInfo.dataCount = total; |
| | | $that.costDetailInfo.paginationInfo.total = totalPages; |
| | | $that.costDetailInfo.costDetails = mappedRecords; |
| | | $that.costDetailInfo.paginationInfo.currentPage = _page; |
| | | $that._freshPageList(); |
| | | } else { |
| | | console.error('接口返回错误:', _json.msg || '未知错误', _json); |
| | | vc.toast(_json.msg || '查询失败'); |
| | | $that.costDetailInfo.costDetails = []; |
| | | $that.costDetailInfo.paginationInfo.dataCount = 0; |
| | | $that.costDetailInfo.paginationInfo.total = 1; |
| | | $that._freshPageList(); |
| | | } |
| | | } catch (e) { |
| | | vc.toast('数据解析失败'); |
| | | $that.costDetailInfo.costDetails = []; |
| | | $that.costDetailInfo.paginationInfo.dataCount = 0; |
| | | $that.costDetailInfo.paginationInfo.total = 1; |
| | | $that._freshPageList(); |
| | | } |
| | | }, |
| | | function (errInfo, error) { |
| | | console.log('请求失败处理'); |
| | | vc.toast('请求失败,请检查网络连接'); |
| | | $that.costDetailInfo.costDetails = []; |
| | | $that.costDetailInfo.paginationInfo.dataCount = 0; |
| | | $that.costDetailInfo.paginationInfo.total = 1; |
| | |
| | | var currentPage = $that.costDetailInfo.paginationInfo.currentPage; |
| | | var total = $that.costDetailInfo.paginationInfo.total; |
| | | var pageList = []; |
| | | |
| | | |
| | | if (total <= 7) { |
| | | // 总页数小于等于7,显示所有页码 |
| | | for (var i = 1; i <= total; i++) { |
| | | pageList.push({ |
| | | page: i, |
| | |
| | | }); |
| | | } |
| | | } else { |
| | | // 总页数大于7,显示部分页码 |
| | | if (currentPage <= 4) { |
| | | // 当前页在前4页 |
| | | for (var i = 1; i <= 5; i++) { |
| | | pageList.push({ |
| | | page: i, |
| | |
| | | currentPage: false |
| | | }); |
| | | } else if (currentPage >= total - 3) { |
| | | // 当前页在后4页 |
| | | pageList.push({ |
| | | page: 1, |
| | | pageView: 1, |
| | |
| | | }); |
| | | } |
| | | } else { |
| | | // 当前页在中间 |
| | | pageList.push({ |
| | | page: 1, |
| | | pageView: 1, |
| | |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | $that.costDetailInfo.paginationInfo.pageList = pageList; |
| | | }, |
| | | _queryCostDetails: function () { |
| | | $that._listCostDetails(DEFAULT_PAGE, $that.costDetailInfo.paginationInfo.rows); |
| | | }, |
| | | _resetQuery: function () { |
| | | $that.costDetailInfo.conditions.date = ''; |
| | | $that.costDetailInfo.conditions.communityName = ''; |
| | | if ($that.costDetailInfo.communityList && $that.costDetailInfo.communityList.length > 0) { |
| | | $that.costDetailInfo.conditions.communityName = $that.costDetailInfo.communityList[0].name; |
| | | } else { |
| | | $that.costDetailInfo.conditions.communityName = ''; |
| | | } |
| | | $that.costDetailInfo.conditions.communityCode = ''; |
| | | $that.costDetailInfo.conditions.flowNumber = ''; |
| | | $that.costDetailInfo.conditions.projectCode = ''; |
| | | $that.costDetailInfo.conditions.year = ''; |
| | | $that.costDetailInfo.conditions.projectName = ''; |
| | | $('.queryDate').val(''); |
| | | $that._listCostDetails(DEFAULT_PAGE, $that.costDetailInfo.paginationInfo.rows); |
| | | }, |
| | |
| | | $that._listCostDetails(page, $that.costDetailInfo.paginationInfo.rows); |
| | | }, |
| | | _downloadTemplate: function () { |
| | | // 下载模板 |
| | | vc.toast('模板下载功能'); |
| | | }, |
| | | _importCostDetail: function () { |
| | | // 打开本地文件 |
| | | vc.toast('费用导入功能'); |
| | | }, |
| | | _addCostDetail: function () { |
| | | // 跳转到添加页面 |
| | | vc.jumpToPage('/#/pages/property/costDetail/add'); |
| | | }, |
| | | _viewCostDetail: function (_item) { |
| | | // 查看详情 |
| | | vc.jumpToPage('/#/pages/property/costDetail/detail?costDetailId=' + _item.costDetailId); |
| | | }, |
| | | _viewMore: function (_item) { |
| | | // 查看更多 |
| | | vc.jumpToPage('/#/pages/property/costDetail/more?costDetailId=' + _item.costDetailId); |
| | | }, |
| | | _editCostDetail: function (_item) { |
| | | // 编辑 |
| | | vc.jumpToPage('/#/pages/property/costDetail/edit?costDetailId=' + _item.costDetailId); |
| | | }, |
| | | _deleteCostDetail: function (_item) { |
| | | vc.confirm('确定要删除这条费用明细吗?', function () { |
| | | var param = { |
| | | params: { |
| | | costDetailId: _item.costDetailId |
| | | } |
| | | }; |
| | | vc.http.apiPost('/costDetail/deleteCostDetail', |
| | | param, |
| | | function (json, res) { |
| | | vc.toast('删除成功'); |
| | | $that._listCostDetails($that.costDetailInfo.paginationInfo.currentPage, $that.costDetailInfo.paginationInfo.rows); |
| | | if (!_item || !_item.costDetailId) { |
| | | vc.toast('删除失败:缺少必要的数据'); |
| | | return; |
| | | } |
| | | if (typeof vc.confirm === 'function') { |
| | | vc.confirm('确定要删除这条费用明细吗?', function () { |
| | | var param = { |
| | | id: _item.costDetailId, |
| | | communityId: vc.getCurrentCommunity().communityId |
| | | }; |
| | | vc.http.apiPost('/maintenancePayment/deleteMaintenancePayment', |
| | | JSON.stringify(param), { |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | } |
| | | }, |
| | | function (errInfo, error) { |
| | | vc.message(errInfo); |
| | | } |
| | | ); |
| | | }); |
| | | function (json, res) { |
| | | try { |
| | | var _json = JSON.parse(json); |
| | | if (_json.code === 0 || _json.code === '0') { |
| | | vc.toast(_json.msg || '删除成功'); |
| | | $that._listCostDetails($that.costDetailInfo.paginationInfo.currentPage, $that.costDetailInfo.paginationInfo.rows); |
| | | } else { |
| | | vc.toast(_json.msg || '删除失败'); |
| | | } |
| | | } catch (e) { |
| | | console.error('删除响应解析失败:', e); |
| | | vc.toast('删除失败,请重试'); |
| | | } |
| | | }, |
| | | function (errInfo, error) { |
| | | console.error('删除请求失败:', errInfo, error); |
| | | vc.toast(errInfo || '删除失败,请检查网络连接'); |
| | | } |
| | | ); |
| | | }); |
| | | } else { |
| | | if (window.confirm('确定要删除这条费用明细吗?')) { |
| | | var param = { |
| | | id: _item.costDetailId, |
| | | communityId: vc.getCurrentCommunity().communityId |
| | | }; |
| | | vc.http.apiPost('/maintenancePayment/deleteMaintenancePayment', |
| | | JSON.stringify(param), { |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | } |
| | | }, |
| | | function (json, res) { |
| | | try { |
| | | var _json = JSON.parse(json); |
| | | if (_json.code === 0 || _json.code === '0') { |
| | | vc.toast(_json.msg || '删除成功'); |
| | | $that._listCostDetails($that.costDetailInfo.paginationInfo.currentPage, $that.costDetailInfo.paginationInfo.rows); |
| | | } else { |
| | | vc.toast(_json.msg || '删除失败'); |
| | | } |
| | | } catch (e) { |
| | | console.error('删除响应解析失败:', e); |
| | | vc.toast('删除失败,请重试'); |
| | | } |
| | | }, |
| | | function (errInfo, error) { |
| | | console.error('删除请求失败:', errInfo, error); |
| | | vc.toast(errInfo || '删除失败,请检查网络连接'); |
| | | } |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |