| | |
| | | } |
| | | }, |
| | | _initMethod: function () { |
| | | // 获取费用类型字典 |
| | | vc.getDict('pay_fee_config', "fee_type_cd", function (_data) { |
| | | $that.importMeterWaterFeeInfo.feeTypeCds = _data; |
| | | vc.component.importMeterWaterFeeInfo.feeTypeCds = _data; |
| | | }); |
| | | |
| | | // 初始化社区ID |
| | | vc.component._refreshCommunityId(); |
| | | }, |
| | | _initEvent: function () { |
| | | vc.on('importMeterWaterFee', 'openImportMeterWaterFeeModal', |
| | | function (_room) { |
| | | $that._listImportMeterTypes(); |
| | | // 打开模态框时刷新社区ID |
| | | vc.component._refreshCommunityId(); |
| | | vc.component._listImportMeterTypes(); |
| | | $('#importMeterWaterFeeModel').modal('show'); |
| | | } |
| | | ); |
| | |
| | | methods: { |
| | | importMeterWaterFeeValidate() { |
| | | return vc.validate.validate({ |
| | | importMeterWaterFeeInfo: $that.importMeterWaterFeeInfo |
| | | importMeterWaterFeeInfo: vc.component.importMeterWaterFeeInfo |
| | | }, { |
| | | 'importMeterWaterFeeInfo.communityId': [ |
| | | { |
| | |
| | | }); |
| | | }, |
| | | _importMeterWaterData: function () { |
| | | if (!$that.importMeterWaterFeeValidate()) { |
| | | if (!vc.component.importMeterWaterFeeValidate()) { |
| | | vc.toast(vc.validate.errInfo); |
| | | return; |
| | | } |
| | | // 导入数据 |
| | | if (!$that.checkFileType($that.importMeterWaterFeeInfo.excelTemplate.name.split('.')[1])) { |
| | | if (!vc.component.checkFileType(vc.component.importMeterWaterFeeInfo.excelTemplate.name.split('.')[1])) { |
| | | vc.toast('不是有效的Excel格式'); |
| | | return; |
| | | } |
| | | // 移除文件大小限制检查 |
| | | // if (!$that.checkFileSize($that.importMeterWaterFeeInfo.excelTemplate.size)) { |
| | | // if (!vc.component.checkFileSize(vc.component.importMeterWaterFeeInfo.excelTemplate.size)) { |
| | | // vc.toast('Excel文件大小不能超过20M'); |
| | | // return; |
| | | // } |
| | | let param = new FormData(); |
| | | param.append("uploadFile", $that.importMeterWaterFeeInfo.excelTemplate); |
| | | param.append('communityId', $that.importMeterWaterFeeInfo.communityId); |
| | | param.append('feeTypeCd', $that.importMeterWaterFeeInfo.feeTypeCd); |
| | | param.append('configId', $that.importMeterWaterFeeInfo.configId); |
| | | param.append('meterType', $that.importMeterWaterFeeInfo.meterType); |
| | | param.append("uploadFile", vc.component.importMeterWaterFeeInfo.excelTemplate); |
| | | param.append('communityId', vc.component.importMeterWaterFeeInfo.communityId); |
| | | param.append('feeTypeCd', vc.component.importMeterWaterFeeInfo.feeTypeCd); |
| | | param.append('configId', vc.component.importMeterWaterFeeInfo.configId); |
| | | param.append('meterType', vc.component.importMeterWaterFeeInfo.meterType); |
| | | param.append('userId', '-1'); // 添加userId参数 |
| | | param.append('USER-ID', '-1'); // 添加USER-ID参数(大写形式) |
| | | // 根据费用类型选择对应的适配器 |
| | | if ($that.importMeterWaterFeeInfo.feeTypeCd === '630000017') { |
| | | if (vc.component.importMeterWaterFeeInfo.feeTypeCd === '630000017') { |
| | | // 水费使用 importMeterWaterFeeV2 |
| | | param.append('importAdapt', "importMeterWaterFeeV2"); |
| | | } else if ($that.importMeterWaterFeeInfo.feeTypeCd === '630000007') { |
| | | } else if (vc.component.importMeterWaterFeeInfo.feeTypeCd === '630000007') { |
| | | // 电费使用 importElectricityFeeV2 |
| | | param.append('importAdapt', "importElectricityFeeV2"); |
| | | } else { |
| | | // 其他费用使用原有适配器 |
| | | param.append('importAdapt', "importMeterWaterFee"); |
| | | } |
| | | |
| | | // 添加详细错误信息参数,让后端返回完整的提示词 |
| | | param.append('showDetailError', 'true'); |
| | | |
| | | // 打印调试信息 |
| | | console.log('导入请求参数详情:', { |
| | | communityId: vc.component.importMeterWaterFeeInfo.communityId, |
| | | feeTypeCd: vc.component.importMeterWaterFeeInfo.feeTypeCd, |
| | | importAdapt: vc.component.importMeterWaterFeeInfo.feeTypeCd === '630000017' ? 'importMeterWaterFeeV2' : |
| | | vc.component.importMeterWaterFeeInfo.feeTypeCd === '630000007' ? 'importElectricityFeeV2' : 'importMeterWaterFee', |
| | | showDetailError: 'true' |
| | | }); |
| | | |
| | | vc.http.upload( |
| | | 'assetImport', |
| | | 'importData', |
| | |
| | | }); |
| | | }, |
| | | _exportMeterWaterFeeTemplate: function () { |
| | | let _feeTypeCd = $that.importMeterWaterFeeInfo.feeTypeCd; |
| | | let _feeTypeCd = vc.component.importMeterWaterFeeInfo.feeTypeCd; |
| | | |
| | | if (!vc.notNull(_feeTypeCd)) { |
| | | vc.toast('请选择费用类型'); |
| | |
| | | param, |
| | | function (json, res) { |
| | | var _meterTypeManageInfo = JSON.parse(json); |
| | | $that.importMeterWaterFeeInfo.meterTypes = _meterTypeManageInfo.data; |
| | | vc.component.importMeterWaterFeeInfo.meterTypes = _meterTypeManageInfo.data; |
| | | }, |
| | | function (errInfo, error) { |
| | | console.log('请求失败处理'); |
| | |
| | | ); |
| | | }, |
| | | clearAddFeeConfigInfo: function () { |
| | | $that.importMeterWaterFeeInfo = { |
| | | vc.component.importMeterWaterFeeInfo = { |
| | | communityId: vc.getCurrentCommunity().communityId, |
| | | excelTemplate: '', |
| | | secondaryFeeTypeCd: '', |
| | |
| | | }, |
| | | getExcelTemplate: function (e) { |
| | | // 清除旧的文件对象,确保获取最新的文件 |
| | | $that.importMeterWaterFeeInfo.excelTemplate = null; |
| | | vc.component.importMeterWaterFeeInfo.excelTemplate = null; |
| | | |
| | | // 获取用户选择的文件 |
| | | let file = e.target.files[0]; |
| | |
| | | console.log('选择的文件:', file.name, '大小:', file.size, '最后修改时间:', file.lastModified); |
| | | |
| | | // 保存文件对象到组件数据中 |
| | | $that.importMeterWaterFeeInfo.excelTemplate = file; |
| | | vc.component.importMeterWaterFeeInfo.excelTemplate = file; |
| | | |
| | | // 重置input[type=file]的value,确保用户修改文件后再次选择同一文件时能触发change事件 |
| | | // 注意:这个重置必须在获取文件对象之后执行 |
| | |
| | | console.log('开始处理费用类型变更,feeTypeCd:', _feeTypeCd); |
| | | |
| | | // 立即清空当前选择,避免用户看到旧数据 |
| | | $that.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | $that.importMeterWaterFeeInfo.configId = ''; |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | vc.component.importMeterWaterFeeInfo.configId = ''; |
| | | |
| | | // 清空费用子类型数组,避免显示旧数据 |
| | | $that.$set($that.importMeterWaterFeeInfo, 'secondaryFeeTypeCds', []); |
| | | // 注意:vc框架中可能不支持$set,直接赋值 |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCds = []; |
| | | |
| | | // 添加加载状态提示 |
| | | vc.toast('正在获取费用子类型...', { duration: 500 }); |
| | |
| | | |
| | | // 立即调用收费项目查询,传入空的费用子类型 |
| | | // 确保收费项目列表也能及时更新 |
| | | $that._changeSecondaryFeeTypeCdx(_feeTypeCd, ''); |
| | | vc.component._changeSecondaryFeeTypeCdx(_feeTypeCd, ''); |
| | | |
| | | vc.http.apiGet('/secondaryFeeTypeCdGl.list.show', param, |
| | | function (json, res) { |
| | |
| | | // 确保组件状态更新可靠 |
| | | if (secondaryFeeTypeCds.length > 0) { |
| | | // 使用去重后的数据,确保数据稳定 |
| | | $that.$set($that.importMeterWaterFeeInfo, 'secondaryFeeTypeCds', secondaryFeeTypeCds); |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCds = secondaryFeeTypeCds; |
| | | |
| | | // 自动选择第一个费用子类型 |
| | | $that.importMeterWaterFeeInfo.secondaryFeeTypeCd = secondaryFeeTypeCds[0].secondaryFeeTypeCd; |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd = secondaryFeeTypeCds[0].secondaryFeeTypeCd; |
| | | |
| | | console.log('费用子类型数据处理完成,当前选择:', $that.importMeterWaterFeeInfo.secondaryFeeTypeCd); |
| | | console.log('费用子类型数据处理完成,当前选择:', vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd); |
| | | |
| | | // 重新调用收费项目查询,传入新选择的费用子类型 |
| | | // 确保收费项目列表与当前选择的费用子类型匹配 |
| | | $that._changeSecondaryFeeTypeCdx(_feeTypeCd, $that.importMeterWaterFeeInfo.secondaryFeeTypeCd); |
| | | vc.component._changeSecondaryFeeTypeCdx(_feeTypeCd, vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd); |
| | | } else { |
| | | // 没有可用的费用子类型数据,显示友好提示 |
| | | let noDataOption = { |
| | | secondaryFeeTypeCd: "", |
| | | secondaryFeeTypeName: "无关联子类型,请直接选择收费项目" |
| | | }; |
| | | $that.$set($that.importMeterWaterFeeInfo, 'secondaryFeeTypeCds', [noDataOption]); |
| | | $that.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCds = [noDataOption]; |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | |
| | | console.log('没有可用的费用子类型数据'); |
| | | } |
| | |
| | | vc.toast('获取费用子类型失败: 数据格式错误'); |
| | | |
| | | // 恢复到初始状态 |
| | | $that.$set($that.importMeterWaterFeeInfo, 'secondaryFeeTypeCds', [{ |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCds = [{ |
| | | secondaryFeeTypeCd: "", |
| | | secondaryFeeTypeName: "获取费用子类型失败,请直接选择收费项目" |
| | | }]); |
| | | $that.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | }]; |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | } |
| | | }, |
| | | function (errInfo, error) { |
| | |
| | | vc.toast('获取费用子类型失败: 网络异常'); |
| | | |
| | | // 恢复到初始状态 |
| | | $that.$set($that.importMeterWaterFeeInfo, 'secondaryFeeTypeCds', [{ |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCds = [{ |
| | | secondaryFeeTypeCd: "", |
| | | secondaryFeeTypeName: "获取费用子类型失败,请直接选择收费项目" |
| | | }]); |
| | | $that.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | }]; |
| | | vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd = ''; |
| | | } |
| | | ); |
| | | }, |
| | | _changeSecondaryFeeTypeCdx: function(_feeTypeCd,_secondaryFeeTypeCd) { |
| | | $that.importMeterWaterFeeInfo.configId = ''; |
| | | vc.component.importMeterWaterFeeInfo.configId = ''; |
| | | // 使用当前选择的费用子类型,而不是传入的参数 |
| | | var currentSecondaryFeeTypeCd = $that.importMeterWaterFeeInfo.secondaryFeeTypeCd; |
| | | var currentSecondaryFeeTypeCd = vc.component.importMeterWaterFeeInfo.secondaryFeeTypeCd; |
| | | var param = { |
| | | params: { |
| | | page: 1, |
| | |
| | | vc.http.apiGet('/feeConfig.listFeeConfigs', param, |
| | | function (json, res) { |
| | | var _feeConfigManageInfo = JSON.parse(json); |
| | | $that.importMeterWaterFeeInfo.feeConfigs = _feeConfigManageInfo.feeConfigs; |
| | | vc.component.importMeterWaterFeeInfo.feeConfigs = _feeConfigManageInfo.feeConfigs; |
| | | }, |
| | | function (errInfo, error) { |
| | | console.log('请求失败处理'); |
| | | } |
| | | ); |
| | | }, |
| | | /** |
| | | * 刷新社区ID,确保使用最新的社区ID |
| | | */ |
| | | _refreshCommunityId: function () { |
| | | let currentCommunity = vc.getCurrentCommunity(); |
| | | console.log('当前社区信息:', currentCommunity); |
| | | if (currentCommunity && currentCommunity.communityId) { |
| | | vc.component.importMeterWaterFeeInfo.communityId = currentCommunity.communityId; |
| | | console.log('刷新社区ID成功:', vc.component.importMeterWaterFeeInfo.communityId); |
| | | } else { |
| | | console.error('获取社区ID失败,currentCommunity:', currentCommunity); |
| | | vc.component.importMeterWaterFeeInfo.communityId = ''; |
| | | } |
| | | }, |
| | | } |
| | | }); |
| | | })(window.vc); |