From da84a8d3418433c7de77068c933349c874ec70bc Mon Sep 17 00:00:00 2001
From: zhangjq <z16372660229@163.com>
Date: 星期一, 26 一月 2026 11:36:10 +0800
Subject: [PATCH] ZJQ修复楼栋树结构导入日志稳定性
---
public/pages/property/assetImportLog/assetImportLog.js | 17 ++++++++
public/pages/property/assetImportLogDetail/assetImportLogDetail.js | 17 ++++++++
public/components/property/roomTreeDiv/roomTreeDiv.js | 55 +++++++++++++++++----------
3 files changed, 69 insertions(+), 20 deletions(-)
diff --git a/public/components/property/roomTreeDiv/roomTreeDiv.js b/public/components/property/roomTreeDiv/roomTreeDiv.js
index 9e0dc5d..a308bfa 100644
--- a/public/components/property/roomTreeDiv/roomTreeDiv.js
+++ b/public/components/property/roomTreeDiv/roomTreeDiv.js
@@ -77,6 +77,17 @@
communityId: vc.getCurrentCommunity().communityId
}
};
+
+ // 楠岃瘉绀惧尯ID鏄惁瀛樺湪
+ let communityId = vc.getCurrentCommunity().communityId;
+ console.log('褰撳墠绀惧尯ID:', communityId);
+ if (!communityId) {
+ console.error('鏈幏鍙栧埌鏈夋晥鐨勭ぞ鍖篒D');
+ $that.roomTreeDivInfo.units = [];
+ $that._initJsTreeRoomTreeDivFloorUnit();
+ return;
+ }
+
// 鍙戦�� GET 璇锋眰鑾峰彇鍗曞厓鏁版嵁
vc.http.apiGet('/unit.queryUnits',
param,
@@ -88,39 +99,39 @@
console.log('鍗曞厓API杩斿洖鍘熷鏁版嵁:', json);
let unitsData = [];
- if (json) {
+ if (json && json.trim() !== '') {
try {
// 瑙f瀽 JSON 鏁版嵁
let _unitInfo = JSON.parse(json);
console.log('瑙f瀽鍚庣殑鍗曞厓鏁版嵁:', _unitInfo);
// 澧炲己鏁版嵁澶勭悊锛屾敮鎸佸绉嶅搷搴旀牸寮�
- if (_unitInfo && Array.isArray(_unitInfo)) {
+ if (_unitInfo && _unitInfo.code == 0) {
+ // 鏍囧噯缁勪欢API杩斿洖鏍煎紡
+ if (_unitInfo.data && Array.isArray(_unitInfo.data)) {
+ unitsData = _unitInfo.data;
+ console.log('浣跨敤鏍囧噯鏍煎紡.data瀛楁鏁扮粍锛屽叡', unitsData.length, '鏉″崟鍏冩暟鎹�');
+ } else if (_unitInfo.units && Array.isArray(_unitInfo.units)) {
+ unitsData = _unitInfo.units;
+ console.log('浣跨敤鏍囧噯鏍煎紡.units瀛楁鏁扮粍锛屽叡', unitsData.length, '鏉″崟鍏冩暟鎹�');
+ }
+ } else if (_unitInfo && Array.isArray(_unitInfo)) {
+ // 鐩存帴鏁扮粍鏍煎紡
unitsData = _unitInfo;
console.log('浣跨敤鐩存帴鏁扮粍鏍煎紡锛屽叡', unitsData.length, '鏉″崟鍏冩暟鎹�');
- } else if (_unitInfo && _unitInfo.data && Array.isArray(_unitInfo.data)) {
- unitsData = _unitInfo.data;
- console.log('浣跨敤.data瀛楁鏁扮粍锛屽叡', unitsData.length, '鏉″崟鍏冩暟鎹�');
- } else if (_unitInfo && _unitInfo.units && Array.isArray(_unitInfo.units)) {
- unitsData = _unitInfo.units;
- console.log('浣跨敤.units瀛楁鏁扮粍锛屽叡', unitsData.length, '鏉″崟鍏冩暟鎹�');
} else if (_unitInfo && typeof _unitInfo === 'object') {
- // 澶勭悊鍏朵粬鍙兘鐨勫璞℃牸寮�
- console.warn('鍗曞厓鏁版嵁鏍煎紡涓嶇鍚堥鏈燂紝灏濊瘯鏌ユ壘鏁扮粍瀛楁:', _unitInfo);
- // 閬嶅巻瀵硅薄灞炴�э紝鏌ユ壘鍙兘鐨勬暟鎹暟缁�
- for (let key in _unitInfo) {
- if (Array.isArray(_unitInfo[key])) {
- unitsData = _unitInfo[key];
- console.log('浠�', key, '瀛楁鑾峰彇鍗曞厓鏁版嵁锛屽叡', unitsData.length, '鏉�');
- break;
- }
- }
+ // 鍗曞璞℃牸寮�
+ unitsData = [_unitInfo];
+ console.log('浣跨敤鍗曞璞℃牸寮忥紝鍏� 1 鏉″崟鍏冩暟鎹�');
} else {
console.warn('鍗曞厓鏁版嵁鏍煎紡涓嶇鍚堥鏈燂紝鏃犳硶鎻愬彇鏁扮粍:', _unitInfo);
}
} catch (e) {
console.error('瑙f瀽鍗曞厓鏁版嵁鏃跺彂鐢熼敊璇�:', e);
+ console.error('鍘熷鍝嶅簲鏁版嵁:', json);
}
+ } else {
+ console.warn('鍗曞厓API杩斿洖绌烘暟鎹�');
}
console.log('鏈�缁堝鐞嗗悗鐨勫崟鍏冩暟鎹�:', unitsData);
@@ -173,8 +184,12 @@
if (_callName == 'oweFeeCallable') {
return;
}
- // 榛樿閫変腑绗竴涓崟鍏�
- $('#jstree_floorUnitRoomDiv').jstree('select_node', _data[0].children[0].id /* , true */);
+ // 榛樿閫変腑绗竴涓崟鍏冿紝娣诲姞瀹夊叏妫�鏌ラ伩鍏嶅嚭閿�
+ if (_data && _data.length > 0 && _data[0].children && _data[0].children.length > 0) {
+ $('#jstree_floorUnitRoomDiv').jstree('select_node', _data[0].children[0].id /* , true */);
+ } else {
+ console.log('娌℃湁鍙敤鐨勫崟鍏冩暟鎹紝鏃犳硶榛樿閫変腑');
+ }
});
/**
* 鐩戝惉鏍戣妭鐐瑰彉鍖栦簨浠�
diff --git a/public/pages/property/assetImportLog/assetImportLog.js b/public/pages/property/assetImportLog/assetImportLog.js
index fefc00f..bf270b9 100644
--- a/public/pages/property/assetImportLog/assetImportLog.js
+++ b/public/pages/property/assetImportLog/assetImportLog.js
@@ -25,6 +25,11 @@
vc.component._listAssetImportLogs(_currentPage, DEFAULT_ROWS);
});
},
+ _destroyedMethod: function () {
+ console.log('瀵煎叆鏃ュ織鍒楄〃椤甸潰宸查攢姣侊紝娓呯悊璧勬簮');
+ // 鏍囪缁勪欢宸查攢姣侊紝鐢ㄤ簬寮傛鍥炶皟涓鏌�
+ vc.component._isDestroyed = true;
+ },
methods: {
_listAssetImportLogs: function (_page, _rows) {
var param = {
@@ -39,6 +44,12 @@
param,
function (json, res) {
try {
+ // 妫�鏌ョ粍浠舵槸鍚﹀凡閿�姣�
+ if (vc.component._isDestroyed) {
+ console.log('缁勪欢宸查攢姣侊紝璺宠繃鏁版嵁澶勭悊');
+ return;
+ }
+
let _assetImportLogInfo = JSON.parse(json);
console.log('鏌ヨ瀵煎叆鏃ュ織鎴愬姛锛岃繑鍥炴暟鎹�:', _assetImportLogInfo);
@@ -67,6 +78,12 @@
}
},
function (errInfo, error) {
+ // 妫�鏌ョ粍浠舵槸鍚﹀凡閿�姣�
+ if (vc.component._isDestroyed) {
+ console.log('缁勪欢宸查攢姣侊紝璺宠繃閿欒澶勭悊');
+ return;
+ }
+
// 璇︾粏璁板綍閿欒淇℃伅锛屼究浜庤皟璇�
console.error('璇锋眰瀵煎叆鏃ュ織澶辫触:', errInfo, error);
diff --git a/public/pages/property/assetImportLogDetail/assetImportLogDetail.js b/public/pages/property/assetImportLogDetail/assetImportLogDetail.js
index 9197566..d742a76 100644
--- a/public/pages/property/assetImportLogDetail/assetImportLogDetail.js
+++ b/public/pages/property/assetImportLogDetail/assetImportLogDetail.js
@@ -72,6 +72,11 @@
$that._listAssetImportLogDetails(_currentPage, DEFAULT_ROWS);
});
},
+ _destroyedMethod: function() {
+ console.log('瀵煎叆鏃ュ織璇︽儏椤甸潰宸查攢姣侊紝娓呯悊璧勬簮');
+ // 閲嶇疆鐘舵�侊紝閬垮厤缁勪欢閿�姣佸悗浠嶆湁浠g爜璁块棶缁勪欢鏁版嵁
+ $that = null;
+ },
methods: {
_openDelRoomModel: function(content) {
// 瑙f瀽 JSON 瀛楃涓�
@@ -118,6 +123,12 @@
vc.http.apiGet('/assetImportLogDetail/queryAssetImportLogDetail',
params,
function(json, res) {
+ // 妫�鏌ョ粍浠舵槸鍚﹀凡閿�姣�
+ if (!$that) {
+ console.log('缁勪欢宸查攢姣侊紝璺宠繃鏃ュ織璇︽儏澶勭悊');
+ return;
+ }
+
console.log('鏌ヨ鏃ュ織璇︽儏鍝嶅簲:', json);
try {
// 妫�鏌ュ搷搴旀槸鍚︿负绌�
@@ -194,6 +205,12 @@
}
},
function(errInfo, error) {
+ // 妫�鏌ョ粍浠舵槸鍚﹀凡閿�姣�
+ if (!$that) {
+ console.log('缁勪欢宸查攢姣侊紝璺宠繃鏃ュ織璇︽儏閿欒澶勭悊');
+ return;
+ }
+
console.log('璇锋眰鏃ュ織璇︽儏澶辫触:', errInfo, error);
// 濡傛灉鏄綉缁滈敊璇垨瓒呮椂锛屼笖閲嶈瘯娆℃暟鏈揪涓婇檺锛屽垯閲嶈瘯
--
Gitblit v1.8.0