zhangjiaqing
8 天以前 1cef3adee31c6934c0da4b4f0b8a6f5ac03b364f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/**
 入驻小区
 **/
(function(vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            reportFeeSummaryInfo: {
                fees: [],
                feeConfigs: [],
                feeConfigNames: [],
                total: 0,
                records: 1,
                moreCondition: false,
                title: '',
                roomUnits: [],
                totalReceivableAmount: 0.0,
                allReceivableAmount: 0.0,
                totalReceivedAmount: 0.0,
                allReceivedAmount: 0.0,
                totalPreferentialAmount: 0.0,
                allHisOweReceivedAmount: 0.0,
                allOweAmount: 0.0,
                conditions: {
                    floorId: '',
                    floorName: '',
                    roomNum: '',
                    unitId: '',
                    startTime: '',
                    endTime: '',
                    communityId: vc.getCurrentCommunity().communityId
                }
            }
        },
        _initMethod: function() {
 
            vc.component._listAllFees(DEFAULT_PAGE, DEFAULT_ROWS);
            $(".popover-show").mouseover(() => {
                $('.popover-show').popover('show');
            })
            $(".popover-show").mouseleave(() => {
                $('.popover-show').popover('hide');
            })
        },
        _initEvent: function() {
            $('#configIds').on('changed.bs.select', function(e, clickedIndex, isSelected, previousValue) {
                // do something...
                if (isSelected) {
                    $that.reportFeeSummaryInfo.feeConfigNames.push({
                        configId: $that.reportFeeSummaryInfo.feeConfigs[clickedIndex].configId,
                        configName: $that.reportFeeSummaryInfo.feeConfigs[clickedIndex].feeName
                    })
                } else {
                    let _feeConfigNames = [];
                    $that.reportFeeSummaryInfo.feeConfigNames.forEach(item => {
                        if (item.configId != $that.reportFeeSummaryInfo.feeConfigs[clickedIndex].configId) {
                            _feeConfigNames.push(item);
                        }
                    });
                    $that.reportFeeSummaryInfo.feeConfigNames = _feeConfigNames;
                }
            });
            vc.on('reportFeeSummary', 'chooseFloor', function(_param) {
                vc.component.reportFeeSummaryInfo.conditions.floorId = _param.floorId;
                vc.component.reportFeeSummaryInfo.conditions.floorName = _param.floorName;
                vc.component.loadUnits(_param.floorId);
            });
            vc.on('pagination', 'page_event', function(_currentPage) {
                vc.component._listFees(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            //查询
            _queryMethod: function() {
                vc.component._listAllFees(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //查询方法
            _listFees: function(_yearMonth) {
                // 检查是否为本地开发环境
                const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
                
                if (isLocalhost) {
                    // 本地开发环境,使用模拟数据
                    setTimeout(() => { // 模拟异步请求延迟
                        let _json = {
                            data: [
                                {
                                    roomId: '1',
                                    roomName: '1-1-101',
                                    feeConfigDtos: [
                                        {configId: '1', feeName: '物业费', amount: '100.00', receivedAmount: '100.00'},
                                        {configId: '2', feeName: '水费', amount: '50.00', receivedAmount: '50.00'}
                                    ],
                                    receivableAmount: '150.00',
                                    receivedAmount: '150.00',
                                    preferentialAmount: '0.00',
                                    oweAmount: '0.00'
                                },
                                {
                                    roomId: '2',
                                    roomName: '1-1-102',
                                    feeConfigDtos: [
                                        {configId: '1', feeName: '物业费', amount: '100.00', receivedAmount: '80.00'},
                                        {configId: '3', feeName: '电费', amount: '60.00', receivedAmount: '60.00'}
                                    ],
                                    receivableAmount: '160.00',
                                    receivedAmount: '140.00',
                                    preferentialAmount: '20.00',
                                    oweAmount: '0.00'
                                }
                            ]
                        };
                        //vc.component.reportFeeSummaryInfo.fees = _json.data;
                        _json.data.forEach(item => {
                            item.yearMonth = _yearMonth;
                            vc.component.reportFeeSummaryInfo.fees.push(item);
                        });
                    }, 500);
                } else {
                    // 生产环境,使用真实后端服务
                    vc.component.reportFeeSummaryInfo.conditions.page = 1;
                    vc.component.reportFeeSummaryInfo.conditions.row = 1;
                    vc.component.reportFeeSummaryInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
                    $that.reportFeeSummaryInfo.conditions.startDate = _yearMonth + "-01";
                    // 下个月
                    let _date = new Date(Date.parse($that.reportFeeSummaryInfo.conditions.startDate.replace(/-/g, "/")));
                    vc.component.reportFeeSummaryInfo.conditions.endDate = vc.addMonthDate(_date, 1);
 
                    let param = {
                        params: vc.component.reportFeeSummaryInfo.conditions
                    };
                    param.params.roomNum = param.params.roomNum.trim();
                    // let _configIds = "";
                    // $that.reportFeeSummaryInfo.feeConfigNames.forEach(item => {
                    //     _configIds += (item.configId + ',')
                    // })
                    // if (_configIds.endsWith(',')) {
                    //     _configIds = _configIds.substring(0, _configIds.length - 1);
                    // }
                    // param.params.configIds = _configIds;
                    //发送get请求
                    vc.http.apiGet('/reportFeeMonthStatistics.queryReportFeeSummary',
                        param,
                        function(json, res) {
                            let _json = JSON.parse(json);
                            //vc.component.reportFeeSummaryInfo.fees = _json.data;
                            _json.data.forEach(item => {
                                item.yearMonth = _yearMonth;
                                vc.component.reportFeeSummaryInfo.fees.push(item);
                            });
                        },
                        function(errInfo, error) {
                            console.log('请求失败处理');
                        }
                    );
                }
            },
            //重置
            _resetMethod: function(_page, _rows) {
                vc.component.reportFeeSummaryInfo.conditions.floorName = "";
                vc.component.reportFeeSummaryInfo.conditions.floorId = "";
                vc.component.reportFeeSummaryInfo.conditions.unitId = "";
                vc.component.reportFeeSummaryInfo.conditions.roomNum = "";
                vc.component.reportFeeSummaryInfo.conditions.startTime = "";
                vc.component.reportFeeSummaryInfo.conditions.endTime = "";
                $that._listAllFees(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            loadUnits: function(_floorId) {
                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) {
                            let tmpUnits = JSON.parse(json);
                            vc.component.reportFeeSummaryInfo.roomUnits = tmpUnits;
                            return;
                        }
                        vc.toast(json);
                    },
                    function(errInfo, error) {
                        console.log('请求失败处理');
                        vc.toast(errInfo);
                    });
            },
            _openChooseFloorMethod: function() {
                vc.emit('searchFloor', 'openSearchFloorModel', {});
            },
            _moreCondition: function() {
                if (vc.component.reportFeeSummaryInfo.moreCondition) {
                    vc.component.reportFeeSummaryInfo.moreCondition = false;
                } else {
                    vc.component.reportFeeSummaryInfo.moreCondition = true;
                }
            },
 
            _getFeeReceivedAmountAmount: function(item, fee) {
                let _items = fee.feeConfigDtos;
                if (!_items) {
                    return 0;
                }
                let _value = 0;
                _items.forEach(tmp => {
                    if (tmp.configId == item.configId) {
                        _value = tmp.amount;
                        return;
                    }
                })
                return _value;
            },
            _exportExcel: function() {
                // 检查是否为本地开发环境
                const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
                
                if (isLocalhost) {
                    // 本地开发环境,模拟导出成功
                    setTimeout(() => { // 模拟异步请求延迟
                        vc.toast('导出任务已提交,稍后可在下载中心查看');
                        // 可以跳转到下载中心页面
                        // vc.jumpToPage('/#/pages/property/downloadTempFile?tab=下载中心')
                    }, 500);
                } else {
                    // 生产环境,使用真实后端服务
                    vc.jumpToPage('/callComponent/exportReportFee/exportData?pagePath=reportFeeSummary&' + vc.objToGetParam($that.reportFeeSummaryInfo.conditions));
                }
            },
            _computeSum: function(a, b) {
                return (parseFloat(a) + parseFloat(b)).toFixed(2)
            },
 
            _printFeeSummary: function() {
                let _param = vc.objToGetParam($that.reportFeeSummaryInfo.conditions);
                window.open('/print.html#/pages/property/reportFeeSummaryPrint?' + _param);
            },
            _listAllFees: function() {
                vc.component.reportFeeSummaryInfo.fees = [];
                let data = new Date();
                //获取年
                let year = data.getFullYear();
                //获取月
                let mon = data.getMonth() + 1;
                let arry = new Array();
                for (let i = 0; i < 12; i++) {
                    if (mon <= 0) {
                        year = year - 1;
                        mon = mon + 12;
                    }
                    if (mon < 10) {
                        mon = "0" + mon;
                    }
                    arry[i] = year + "-" + mon;
                    mon = mon - 1;
                }
 
                arry.forEach(item => {
                    $that._listFees(item);
                })
 
            }
        }
    });
})(window.vc);