zhangjq
2026-01-27 6f51f667ae7b13dca029045c221d0b1722cf98df
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
/**
 入驻小区
 **/
(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);