zhangjq
2026-01-18 fbb141768d08dbea8d1324f7fe54b43598bb7bd2
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
/**
 入驻小区
 **/
(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,
                importType: 'residential',
                conditions: {
                    configId: '',
                    secondaryFeeTypeCd: '',
                    feeFlag: '',
                    billType: '',
                    feeName: '',
                    feeTypeCd: '',
                    isDefault: 'F',
                    paymentCd: '',
                    deductFrom: ''
                }
            },
            excelFile: null,
        },
        _initMethod: function() {
            $that._initDicts(); // 初始化字典数据
                let param = {
                    params: {
                        feeTypeCd: ''
                    }
                };
                vc.http.apiGet('/secondaryFeeTypeCdGl/list', param,
                    function(json) {
                        let result = JSON.parse(json);
                        $that.feeConfigManageInfo.secondaryFeeTypeCds = result;  // 假设result.data是返回的二级费用类型数组
                    },
                    function(errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            $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);
                        $that.$set($that.feeConfigManageInfo, 'secondaryFeeTypeCds', result);
                    },
                    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)
            },
            // 获取文件
            getFile: function(e) {
                var files = e.target.files;
                if (files.length === 0) {
                    return;
                }
                $that.excelFile = files[0];
            },
            // 打开导入模态框
            _openImportFeeConfigModal: function() {
                $that.excelFile = null;
                $('#importFeeConfigModal').modal('show');
            },
            // 检查文件类型
            checkFileType: function(fileType) {
                var arrType = ['xlsx', 'xls'];
                return arrType.indexOf(fileType) > -1;
            },
            // 检查文件大小
            checkFileSize: function(fileSize) {
                return fileSize < 20 * 1024 * 1024; // 20MB
            },
            // 导入费用配置数据
            _importFeeConfigData: function() {
                if (!$that.excelFile) {
                    vc.toast('请选择要导入的文件');
                    return;
                }
                // 验证文件类型
                if (!vc.component.checkFileType($that.excelFile.name.split('.')[1])) {
                    vc.toast('不是有效的Excel格式');
                    return;
                }
                // 验证文件大小
                if (!vc.component.checkFileSize($that.excelFile.size)) {
                    vc.toast('Excel文件大小不能超过20M');
                    return;
                }
                var formData = new FormData();
                formData.append('uploadFile', $that.excelFile);
                formData.append('importAdapt', 'importRoomOwnerV2');
                formData.append('communityId', vc.getCurrentCommunity().communityId);
                formData.append('userId', vc.getLoginUser().userId);
                var param = {
                    url: '/callComponent/upload/assetImport/importData',
                    data: formData,
                    contentType: false,
                    processData: false,
                    type: 'post',
                    success: function(json, res) {
                        var _json = JSON.parse(json);
                        if (_json.code === 0) {
                            vc.toast('导入成功');
                            $('#importFeeConfigModal').modal('hide');
                            // 刷新数据
                            $that._listFeeConfigs($that.feeConfigManageInfo.curPage, DEFAULT_ROWS);
                        } else {
                            vc.toast(_json.msg);
                        }
                    },
                    error: function(errInfo, error) {
                        console.log('请求失败处理');
                        vc.toast('导入失败,请检查文件格式');
                    }
                };
                vc.http.request(param);
            }
        }
    });
})(window.vc);