From 5bdaf416d66b675131004de1aba5d161772a52b0 Mon Sep 17 00:00:00 2001
From: liubp <1535785116@qq.com>
Date: 星期五, 19 十二月 2025 18:27:52 +0800
Subject: [PATCH] 添加所属小区字段

---
 public/pages/property/costDetail/costDetail.js |  244 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 244 insertions(+), 0 deletions(-)

diff --git a/public/pages/property/costDetail/costDetail.js b/public/pages/property/costDetail/costDetail.js
index e69de29..978e309 100644
--- a/public/pages/property/costDetail/costDetail.js
+++ b/public/pages/property/costDetail/costDetail.js
@@ -0,0 +1,244 @@
+/**
+ 璐圭敤鏄庣粏琛�
+ **/
+(function (vc) {
+    var DEFAULT_PAGE = 1;
+    var DEFAULT_ROWS = 15;
+    var $that = {};
+    vc.extends({
+        data: {
+            costDetailInfo: {
+                costDetails: [],
+                paginationInfo: {
+                    currentPage: 1,
+                    rows: DEFAULT_ROWS,
+                    total: 1,
+                    dataCount: 0,
+                    pageList: []
+                },
+                jumpPage: 1,
+                conditions: {
+                    date: '',
+                    communityName: '',
+                    communityCode: ''
+                }
+            }
+        },
+        _initMethod: function () {
+            $that = vc.component;
+            $that._injectStyles();
+            $that._listCostDetails(DEFAULT_PAGE, DEFAULT_ROWS);
+            $that._initDate();
+        },
+        _initEvent: function () {
+            vc.on('costDetail', 'listCostDetail', function (_param) {
+                $that._listCostDetails(DEFAULT_PAGE, DEFAULT_ROWS);
+            });
+        },
+        methods: {
+            _initDate: function () {
+                $(".queryDate").datetimepicker({
+                    language: 'zh-CN',
+                    fontAwesome: 'fa',
+                    format: 'yyyy-mm-dd hh:ii:ss',
+                    initTime: true,
+                    initialDate: new Date(),
+                    autoClose: 1,
+                    todayBtn: true
+                });
+                $('.queryDate').datetimepicker()
+                    .on('changeDate', function (ev) {
+                        var value = $(".queryDate").val();
+                        $that.costDetailInfo.conditions.date = value;
+                    });
+                //闃叉澶氭鐐瑰嚮鏃堕棿鎻掍欢澶卞幓鐒︾偣
+                var queryDateElements = document.getElementsByClassName('form-control queryDate');
+                if (queryDateElements.length > 0) {
+                    queryDateElements[0].addEventListener('click', function(e) {
+                        e.currentTarget.blur();
+                    });
+                }
+            },
+            _listCostDetails: function (_page, _rows) {
+                $that.costDetailInfo.conditions.page = _page;
+                $that.costDetailInfo.conditions.row = _rows;
+                $that.costDetailInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
+                var param = {
+                    params: $that.costDetailInfo.conditions
+                };
+                //鍙戦�乬et璇锋眰
+                vc.http.apiGet('/costDetail/queryCostDetail',
+                    param,
+                    function (json, res) {
+                        var _json = JSON.parse(json);
+                        $that.costDetailInfo.paginationInfo.dataCount = _json.total || 0;
+                        $that.costDetailInfo.paginationInfo.total = _json.records || 1;
+                        $that.costDetailInfo.costDetails = _json.data || [];
+                        $that.costDetailInfo.paginationInfo.currentPage = _page;
+                        $that._freshPageList();
+                    },
+                    function (errInfo, error) {
+                        console.log('璇锋眰澶辫触澶勭悊');
+                        $that.costDetailInfo.costDetails = [];
+                        $that.costDetailInfo.paginationInfo.dataCount = 0;
+                        $that.costDetailInfo.paginationInfo.total = 1;
+                        $that._freshPageList();
+                    }
+                );
+            },
+            _freshPageList: function () {
+                var currentPage = $that.costDetailInfo.paginationInfo.currentPage;
+                var total = $that.costDetailInfo.paginationInfo.total;
+                var pageList = [];
+                
+                if (total <= 7) {
+                    // 鎬婚〉鏁板皬浜庣瓑浜�7锛屾樉绀烘墍鏈夐〉鐮�
+                    for (var i = 1; i <= total; i++) {
+                        pageList.push({
+                            page: i,
+                            pageView: i,
+                            currentPage: i == currentPage
+                        });
+                    }
+                } else {
+                    // 鎬婚〉鏁板ぇ浜�7锛屾樉绀洪儴鍒嗛〉鐮�
+                    if (currentPage <= 4) {
+                        // 褰撳墠椤靛湪鍓�4椤�
+                        for (var i = 1; i <= 5; i++) {
+                            pageList.push({
+                                page: i,
+                                pageView: i,
+                                currentPage: i == currentPage
+                            });
+                        }
+                        pageList.push({
+                            page: 0,
+                            pageView: '...',
+                            currentPage: false
+                        });
+                        pageList.push({
+                            page: total,
+                            pageView: total,
+                            currentPage: false
+                        });
+                    } else if (currentPage >= total - 3) {
+                        // 褰撳墠椤靛湪鍚�4椤�
+                        pageList.push({
+                            page: 1,
+                            pageView: 1,
+                            currentPage: false
+                        });
+                        pageList.push({
+                            page: 0,
+                            pageView: '...',
+                            currentPage: false
+                        });
+                        for (var i = total - 4; i <= total; i++) {
+                            pageList.push({
+                                page: i,
+                                pageView: i,
+                                currentPage: i == currentPage
+                            });
+                        }
+                    } else {
+                        // 褰撳墠椤靛湪涓棿
+                        pageList.push({
+                            page: 1,
+                            pageView: 1,
+                            currentPage: false
+                        });
+                        pageList.push({
+                            page: 0,
+                            pageView: '...',
+                            currentPage: false
+                        });
+                        for (var i = currentPage - 1; i <= currentPage + 1; i++) {
+                            pageList.push({
+                                page: i,
+                                pageView: i,
+                                currentPage: i == currentPage
+                            });
+                        }
+                        pageList.push({
+                            page: 0,
+                            pageView: '...',
+                            currentPage: false
+                        });
+                        pageList.push({
+                            page: total,
+                            pageView: total,
+                            currentPage: false
+                        });
+                    }
+                }
+                
+                $that.costDetailInfo.paginationInfo.pageList = pageList;
+            },
+            _queryCostDetails: function () {
+                $that._listCostDetails(DEFAULT_PAGE, $that.costDetailInfo.paginationInfo.rows);
+            },
+            _resetQuery: function () {
+                $that.costDetailInfo.conditions.date = '';
+                $that.costDetailInfo.conditions.communityName = '';
+                $that.costDetailInfo.conditions.communityCode = '';
+                $('.queryDate').val('');
+                $that._listCostDetails(DEFAULT_PAGE, $that.costDetailInfo.paginationInfo.rows);
+            },
+            _changePageSize: function () {
+                $that._listCostDetails(DEFAULT_PAGE, $that.costDetailInfo.paginationInfo.rows);
+            },
+            _goToPage: function (_page) {
+                if (!_page || _page < 1 || _page > $that.costDetailInfo.paginationInfo.total) {
+                    return;
+                }
+                $that._listCostDetails(_page, $that.costDetailInfo.paginationInfo.rows);
+            },
+            _jumpToPage: function () {
+                var page = parseInt($that.costDetailInfo.jumpPage);
+                if (isNaN(page) || page < 1) {
+                    page = 1;
+                }
+                if (page > $that.costDetailInfo.paginationInfo.total) {
+                    page = $that.costDetailInfo.paginationInfo.total;
+                }
+                $that._listCostDetails(page, $that.costDetailInfo.paginationInfo.rows);
+            },
+            _addCostDetail: function () {
+                // 璺宠浆鍒版坊鍔犻〉闈㈡垨鎵撳紑娣诲姞寮圭獥
+                vc.jumpToPage('/#/pages/property/costDetail/add');
+            },
+            _importCostDetail: function () {
+                // 鎵撳紑瀵煎叆寮圭獥鎴栬烦杞埌瀵煎叆椤甸潰
+                vc.toast('璐圭敤瀵煎叆鍔熻兘');
+            },
+            _viewMore: function (_item) {
+                // 鏌ョ湅璇︽儏
+                vc.jumpToPage('/#/pages/property/costDetail/detail?costDetailId=' + _item.costDetailId);
+            },
+            _editCostDetail: function (_item) {
+                // 缂栬緫
+                vc.jumpToPage('/#/pages/property/costDetail/edit?costDetailId=' + _item.costDetailId);
+            },
+            _deleteCostDetail: function (_item) {
+                vc.confirm('纭畾瑕佸垹闄よ繖鏉¤垂鐢ㄦ槑缁嗗悧锛�', function () {
+                    var param = {
+                        params: {
+                            costDetailId: _item.costDetailId
+                        }
+                    };
+                    vc.http.apiPost('/costDetail/deleteCostDetail',
+                        param,
+                        function (json, res) {
+                            vc.toast('鍒犻櫎鎴愬姛');
+                            $that._listCostDetails($that.costDetailInfo.paginationInfo.currentPage, $that.costDetailInfo.paginationInfo.rows);
+                        },
+                        function (errInfo, error) {
+                            vc.message(errInfo);
+                        }
+                    );
+                });
+            }
+        }
+    });
+})(window.vc);
+

--
Gitblit v1.8.0