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
/**
 入驻小区
 **/
(function(vc) {
    window.addEventListener('error', function(event) {
        console.error("=== 全局未捕获错误 ===");
        console.error("错误信息:", event.error);
        console.error("错误位置:", event.filename, "行号:", event.lineno);
    });
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            feeConfigManageInfo: {
                feeConfigs: [],
                total: 0,
                records: 1,
                moreCondition: false,
                feeName: '',
                feeTypeCds: [],
                feeFlags: [],
                secondaryFeeTypeCds: [],
                paymentCds: [],
                billTypes: [],
                isDefaults: [],
                curPage: DEFAULT_PAGE,
                conditions: {
                    configId: '',
                    secondaryFeeTypeCd: '',
                    feeFlag: '',
                    billType: '',
                    feeName: '',
                    feeTypeCd: '',
                    isDefault: 'F',
                    paymentCd: '',
                    deductFrom: ''
                }
            }
        },
        _initMethod: function() {
            $that._initDicts(); // 初始化字典数据
                let param = {
                    params: {
                        feeTypeCd: ''
                    }
                };
                vc.http.apiGet('/secondaryFeeTypeCdGl/list', param,
                    function(json) {
                        let result = JSON.parse(json);
                        console.log('获取到的费用子类型数据:', result);
                        // 处理费用子类型数据,统一字段名
                        let processedResult = [];
                        if (Array.isArray(result)) {
                            processedResult = result.map(item => {
                                return {
                                    secondaryFeeTypeCd: item.secondaryFeeTypeCd || item.secondary_fee_type_cd,
                                    secondaryFeeTypeName: item.secondaryFeeTypeName || item.secondary_fee_type_cd_name || item.name
                                };
                            });
                        }
                        $that.feeConfigManageInfo.secondaryFeeTypeCds = processedResult;
                        console.log('处理后的费用子类型数据:', processedResult);
                    },
                    function(errInfo, error) {
                        console.log('请求失败处理:', errInfo, error);
                    }
                );
            $that._listFeeConfigs(DEFAULT_PAGE, DEFAULT_ROWS); // 获取费用配置项
        },
        
        _initEvent: function() {
            vc.on('feeConfigManage', 'listFeeConfig',
                function(_param) {
                    $that._listFeeConfigs($that.feeConfigManageInfo.curPage, DEFAULT_ROWS);
                });
            vc.on('pagination', 'page_event',
                function(_currentPage) {
                    $that.feeConfigManageInfo.curPage = _currentPage;
                    $that._listFeeConfigs(_currentPage, DEFAULT_ROWS);
                });
        },
        methods: {
            _initDicts: function() {
                console.log("initDicts");              
                vc.getDict('pay_fee_config', "fee_type_cd", function(_data) {
                    $that.feeConfigManageInfo.feeTypeCds = [{
                        statusCd: '',
                        name: '全部'
                    }];
                    _data.forEach(item => {
                        $that.feeConfigManageInfo.feeTypeCds.push(item);
                    });
                });
                //关联字典表费用标识
                vc.getDict('pay_fee_config', 'fee_flag', function(_data) {
                    $that.feeConfigManageInfo.feeFlags = _data;
                });
                //关联字典表付费类型
                vc.getDict('pay_fee_config', 'payment_cd', function(_data) {
                    $that.feeConfigManageInfo.paymentCds = _data;
                });
                //关联字典表费用项
                vc.getDict('pay_fee_config', 'is_default', function(_data) {
                    $that.feeConfigManageInfo.isDefaults = _data;
                })
            },
            // 切换费用类型
            swatchFeeTypeCd: function(item) {
                $that.feeConfigManageInfo.conditions.feeTypeCd = item.statusCd;
                $that._secondaryFeeTypeCds(item.statusCd); // 使用新的接口
                $that._listFeeConfigs(DEFAULT_PAGE, DEFAULT_ROWS); // 查询费用配置
            },
            // 获取二级费用类型
            _secondaryFeeTypeCds: function(feeTypeCd = '') {
                console.log("=== 进入_secondaryFeeTypeCds方法 ===");
                let param = {
                    params: {
                        feeTypeCd: feeTypeCd
                    }
                };
                vc.http.apiGet('/secondaryFeeTypeCdGl/list', param,
                    function(json, res) {
                        let result = JSON.parse(json);
                        console.log('Fetched secondary fee types:', result);
                        // 处理费用子类型数据,统一字段名
                        let processedResult = [];
                        if (Array.isArray(result)) {
                            processedResult = result.map(item => {
                                return {
                                    secondaryFeeTypeCd: item.secondaryFeeTypeCd || item.secondary_fee_type_cd,
                                    secondaryFeeTypeName: item.secondaryFeeTypeName || item.secondary_fee_type_cd_name || item.name
                                };
                            });
                        }
                        $that.$set($that.feeConfigManageInfo, 'secondaryFeeTypeCds', processedResult);
                        console.log('处理后的费用子类型数据:', processedResult);
                    },
                    function(errInfo, error) {
                        console.log('_secondaryFeeTypeCds方法请求失败处理:', errInfo, error); // 打印错误信息
                    }
                );
            },
 
            //查询方法
            _listFeeConfigs: function(_page, _rows) {
 
                $that.feeConfigManageInfo.conditions.page = _page;
                $that.feeConfigManageInfo.conditions.row = _rows;
                $that.feeConfigManageInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
                let param = {
                    params: $that.feeConfigManageInfo.conditions
                };
                //收费项目选框去空
                param.params.feeName = param.params.feeName.trim();
                //费用项ID选框去空
                param.params.configId = param.params.configId.trim();
                //发送get请求
                vc.http.apiGet('/feeConfig.listFeeConfigs', param,
                    function(json, res) {
                        let _json = JSON.parse(json);
                        $that.feeConfigManageInfo.total = _json.total;
                        $that.feeConfigManageInfo.records = _json.records;
                        $that.feeConfigManageInfo.feeConfigs = _json.feeConfigs;
                        vc.emit('pagination', 'init', {
                            total: $that.feeConfigManageInfo.records,
                            dataCount: $that.feeConfigManageInfo.total,
                            currentPage: _page
                        });
                    },
                    function(errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
                
            },
            //重置方法
            _resetListFeeConfigs: function() {
                $that.feeConfigManageInfo.conditions.configId = '';
                $that.feeConfigManageInfo.conditions.feeName = '';
                $that.feeConfigManageInfo.conditions.feeTypeCd = '';
                $that.feeConfigManageInfo.conditions.feeFlag = '';
                $that.feeConfigManageInfo.conditions.secondaryFeeTypeCd = '';
                $that.feeConfigManageInfo.conditions.paymentCd = '';
                $that.feeConfigManageInfo.conditions.billType = '';
                $that.feeConfigManageInfo.conditions.isDefault = '';
                $that.feeConfigManageInfo.conditions.deductFrom = '';
                $that._listFeeConfigs(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _openAddFeeConfigModal: function() {
                vc.emit('addFeeConfig', 'openAddFeeConfigModal', {});
            },
            _openEditFeeConfigModel: function(_feeConfig) {
                vc.emit('editFeeConfig', 'openEditFeeConfigModal', _feeConfig);
            },
            _openDeleteFeeConfigModel: function(_feeConfig) {
                vc.emit('deleteFeeConfig', 'openDeleteFeeConfigModal', _feeConfig);
            },
            //查询
            _queryFeeConfigMethod: function() {
                $that._listFeeConfigs(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetFeeConfigMethod: function() {
                $that._resetListFeeConfigs(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function() {
                if ($that.feeConfigManageInfo.moreCondition) {
                    $that.feeConfigManageInfo.moreCondition = false;
                } else {
                    $that.feeConfigManageInfo.moreCondition = true;
                }
            },
            _settingConfigDiscount: function(_feeConfig) {
                vc.jumpToPage('/#/pages/property/payFeeConfigDiscountManage?configId=' + _feeConfig.configId + "&feeName=" + _feeConfig.feeName);
            },
            // swatchFeeTypeCd: function(item) {
            //     $that.feeConfigManageInfo.conditions.feeTypeCd = item.statusCd;
            //     $that._listFeeConfigs(DEFAULT_PAGE, DEFAULT_ROWS);
            // },
            _openFeeConfigDetail: function(_feeConfig) {
                window.open('/#/pages/fee/feeConfigDetail?configId=' + _feeConfig.configId)
            }
        }
    });
})(window.vc);