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/more/more.js |  398 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 343 insertions(+), 55 deletions(-)

diff --git a/public/pages/property/costDetail/more/more.js b/public/pages/property/costDetail/more/more.js
index 1e3e719..49d9fb9 100644
--- a/public/pages/property/costDetail/more/more.js
+++ b/public/pages/property/costDetail/more/more.js
@@ -1,5 +1,5 @@
 /**
- 涓氬浼氬叕绾︾鐞�
+ 璐圭敤鏄庣粏鏇村绠$悊
  **/
 (function (vc) {
     var DEFAULT_PAGE = 1;
@@ -27,15 +27,27 @@
                     amount: '',
                     meetingResolution: '1',
                     consultationForm: '1'
+                },
+                addForm: {
+                    plannedAnnouncementStart: '',
+                    plannedAnnouncementEnd: '',
+                    publishedAnnouncementStart: '',
+                    publishedAnnouncementEnd: ''
+                },
+                editAnnouncementForm: {
+                    id: '',
+                    mpId: '',
+                    plannedAnnouncementStart: '',
+                    plannedAnnouncementEnd: '',
+                    publishedAnnouncementStart: '',
+                    publishedAnnouncementEnd: ''
                 }
             }
         },
         _initMethod: function () {
             $that = vc.component;
             $that._initDate();
-            // 杩涘叆椤甸潰鏃剁珛鍗宠皟鐢ㄦ帴鍙�
             $that._loadPublicIncomeData(DEFAULT_PAGE, DEFAULT_ROWS);
-            // 鏍规嵁褰撳墠鏍囩椤靛姞杞芥暟鎹�
             if ($that.moreInfo.currentTab !== 'publicIncome') {
                 $that._listData(DEFAULT_PAGE, DEFAULT_ROWS);
             }
@@ -44,7 +56,6 @@
         },
         methods: {
             _initDate: function () {
-                // 鍒濆鍖栨棩鏈熼�夋嫨鍣�
                 $(".startDate").datetimepicker({
                     minView: "month",
                     language: 'zh-CN',
@@ -68,12 +79,11 @@
                     clearBtn: true
                 });
 
-                // 璁剧疆榛樿鏃ユ湡涓哄綋鍓嶆湀浠�
                 var now = new Date();
                 var year = now.getFullYear();
                 var month = now.getMonth() + 1;
                 var startDateStr = year + '-' + (month < 10 ? '0' + month : month) + '-01';
-                var endDate = new Date(year, month, 0); // 鑾峰彇褰撴湀鏈�鍚庝竴澶�
+                var endDate = new Date(year, month, 0);
                 var endDateStr = year + '-' + (month < 10 ? '0' + month : month) + '-' + endDate.getDate();
 
                 $that.moreInfo.conditions.startDate = startDateStr;
@@ -100,7 +110,6 @@
                         }
                     });
 
-                // 闃叉澶氭鐐瑰嚮鏃堕棿鎻掍欢澶卞幓鐒︾偣
                 var startDateElements = document.getElementsByClassName('form-control startDate');
                 if (startDateElements.length > 0) {
                     startDateElements[0].addEventListener('click', function (e) {
@@ -116,19 +125,17 @@
             },
             changeTab: function (_tab) {
                 $that.moreInfo.currentTab = _tab;
-                // 鏍规嵁鏍囩椤靛姞杞戒笉鍚屾暟鎹�
                 if (_tab === 'publicIncome') {
-                    // 鍏叡鏀剁泭閲戞爣绛撅紝璋冪敤鐗规畩鎺ュ彛
                     $that._loadPublicIncomeData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows);
+                } else if (_tab === 'convention') {
+                    $that._loadConventionData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows);
                 } else {
                     $that._listData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows);
                 }
             },
             _loadPublicIncomeData: function (_page, _rows) {
-                // 鑾峰彇URL鍙傛暟涓殑costDetailId
                 var costDetailId = vc.getParam('costDetailId');
                 if (!costDetailId) {
-                    // 灏濊瘯浠巋ash涓幏鍙�
                     var hash = location.hash;
                     if (hash && hash.indexOf('?') !== -1) {
                         var hashParams = hash.substring(hash.indexOf('?') + 1);
@@ -142,12 +149,12 @@
                         }
                     }
                 }
-                
+
                 if (!costDetailId) {
                     vc.toast('缂哄皯costDetailId鍙傛暟');
                     return;
                 }
-                
+
                 var param = {
                     params: {
                         mpId: costDetailId,
@@ -155,8 +162,7 @@
                         row: _rows
                     }
                 };
-                
-                // 璋冪敤鍏叡鏀剁泭閲戞帴鍙�
+
                 vc.http.apiGet('/announcementTimeRange/queryAnnouncementTimeRangeInfo',
                     param,
                     function (json, res) {
@@ -165,19 +171,17 @@
                             if (_json.code === "0000") {
                                 var total = _json.total || 0;
                                 var rows = _rows || DEFAULT_ROWS;
-                                // 璁$畻鎬婚〉鏁�
                                 var totalPages = Math.ceil(total / rows);
                                 if (totalPages === 0) {
                                     totalPages = 1;
                                 }
-                                
+
                                 $that.moreInfo.paginationInfo.dataCount = total;
                                 $that.moreInfo.paginationInfo.total = totalPages;
-                                
-                                // 鏄犲皠鏁版嵁瀛楁
+
                                 var dataList = [];
                                 if (_json.data && Array.isArray(_json.data)) {
-                                    dataList = _json.data.map(function(item) {
+                                    dataList = _json.data.map(function (item) {
                                         return {
                                             id: item.id,
                                             mpId: item.mpId,
@@ -191,7 +195,90 @@
                                         };
                                     });
                                 }
-                                
+
+                                $that.moreInfo.dataList = dataList;
+                                $that.moreInfo.paginationInfo.currentPage = _page;
+                                $that._freshPageList();
+                            } else {
+                                vc.toast(_json.msg || '鏌ヨ澶辫触');
+                                $that.moreInfo.dataList = [];
+                                $that.moreInfo.paginationInfo.dataCount = 0;
+                                $that.moreInfo.paginationInfo.total = 1;
+                                $that.moreInfo.paginationInfo.currentPage = _page;
+                                $that._freshPageList();
+                            }
+                        } catch (e) {
+                            console.error('鏁版嵁瑙f瀽澶辫触:', e);
+                            vc.toast('鏁版嵁瑙f瀽澶辫触');
+                            $that.moreInfo.dataList = [];
+                            $that.moreInfo.paginationInfo.dataCount = 0;
+                            $that.moreInfo.paginationInfo.total = 1;
+                            $that.moreInfo.paginationInfo.currentPage = _page;
+                            $that._freshPageList();
+                        }
+                    },
+                    function (errInfo, error) {
+                        console.error('璇锋眰澶辫触:', errInfo, error);
+                        vc.toast(errInfo || '璇锋眰澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�');
+                        $that.moreInfo.dataList = [];
+                        $that.moreInfo.paginationInfo.dataCount = 0;
+                        $that.moreInfo.paginationInfo.total = 1;
+                        $that.moreInfo.paginationInfo.currentPage = _page;
+                        $that._freshPageList();
+                    }
+                );
+            },
+            _loadConventionData: function (_page, _rows) {
+                var costDetailId = vc.getParam('costDetailId');
+                if (!costDetailId) {
+                    var hash = location.hash;
+                    if (hash && hash.indexOf('?') !== -1) {
+                        var hashParams = hash.substring(hash.indexOf('?') + 1);
+                        var params = hashParams.split('&');
+                        for (var i = 0; i < params.length; i++) {
+                            var param = params[i].split('=');
+                            if (param[0] === 'costDetailId') {
+                                costDetailId = decodeURIComponent(param[1] || '');
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                if (!costDetailId) {
+                    vc.toast('缂哄皯costDetailId鍙傛暟');
+                    return;
+                }
+
+                var param = {
+                    params: {
+                        mpId: costDetailId,
+                        page: _page || 1,
+                        row: _rows || DEFAULT_ROWS
+                    }
+                };
+
+                vc.http.apiGet('/ownersCommitteeConvention/queryOwnersCommitteeConvention',
+                    param,
+                    function (json, res) {
+                        try {
+                            var _json = JSON.parse(json);
+                            if (_json.code === "0000") {
+                                var total = _json.total || 0;
+                                var rows = _rows || DEFAULT_ROWS;
+                                var totalPages = Math.ceil(total / rows);
+                                if (totalPages === 0) {
+                                    totalPages = 1;
+                                }
+
+                                $that.moreInfo.paginationInfo.dataCount = total;
+                                $that.moreInfo.paginationInfo.total = totalPages;
+
+                                var dataList = [];
+                                if (_json.data && Array.isArray(_json.data)) {
+                                    dataList = _json.data;
+                                }
+
                                 $that.moreInfo.dataList = dataList;
                                 $that.moreInfo.paginationInfo.currentPage = _page;
                                 $that._freshPageList();
@@ -232,7 +319,6 @@
                 var param = {
                     params: $that.moreInfo.conditions
                 };
-                // 鍙戦�乬et璇锋眰 - 杩欓噷闇�瑕佹牴鎹疄闄匒PI璋冩暣
                 vc.http.apiGet('/costDetail/queryMore',
                     param,
                     function (json, res) {
@@ -245,7 +331,6 @@
                     },
                     function (errInfo, error) {
                         console.log('璇锋眰澶辫触澶勭悊');
-                        // 妯℃嫙鏁版嵁鐢ㄤ簬婕旂ず
                         $that.moreInfo.dataList = [
                             {
                                 amount: '寮犱笁涓�',
@@ -266,7 +351,6 @@
                 var pageList = [];
 
                 if (total <= 7) {
-                    // 鎬婚〉鏁板皬浜庣瓑浜�7锛屾樉绀烘墍鏈夐〉鐮�
                     for (var i = 1; i <= total; i++) {
                         pageList.push({
                             page: i,
@@ -275,9 +359,7 @@
                         });
                     }
                 } else {
-                    // 鎬婚〉鏁板ぇ浜�7锛屾樉绀洪儴鍒嗛〉鐮�
                     if (currentPage <= 4) {
-                        // 褰撳墠椤靛湪鍓�4椤�
                         for (var i = 1; i <= 5; i++) {
                             pageList.push({
                                 page: i,
@@ -296,7 +378,6 @@
                             currentPage: false
                         });
                     } else if (currentPage >= total - 3) {
-                        // 褰撳墠椤靛湪鍚�4椤�
                         pageList.push({
                             page: 1,
                             pageView: 1,
@@ -315,7 +396,6 @@
                             });
                         }
                     } else {
-                        // 褰撳墠椤靛湪涓棿
                         pageList.push({
                             page: 1,
                             pageView: 1,
@@ -351,6 +431,8 @@
             _changePageSize: function () {
                 if ($that.moreInfo.currentTab === 'publicIncome') {
                     $that._loadPublicIncomeData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows);
+                } else if ($that.moreInfo.currentTab === 'convention') {
+                    $that._loadConventionData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows);
                 } else {
                     $that._listData(DEFAULT_PAGE, $that.moreInfo.paginationInfo.rows);
                 }
@@ -361,6 +443,8 @@
                 }
                 if ($that.moreInfo.currentTab === 'publicIncome') {
                     $that._loadPublicIncomeData(_page, $that.moreInfo.paginationInfo.rows);
+                } else if ($that.moreInfo.currentTab === 'convention') {
+                    $that._loadConventionData(_page, $that.moreInfo.paginationInfo.rows);
                 } else {
                     $that._listData(_page, $that.moreInfo.paginationInfo.rows);
                 }
@@ -375,20 +459,101 @@
                 }
                 if ($that.moreInfo.currentTab === 'publicIncome') {
                     $that._loadPublicIncomeData(page, $that.moreInfo.paginationInfo.rows);
+                } else if ($that.moreInfo.currentTab === 'convention') {
+                    $that._loadConventionData(page, $that.moreInfo.paginationInfo.rows);
                 } else {
                     $that._listData(page, $that.moreInfo.paginationInfo.rows);
                 }
             },
             _add: function () {
-                // 娣诲姞鍔熻兘
-                vc.toast('娣诲姞鍔熻兘');
+                if ($that.moreInfo.currentTab !== 'publicIncome') {
+                    return;
+                }
+                $that.moreInfo.addForm = {
+                    plannedAnnouncementStart: '',
+                    plannedAnnouncementEnd: '',
+                    publishedAnnouncementStart: '',
+                    publishedAnnouncementEnd: ''
+                };
+                $that._showAddAnnouncementModal();
+            },
+            _showAddAnnouncementModal: function () {
+                const modal = document.getElementById('addAnnouncementTimeRangeModal');
+                modal.classList.add('show');
+                modal.style.display = 'block';
+                modal.removeAttribute('inert');
+                modal.removeAttribute('aria-hidden');
+                modal.setAttribute('aria-modal', 'true');
+                modal.focus();
+            },
+            _hideAddAnnouncementModal: function () {
+                const modal = document.getElementById('addAnnouncementTimeRangeModal');
+                modal.classList.remove('show');
+                modal.style.display = 'none';
+                modal.setAttribute('inert', '');
+                modal.setAttribute('aria-hidden', 'true');
+                modal.removeAttribute('aria-modal');
+            },
+            _saveAddAnnouncementTimeRange: function () {
+                var costDetailId = vc.getParam('costDetailId');
+                if (!costDetailId) {
+                    var hash = location.hash;
+                    if (hash && hash.indexOf('?') !== -1) {
+                        var hashParams = hash.substring(hash.indexOf('?') + 1);
+                        var params = hashParams.split('&');
+                        for (var i = 0; i < params.length; i++) {
+                            var param = params[i].split('=');
+                            if (param[0] === 'costDetailId') {
+                                costDetailId = decodeURIComponent(param[1] || '');
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                if (!costDetailId) {
+                    vc.toast('缂哄皯costDetailId鍙傛暟');
+                    return;
+                }
+
+                var requestData = {
+                    mpId: costDetailId,
+                    plannedAnnouncementStart: $that.moreInfo.addForm.plannedAnnouncementStart || '',
+                    plannedAnnouncementEnd: $that.moreInfo.addForm.plannedAnnouncementEnd || '',
+                    publishedAnnouncementStart: $that.moreInfo.addForm.publishedAnnouncementStart || '',
+                    publishedAnnouncementEnd: $that.moreInfo.addForm.publishedAnnouncementEnd || ''
+                };
+
+                vc.http.apiPost('/announcementTimeRange/saveAnnouncementTimeRangeInfo',
+                    JSON.stringify(requestData),
+                    {
+                        emulateJSON: true
+                    },
+                    function (json, res) {
+                        try {
+                            var _json = JSON.parse(json);
+                            if (_json.code === "0000") {
+                                vc.toast(_json.msg || '淇濆瓨鎴愬姛');
+                                $that._hideAddAnnouncementModal();
+                                $that._loadPublicIncomeData($that.moreInfo.paginationInfo.currentPage, $that.moreInfo.paginationInfo.rows);
+                            } else {
+                                vc.toast(_json.msg || '淇濆瓨澶辫触');
+                            }
+                        } catch (e) {
+                            console.error('鏁版嵁瑙f瀽澶辫触:', e);
+                            vc.toast('鏁版嵁瑙f瀽澶辫触');
+                        }
+                    },
+                    function (errInfo, error) {
+                        console.error('璇锋眰澶辫触:', errInfo, error);
+                        vc.toast(errInfo || '淇濆瓨澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�');
+                    }
+                );
             },
             _export: function () {
-                // 瀵煎嚭鍔熻兘
                 vc.toast('瀵煎嚭鍔熻兘');
             },
             _viewDetailPublicIncome: function (_item) {
-                // 鏌ョ湅璇︽儏
                 vc.toast('鏌ョ湅璇︽儏鍔熻兘');
             },
             _showEditPublicModal: function () {
@@ -409,16 +574,104 @@
                 modal.removeAttribute('aria-modal');
             },
             _editPublicIncome: function (_item) {
-                // 缂栬緫 - 濉厖琛ㄥ崟鏁版嵁
-                // $that.moreInfo.editForm.id = _item.id || '';
-                // $that.moreInfo.editForm.amount = _item.amount || '';
-                // $that.moreInfo.editForm.meetingResolution = _item.meetingResolution || '1';
-                // $that.moreInfo.editForm.consultationForm = _item.consultationForm || '1';
-                // 鎵撳紑寮圭獥
-                $that._showEditPublicModal();
+                if (!_item || !_item.id) {
+                    vc.toast('鏁版嵁閿欒锛屾棤娉曠紪杈�');
+                    return;
+                }
+
+                var costDetailId = vc.getParam('costDetailId');
+                if (!costDetailId) {
+                    var hash = location.hash;
+                    if (hash && hash.indexOf('?') !== -1) {
+                        var hashParams = hash.substring(hash.indexOf('?') + 1);
+                        var params = hashParams.split('&');
+                        for (var i = 0; i < params.length; i++) {
+                            var param = params[i].split('=');
+                            if (param[0] === 'costDetailId') {
+                                costDetailId = decodeURIComponent(param[1] || '');
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                var formatDate = function (dateStr) {
+                    if (!dateStr || dateStr === '-' || dateStr.trim() === '') {
+                        return '';
+                    }
+                    return dateStr.trim();
+                };
+
+                $that.moreInfo.editAnnouncementForm = {
+                    id: _item.id || '',
+                    mpId: costDetailId || _item.mpId || '',
+                    plannedAnnouncementStart: formatDate(_item.proposedStartDate),
+                    plannedAnnouncementEnd: formatDate(_item.proposedEndDate),
+                    publishedAnnouncementStart: formatDate(_item.publishedStartDate),
+                    publishedAnnouncementEnd: formatDate(_item.publishedEndDate)
+                };
+
+                $that._showEditAnnouncementModal();
+            },
+            _showEditAnnouncementModal: function () {
+                const modal = document.getElementById('editAnnouncementTimeRangeModal');
+                modal.classList.add('show');
+                modal.style.display = 'block';
+                modal.removeAttribute('inert');
+                modal.removeAttribute('aria-hidden');
+                modal.setAttribute('aria-modal', 'true');
+                modal.focus();
+            },
+            _hideEditAnnouncementModal: function () {
+                const modal = document.getElementById('editAnnouncementTimeRangeModal');
+                modal.classList.remove('show');
+                modal.style.display = 'none';
+                modal.setAttribute('inert', '');
+                modal.setAttribute('aria-hidden', 'true');
+                modal.removeAttribute('aria-modal');
+            },
+            _saveEditAnnouncementTimeRange: function () {
+                if (!$that.moreInfo.editAnnouncementForm.id) {
+                    vc.toast('缂哄皯涓婚敭ID锛屾棤娉曚繚瀛�');
+                    return;
+                }
+
+                var requestData = {
+                    id: $that.moreInfo.editAnnouncementForm.id,
+                    mpId: $that.moreInfo.editAnnouncementForm.mpId || '',
+                    plannedAnnouncementStart: $that.moreInfo.editAnnouncementForm.plannedAnnouncementStart || '',
+                    plannedAnnouncementEnd: $that.moreInfo.editAnnouncementForm.plannedAnnouncementEnd || '',
+                    publishedAnnouncementStart: $that.moreInfo.editAnnouncementForm.publishedAnnouncementStart || '',
+                    publishedAnnouncementEnd: $that.moreInfo.editAnnouncementForm.publishedAnnouncementEnd || ''
+                };
+
+                vc.http.apiPost('/announcementTimeRange/updateAnnouncementTimeRangeInfo',
+                    JSON.stringify(requestData),
+                    {
+                        emulateJSON: true
+                    },
+                    function (json, res) {
+                        try {
+                            var _json = JSON.parse(json);
+                            if (_json.code === "0000") {
+                                vc.toast(_json.msg || '淇敼鎴愬姛');
+                                $that._hideEditAnnouncementModal();
+                                $that._loadPublicIncomeData($that.moreInfo.paginationInfo.currentPage, $that.moreInfo.paginationInfo.rows);
+                            } else {
+                                vc.toast(_json.msg || '淇敼澶辫触');
+                            }
+                        } catch (e) {
+                            console.error('鏁版嵁瑙f瀽澶辫触:', e);
+                            vc.toast('鏁版嵁瑙f瀽澶辫触');
+                        }
+                    },
+                    function (errInfo, error) {
+                        console.error('璇锋眰澶辫触:', errInfo, error);
+                        vc.toast(errInfo || '淇敼澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�');
+                    }
+                );
             },
             _saveEditPublicIncome: function () {
-                // 淇濆瓨缂栬緫
                 var param = {
                     params: {
                         id: $that.moreInfo.editForm.id,
@@ -441,23 +694,58 @@
                 );
             },
             _delete: function (_item) {
+                if (!_item || !_item.id) {
+                    vc.toast('鏁版嵁閿欒锛屾棤娉曞垹闄�');
+                    return;
+                }
+
                 vc.confirm('纭畾瑕佸垹闄よ繖鏉¤褰曞悧锛�', function () {
-                    var param = {
-                        params: {
+                    if ($that.moreInfo.currentTab === 'publicIncome') {
+                        var requestData = {
                             id: _item.id
-                        }
-                    };
-                    // 杩欓噷闇�瑕佹牴鎹疄闄匒PI璋冩暣
-                    vc.http.apiPost('/costDetail/deleteMore',
-                        param,
-                        function (json, res) {
-                            vc.toast('鍒犻櫎鎴愬姛');
-                            $that._listData($that.moreInfo.paginationInfo.currentPage, $that.moreInfo.paginationInfo.rows);
-                        },
-                        function (errInfo, error) {
-                            vc.message(errInfo);
-                        }
-                    );
+                        };
+
+                        vc.http.apiPost('/announcementTimeRange/deleteAnnouncementTimeRangeInfo',
+                            JSON.stringify(requestData),
+                            {
+                                emulateJSON: true
+                            },
+                            function (json, res) {
+                                try {
+                                    var _json = JSON.parse(json);
+                                    if (_json.code === "0000") {
+                                        vc.toast(_json.msg || '鍒犻櫎鎴愬姛');
+                                        $that._loadPublicIncomeData($that.moreInfo.paginationInfo.currentPage, $that.moreInfo.paginationInfo.rows);
+                                    } else {
+                                        vc.toast(_json.msg || '鍒犻櫎澶辫触');
+                                    }
+                                } catch (e) {
+                                    console.error('鏁版嵁瑙f瀽澶辫触:', e);
+                                    vc.toast('鏁版嵁瑙f瀽澶辫触');
+                                }
+                            },
+                            function (errInfo, error) {
+                                console.error('璇锋眰澶辫触:', errInfo, error);
+                                vc.toast(errInfo || '鍒犻櫎澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�');
+                            }
+                        );
+                    } else {
+                        var param = {
+                            params: {
+                                id: _item.id
+                            }
+                        };
+                        vc.http.apiPost('/costDetail/deleteMore',
+                            param,
+                            function (json, res) {
+                                vc.toast('鍒犻櫎鎴愬姛');
+                                $that._listData($that.moreInfo.paginationInfo.currentPage, $that.moreInfo.paginationInfo.rows);
+                            },
+                            function (errInfo, error) {
+                                vc.message(errInfo);
+                            }
+                        );
+                    }
                 });
             }
         }

--
Gitblit v1.8.0