@layout("/common/_container.html"){
|
<div class="ibox float-e-margins">
|
<div class="ibox-content">
|
<div class="form-horizontal">
|
<input type="hidden" id="id" value="${id}">
|
<div class="row">
|
<div class="col-sm-12">
|
<button class="btn btn-primary" onclick="DialogInfo._add('')">添加一级分类</button>
|
</div>
|
<div class="col-sm-12">
|
<ul class="ztree" id="classify_tree"></ul>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<script>
|
|
var DialogInfo = {
|
$parent: window.parent.MemMerchant,
|
validFields: {
|
|
}
|
}
|
DialogInfo.get = function( key) {
|
return $( "#" + key).val();
|
}
|
DialogInfo.close = function () {
|
this.$parent.search();
|
window.parent.layer.close( this.$parent.layerIndex);
|
}
|
// 获取提交数据
|
DialogInfo.get_submit_data = function() {
|
return {
|
id: this.get( "id"),
|
}
|
}
|
// 提交
|
DialogInfo.addSubmit = function () {
|
|
|
}
|
|
/* 添加/移除 节点 */
|
var is_exist = function( id) { return $( "#" + id).length > 0; }
|
DialogInfo.removeHoverDom = function( treeId, node) {
|
$("#add_btn_"+node.tId+",#remove_btn_"+node.tId).remove()
|
}
|
DialogInfo.addHoverDom = function( treeId, node) {
|
var $node_span = $("#" + node.tId + "_span");
|
|
var btn_list = [];
|
var re_str = $("<span id='remove_btn_" + node.tId
|
+ "' title='删除此分类' onfocus='this.blur()' style='color: red;margin-left: 3em'>删除此分类</span>");
|
if ( !is_exist("remove_btn_" + node.tId)) {
|
btn_list.push( re_str);
|
re_str.on( "click", function () {
|
return DialogInfo._remove( node);
|
})
|
}
|
|
if ( !node['pId']) {
|
var add_str = $("<span id='add_btn_" + node.tId
|
+ "' title='添加二级分类' onfocus='this.blur()' style='color: blue;margin-left: 3em'>添加二级分类</span>");
|
if ( !is_exist("add_btn_" + node.tId)) {
|
btn_list.push( add_str);
|
add_str.on( "click", function () {
|
return DialogInfo._add( node.id);
|
})
|
}
|
}
|
$node_span.after( btn_list);
|
}
|
|
/**
|
* 删除节点
|
*/
|
DialogInfo._remove = function( item) {
|
Feng.confirm( "是否确定".concat("删除").concat("所选中的数据?"), function () {
|
Feng.base_ajax_data( "/memMerchant/deleteMallClassifyMerchant", { id: item.id, merchantId: DialogInfo.get( "id") }, function ( data) {
|
Feng.success( "删除成功");
|
DialogInfo.refresh_tree( data);
|
});
|
});
|
}
|
|
/**
|
* 新增节点
|
*/
|
DialogInfo._add = function( id) {
|
this.layerIndex = layer.open({
|
type: 2,
|
title: '新增分类',
|
area: ['60%', '60%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/memMerchant/add-classify/' + this.get( "id") + "?classifyOneId=" + id
|
});
|
}
|
|
/* 刷新树 */
|
DialogInfo.refresh_tree = function (nodes) {
|
this.zTreeObj = $.fn.zTree.init($("#classify_tree"), {
|
callback: {
|
beforeDrag: function() { return false; }
|
},
|
view: {
|
selectedMulti: false,
|
addHoverDom: DialogInfo.addHoverDom,
|
removeHoverDom: DialogInfo.removeHoverDom
|
},
|
data: { simpleData: { enable:true } }
|
}, nodes);
|
|
this.zTreeObj.expandAll( true);
|
}
|
|
$(function () {
|
DialogInfo.refresh_tree( JSON.parse( `${classifyList!}`));
|
})
|
</script>
|
@}
|