liubp
2025-12-26 c08d1c10fbafd7f57eb51c51269a95c281383ae3
public/pages/property/costDetail/detail/detail.js
@@ -28,14 +28,13 @@
        },
        _initMethod: function () {
            $that = vc.component;
            // 从URL获取costDetailId
            var costDetailId = vc.getParam('costDetailId');
            if (costDetailId) {
                $that.costDetailInfo.costDetailId = costDetailId;
                $that._loadCostDetail();
            } else {
                vc.toast('缺少费用明细ID');
                setTimeout(function() {
                setTimeout(function () {
                    vc.goBack();
                }, 1500);
            }
@@ -44,31 +43,29 @@
        },
        methods: {
            _loadCostDetail: function () {
                // 查询所有数据,然后找到匹配的记录
                var params = {
                    communityName: vc.getCurrentCommunity().name,
                    page: 1,
                    row: 1000  // 查询足够多的数据以找到目标记录
                    row: 1000
                };
                var param = {
                    params: params
                };
                console.log('开始加载费用明细详情,ID:', $that.costDetailInfo.costDetailId);
                vc.http.apiGet('/maintenancePayment/queryMaintenancePayment',
                    param,
                    function (json, res) {
                        try {
                            var _json = JSON.parse(json);
                            console.log('API返回数据:', _json);
                            if (_json.code === 0 && _json.data) {
                                var records = Array.isArray(_json.data) ? _json.data : [];
                                console.log('查询到记录数:', records.length);
                                // 查找匹配的记录 - 支持字符串和数字类型的ID比较
                                var foundItem = null;
                                var targetId = String($that.costDetailInfo.costDetailId);
                                for (var i = 0; i < records.length; i++) {
@@ -80,21 +77,21 @@
                                        break;
                                    }
                                }
                                if (foundItem) {
                                    $that._fillDetailData(foundItem);
                                    console.log('详情数据已填充:', $that.costDetailInfo);
                                } else {
                                    console.error('未找到匹配的记录,目标ID:', $that.costDetailInfo.costDetailId);
                                    vc.toast('未找到该费用明细,ID: ' + $that.costDetailInfo.costDetailId);
                                    setTimeout(function() {
                                    setTimeout(function () {
                                        vc.goBack();
                                    }, 1500);
                                }
                            } else {
                                console.error('API返回错误:', _json);
                                vc.toast(_json.msg || '未找到该费用明细');
                                setTimeout(function() {
                                setTimeout(function () {
                                    vc.goBack();
                                }, 1500);
                            }
@@ -111,23 +108,19 @@
            },
            _fillDetailData: function (item) {
                console.log('开始填充详情数据,原始数据:', item);
                // 填充详情数据
                var dateStr = '';
                if (item.date) {
                    // 如果日期格式是 yyyy-mm-dd 或 yyyy-mm-dd HH:mm:ss,只取日期部分
                    dateStr = item.date.substring(0, 10);
                } else if (item.year && item.month) {
                    var monthStr = item.month < 10 ? '0' + item.month : String(item.month);
                    var dayStr = item.day ? (item.day < 10 ? '0' + item.day : String(item.day)) : '01';
                    dateStr = item.year + '-' + monthStr + '-' + dayStr;
                } else if (item.year && item.month) {
                    // 只有年月的情况
                    var monthStr = item.month < 10 ? '0' + item.month : String(item.month);
                    dateStr = item.year + '-' + monthStr;
                }
                // 使用Vue.set或者直接赋值来确保响应式更新
                vc.component.costDetailInfo.flowCode = item.flowNumber || '';
                vc.component.costDetailInfo.date = dateStr;
                vc.component.costDetailInfo.communityName = item.projectName || '';
@@ -141,19 +134,18 @@
                vc.component.costDetailInfo.approvalDepartment = item.reportDepartment || '';
                vc.component.costDetailInfo.fundTypeLevel1 = item.fundTypeLevel1 || '';
                vc.component.costDetailInfo.fundTypeLevel2 = item.fundTypeLevel2 || '';
                // 处理buildingType字段
                var buildingType = item.buildingOrAll || '1';
                if (buildingType === '全体' || buildingType === '2' || buildingType === 2) {
                    vc.component.costDetailInfo.buildingType = '全体';
                } else {
                    vc.component.costDetailInfo.buildingType = '1';
                }
                vc.component.costDetailInfo.maintenanceType = item.maintenanceType || '';
                vc.component.costDetailInfo.ownerScope = item.ownerScope || '';
                vc.component.costDetailInfo.buildingScope = item.buildingScope || '';
                console.log('详情数据填充完成:', vc.component.costDetailInfo);
            },
            _goBack: function () {