* Adjust code .

This commit is contained in:
guofeilong
2023-03-30 13:47:13 +08:00
parent f6cab52121
commit 6a39183729
+95 -91
View File
@@ -51,6 +51,98 @@ $(function()
if(item.active) $li.addClass('active open in');
}
});
ele.on('click', '.icon-drop', function(e)
{
$('.dropdown-in-tree').css('display', 'none');
var isCatalogue = $(this).attr('data-isCatalogue') === 'false' ? false : true;
var dropDownID = isCatalogue ? 'dropDownCatalogue' : 'dropDownLibrary';
var libID = 0;
var moduleID = 0;
var parentID = 0;
var $module = $(this).closest('a');
var hasChildren = $module.data('has-children');
var moduleType = '';
if($module.hasClass('lib'))
{
libID = $module.data('id');
moduleType = $module.data('type');
parentID = libID;
moduleID = libID;
}
else
{
moduleID = $module.data('id');
libID = $module.closest('.lib').data('id');
moduleType = $module.closest('.lib').data('type');
parentID = $module.closest('ul').closest('.lib').data('id');
}
moduleData = {
"libID" : libID,
"parentID" : parentID,
"objectID" : moduleID,
"moduleType": moduleType == 'lib' ? 'doc' : moduleType,
};
var option = {
left : e.pageX,
top : e.pageY,
type : dropDownID,
libID : libID,
moduleID : moduleID,
hasChildren : hasChildren
};
var dropDown = renderDropdown(option);
$(".m-doc-tablecontents").append(dropDown);
e.stopPropagation();
}).on('blur', '.file-tree input.input-tree', function()
{
var $input = $(this);
var value = $input.val();
if(!value)
{
$input.closest('[data-id=insert]').remove();
return;
}
moduleData.name = value;
$.post(createLink('tree', 'ajaxCreateModule'), moduleData, function(result)
{
result = JSON.parse(result);
if(result.result == 'fail')
{
bootbox.alert(
result.message[0],
function()
{
setTimeout(function()
{
$('.file-tree .input-tree').focus()
}, 10)
}
);
return false;
}
var module = result.module;
var resultDom = $('[data-id=aTreeModal]').html().replace(/%name%/g, module.name).replace(/%id%/g, module.id).replace('insert', module.id);
$input.closest('ul').find('.has-input').css('padding-left', '15px');
$input.after(resultDom);
$input.remove();
if(moduleData.isUpdate)
{
$.getJSON(createLink('doc', 'tableContents', 'type=' + objectType + '&objectID=' + objectID , 'json'), function(data){
var treeData = JSON.parse(data.data);
console.log(treeData);
debugger;
$('#fileTree').data('zui.tree').reload(treeData.libTree);
$('li.has-list > ul').addClass("menu-active-primary menu-hover-primary");
});
}
});
});
}
if(Array.isArray(treeData))
@@ -124,95 +216,6 @@ $(function()
"isUpdate" : ""
};
$('#fileTree').on('click', '.icon-drop', function(e)
{
$('.dropdown-in-tree').css('display', 'none');
var isCatalogue = $(this).attr('data-isCatalogue') === 'false' ? false : true;
var dropDownID = isCatalogue ? 'dropDownCatalogue' : 'dropDownLibrary';
var libID = 0;
var moduleID = 0;
var parentID = 0;
var $module = $(this).closest('a');
var hasChildren = $module.data('has-children');
var moduleType = '';
if($module.hasClass('lib'))
{
libID = $module.data('id');
moduleType = $module.data('type');
parentID = libID;
moduleID = libID;
}
else
{
moduleID = $module.data('id');
libID = $module.closest('.lib').data('id');
moduleType = $module.closest('.lib').data('type');
parentID = $module.closest('ul').closest('.lib').data('id');
}
moduleData = {
"libID" : libID,
"parentID" : parentID,
"objectID" : moduleID,
"moduleType": moduleType == 'lib' ? 'doc' : moduleType,
};
var option = {
left : e.pageX,
top : e.pageY,
type : dropDownID,
libID : libID,
moduleID : moduleID,
hasChildren : hasChildren
};
console.log(option)
var dropDown = renderDropdown(option);
$(".m-doc-tablecontents").append(dropDown);
e.stopPropagation();
}).on('blur', '.file-tree input.input-tree', function()
{
var $input = $(this);
var value = $input.val();
if(!value)
{
$input.closest('[data-id=insert]').remove();
return;
}
moduleData.name = value;
$.post(createLink('tree', 'ajaxCreateModule'), moduleData, function(result)
{
result = JSON.parse(result);
if(result.result == 'fail')
{
bootbox.alert(
result.message[0],
function()
{
setTimeout(function()
{
$('.file-tree .input-tree').focus()
}, 10)
}
);
return false;
}
var module = result.module;
var resultDom = $('[data-id=aTreeModal]').html().replace(/%name%/g, module.name).replace(/%id%/g, module.id).replace('insert', module.id);
$input.closest('ul').find('.has-input').css('padding-left', '15px');
$input.after(resultDom);
$input.remove();
if(moduleData.isUpdate)
{
$.getJSON(createLink('doc', 'tableContents', 'type=' + objectType + '&objectID=' + objectID , 'json'), function(data){
var treeData = JSON.parse(data.data);
$('#fileTree').data('zui.tree').reload(treeData.libTree);
$('li.has-list > ul').addClass("menu-active-primary menu-hover-primary");
});
}
});
});
$('body').on('click', function()
{
@@ -262,7 +265,7 @@ $(function()
var $input = $('[data-id=liTreeModal]').html();
var $rootDom = $('[data-id=' + item.moduleid + ']a + ul');
$rootDom.append($input);
$tree.data('zui.tree').expand($('li[data-id="' + item.libid + '"]'));
$rootDom.closest('.tree').data('zui.tree').expand($('li[data-id="' + item.libid + '"]'));
}
else
{
@@ -285,7 +288,6 @@ $(function()
break;
case 'addCataChild' :
moduleData.parentID = item.id;
console.log(item);
if(item.hasChildren)
{
var $input = $('[data-id=liTreeModal]').html();
@@ -308,6 +310,7 @@ $(function()
}).on('blur', '.file-tree input.input-tree', function()
{
var $input = $(this);
var $tree = $input.closest('.tree');
var value = $input.val();
if(!value)
{
@@ -342,6 +345,7 @@ $(function()
{
$.getJSON(createLink('doc', 'tableContents', 'type=' + objectType + '&objectID=' + objectID , 'json'), function(data){
var treeData = JSON.parse(data.data);
console.log('treeData:', treeData);
$('#fileTree').data('zui.tree').reload(treeData.libTree);
$('li.has-list > ul').addClass("menu-active-primary menu-hover-primary");
});