Files
PropertyDeployment/resources/Web/MicroCommunityWeb/html/components/inspection/communityInspectionTree/communityInspectionTree.js
2025-12-09 20:22:03 +08:00

95 lines
3.9 KiB
JavaScript

(function (vc) {
let DEFAULT_PAGE = 1;
let DEFAULT_ROW = 10;
vc.extends({
data: {
communityInspectionTreeInfo: {
plans: [],
callName: ''
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('communityInspectionTree', 'initCommunityInspectionTree', function (_param) {
$that.communityInspectionTreeInfo.callName = _param.callName;
$that._loadCommunityInspectionTree();
});
},
methods: {
_loadCommunityInspectionTree: function () {
let param = {
params: {
hc:1.8
}
};
//发送get请求
vc.http.apiGet('/community.queryCommunityInspectionTree',
param,
function (json) {
let _json = JSON.parse(json);
$that.communityInspectionTreeInfo.plans = _json.data;
$that._initJsTreeCommunityInspectionTree();
},
function () {
console.log('请求失败处理');
});
},
_initJsTreeCommunityInspectionTree: function () {
let _data = $that.communityInspectionTreeInfo.plans;
$.jstree.destroy()
$("#jstree_communityInspectionTreeDiv").jstree({
"checkbox": {
"keep_selected_style": false
},
'state': { //一些初始化状态
"opened": true,
},
'core': {
"check_callback": true,
'data': _data
}
});
$("#jstree_communityInspectionTreeDiv").on("ready.jstree", function (e, data) {
});
$('#jstree_communityInspectionTreeDiv').on("changed.jstree", function (e, data) {
if (data.action == 'model' || data.action == 'ready') {
return;
}
let _selected = data.selected[0];
if (_selected.startsWith('c_')) {
vc.emit($that.communityInspectionTreeInfo.callName, 'notifyQuery', {
communityName: data.node.original.communityName,
communityId: data.node.original.communityId,
inspectionPlanId: '',
staffId: ''
})
return;
}
if (_selected.startsWith('p_')) {
vc.emit($that.communityInspectionTreeInfo.callName, 'notifyQuery', {
communityId: data.node.original.communityId,
inspectionPlanId: data.node.original.inspectionPlanId,
staffId: ''
})
return;
}
//console.log(_selected, data.node.original.unitId)
if (_selected.startsWith('s_')) {
vc.emit($that.communityInspectionTreeInfo.callName, 'notifyQuery', {
communityId: data.node.original.communityId,
inspectionPlanId: data.node.original.inspectionPlanId,
staffId: data.node.original.staffId,
})
}
});
$('#jstree_communityInspectionTreeDiv')
.on('click', '.jstree-anchor', function (e) {
$(this).jstree(true).toggle_node(e.target);
})
},
}
});
})(window.vc);