From c1fd6952f42461bc7e83c97f594a52fc1af934eb Mon Sep 17 00:00:00 2001
From: liubp <1535785116@qq.com>
Date: 星期四, 25 十二月 2025 18:15:43 +0800
Subject: [PATCH] 费用明细表,查询,编辑,删除,添加接口对接,公益金表接口对接,页面样式优化
---
public/pages/property/costDetail/edit/edit.js | 243 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 239 insertions(+), 4 deletions(-)
diff --git a/public/pages/property/costDetail/edit/edit.js b/public/pages/property/costDetail/edit/edit.js
index 369a818..da0016a 100644
--- a/public/pages/property/costDetail/edit/edit.js
+++ b/public/pages/property/costDetail/edit/edit.js
@@ -1,10 +1,245 @@
-
+/**
+ 缂栬緫璐圭敤鏄庣粏
+ **/
(function (vc) {
+ var $that = {};
vc.extends({
data: {
- fundType: 'repair', // 榛樿閫変腑缁翠慨璧勯噾
- fundSystemType: 'out' // 榛樿閫変腑绯荤粺澶�
+ costDetailInfo: {
+ costDetailId: '',
+ flowCode: '',
+ date: '',
+ communityName: '',
+ communityCode: '',
+ projectContent: '',
+ managementAmount: '',
+ managementStamped: '1',
+ committeeAmount: '',
+ appraisalAmount: '',
+ committeeStamped: '1',
+ approvalDepartment: '',
+ fundTypeLevel1: '',
+ fundTypeLevel2: '',
+ buildingType: '1',
+ maintenanceType: '',
+ fundType: 'repair', // 榛樿閫変腑缁翠慨璧勯噾
+ fundSystemType: 'out' // 榛樿閫変腑绯荤粺澶�
+ }
+ },
+ _initMethod: function () {
+ $that = vc.component;
+ // 浠嶶RL鑾峰彇costDetailId
+ var costDetailId = vc.getParam('costDetailId');
+ if (costDetailId) {
+ $that.costDetailInfo.costDetailId = costDetailId;
+ $that._loadCostDetail();
+ } else {
+ vc.toast('缂哄皯璐圭敤鏄庣粏ID');
+ setTimeout(function() {
+ vc.goBack();
+ }, 1500);
+ }
+ },
+ methods: {
+ _loadCostDetail: function () {
+ // 鏌ヨ鎵�鏈夋暟鎹紝鐒跺悗鎵惧埌鍖归厤鐨勮褰�
+ var params = {
+ communityName: vc.getCurrentCommunity().name,
+ page: 1,
+ 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++) {
+ var recordId = String(records[i].id);
+ console.log('姣旇緝ID: 鐩爣=' + targetId + ', 璁板綍=' + recordId);
+ if (recordId === targetId || records[i].id == $that.costDetailInfo.costDetailId) {
+ foundItem = records[i];
+ console.log('鎵惧埌鍖归厤璁板綍:', foundItem);
+ 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() {
+ vc.goBack();
+ }, 1500);
+ }
+ } else {
+ console.error('API杩斿洖閿欒:', _json);
+ vc.toast('鏈壘鍒拌璐圭敤鏄庣粏');
+ setTimeout(function() {
+ vc.goBack();
+ }, 1500);
+ }
+ } catch (e) {
+ console.error('鏁版嵁瑙f瀽澶辫触:', e);
+ vc.toast('鏁版嵁瑙f瀽澶辫触: ' + e.message);
+ }
+ },
+ function (errInfo, error) {
+ console.error('璇锋眰澶辫触:', errInfo, error);
+ vc.toast('璇锋眰澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�');
+ }
+ );
+ },
+ _fillFormData: function (item) {
+ console.log('寮�濮嬪~鍏呰〃鍗曟暟鎹紝鍘熷鏁版嵁:', item);
+
+ // 濉厖琛ㄥ崟鏁版嵁
+ var dateStr = '';
+ if (item.date) {
+ dateStr = item.date.substring(0, 10); // 鍙栨棩鏈熼儴鍒� yyyy-mm-dd
+ } 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 || '';
+ vc.component.costDetailInfo.communityCode = item.projectCode || '';
+ vc.component.costDetailInfo.projectContent = item.projectContent || '';
+ vc.component.costDetailInfo.managementAmount = item.managementOfficeAmount || '';
+ vc.component.costDetailInfo.managementStamped = (item.managementOfficeSeal === '鏄�' || item.managementOfficeSeal === '1') ? '1' : '0';
+ vc.component.costDetailInfo.committeeAmount = item.ownersCommitteeAmount || '';
+ vc.component.costDetailInfo.appraisalAmount = item.auditAmount || '';
+ vc.component.costDetailInfo.committeeStamped = (item.ownersCommitteeSeal === '鏄�' || item.ownersCommitteeSeal === '1') ? '1' : '0';
+ vc.component.costDetailInfo.approvalDepartment = item.reportDepartment || '';
+ 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';
+ }
+
+ 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;
+ }
+ if (!$that.costDetailInfo.date) {
+ vc.toast('璇烽�夋嫨鏃ユ湡');
+ return;
+ }
+ if (!$that.costDetailInfo.communityName) {
+ vc.toast('璇疯緭鍏ュ皬鍖哄悕绉�');
+ return;
+ }
+ if (!$that.costDetailInfo.communityCode) {
+ vc.toast('璇疯緭鍏ュ皬鍖虹紪鐮�');
+ return;
+ }
+
+ // 鏋勫缓淇濆瓨鏁版嵁
+ var saveData = {
+ id: $that.costDetailInfo.costDetailId,
+ flowNumber: $that.costDetailInfo.flowCode,
+ date: $that.costDetailInfo.date,
+ projectName: $that.costDetailInfo.communityName,
+ projectCode: $that.costDetailInfo.communityCode,
+ projectContent: $that.costDetailInfo.projectContent,
+ managementOfficeAmount: parseFloat($that.costDetailInfo.managementAmount) || 0,
+ managementOfficeSeal: $that.costDetailInfo.managementStamped === '1' ? '鏄�' : '鍚�',
+ ownersCommitteeAmount: parseFloat($that.costDetailInfo.committeeAmount) || 0,
+ 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'),
+ maintenanceType: $that.costDetailInfo.maintenanceType || '',
+ communityId: vc.getCurrentCommunity().communityId
+ };
+
+ // 瑙f瀽鏃ユ湡
+ if (saveData.date) {
+ var dateParts = saveData.date.split('-');
+ if (dateParts.length >= 2) {
+ saveData.year = parseInt(dateParts[0]);
+ saveData.month = parseInt(dateParts[1]);
+ if (dateParts.length >= 3) {
+ saveData.day = parseInt(dateParts[2]);
+ }
+ }
+ }
+
+ // 璋冪敤鏇存柊API
+ vc.http.apiPost('/maintenancePayment/updateMaintenancePayment',
+ JSON.stringify(saveData), {
+ emulateJSON: true
+ },
+ function (json, res) {
+ try {
+ var _json = JSON.parse(json);
+ if (_json.code === 0) {
+ vc.toast('淇濆瓨鎴愬姛');
+ setTimeout(function() {
+ vc.goBack();
+ }, 1000);
+ } else {
+ vc.toast(_json.msg || '淇濆瓨澶辫触');
+ }
+ } catch (e) {
+ vc.toast('淇濆瓨澶辫触');
+ }
+ },
+ function (errInfo, error) {
+ vc.toast('淇濆瓨澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�');
+ }
+ );
+ },
+ _cancel: function () {
+ vc.goBack();
+ }
}
});
})(window.vc);
-
--
Gitblit v1.8.0