Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-ui
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
simba
9 years ago
Commit
f8f7b7cd552371aab9fb1d0ecb06abd8dbafcd6d
2 parents
5605ab3a
6289ca70
Merge branch 'master' of
http://git.yoho.cn/ops/monitor-ui
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
598 additions
and
244 deletions
monitor-ui-common/src/main/java/com/ui/contants/HttpUriContants.java
monitor-ui-common/src/main/java/com/ui/model/domain/MObjectModel.java
monitor-ui-common/src/main/java/com/ui/model/req/MObjectInfoReq.java
monitor-ui-ctrl/src/main/java/com/ui/ctrl/HostGroupCtrl.java
monitor-ui-ctrl/src/main/java/com/ui/ctrl/MObjectInfoCtrl.java
monitor-ui-web/src/main/webapp/index.jsp
monitor-ui-web/src/main/webapp/js/global.js
monitor-ui-web/src/main/webapp/jsp/host/hostGroupList.jsp
monitor-ui-web/src/main/webapp/jsp/mobject/mobjectInfo.jsp
monitor-ui-web/src/main/webapp/jsp/table.jsp
monitor-ui-common/src/main/java/com/ui/contants/HttpUriContants.java
View file @
f8f7b7c
...
...
@@ -5,7 +5,10 @@ package com.ui.contants;
*/
public
class
HttpUriContants
{
public
static
String
TEST_GET_URI
=
"/test/get"
;
/*** 机组信息 ****/
public
static
final
String
HOST_GROUP_GETALL
=
"/hostGroup/getHostGroups"
;
/*** 机组信息 ****/
public
static
String
GET_ALL_TYPE
=
"/type/query"
;
}
...
...
monitor-ui-common/src/main/java/com/ui/model/domain/MObjectModel.java
0 → 100644
View file @
f8f7b7c
package
com
.
ui
.
model
.
domain
;
import
lombok.Data
;
/**
* Created by yoho on 2016/6/16.
*/
@Data
public
class
MObjectModel
{
private
int
moId
;
private
String
moName
;
private
String
moHostIp
;
private
String
moTypeName
;
private
String
moStatus
;
private
int
moHostId
;
private
int
moTypeId
;
private
String
moTags
;
private
String
moUrl
;
}
...
...
monitor-ui-common/src/main/java/com/ui/model/req/MObjectInfoReq.java
0 → 100644
View file @
f8f7b7c
package
com
.
ui
.
model
.
req
;
import
lombok.Data
;
/**
* Created by yoho on 2016/6/16.
*/
@Data
public
class
MObjectInfoReq
extends
PageRequest
{
String
typeIds
=
"0"
;
String
hostIds
=
"0"
;
int
isType
=
1
;
}
...
...
monitor-ui-ctrl/src/main/java/com/ui/ctrl/HostGroupCtrl.java
0 → 100644
View file @
f8f7b7c
package
com
.
ui
.
ctrl
;
import
com.alibaba.fastjson.JSON
;
import
com.ui.contants.HttpUriContants
;
import
com.ui.http.HttpRestClient
;
import
com.ui.model.BaseResponse
;
import
com.ui.model.req.PageRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
* Created by yoho on 2016/6/14.
* 查询机器信息
*/
@Controller
@RequestMapping
(
"hostGroup"
)
public
class
HostGroupCtrl
{
Logger
log
=
LoggerFactory
.
getLogger
(
HostGroupCtrl
.
class
);
@Autowired
HttpRestClient
httpRestClient
;
@RequestMapping
(
"/getHostGroups"
)
@ResponseBody
public
BaseResponse
getHostGroups
(
PageRequest
req
)
{
BaseResponse
response
=
httpRestClient
.
defaultPost
(
HttpUriContants
.
HOST_GROUP_GETALL
,
req
,
BaseResponse
.
class
);
System
.
out
.
println
(
"*****************************"
+
JSON
.
toJSON
(
response
));
return
response
;
}
}
...
...
monitor-ui-ctrl/src/main/java/com/ui/ctrl/MObjectInfoCtrl.java
0 → 100644
View file @
f8f7b7c
package
com
.
ui
.
ctrl
;
import
com.ui.http.HttpRestClient
;
import
com.ui.model.BaseResponse
;
import
com.ui.model.req.MObjectInfoReq
;
import
com.ui.model.req.PageRequest
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
/**
* Created by yoho on 2016/6/16.
*/
@RestController
@RequestMapping
(
value
=
"/mobject"
)
public
class
MObjectInfoCtrl
{
@Autowired
HttpRestClient
httpRestClient
;
@RequestMapping
(
value
=
"/query"
,
method
=
RequestMethod
.
POST
)
public
BaseResponse
queryAllMObjectInfo
(
MObjectInfoReq
request
)
{
BaseResponse
response
=
httpRestClient
.
defaultPost
(
"/mobject/query"
,
request
,
BaseResponse
.
class
);
return
response
;
}
}
...
...
monitor-ui-web/src/main/webapp/index.jsp
View file @
f8f7b7c
...
...
@@ -33,6 +33,7 @@
<script
src=
"<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js"
charset=
"UTF-8"
type=
"text/javascript"
></script>
<script
src=
"<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js"
charset=
"UTF-8"
type=
"text/javascript"
></script>
<script
src=
"<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js"
charset=
"UTF-8"
type=
"text/javascript"
></script>
<script
src=
"<%=basePath %>js/bootstrap-plugin/bootstrap.form.js"
charset=
"UTF-8"
type=
"text/javascript"
></script>
<link
rel=
"stylesheet"
href=
"./js/jstree/themes/default/style.min.css"
/>
<script
src=
"./js/jstree/jstree.min.js"
></script>
<script>
...
...
monitor-ui-web/src/main/webapp/js/global.js
View file @
f8f7b7c
...
...
@@ -45,6 +45,7 @@ var opMap = {
"contain"
:
"包含"
,
"not_contain"
:
"不包含"
};
//全局的panel的样式
var
panelStyle
=
"panel-primary"
;
...
...
monitor-ui-web/src/main/webapp/jsp/host/hostGroupList.jsp
View file @
f8f7b7c
...
...
@@ -11,28 +11,15 @@
<div class="widget-box">
<div class="widget-title">
<h5>
Dynamic table
</h5>
<h5>
机组信息列表
</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 53px;">
<div>
<div class="form-inline" role="form" id="inBoxQueryDiv"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span>
<input type="text" id="" class="form-control" placeholder=""/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span>
<input type="text" id="" class="form-control" placeholder=""/>
</div>
<button id="submit" class="btn btn-default">搜索</button>
</div>
<button id="addBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 900px;">新增</button>
</div>
</div>
<div id="table">
<div id="hostGroupTable">
</div>
</div>
...
...
@@ -40,30 +27,42 @@
</div>
<script>
$(function () {
var data = [];
for (var i = 0; i < 20; i++) {
data.push({
userId: i,
userName: "用户" + i,
status: i % 3 == 0 ? 0 : 1
});
}
$("#table").table({
striped: true,
panelClass: "panel-success",
pagination: true,
columns: [{
title: "用户id",
field: "userId"
//加载表格
$("#hostGroupTable").table({
columnAutoWidth : false,
url : contextPath+"hostGroup/getHostGroups",
striped : true,
title : "主机信息列表",
pagination : true,
pageSize : 10,
loadFilter : function(data) {
return defaultLoadFilter(data);
},
columns : [{
title : "ID",
field : "id",
width : "5%"
}, {
title : "机组名",
field : "groupName",
width : "8%"
}, {
title: "用户名称",
field: "userName"
title : "createTime",
field : "createTime",
width : "10%"
}, {
title: "状态",
field: "status"
}],
data: data
title : "updateTime",
field : "updateTime",
width : "5%"
},{
title : "操作",
field : "op",
width : "15%"
}]
});
});
</script>
\ No newline at end of file
...
...
monitor-ui-web/src/main/webapp/jsp/mobject/mobjectInfo.jsp
0 → 100644
View file @
f8f7b7c
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">Tables</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>Dynamic table</h5>
</div>
<!-- 树 -->
<div style="margin-top: 45px; float: left;margin-top: 54px;border: dashed;width: 300px;color: #D3D3D3;height: 580px;">
<div class="widget-title">
<h5>Tree Title</h5>
</div>
<ul class="ui-widget ui-helper-clearfix" id="icons" style="float: left;margin-left: 165px;">
<li title=".ui-icon-plusthick" class="ui-state-default ui-corner-all" onclick="deletebtn()"><span
class="ui-icon ui-icon-plusthick"></span></li>
</ul>
<ul class="ui-widget ui-helper-clearfix" id="icons" style="margin-right: 12px;">
<li title=".ui-icon-minusthick" class="ui-state-default ui-corner-all" onclick="editbtn()"><span
class="ui-icon ui-icon-minusthick"></span></li>
</ul>
<div id="continer"></div>
</div>
<!-- 列表 -->
<div class="widget-content nopadding" style="margin-left: 300px;">
<div class="widget-title" style="height: 53px;">
<div>
<div class="form-inline" role="form" id="inBoxQueryDiv"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span>
<input type="text" id="" class="form-control" placeholder=""/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span>
<input type="text" id="" class="form-control" placeholder=""/>
</div>
<button id="submit" class="btn btn-default">搜索</button>
</div>
<button id="addBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 500px;">新增</button>
</div>
</div>
<div id="table"></div>
</div>
</div>
</div>
<script>
$(function () {
$("#table").table({
url: contextPath + "/mobject/query",
striped: true,
panelClass: "panel-success",
pagination: true,
pageSize: 10,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "名称",
field: "moName"
}, {
title: "所属主机",
field: "moHostIp"
}, {
title: "类型",
field: "moTypeName"
}, {
title: "状态",
field: "moStatus"
}, {
title: "标签",
field: "moTags"
}, {
title: "操作",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var editBtn = $("<button>").addClass("btn btn-inverse btn-mini").html("修改").appendTo(div);
//修改
editBtn.click(function () {
alert(rowData.moId);
});
div.append(" ");
var delBtn = $("<button>").addClass("btn btn-danger btn-mini").html("删除").appendTo(div);
delBtn.click(function () {
});
return div;
}
}],
/* data: data*/
});
});
//模拟数据
var jsonData = [
{"id": "1", "name": "父节点1", "url": "www.baidu.com", "pid": "0"},
{"id": "4", "name": "父节点11", "url": "", "pid": "1"},
{"id": "14", "name": "父节点112", "url": "", "pid": "4"},
{"id": "5", "name": "父节点12", "url": "", "pid": "1"},
{"id": "6", "name": "父节点13", "url": "", "pid": "1"},
{"id": "2", "name": "父节点4", "url": "", "pid": "0"},
{"id": "7", "name": "父节点41", "url": "", "pid": "2"},
{"id": "8", "name": "父节点42", "url": "", "pid": "2"},
{"id": "9", "name": "父节点43", "url": "", "pid": "2"},
{"id": "3", "name": "父节点5", "url": "", "pid": "0"},
{"id": "10", "name": "父节点51", "url": "", "pid": "3"},
{"id": "13", "name": "父节点111", "url": "", "pid": "4"},
{"id": "11", "name": "父节点52", "url": "", "pid": "3"},
{"id": "12", "name": "父节点53", "url": "", "pid": "3"}
];
//主方法,运用递归实现
function createTree(jsons, pid) {
if (jsons != null) {
var ul = '<ul class="" style="width: 120px;" >';
for (var i = 0; i < jsons.length; i++) {
if (jsons[i].pid == pid) {
ul += '<input type="checkbox" name="checkBox" value=' + jsons[i].id + ' style="float: left;margin-top: 6px;width:10px;height:10px;"><li class="tree" value=' + jsons[i].id + '><a href="#">' + jsons[i].name + "</a></li>";
ul += createTree(jsons, jsons[i].id);
}
}
ul += "</ul>";
}
return ul;
}
$(function () {
var ul = createTree(jsonData, 0);
$("#continer").append(ul);
//控制菜单的隐藏显示
$("ul[class] li").each(function () {
$(this).click(function () {
$(this).next().toggle();
});
});
});
var dom = document.getElementById("icons");
var str = dom.getAttribute("style");
str = str.replace(/height\b\s*\:\s*\d+\px;?/ig, "");
dom.setAttribute("style", str);
function deletebtn() {
alert(1);
}
function editbtn() {
alert(2);
}
</script>
\ No newline at end of file
...
...
monitor-ui-web/src/main/webapp/jsp/table.jsp
View file @
f8f7b7c
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page language="java" contentType="text/html;charset=utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">Tables</a>
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">Tables</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<div class="widget-box">
<div class="widget-title">
<h5>Dynamic table</h5>
</div>
<!-- 树 -->
<div style="margin-top: 45px; float: left;margin-top: 54px;border: dashed;width: 300px;color: #D3D3D3;height: 580px;">
<div class="widget-title">
<h5>Tree Title</h5>
</div>
<ul class="ui-widget ui-helper-clearfix" id="icons" style="float: left;margin-left: 165px;">
<li title=".ui-icon-plusthick" class="ui-state-default ui-corner-all" onclick="deletebtn()"><span
class="ui-icon ui-icon-plusthick"></span></li>
</ul>
<ul class="ui-widget ui-helper-clearfix" id="icons" style="margin-right: 12px;">
<li title=".ui-icon-minusthick" class="ui-state-default ui-corner-all" onclick="editbtn()"><span
class="ui-icon ui-icon-minusthick"></span></li>
</ul>
<div id="continer"></div>
<div id="jstree"></div>
</div>
<!-- 列表 -->
<div class="widget-content nopadding" style="margin-left: 300px;">
<div class="widget-title" style="height: 53px;">
<div>
<div class="form-inline" role="form" id="inBoxQueryDiv"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span>
<input type="text" id="" class="form-control" placeholder=""/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span>
<input type="text" id="" class="form-control" placeholder=""/>
</div>
<button id="submit" class="btn btn-default">搜索</button>
</div>
<button id="addBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 500px;">新增</button>
</div>
</div>
<div id="table"></div>
</div>
</div>
</div>
<script>
$(function () {
var data = [];
for (var i = 0; i < 20; i++) {
data.push({
moName: i,
moHostIp: "用户" + i,
moType: i % 3 == 0 ? 0 : 1,
moStatus: "normal"
});
}
$("#table").table({
striped: true,
panelClass: "panel-success",
pagination: true,
columns: [{
title: "监控网元",
field: "moName"
}, {
title: "主机地址",
field: "moHostIp"
}, {
title: "网元类型",
field: "moType"
}, {
title: "网元状态",
field: "moStatus"
}, {
title: "操作",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var editBtn = $("<button>").addClass("btn btn-inverse btn-mini").html("修改").appendTo(div);
//修改
editBtn.click(function () {
editTemplate(rowData.inboxTemplateId);
});
div.append(" ");
var delBtn = $("<button>").addClass("btn btn-danger btn-mini").html("删除").appendTo(div);
delBtn.click(function () {
});
return div;
}
}],
data: data
});
});
<h5>Dynamic table</h5>
</div>
<!-- 树 -->
<div
style="margin-top: 45px; float: left; margin-top: 54px; border: dashed; width: 300px; color: #D3D3D3; height: 580px;">
<div class="widget-title">
<h5>Tree Title</h5>
</div>
<ul class="ui-widget ui-helper-clearfix" id="icons"
style="float: left; margin-left: 165px;">
<li title=".ui-icon-plusthick"
class="ui-state-default ui-corner-all" onclick="deletebtn()"><span
class="ui-icon ui-icon-plusthick"></span></li>
</ul>
<ul class="ui-widget ui-helper-clearfix" id="icons"
style="margin-right: 12px;">
<li title=".ui-icon-minusthick"
class="ui-state-default ui-corner-all" onclick="editbtn()"><span
class="ui-icon ui-icon-minusthick"></span></li>
</ul>
<div id="continer"></div>
</div>
<!-- 列表 -->
<div class="widget-content nopadding" style="margin-left: 300px;">
<div class="widget-title" style="height: 53px;">
<div>
<div class="form-inline" role="form" id="inBoxQueryDiv"
style="margin-top: 12px; margin-left: 25px; float: left;">
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span> <input type="text"
id="" class="form-control" placeholder="" />
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">IP:</span> <input type="text"
id="" class="form-control" placeholder="" />
</div>
<button id="submit" class="btn btn-default">搜索</button>
</div>
<button id="addBtn" class="btn btn-primary"
style="margin-top: 12px; margin-left: 500px;"
data-target="#myModal" data-toggle="modal">新增</button>
</div>
</div>
<div id="table"></div>
</div>
var dom = document.getElementById("icons");
var str = dom.getAttribute("style");
str = str.replace(/height\b\s*\:\s*\d+\px;?/ig, "");
dom.setAttribute("style", str);
function deletebtn() {
alert(1);
}
function editbtn() {
alert(2);
}
</script>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">新增</h4>
</div>
<div class="modal-body">
<div class="row-fluid">
<div class="span12">
<div class="widget-content nopadding">
<form action="#" method="get" class="form-horizontal">
<div class="control-group">
<label class="control-label" style="float: left;">Normal
text input</label>
<div class="controls">
<input type="text" />
</div>
</div>
<div class="control-group">
<label class="control-label" style="float: left;">Password
input</label>
<div class="controls">
<input type="password" />
</div>
</div>
<div class="control-group">
<label class="control-label" style="float: left;">Input
with description</label>
<div class="controls">
<input type="text" />
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="button" id="submitBtn" class="btn btn-primary">提交更改</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
</div>
</div>
<script>
var treeData = [];
var addType = function (id, pid, name, isleaf) {
var rel = 0;
$.get("type/add",
{
"id": id, "pid": pid, "name": name, "isleaf": isleaf
}
,
function (data, state) {
}
);
return rel;
};
var delType = function () {
var rel = 0;
$.get("type/del", function (data, state) {
$(function() {
var data = [];
for (var i = 0; i < 20; i++) {
data.push({
moName : i,
moHostIp : "用户" + i,
moType : i % 3 == 0 ? 0 : 1,
moStatus : "normal"
});
}
$("#table").table(
{
striped : true,
panelClass : "panel-success",
pagination : true,
columns : [
{
title : "监控网元",
field : "moName"
},
{
title : "主机地址",
field : "moHostIp"
},
{
title : "网元类型",
field : "moType"
},
{
title : "网元状态",
field : "moStatus"
},
{
title : "操作",
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var editBtn = $("<button value='"+rowData.mid+"' data-target='#myModal' data-toggle='modal'>").addClass("btn btn-xs btn-success").html("edit").appendTo(div);
div.append(" ");
var delBtn = $("<button>").addClass("btn btn-xs btn-danger").html("delete")
.appendTo(div);
delBtn.click(function() {
});
return div;
}
} ],
data : data
});
});
});
return rel;
};
var updateType = function () {
var rel = 0;
//模拟数据
var jsonData = [ {
"id" : "1",
"name" : "父节点1",
"url" : "www.baidu.com",
"pid" : "0"
}, {
"id" : "4",
"name" : "父节点11",
"url" : "",
"pid" : "1"
},
{
"id" : "14",
"name" : "父节点112",
"url" : "",
"pid" : "4"
}, {
"id" : "5",
"name" : "父节点12",
"url" : "",
"pid" : "1"
}, {
"id" : "6",
"name" : "父节点13",
"url" : "",
"pid" : "1"
}, {
"id" : "2",
"name" : "父节点4",
"url" : "",
"pid" : "0"
}, {
"id" : "7",
"name" : "父节点41",
"url" : "",
"pid" : "2"
}, {
"id" : "8",
"name" : "父节点42",
"url" : "",
"pid" : "2"
}, {
"id" : "9",
"name" : "父节点43",
"url" : "",
"pid" : "2"
}, {
"id" : "3",
"name" : "父节点5",
"url" : "",
"pid" : "0"
}, {
"id" : "10",
"name" : "父节点51",
"url" : "",
"pid" : "3"
}, {
"id" : "13",
"name" : "父节点111",
"url" : "",
"pid" : "4"
}, {
"id" : "11",
"name" : "父节点52",
"url" : "",
"pid" : "3"
}, {
"id" : "12",
"name" : "父节点53",
"url" : "",
"pid" : "3"
} ];
return rel;
};
//主方法,运用递归实现
function createTree(jsons, pid) {
if (jsons != null) {
var ul = '<ul class="" style="width: 120px;" >';
for (var i = 0; i < jsons.length; i++) {
if (jsons[i].pid == pid) {
ul += '<input type="checkbox" name="checkBox" value='+jsons[i].id+' style="float: left;margin-top: 6px;width:10px;height:10px;"><li class="tree" value='+jsons[i].id+'><a href="#">'
+ jsons[i].name + "</a></li>";
ul += createTree(jsons, jsons[i].id);
}
}
ul += "</ul>";
}
return ul;
}
$(function () {
$.get("type/all", function (data, state) {
console.log(state)
console.log(data);
var jsonData = JSON.parse(data);
treeData=[]; //重置
$.each(jsonData, function (n, val) {
var treeNode = {};
treeNode.id = "" + val.typeId;
treeNode.parent = "" + (val.typeParentId == 0 ? "#" : val.typeParentId);
treeNode.text = val.typeName;
treeData.push(treeNode)
})
$(function() {
var ul = createTree(jsonData, 0);
$("#continer").append(ul);
//控制菜单的隐藏显示
$("ul[class] li").each(function() {
$(this).click(function() {
$(this).next().toggle();
});
});
$('#jstree').jstree({
"plugins": ["themes", "checkbox", "contextmenu", "ui", "types"],
'core': {
"themes": {
"icons": false
},
'data': treeData
},
'contextmenu': {
"items": {
"ADD": {
"label": "ADD",
"action": function (obj) {
var inst = jQuery.jstree.reference(obj.reference);
var clickedNode = inst.get_node(obj.reference);
alert("add operation--clickedNode's id is:" + clickedNode.id);
}
}, "DEL": {
"label": "DEL",
"action": function (obj) {
var inst = jQuery.jstree.reference(obj.reference);
var clickedNode = inst.get_node(obj.reference);
console.log("del operation--clickedNode's id is:" + clickedNode.id);
addType()
}
}, "UPDATE": {
"label": "UPDATE",
"action": function (obj) {
var inst = jQuery.jstree.reference(obj.reference);
var clickedNode = inst.get_node(obj.reference);
alert("update operation--clickedNode's id is:" + clickedNode.id);
}
}
}
}
}).bind("loaded.jstree", function (event, data) {
$(this).jstree("open_all");
});
});
// .bind("select_node.jstree", function(event, data) {
//
// var evt = window.event || event;
// var button = evt.which || evt.button;
// console.log("fdfdfdf"+button);
// if( button != 1 ) return false;
//
// })
});
function deletebtn() {
alert(1);
}
});
</script>
\ No newline at end of file
function editbtn() {
alert(2);
}
$("#submitBtn").click(function(){
alert(1);
$("#inBoxQueryDiv").form("submit", {
submitUrl : '',
submitData : {
},
onBeforeSubmit : function() {
},
success : function(data) {
}
});
});
</script>
...
...
Please
register
or
login
to post a comment