zhangjiaqing
8 天以前 1cef3adee31c6934c0da4b4f0b8a6f5ac03b364f
public/pages/property/costDetail/costDetail.js
@@ -59,16 +59,21 @@
            });
        },
        methods: {
            _computeTableDivWidth: function () {
                let mainWidth = document.getElementsByTagName('body')[0].clientWidth - document.getElementById('menu-nav').offsetWidth;
                mainWidth = mainWidth - 20 - 15 - 20;
                return mainWidth + 'px';
            },
            _initDate: function () {
            },
            _loadCommunityList: function () {
                var currentCommunity = vc.getCurrentCommunity();
                console.log('当前小区:', currentCommunity);
                // 尝试从localStorage获取小区列表,可能存储在不同的键名下
                var communityListKeys = ['communityList', 'communityInfos', 'communities'];
                var communityInfos = null;
                for (var key of communityListKeys) {
                    try {
                        let localCommunityList = JSON.parse(window.localStorage.getItem(key));
@@ -81,13 +86,13 @@
                        console.error('解析localStorage中的' + key + '失败:', e);
                    }
                }
                // 如果localStorage中没有小区列表,使用vc.getCommunitys()
                if (!communityInfos) {
                    communityInfos = vc.getCommunitys();
                    console.log('使用vc.getCommunitys()获取小区列表:', communityInfos);
                }
                // 如果还是没有小区列表,通过API获取
                if (!communityInfos || !Array.isArray(communityInfos) || (Array.isArray(communityInfos) && communityInfos.length <= 3)) {
                    console.log('小区列表不完整,通过API获取');
@@ -116,7 +121,7 @@
                        }
                    );
                }
                if (communityInfos && Array.isArray(communityInfos) && communityInfos.length > 0) {
                    $that.costDetailInfo.communityList = communityInfos;
                    // 默认选择"请选择",显示所有小区的数据
@@ -144,7 +149,7 @@
                    page: _page,
                    row: _rows
                };
                // 如果用户选择了"请选择",传入空字符串,看看后端是否会返回所有小区的数据
                if (!selectedCommunityName) {
                    params.communityName = '';
@@ -189,8 +194,9 @@
                                    return {
                                        flowCode: item.flowNumber || '--',
                                        communityCode: item.projectCode || '--',
                                        projectCode: item.projectCode || '--',
                                        communityName: item.projectName || '--',
                                        auxiliaryColumn: item.auxiliaryColumn || '--',
                                        date: item.date || '--',
                                        projectContent: item.projectContent || '--',
                                        managementAmount: item.managementOfficeAmount || '--',
@@ -204,7 +210,52 @@
                                        buildingType: item.buildingOrAll || '--',
                                        maintenanceType: item.maintenanceType || '--',
                                        costDetailId: item.id,
                                        _originalData: item
                                        _originalData: item,
                                        projectCode: item.projectCode || '--',
                                        auxiliaryColumn: item.auxiliaryColumn || '--',
                                        flowNumber: item.flowNumber || '--',
                                        serialNumber: item.serialNumber || '--',
                                        projectName: item.projectName || '--',
                                        year: item.year || '--',
                                        month: item.month || '--',
                                        day: item.day || '--',
                                        date: item.date || '--',
                                        projectContent: item.projectContent || '--',
                                        managementOfficeAmount: item.managementOfficeAmount || '--',
                                        managementOfficeSeal: item.managementOfficeSeal || '--',
                                        ownersCommitteeAmount: item.ownersCommitteeAmount || '--',
                                        auditAmount: item.auditAmount || '--',
                                        ownersCommitteeSeal: item.ownersCommitteeSeal || '--',
                                        reportDepartment: item.reportDepartment || '--',
                                        fundTypeLevel1: item.fundTypeLevel1 || '--',
                                        fundTypeLevel2: item.fundTypeLevel2 || '--',
                                        maintenanceType: item.maintenanceType || '--',
                                        buildingOrAll: item.buildingOrAll || '--',
                                        specificAnnouncementStatus: item.specificAnnouncementStatus || '--',
                                        quota: item.quota || '--',
                                        ownersCommitteeResolution: item.ownersCommitteeResolution || '--',
                                        ownersCommitteeConsultation: item.ownersCommitteeConsultation || '--',
                                        withdrawalEncounteredProblem: item.withdrawalEncounteredProblem || '--',
                                        shortageOrArrears: item.shortageOrArrears || '--',
                                        roadName: item.roadName || '--',
                                        lane: item.lane || '--',
                                        door: item.door || '--',
                                        room: item.room || '--',
                                        doorRoomNumber: item.doorRoomNumber || '--',
                                        ownerAddress: item.ownerAddress || '--',
                                        qualityGuaranteePeriod2: item.qualityGuaranteePeriod2 || '--',
                                        qualityGuaranteeRatio: item.qualityGuaranteeRatio || '--',
                                        qualityGuaranteeAmount: item.qualityGuaranteeAmount || '--',
                                        acceptanceDate: item.acceptanceDate || '--',
                                        auditDate: item.auditDate || '--',
                                        availableWithdrawalDate: item.availableWithdrawalDate || '--',
                                        managementFeeRatio: item.managementFeeRatio || '--',
                                        payeeName: item.payeeName || '--',
                                        idCardNumber: item.idCardNumber || '--',
                                        bankName: item.bankName || '--',
                                        bankAccount: item.bankAccount || '--',
                                        advancedPayment: item.advancedPayment || '--',
                                        payableAmountD: item.payableAmountD || '--'
                                    };
                                });
@@ -372,14 +423,14 @@
                    // 模板路径,可根据需要从配置或后端获取
                    var templatePath = '/import/费用导入模板.xlsx';
                    var templateName = '费用导入模板.xlsx';
                    link.href = templatePath;
                    link.download = templateName;
                    link.style.display = 'none';
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);
                    vc.toast('模板下载中,请稍候...');
                } catch (e) {
                    console.error('模板下载失败:', e);
@@ -410,7 +461,7 @@
                $('#importCostDetailModal').modal('show');
                console.log('模态框已显示');
            },
            importCostDetailValidate() {
                return vc.validate.validate({
                    importCostDetailInfo: $that.importCostDetailInfo
@@ -427,23 +478,23 @@
                    }]
                });
            },
            /**
             * 文件选择处理
             * 功能:处理文件选择事件,更新文件信息
             * @param {Event} e 文件选择事件
             */
            getExcelTemplate: function(e) {
            getExcelTemplate: function (e) {
                console.log('选择文件:', e.target.files[0]);
                $that.importCostDetailInfo.excelTemplate = e.target.files[0];
                console.log('文件信息:', $that.importCostDetailInfo.excelTemplate);
            },
            /**
             * 导入数据
             * 功能:执行费用明细数据导入
             */
            _importData: function() {
            _importData: function () {
                console.log('开始执行导入数据');
                try {
                    // 验证表单
@@ -453,7 +504,7 @@
                        return;
                    }
                    console.log('验证通过');
                    // 验证文件是否存在
                    if (!$that.importCostDetailInfo.excelTemplate) {
                        console.log('未选择文件');
@@ -461,7 +512,7 @@
                        return;
                    }
                    console.log('文件存在:', $that.importCostDetailInfo.excelTemplate);
                    // 验证文件类型
                    const fileExtension = $that.importCostDetailInfo.excelTemplate.name.split('.').pop();
                    if (!fileExtension || !$that.checkOwnerFileType(fileExtension)) {
@@ -470,16 +521,16 @@
                        return;
                    }
                    console.log('文件类型验证通过:', fileExtension);
                    // 验证文件大小
                    if (!$that.checkOwnerFileSize($that.importCostDetailInfo.excelTemplate.size)) {
                        console.log('文件大小超过限制');
                        // 移除文件大小限制检查
                    // vc.toast('Excel文件大小不能超过20M');
                    // return;
                        // vc.toast('Excel文件大小不能超过20M');
                        // return;
                    }
                    console.log('文件大小验证通过:', $that.importCostDetailInfo.excelTemplate.size);
                    // 设置导入状态
                    $that.importStatus = {
                        isImporting: true,
@@ -487,15 +538,15 @@
                        message: '正在准备导入...'
                    };
                    console.log('设置导入状态为导入中');
                    // 模拟进度更新
                    let progressInterval = setInterval(function() {
                    let progressInterval = setInterval(function () {
                        if ($that.importStatus.progress < 90) {
                            $that.importStatus.progress += 10;
                            $that.importStatus.message = '导入中... ' + $that.importStatus.progress + '%';
                        }
                    }, 500);
                    // 构建表单数据
                    var param = new FormData();
                    param.append("uploadFile", $that.importCostDetailInfo.excelTemplate);
@@ -514,17 +565,17 @@
                        'assetImport',
                        'importData',
                        param, {
                            emulateJSON: true,
                            headers: {
                                "Content-Type": "multipart/form-data"
                            }
                        },
                        function(json, res) {
                        emulateJSON: true,
                        headers: {
                            "Content-Type": "multipart/form-data"
                        }
                    },
                        function (json, res) {
                            // 清除进度更新
                            clearInterval(progressInterval);
                            $that.importStatus.progress = 100;
                            $that.importStatus.message = '导入完成';
                            try {
                                let _json = JSON.parse(json);
                                if (_json.code == 0) {
@@ -565,7 +616,7 @@
                                };
                            }
                        },
                        function(errInfo, error) {
                        function (errInfo, error) {
                            // 清除进度更新
                            clearInterval(progressInterval);
                            console.error('导入请求失败:', errInfo, error);
@@ -589,13 +640,13 @@
                    };
                }
            },
            /**
             * 清空导入表单信息
             * 功能:重置导入表单的所有字段
             * 调用时机:打开导入弹窗前和导入完成后
             */
            clearImportInfo: function() {
            clearImportInfo: function () {
                $that.importCostDetailInfo = {
                    communityId: vc.getCurrentCommunity().communityId,
                    excelTemplate: ''
@@ -606,13 +657,13 @@
                    message: ''
                };
            },
            /**
             * 查看导入历史记录
             * 功能:跳转到导入历史记录页面
             * 实现:跳转到资产导入日志列表页面,带上费用明细导入的筛选条件
             */
            _viewImportHistory: function() {
            _viewImportHistory: function () {
                try {
                    // 跳转到导入日志列表页面,筛选费用明细导入记录
                    vc.jumpToPage('/#/pages/property/assetImportLog?logType=importReportMainV2&source=costDetailReport');
@@ -621,8 +672,8 @@
                    vc.toast('跳转到导入历史页面失败,请重试');
                }
            },
            checkOwnerFileType: function(fileType) {
            checkOwnerFileType: function (fileType) {
                const acceptTypes = ['xlsx', 'xls'];
                for (var i = 0; i < acceptTypes.length; i++) {
                    if (fileType === acceptTypes[i]) {
@@ -631,8 +682,8 @@
                }
                return false;
            },
            checkOwnerFileSize: function(fileSize) {
            checkOwnerFileSize: function (fileSize) {
                //20M
                const MAX_SIZE = 20 * 1024 * 1024;
                if (fileSize > MAX_SIZE) {