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/edit/edit.js |  338 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 286 insertions(+), 52 deletions(-)

diff --git a/public/pages/property/costDetail/edit/edit.js b/public/pages/property/costDetail/edit/edit.js
index da0016a..dc6d725 100644
--- a/public/pages/property/costDetail/edit/edit.js
+++ b/public/pages/property/costDetail/edit/edit.js
@@ -22,51 +22,234 @@
                 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;
-            // 浠嶶RL鑾峰彇costDetailId
+            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);
             var costDetailId = vc.getParam('costDetailId');
             if (costDetailId) {
                 $that.costDetailInfo.costDetailId = costDetailId;
                 $that._loadCostDetail();
             } else {
                 vc.toast('缂哄皯璐圭敤鏄庣粏ID');
-                setTimeout(function() {
+                setTimeout(function () {
                     vc.goBack();
                 }, 1500);
             }
         },
         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);
+                }
+            },
             _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);
-                                
-                                // 鏌ユ壘鍖归厤鐨勮褰� - 鏀寔瀛楃涓插拰鏁板瓧绫诲瀷鐨処D姣旇緝
+
                                 var foundItem = null;
                                 var targetId = String($that.costDetailInfo.costDetailId);
                                 for (var i = 0; i < records.length; i++) {
@@ -78,21 +261,21 @@
                                         break;
                                     }
                                 }
-                                
+
                                 if (foundItem) {
                                     $that._fillFormData(foundItem);
                                     console.log('琛ㄥ崟鏁版嵁宸插~鍏�:', $that.costDetailInfo);
                                 } else {
                                     console.error('鏈壘鍒板尮閰嶇殑璁板綍锛岀洰鏍嘔D:', $that.costDetailInfo.costDetailId);
                                     vc.toast('鏈壘鍒拌璐圭敤鏄庣粏锛孖D: ' + $that.costDetailInfo.costDetailId);
-                                    setTimeout(function() {
+                                    setTimeout(function () {
                                         vc.goBack();
                                     }, 1500);
                                 }
                             } else {
                                 console.error('API杩斿洖閿欒:', _json);
                                 vc.toast('鏈壘鍒拌璐圭敤鏄庣粏');
-                                setTimeout(function() {
+                                setTimeout(function () {
                                     vc.goBack();
                                 }, 1500);
                             }
@@ -109,18 +292,16 @@
             },
             _fillFormData: function (item) {
                 console.log('寮�濮嬪~鍏呰〃鍗曟暟鎹紝鍘熷鏁版嵁:', item);
-                
-                // 濉厖琛ㄥ崟鏁版嵁
+
                 var dateStr = '';
                 if (item.date) {
-                    dateStr = item.date.substring(0, 10); // 鍙栨棩鏈熼儴鍒� yyyy-mm-dd
+                    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;
                 }
-                
-                // 浣跨敤Vue.set鎴栬�呯洿鎺ヨ祴鍊兼潵纭繚鍝嶅簲寮忔洿鏂�
+
                 vc.component.costDetailInfo.flowCode = item.flowNumber || '';
                 vc.component.costDetailInfo.date = dateStr;
                 vc.component.costDetailInfo.communityName = item.projectName || '';
@@ -132,36 +313,61 @@
                 vc.component.costDetailInfo.appraisalAmount = item.auditAmount || '';
                 vc.component.costDetailInfo.committeeStamped = (item.ownersCommitteeSeal === '鏄�' || item.ownersCommitteeSeal === '1') ? '1' : '0';
                 vc.component.costDetailInfo.approvalDepartment = item.reportDepartment || '';
+
+                if (item.fundTypeLevel1 === '缁翠慨璧勯噾') {
+                    vc.component.costDetailInfo.fundType = 'repair';
+                    if (item.fundTypeLevel2) {
+                        vc.component.costDetailInfo.ownerScope = typeof item.fundTypeLevel2 === 'string'
+                            ? item.fundTypeLevel2.split(',').filter(function (item) { return item.trim(); })
+                            : [];
+                    } else {
+                        vc.component.costDetailInfo.ownerScope = [];
+                    }
+                    if (item.buildingOrAll) {
+                        vc.component.costDetailInfo.buildingScope = typeof item.buildingOrAll === 'string'
+                            ? item.buildingOrAll.split(',').filter(function (item) { return item.trim(); })
+                            : [];
+                    } else {
+                        vc.component.costDetailInfo.buildingScope = [];
+                    }
+                    vc.component.costDetailInfo.fundSystemType = 'out';
+                } else if (item.fundTypeLevel1 === '鍏叡鏀剁泭') {
+                    vc.component.costDetailInfo.fundType = 'public';
+                    if (item.fundTypeLevel2 === '绯荤粺澶�') {
+                        vc.component.costDetailInfo.fundSystemType = 'out';
+                    } else if (item.fundTypeLevel2 === '绯荤粺鍐�') {
+                        vc.component.costDetailInfo.fundSystemType = 'in';
+                    } else {
+                        vc.component.costDetailInfo.fundSystemType = 'out';
+                    }
+                    vc.component.costDetailInfo.ownerScope = [];
+                    vc.component.costDetailInfo.buildingScope = [];
+                } else {
+                    vc.component.costDetailInfo.fundType = 'repair';
+                    vc.component.costDetailInfo.ownerScope = [];
+                    vc.component.costDetailInfo.buildingScope = [];
+                    vc.component.costDetailInfo.fundSystemType = 'out';
+                }
+
                 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';
+                    if (buildingType && buildingType.indexOf(',') !== -1) {
+                        vc.component.costDetailInfo.buildingType = '1';
+                    } else {
+                        vc.component.costDetailInfo.buildingType = buildingType || '1';
+                    }
                 }
-                
+
                 vc.component.costDetailInfo.maintenanceType = item.maintenanceType || '';
-                
-                // 璁剧疆鍩洪噾绫诲瀷
-                if (item.fundTypeLevel1) {
-                    vc.component.costDetailInfo.fundType = (item.fundTypeLevel1 === '缁翠慨璧勯噾' || item.fundTypeLevel1 === '1') ? 'repair' : 'public';
-                } else {
-                    vc.component.costDetailInfo.fundType = 'repair'; // 榛樿鍊�
-                }
-                
-                if (item.fundTypeLevel2) {
-                    vc.component.costDetailInfo.fundSystemType = (item.fundTypeLevel2 === '绯荤粺澶�' || item.fundTypeLevel2 === 'out') ? 'out' : 'in';
-                } else {
-                    vc.component.costDetailInfo.fundSystemType = 'out'; // 榛樿鍊�
-                }
-                
+
                 console.log('琛ㄥ崟鏁版嵁濉厖瀹屾垚:', vc.component.costDetailInfo);
             },
             _saveCostDetail: function () {
-                // 楠岃瘉蹇呭~瀛楁
                 if (!$that.costDetailInfo.flowCode) {
                     vc.toast('璇疯緭鍏ユ祦杞紪鐮�');
                     return;
@@ -178,8 +384,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 = {
                     id: $that.costDetailInfo.costDetailId,
                     flowNumber: $that.costDetailInfo.flowCode,
@@ -193,14 +426,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) {
@@ -211,18 +446,17 @@
                         }
                     }
                 }
-                
-                // 璋冪敤鏇存柊API
+
                 vc.http.apiPost('/maintenancePayment/updateMaintenancePayment',
                     JSON.stringify(saveData), {
-                        emulateJSON: true
-                    },
+                    emulateJSON: true
+                },
                     function (json, res) {
                         try {
                             var _json = JSON.parse(json);
                             if (_json.code === 0) {
                                 vc.toast('淇濆瓨鎴愬姛');
-                                setTimeout(function() {
+                                setTimeout(function () {
                                     vc.goBack();
                                 }, 1000);
                             } else {

--
Gitblit v1.8.0