| | |
| | | billTypes: [], |
| | | isDefaults: [], |
| | | curPage: DEFAULT_PAGE, |
| | | importType: 'residential', |
| | | conditions: { |
| | | configId: '', |
| | | secondaryFeeTypeCd: '', |
| | |
| | | paymentCd: '', |
| | | deductFrom: '' |
| | | } |
| | | }, |
| | | excelFile: null, |
| | | } |
| | | }, |
| | | _initMethod: function() { |
| | | $that._initDicts(); // 初始化字典数据 |
| | |
| | | vc.http.apiGet('/secondaryFeeTypeCdGl/list', param, |
| | | function(json) { |
| | | let result = JSON.parse(json); |
| | | $that.feeConfigManageInfo.secondaryFeeTypeCds = result; // 假设result.data是返回的二级费用类型数组 |
| | | 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('请求失败处理'); |
| | | console.log('请求失败处理:', errInfo, error); |
| | | } |
| | | ); |
| | | $that._listFeeConfigs(DEFAULT_PAGE, DEFAULT_ROWS); // 获取费用配置项 |
| | |
| | | function(json, res) { |
| | | let result = JSON.parse(json); |
| | | console.log('Fetched secondary fee types:', result); |
| | | $that.$set($that.feeConfigManageInfo, 'secondaryFeeTypeCds', 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); // 打印错误信息 |
| | |
| | | // }, |
| | | _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', 'importFeeConfig'); |
| | | formData.append('communityId', vc.getCurrentCommunity().communityId); |
| | | let userInfo = vc.getData('/nav/getUserInfo'); |
| | | formData.append('userId', userInfo ? userInfo.userId : ''); |
| | | formData.append('userName', userInfo ? userInfo.name : ''); |
| | | // 使用正确的模块名和方法名格式 |
| | | vc.http.upload( |
| | | 'assetImport', |
| | | 'importData', |
| | | formData, { |
| | | emulateJSON: true, |
| | | headers: { |
| | | "Content-Type": "multipart/form-data" |
| | | } |
| | | }, |
| | | function(json, res) { |
| | | try { |
| | | var _json = JSON.parse(json); |
| | | if (_json.code === 0) { |
| | | $('#importFeeConfigModal').modal('hide'); |
| | | // 检查_json.data的类型,确保正确处理 |
| | | if (typeof _json.data === 'object' && _json.data !== null) { |
| | | if (Array.isArray(_json.data) && _json.data.length > 0) { |
| | | // 如果是数组,使用第一个元素的logId |
| | | vc.jumpToPage('/#/pages/property/assetImportLogDetail?logId=' + _json.data[0].logId + '&logType=importFeeConfig'); |
| | | } else if (_json.data.logId) { |
| | | // 如果是对象且有logId属性,直接使用 |
| | | vc.jumpToPage('/#/pages/property/assetImportLogDetail?logId=' + _json.data.logId + '&logType=importFeeConfig'); |
| | | } else { |
| | | // 否则显示导入成功信息 |
| | | vc.toast('导入成功'); |
| | | // 刷新数据 |
| | | $that._listFeeConfigs($that.feeConfigManageInfo.curPage, DEFAULT_ROWS); |
| | | } |
| | | } else { |
| | | // 如果是数字,显示导入成功信息 |
| | | vc.toast('导入成功,共导入 ' + _json.data + ' 条数据'); |
| | | // 刷新数据 |
| | | $that._listFeeConfigs($that.feeConfigManageInfo.curPage, DEFAULT_ROWS); |
| | | } |
| | | // 清空文件选择 |
| | | $that.excelFile = ''; |
| | | $('#excelTemplate').val(''); |
| | | } else { |
| | | vc.toast(_json.msg); |
| | | } |
| | | } catch (e) { |
| | | vc.toast('导入失败:数据解析错误'); |
| | | } |
| | | }, |
| | | function(errInfo, error) { |
| | | // 显示后端返回的具体错误信息,而不是固定提示 |
| | | if (errInfo && errInfo !== 'undefined') { |
| | | vc.toast('导入失败:' + errInfo); |
| | | } else { |
| | | vc.toast('导入失败:网络错误或服务器异常'); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | } |
| | | }); |