liubp
2025-12-26 c08d1c10fbafd7f57eb51c51269a95c281383ae3
public/pages/property/costDetail/add/add.js
@@ -21,16 +21,201 @@
                fundTypeLevel2: '',
                buildingType: '1',
                maintenanceType: '',
                fundType: 'repair', // 默认选中维修资金
                fundSystemType: 'out' // 默认选中系统外
            }
                fundType: 'repair',
                fundSystemType: 'out',
                ownerScope: [],
                buildingScope: []
            },
            ownerScopeOptions: [
                '机动车停车库(位)',
                '小区道路',
                '交通附属设施',
                '非机动车车库(相朋)',
                '小区公共照明',
                '锅炉',
                '排水、排污设施',
                '消防系统',
                '安防设施',
                '公共景观绿化',
                '健身、游乐设施',
                '小区宣传、标识',
                '强电',
                '弱电',
                '通信设施',
                '公共用房',
                '平屋面',
                '楼栋外立面',
                '供电设施',
                '暖通系统',
                '供水系统',
                '通用设施(配件)'
            ],
            ownerScopeDropdownOpen: false,
            buildingScopeOptions: [
                '机动车停车库(位)',
                '交通附属设施',
                '小区道路',
                '公共景观绿化',
                '非机动车车库(棚)',
                '锅炉',
                '排水、排污设施',
                '消防系统',
                '安防设施',
                '健身、游乐设施',
                '小区宣传、标识',
                '强电',
                '弱电',
                '通信设施',
                '公共用房',
                '平屋面',
                '太阳能设施',
                '坡屋面',
                '结构',
                '楼栋外立面',
                '楼幢入口',
                '楼幢公共',
                '楼道设施',
                '供电设施',
                '暖通系统',
                '供水系统',
                '通用设施(配件)',
                '法院强制执行'
            ],
            buildingScopeDropdownOpen: false
        },
        _initMethod: function () {
            $that = vc.component;
            if (!$that.costDetailInfo) {
                $that.costDetailInfo = {};
            }
            if (!$that.costDetailInfo.ownerScope || !Array.isArray($that.costDetailInfo.ownerScope)) {
                $that.costDetailInfo.ownerScope = [];
            }
            if (!$that.costDetailInfo.buildingScope || !Array.isArray($that.costDetailInfo.buildingScope)) {
                $that.costDetailInfo.buildingScope = [];
            }
            if (!$that.ownerScopeOptions || !Array.isArray($that.ownerScopeOptions)) {
                $that.ownerScopeOptions = [
                    '机动车停车库(位)',
                    '小区道路',
                    '交通附属设施',
                    '非机动车车库(相朋)',
                    '小区公共照明',
                    '锅炉',
                    '排水、排污设施',
                    '消防系统',
                    '安防设施',
                    '公共景观绿化',
                    '健身、游乐设施',
                    '小区宣传、标识',
                    '强电',
                    '弱电',
                    '通信设施',
                    '公共用房',
                    '平屋面',
                    '楼栋外立面',
                    '供电设施',
                    '暖通系统',
                    '供水系统',
                    '通用设施(配件)'
                ];
            }
            if ($that.ownerScopeDropdownOpen === undefined) {
                $that.ownerScopeDropdownOpen = false;
            }
            if (!$that.buildingScopeOptions || !Array.isArray($that.buildingScopeOptions)) {
                $that.buildingScopeOptions = [
                    '机动车停车库(位)',
                    '交通附属设施',
                    '小区道路',
                    '公共景观绿化',
                    '非机动车车库(棚)',
                    '锅炉',
                    '排水、排污设施',
                    '消防系统',
                    '安防设施',
                    '健身、游乐设施',
                    '小区宣传、标识',
                    '强电',
                    '弱电',
                    '通信设施',
                    '公共用房',
                    '平屋面',
                    '太阳能设施',
                    '坡屋面',
                    '结构',
                    '楼栋外立面',
                    '楼幢入口',
                    '楼幢公共',
                    '楼道设施',
                    '供电设施',
                    '暖通系统',
                    '供水系统',
                    '通用设施(配件)',
                    '法院强制执行'
                ];
            }
            if ($that.buildingScopeDropdownOpen === undefined) {
                $that.buildingScopeDropdownOpen = false;
            }
            var clickHandler = function (e) {
                if (!e.target.closest('.multi-select-wrapper')) {
                    if ($that && $that.ownerScopeDropdownOpen !== undefined) {
                        $that.ownerScopeDropdownOpen = false;
                    }
                    if ($that && $that.buildingScopeDropdownOpen !== undefined) {
                        $that.buildingScopeDropdownOpen = false;
                    }
                }
            };
            setTimeout(function () {
                document.addEventListener('click', clickHandler);
            }, 100);
        },
        methods: {
            toggleOwnerScopeDropdown: function () {
                if ($that && $that.ownerScopeDropdownOpen !== undefined) {
                    $that.ownerScopeDropdownOpen = !$that.ownerScopeDropdownOpen;
                }
            },
            toggleOwnerScopeOption: function (option) {
                if (!$that || !$that.costDetailInfo || !$that.costDetailInfo.ownerScope) {
                    return;
                }
                var index = $that.costDetailInfo.ownerScope.indexOf(option);
                if (index === -1) {
                    $that.costDetailInfo.ownerScope.push(option);
                } else {
                    $that.costDetailInfo.ownerScope.splice(index, 1);
                }
            },
            removeOwnerScopeItem: function (index) {
                if ($that && $that.costDetailInfo && $that.costDetailInfo.ownerScope) {
                    $that.costDetailInfo.ownerScope.splice(index, 1);
                }
            },
            toggleBuildingScopeDropdown: function () {
                if ($that && $that.buildingScopeDropdownOpen !== undefined) {
                    $that.buildingScopeDropdownOpen = !$that.buildingScopeDropdownOpen;
                }
            },
            toggleBuildingScopeOption: function (option) {
                if (!$that || !$that.costDetailInfo || !$that.costDetailInfo.buildingScope) {
                    return;
                }
                var index = $that.costDetailInfo.buildingScope.indexOf(option);
                if (index === -1) {
                    $that.costDetailInfo.buildingScope.push(option);
                } else {
                    $that.costDetailInfo.buildingScope.splice(index, 1);
                }
            },
            removeBuildingScopeItem: function (index) {
                if ($that && $that.costDetailInfo && $that.costDetailInfo.buildingScope) {
                    $that.costDetailInfo.buildingScope.splice(index, 1);
                }
            },
            _saveCostDetail: function () {
                // 验证必填字段
                if (!$that.costDetailInfo.flowCode) {
                    vc.toast('请输入流转编码');
                    return;
@@ -47,8 +232,35 @@
                    vc.toast('请输入小区编码');
                    return;
                }
                // 构建保存数据
                var fundTypeLevel1 = '';
                if ($that.costDetailInfo.fundType === 'repair') {
                    fundTypeLevel1 = '维修资金';
                } else if ($that.costDetailInfo.fundType === 'public') {
                    fundTypeLevel1 = '公共收益';
                }
                var fundTypeLevel2 = '';
                var buildingOrAll = '';
                if ($that.costDetailInfo.fundType === 'repair') {
                    fundTypeLevel2 = ($that.costDetailInfo.ownerScope && $that.costDetailInfo.ownerScope.length > 0)
                        ? $that.costDetailInfo.ownerScope.join(',')
                        : '';
                    buildingOrAll = ($that.costDetailInfo.buildingScope && $that.costDetailInfo.buildingScope.length > 0)
                        ? $that.costDetailInfo.buildingScope.join(',')
                        : '';
                } else if ($that.costDetailInfo.fundType === 'public') {
                    if ($that.costDetailInfo.fundSystemType === 'out') {
                        fundTypeLevel2 = '系统外';
                    } else if ($that.costDetailInfo.fundSystemType === 'in') {
                        fundTypeLevel2 = '系统内';
                    }
                    buildingOrAll = '';
                } else {
                    buildingOrAll = '';
                }
                var saveData = {
                    flowNumber: $that.costDetailInfo.flowCode,
                    date: $that.costDetailInfo.date,
@@ -61,14 +273,16 @@
                    auditAmount: parseFloat($that.costDetailInfo.appraisalAmount) || 0,
                    ownersCommitteeSeal: $that.costDetailInfo.committeeStamped === '1' ? '是' : '否',
                    reportDepartment: $that.costDetailInfo.approvalDepartment || '',
                    fundTypeLevel1: $that.costDetailInfo.fundType === 'repair' ? '维修资金' : '公共收益',
                    fundTypeLevel2: $that.costDetailInfo.fundType === 'public' ? ($that.costDetailInfo.fundSystemType === 'out' ? '系统外' : '系统内') : '',
                    buildingOrAll: $that.costDetailInfo.buildingType === '全体' ? '全体' : ($that.costDetailInfo.buildingType || '1'),
                    fundTypeLevel1: fundTypeLevel1,
                    fundTypeLevel2: fundTypeLevel2,
                    maintenanceType: $that.costDetailInfo.maintenanceType || '',
                    communityId: vc.getCurrentCommunity().communityId
                };
                // 解析日期
                if ($that.costDetailInfo.fundType === 'repair') {
                    saveData.buildingOrAll = buildingOrAll;
                }
                if (saveData.date) {
                    var dateParts = saveData.date.split('-');
                    if (dateParts.length >= 2) {
@@ -81,14 +295,14 @@
                }
                vc.http.apiPost('/maintenancePayment/saveMaintenancePayment',
                    JSON.stringify(saveData), {
                        emulateJSON: true
                    },
                    emulateJSON: true
                },
                    function (json, res) {
                        try {
                            var _json = JSON.parse(json);
                            if (_json.code === 0 || _json.code === '0') {
                                vc.toast('保存成功');
                                setTimeout(function() {
                                setTimeout(function () {
                                    vc.goBack();
                                }, 1000);
                            } else {
@@ -110,5 +324,4 @@
            }
        }
    });
})(window.vc);
})(window.vc);