From c08d1c10fbafd7f57eb51c51269a95c281383ae3 Mon Sep 17 00:00:00 2001
From: liubp <1535785116@qq.com>
Date: 星期五, 26 十二月 2025 18:33:55 +0800
Subject: [PATCH] 公共收益金增删查改

---
 public/pages/property/costDetail/add/add.js |  245 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 229 insertions(+), 16 deletions(-)

diff --git a/public/pages/property/costDetail/add/add.js b/public/pages/property/costDetail/add/add.js
index e4907fb..9b8f12f 100644
--- a/public/pages/property/costDetail/add/add.js
+++ b/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: [
+                '鏈哄姩杞﹀仠杞﹀簱(浣�)',
+                '灏忓尯閬撹矾',
+                '浜ら�氶檮灞炶鏂�',
+                '闈炴満鍔ㄨ溅杞﹀簱(鐩告湅)',
+                '灏忓尯鍏叡鐓ф槑',
+                '閿呯倝',
+                '鎺掓按銆佹帓姹¤鏂�',
+                '娑堥槻绯荤粺',
+                '瀹夐槻璁炬柦',
+                '鍏叡鏅缁垮寲',
+                '鍋ヨ韩銆佹父涔愯鏂�',
+                '灏忓尯瀹d紶銆佹爣璇�',
+                '寮虹數',
+                '寮辩數',
+                '閫氫俊璁炬柦',
+                '鍏叡鐢ㄦ埧',
+                '骞冲眿闈�',
+                '妤兼爧澶栫珛闈�',
+                '渚涚數璁炬柦',
+                '鏆栭�氱郴缁�',
+                '渚涙按绯荤粺',
+                '閫氱敤璁炬柦(閰嶄欢)'
+            ],
+            ownerScopeDropdownOpen: false,
+            buildingScopeOptions: [
+                '鏈哄姩杞﹀仠杞﹀簱(浣�)',
+                '浜ら�氶檮灞炶鏂�',
+                '灏忓尯閬撹矾',
+                '鍏叡鏅缁垮寲',
+                '闈炴満鍔ㄨ溅杞﹀簱(妫�)',
+                '閿呯倝',
+                '鎺掓按銆佹帓姹¤鏂�',
+                '娑堥槻绯荤粺',
+                '瀹夐槻璁炬柦',
+                '鍋ヨ韩銆佹父涔愯鏂�',
+                '灏忓尯瀹d紶銆佹爣璇�',
+                '寮虹數',
+                '寮辩數',
+                '閫氫俊璁炬柦',
+                '鍏叡鐢ㄦ埧',
+                '骞冲眿闈�',
+                '澶槼鑳借鏂�',
+                '鍧″眿闈�',
+                '缁撴瀯',
+                '妤兼爧澶栫珛闈�',
+                '妤煎耿鍏ュ彛',
+                '妤煎耿鍏叡',
+                '妤奸亾璁炬柦',
+                '渚涚數璁炬柦',
+                '鏆栭�氱郴缁�',
+                '渚涙按绯荤粺',
+                '閫氱敤璁炬柦(閰嶄欢)',
+                '娉曢櫌寮哄埗鎵ц'
+            ],
+            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 = [
+                    '鏈哄姩杞﹀仠杞﹀簱(浣�)',
+                    '灏忓尯閬撹矾',
+                    '浜ら�氶檮灞炶鏂�',
+                    '闈炴満鍔ㄨ溅杞﹀簱(鐩告湅)',
+                    '灏忓尯鍏叡鐓ф槑',
+                    '閿呯倝',
+                    '鎺掓按銆佹帓姹¤鏂�',
+                    '娑堥槻绯荤粺',
+                    '瀹夐槻璁炬柦',
+                    '鍏叡鏅缁垮寲',
+                    '鍋ヨ韩銆佹父涔愯鏂�',
+                    '灏忓尯瀹d紶銆佹爣璇�',
+                    '寮虹數',
+                    '寮辩數',
+                    '閫氫俊璁炬柦',
+                    '鍏叡鐢ㄦ埧',
+                    '骞冲眿闈�',
+                    '妤兼爧澶栫珛闈�',
+                    '渚涚數璁炬柦',
+                    '鏆栭�氱郴缁�',
+                    '渚涙按绯荤粺',
+                    '閫氱敤璁炬柦(閰嶄欢)'
+                ];
+            }
+            if ($that.ownerScopeDropdownOpen === undefined) {
+                $that.ownerScopeDropdownOpen = false;
+            }
+            if (!$that.buildingScopeOptions || !Array.isArray($that.buildingScopeOptions)) {
+                $that.buildingScopeOptions = [
+                    '鏈哄姩杞﹀仠杞﹀簱(浣�)',
+                    '浜ら�氶檮灞炶鏂�',
+                    '灏忓尯閬撹矾',
+                    '鍏叡鏅缁垮寲',
+                    '闈炴満鍔ㄨ溅杞﹀簱(妫�)',
+                    '閿呯倝',
+                    '鎺掓按銆佹帓姹¤鏂�',
+                    '娑堥槻绯荤粺',
+                    '瀹夐槻璁炬柦',
+                    '鍋ヨ韩銆佹父涔愯鏂�',
+                    '灏忓尯瀹d紶銆佹爣璇�',
+                    '寮虹數',
+                    '寮辩數',
+                    '閫氫俊璁炬柦',
+                    '鍏叡鐢ㄦ埧',
+                    '骞冲眿闈�',
+                    '澶槼鑳借鏂�',
+                    '鍧″眿闈�',
+                    '缁撴瀯',
+                    '妤兼爧澶栫珛闈�',
+                    '妤煎耿鍏ュ彛',
+                    '妤煎耿鍏叡',
+                    '妤奸亾璁炬柦',
+                    '渚涚數璁炬柦',
+                    '鏆栭�氱郴缁�',
+                    '渚涙按绯荤粺',
+                    '閫氱敤璁炬柦(閰嶄欢)',
+                    '娉曢櫌寮哄埗鎵ц'
+                ];
+            }
+            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
                 };
-                
-                // 瑙f瀽鏃ユ湡
+
+                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);
\ No newline at end of file

--
Gitblit v1.8.0