改为使用vue-cli打包,修改所有的请求方式,优化页面间的交互,增加数据源分组
This commit is contained in:
@@ -84,14 +84,9 @@ public class DatabaseDocController {
|
||||
List<Long> userAuthDbIds = userAuthList.stream().map(val -> NumberUtils.toLong(val.getAuthCustomSuffix().replace(DocAuthConst.DB, ""))).collect(Collectors.toList());
|
||||
wrapper.in("id", userAuthDbIds);
|
||||
}
|
||||
wrapper.select("id", "name", "group_name");
|
||||
List<DbDatasource> datasourceList = dbDatasourceService.list(wrapper);
|
||||
List<DatabaseFactoryBean> dataSourceList = datasourceList.stream().map(val -> {
|
||||
DatabaseFactoryBean bean = new DatabaseFactoryBean();
|
||||
bean.setCnName(val.getName());
|
||||
bean.setId(val.getId());
|
||||
return bean;
|
||||
}).collect(Collectors.toList());
|
||||
return DocDbResponseJson.ok(dataSourceList);
|
||||
return DocDbResponseJson.ok(datasourceList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ public class DatabaseFactoryBean {
|
||||
private String url;
|
||||
private String dbName;
|
||||
private String cnName;
|
||||
private String groupName;
|
||||
private DatabaseProduct databaseProduct;
|
||||
|
||||
public Long getId() {
|
||||
@@ -33,6 +34,14 @@ public class DatabaseFactoryBean {
|
||||
this.cnName = cnName;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
public static enum DatabaseProduct {
|
||||
MYSQL, SQLSERVER, ORACLE
|
||||
}
|
||||
|
||||
@@ -92,11 +92,11 @@ public class TransferDataServer {
|
||||
boolean querySelect = DocUserUtil.haveCustomAuth(DbAuthType.SELECT.getName(), DocAuthConst.DB + transferTask.getQueryDatasourceId());
|
||||
boolean queryUpdate = DocUserUtil.haveCustomAuth(DbAuthType.UPDATE.getName(), DocAuthConst.DB + transferTask.getQueryDatasourceId());
|
||||
if (!manageAuth && !querySelect && !queryUpdate) {
|
||||
throw new ConfirmException("没有该数据源的查询权限,创建任务失败");
|
||||
throw new ConfirmException("没有查询数据源的查询权限,创建任务失败");
|
||||
}
|
||||
boolean storageUpdate = DocUserUtil.haveCustomAuth(DbAuthType.UPDATE.getName(), DocAuthConst.DB + transferTask.getStorageDatasourceId());
|
||||
if (!manageAuth && !storageUpdate) {
|
||||
throw new ConfirmException("没有该数据源的写入权限,创建任务失败");
|
||||
throw new ConfirmException("没有目标数据源的写入权限,创建任务失败");
|
||||
}
|
||||
dbTransferTaskService.resetExecuteInfo(taskId);
|
||||
// 提交任务
|
||||
@@ -135,13 +135,11 @@ public class TransferDataServer {
|
||||
ExecuteResult countResult = sqlExecutor.execute(executeParam);
|
||||
if (CollectionUtils.isEmpty(countResult.getResult())) {
|
||||
String executeInfo = String.format("[%s] 获取总条数失败", DateTime.now().toString());
|
||||
logger.error(executeInfo);
|
||||
dbTransferTaskService.addExecuteInfo(transferTask.getId(), TransferTaskStatus.ERROR.getCode(), executeInfo);
|
||||
return;
|
||||
}
|
||||
Object transferCount = countResult.getResult().get(0).get("counts");
|
||||
String executeInfo = String.format("[%s] 待处理总条数:%s,查询总条数耗时:%sms", DateTime.now().toString(), transferCount, System.currentTimeMillis() - executeStartTime);
|
||||
logger.info(executeInfo);
|
||||
dbTransferTaskService.addExecuteInfo(transferTask.getId(), TransferTaskStatus.EXECUTING.getCode(), executeInfo);
|
||||
} else {
|
||||
String executeInfo = String.format("[%s] 未开启查询总条数,跳过条数查询", DateTime.now().toString());
|
||||
@@ -149,7 +147,6 @@ public class TransferDataServer {
|
||||
}
|
||||
AtomicLong readCount = new AtomicLong(0L);
|
||||
executeParam.setSql(querySql);
|
||||
// executeParam.setSql("select sleep(10)");
|
||||
ExecuteResult executeResult = sqlExecutor.execute(factoryBean, executeParam, resultMap -> {
|
||||
selectResultList.add(resultMap);
|
||||
if (readCount.incrementAndGet() % executeCountLogNum == 0) {
|
||||
@@ -167,7 +164,6 @@ public class TransferDataServer {
|
||||
}
|
||||
if (StringUtils.isNotBlank(executeResult.getErrMsg())) {
|
||||
String executeInfo = String.format("[%s] 执行出错:%s", DateTime.now().toString(), executeResult.getErrMsg());
|
||||
logger.error(executeInfo);
|
||||
dbTransferTaskService.addExecuteInfo(transferTask.getId(), TransferTaskStatus.ERROR.getCode(), executeInfo);
|
||||
} else {
|
||||
String executeInfo = String.format("[%s] 任务执行成功,处理总条数:%s,总耗时:%sms", DateTime.now().toString(), readCount.get(), System.currentTimeMillis() - executeStartTime);
|
||||
|
||||
1
zyplayer-doc-db/src/main/resources/css/app.c4f7a9c4.css
Normal file
1
zyplayer-doc-db/src/main/resources/css/app.c4f7a9c4.css
Normal file
@@ -0,0 +1 @@
|
||||
#app,.el-container,.el-menu{height:100%}.database-list-tree{background-color:#fafafa}.database-list-tree .el-tree-node>.el-tree-node__children{overflow:unset}.login-container{border-radius:5px;-moz-border-radius:5px;background-clip:padding-box;margin:0 auto;width:350px;padding:35px 35px 15px 35px;background:#fff;border:1px solid #eaeaea;-webkit-box-shadow:0 0 25px #cac6c6;box-shadow:0 0 25px #cac6c6}.title{margin:0 auto 40px auto;text-align:center;color:#505458}.remember{margin:0 0 35px 0}.my-info-vue .box-card{margin:10px}.table-info-vue .el-dialog__body{padding:0 20px 10px}.table-info-vue .el-form-item{margin-bottom:5px}.table-info-vue .edit-table-desc{cursor:pointer;color:#409eff}.table-info-vue .description{cursor:pointer}.table-info-vue .el-table td,.table-info-vue .el-table th{padding:5px 0}.table-info-vue .status-info-row{padding:8px 0}.table-info-vue .status-info-row .label{width:80px;display:inline-block;text-align:right;color:#606266}.table-database-vue .el-table td,.table-database-vue .el-table th{padding:5px 0}body,html{margin:0;padding:0;height:100%}.header-right-user-name{color:#fff;padding-right:5px}.el-menu-vertical{border-right:0}.el-menu-vertical,.el-menu-vertical .el-menu{background:#fafafa}.el-header{background-color:#409eff;color:#333;line-height:40px;text-align:right;height:40px!important}.data-transfer-vue .el-button+.el-button{margin-left:4px}.data-executor-vue .ace-monokai .ace_print-margin{display:none}.data-executor-vue .el-card__body{padding:10px}.data-executor-vue .el-table td,.el-table th{padding:6px 0}.data-executor-vue .execute-result-table .el-input__inner{height:25px;line-height:25px;padding:0 5px}.data-executor-vue .execute-result-table .el-textarea__inner{height:27px;min-height:27px;line-height:25px;padding:0 5px;resize:none}.data-executor-vue .execute-use-time{font-size:12px;margin-right:10px}.data-executor-vue-out .el-tabs__nav-scroll{padding-left:20px}.data-executor-vue-out .el-button+.el-button{margin-left:0}.data-executor-vue-out .el-table__body-wrapper{height:calc(100vh - 180px);overflow-y:auto}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +0,0 @@
|
||||
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,l=0,s=[];l<t.length;l++)a=t[l],o[a]&&s.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,u);s.length;)s.shift()();if(u)for(l=0;l<u.length;l++)f=n(n.s=u[l]);return f};var t={},o={2:0};n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(a);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var u=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+e+".js?"+{0:"e961123b6de8434b2cc2",1:"93ce942e3bdbc7dd3435"}[e];var a=setTimeout(r,12e4);return i.onerror=i.onload=r,u.appendChild(i),c},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);
|
||||
//# sourceMappingURL=doc-db-manifest.js.map?df9e1a3cc72f1a225176
|
||||
@@ -1,218 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<!--无论发布在哪、如何修改源码,请勿删除本行原作者信息,感谢-->
|
||||
<meta name="author" content="开发者列表:暮光:城中城,项目地址:https://gitee.com/zyplayer/zyplayer-doc" />
|
||||
<title>数据库文档</title>
|
||||
<link rel="shortcut icon" href="webjars/doc-db/img/api.ico"/>
|
||||
<link rel="stylesheet" href="webjars/zui/css/zui.min.css" />
|
||||
<link rel="stylesheet" href="webjars/zui/css/zui-theme.min.css">
|
||||
<link rel="stylesheet" href="webjars/zui/lib/chosen/chosen.min.css" />
|
||||
<link rel="stylesheet" href="webjars/doc-db/css/doc-db.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row choise-db">
|
||||
<div class="col-md-3">
|
||||
<select id="choiseHost" data-placeholder="选择一个连接" class="chosen-select form-control" tabindex="2">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<select id="choiseDatabase" data-placeholder="选择一个数据库" class="chosen-select form-control" tabindex="2">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<select id="choiseTable" data-placeholder="选择一张表" class="chosen-select form-control" tabindex="2">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<button class="btn btn-primary" type="button" id="fuzzySearchBtn">模糊查询</button>
|
||||
<button class="btn btn-primary" type="button" id="exportBtn">导出</button>
|
||||
<button class="btn" type="button" id="showEchartsBtn">显示表关系图</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-info">
|
||||
<div style="height: 35px;line-height: 35px;">
|
||||
表名:<span class="table-name"></span>
|
||||
<button class="btn pull-right" type="button" id="aboutBtn" style="margin-right: 30px;">关于</button>
|
||||
</div>
|
||||
<div class="desc">
|
||||
<div id="tableDescShow">
|
||||
<span class="table-desc"></span>
|
||||
<i class="icon icon-edit" title="编辑表注释"></i>
|
||||
</div>
|
||||
<textarea id="tableDescInput" rows="2" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-columns">
|
||||
<table class="table table-bordered table-striped table-hover" id="tableCloumnsTable">
|
||||
<thead>
|
||||
<tr><th>字段名</th><th>自增</th><th>类型</th><th>长度</th><th>NULL</th><th>主键</th><th>注释</th></tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="tableRelationBox" class="hide" style="width: 100%;height:100px;">
|
||||
<div class="alert alert-warning alert-dismissable">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<p>
|
||||
Tips:本关系图不是通过外键生成,所以需要在字段注释最后按规则添加外键关系才能生成图表,支持的格式有:<br/>
|
||||
1、T:表,例:XXX(字段注释),T:user_info<br/>
|
||||
2、T:表.关联ID,例:XXX(字段注释),T:user_info.id<br/>
|
||||
3、T:库.表.关联ID,例:XXX(字段注释),T:order_db.user_info.id<br/>
|
||||
实验功能,有更好的建议或展示方式欢迎<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">提交建议</a>!
|
||||
</p>
|
||||
</div>
|
||||
<div id="tableRelationCharts" style="width: 100%;height:100%;margin-bottom: 50px;"></div>
|
||||
</div>
|
||||
<!-- 模糊查询 -->
|
||||
<div class="modal fade" id="fuzzySearchModal">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">关闭</span>
|
||||
</button>
|
||||
<h4 class="modal-title">通过字段名或释义模糊查询</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row choise-db">
|
||||
<div class="col-md-3">
|
||||
<select id="choiseFuzzyHost" data-placeholder="选择一个连接" class="chosen-select form-control" tabindex="2">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<select id="choiseFuzzyDatabase" data-placeholder="选择一个数据库" class="chosen-select form-control" tabindex="2">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<input id="searchText" type="text" class="form-control" placeholder="搜索内容,字段名或注释">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button id="doSearch" class="btn btn-primary" type="button">查询 <i class="icon icon-spin icon-spinner-snake hidden"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-table-box">
|
||||
<table class="table table-bordered table-striped table-hover" id="fuzzySearchTable">
|
||||
<thead>
|
||||
<tr><th>表名</th><th>字段名</th><th>注释</th></tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 导出弹出框 -->
|
||||
<div class="modal fade" id="exportModal">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">关闭</span>
|
||||
</button>
|
||||
<h4 class="modal-title">导出数据库文档</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row choise-db">
|
||||
<div class="col-md-3">
|
||||
<select id="choiseExportHost" data-placeholder="选择一个连接" class="chosen-select form-control" tabindex="2">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<select id="choiseExportDatabase" data-placeholder="选择一个数据库" class="chosen-select form-control" tabindex="2">
|
||||
<option value=""></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button id="doExport" class="btn btn-primary" type="button">确认导出 <i class="icon icon-spin icon-spinner-snake hidden"></i></button>
|
||||
<button id="checkAllTable" class="btn" type="button">全选</button>
|
||||
<button id="notCheckAllTable" class="btn" type="button">全不选</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="alert alert-danger">
|
||||
请到 <a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc-db">源码处下载</a>《对外文档模板.zip》解压,
|
||||
然后将“确认导出”后的文件放至/js目录下,文件名必须为:database.js<br/>
|
||||
然后双击打开目录下的:doc-db.html 即可看到导出的文档
|
||||
</div>
|
||||
<div class="modal-table-box">
|
||||
<ul id="exportUl"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 关于弹出框 -->
|
||||
<div class="modal fade" id="aboutModal">
|
||||
<div class="modal-dialog modal-lg" style="width: 600px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span><span class="sr-only">关闭</span>
|
||||
</button>
|
||||
<h4 class="modal-title">关于zyplayer-doc-db</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal" style="line-height: 30px;">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 no-padding">项目地址:</label>
|
||||
<div class="col-md-6 col-sm-10">
|
||||
<a target="_blank" href="https://gitee.com/zyplayer/zyplayer-doc">zyplayer-doc</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 no-padding">开发人员:</label>
|
||||
<div class="col-md-6 col-sm-10">
|
||||
<a target="_blank" href="http://zyplayer.com">暮光:城中城</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">当前版本:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeNowVersion"></div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">最新版本:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeLastVersion"></div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">升级地址:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeUrl"></div>
|
||||
</div>
|
||||
<div class="form-group upgrade-info">
|
||||
<label class="col-sm-2 no-padding">升级内容:</label>
|
||||
<div class="col-md-10 col-sm-10" id="upgradeContent"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2 no-padding"></div>
|
||||
<div class="col-md-10 col-sm-10">
|
||||
欢迎加群讨论,QQ群号:466363173,欢迎提交需求,欢迎使用和加入开发!
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="webjars/doc-db/js/jquery-3.1.0.min.js"></script>
|
||||
<script type="text/javascript" src="webjars/zui/js/zui.min.js"></script>
|
||||
<script type="text/javascript" src="webjars/zui/lib/chosen/chosen.min.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-db/js/echarts.min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="webjars/doc-db/js/option-table-relation.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-db/js/formatjson.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-db/js/toast.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-db/js/common.js"></script>
|
||||
<script type="text/javascript" src="webjars/doc-db/js/doc-db.js"></script>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,14 +1 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>数据库文档管理</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="text/javascript" src="doc-db-manifest.js?df9e1a3cc72f1a225176"></script><script type="text/javascript" src="doc-db-vendor.js?93ce942e3bdbc7dd3435"></script><script type="text/javascript" src="doc-db-index.js?e961123b6de8434b2cc2"></script></body>
|
||||
|
||||
</html>
|
||||
|
||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon-db.png><title>数据库文档管理</title><link href=css/app.c4f7a9c4.css rel=preload as=style><link href=css/chunk-vendors.7be40bfc.css rel=preload as=style><link href=js/app.6508421c.js rel=preload as=script><link href=js/chunk-vendors.8274a50c.js rel=preload as=script><link href=css/chunk-vendors.7be40bfc.css rel=stylesheet><link href=css/app.c4f7a9c4.css rel=stylesheet></head><body><noscript><strong>We're sorry but zyplayer-db-ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.8274a50c.js></script><script src=js/app.6508421c.js></script></body></html>
|
||||
BIN
zyplayer-doc-db/src/main/resources/favicon-db.png
Normal file
BIN
zyplayer-doc-db/src/main/resources/favicon-db.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Binary file not shown.
Binary file not shown.
1
zyplayer-doc-db/src/main/resources/js/app.6508421c.js
Normal file
1
zyplayer-doc-db/src/main/resources/js/app.6508421c.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,271 +1,271 @@
|
||||
/**
|
||||
* 一些公用方法
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function deserialize(value) {
|
||||
if (typeof value !== 'string' || isEmpty(value)) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
try {
|
||||
return eval('(' + value + ')');// 处理变态的单双引号共存字符串
|
||||
} catch (e) {
|
||||
return value || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateResult(result) {
|
||||
if (result.errCode == 200) {
|
||||
return true;
|
||||
} else if (result.errCode == 400) {
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
window.location = "static/manage/login.html?redirect=" + href;
|
||||
} else {
|
||||
Toast.error(result.errMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回不为空的字符串,为空返回def
|
||||
*/
|
||||
function getNotEmptyStr(str, def){
|
||||
if(isEmpty(str)) {
|
||||
return isEmpty(def)?"":def;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空对象
|
||||
* @param obj
|
||||
* @returns
|
||||
*/
|
||||
function isEmptyObject(obj){
|
||||
return $.isEmptyObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isEmpty(str){
|
||||
return (str == "" || str == null || str == undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isNull(str){
|
||||
return (str == null || str == undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否不是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isNotEmpty(str){
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转字符串,使用空格分隔
|
||||
* @param array
|
||||
* @returns
|
||||
*/
|
||||
function arrToString(array){
|
||||
var temStr = "";
|
||||
if(isEmpty(array)){
|
||||
return temStr;
|
||||
}
|
||||
array.forEach(function(e){
|
||||
if(isNotEmpty(temStr)) {
|
||||
temStr += " ";
|
||||
}
|
||||
temStr += e;
|
||||
});
|
||||
return temStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组array中是否包含str字符串
|
||||
* @param array
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function haveString(array, str){
|
||||
if(isEmpty(array)) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if(array[i] == str) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回对象的第一个属性
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttribute(data) {
|
||||
for ( var key in data) {
|
||||
return data[key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果对象只有一个属性则返回第一个属性,否则返回null
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttributeIfOnly(data) {
|
||||
var len = 0, value = "";
|
||||
for ( var key in data) {
|
||||
if (++len > 1) {
|
||||
return null;
|
||||
}
|
||||
value = data[key];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function postService(url, param, success=function(){}, complete=function(){}){
|
||||
ajaxTemp(url, "POST", "JSON", param, function(result){
|
||||
if (result.errCode == 400) {
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
window.location = "static/manage/login.html?redirect=" + href;
|
||||
} else if (result.errCode != "200") {
|
||||
Toast.warn(result.errMsg);
|
||||
} else {
|
||||
success(result);
|
||||
}
|
||||
},function(){
|
||||
Toast.warn("请求数据失败");
|
||||
}, function(result){
|
||||
complete(result);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax处理事件模板
|
||||
*
|
||||
* @url 后台处理的url,即action
|
||||
* @dataSentType 数据发送的方式,有post,get方式
|
||||
* @dataReceiveType 数据接收格式,有html json text等
|
||||
* @paramsStr 传入后台的参数
|
||||
* @successFunction ajax成功后执行的函数名 ajaxTemp("", "GET", "html", {}, function(){},
|
||||
* function(){}, "");
|
||||
*/
|
||||
function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||
$.ajax({
|
||||
url : url, // 后台处理程序
|
||||
sync : false,
|
||||
type : dataSentType, // 数据发送方式
|
||||
dataType : dataReceiveType, // 接受数据格式
|
||||
data : eval(paramsStr),
|
||||
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
success : function(msg) {
|
||||
if (msg.errCode == 400) {
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
window.location = "static/manage/login.html?redirect=" + href;
|
||||
} else {
|
||||
if (typeof successFunction == "function") {
|
||||
successFunction(msg, id);
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeSend : function() {
|
||||
|
||||
},
|
||||
complete : function(msg) {
|
||||
if (msg.responseText.startWith("<!doctype html>")) {
|
||||
if (msg.responseText.indexOf("THIS_IS_LOGIN_PAGE_FLAG") > 0) {
|
||||
Toast.error('操作失败,登录已失效,请登陆后重试', 3000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(typeof completeFunction == "function") {
|
||||
completeFunction(msg,id);
|
||||
}
|
||||
},
|
||||
error : function(msg) {
|
||||
if(typeof errorFunction == "function") {
|
||||
errorFunction(msg,id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cookie
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
function getCookie(name) {
|
||||
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||
if(arr=document.cookie.match(reg)){
|
||||
return unescape(arr[2]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串格式化
|
||||
*/
|
||||
String.prototype.format = function(args) {
|
||||
if (arguments.length > 0) {
|
||||
var result = this;
|
||||
if (arguments.length == 1 && typeof (args) == "object") {
|
||||
for ( var key in args) {
|
||||
var reg = new RegExp("({" + key + "})", "g");
|
||||
result = result.replace(reg, args[key]);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] == undefined) {
|
||||
return "";
|
||||
} else {
|
||||
var reg = new RegExp("({[" + i + "]})", "g");
|
||||
result = result.replace(reg, arguments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
String.prototype.endWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substring(this.length - str.length) == str);
|
||||
};
|
||||
|
||||
String.prototype.startWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substr(0, str.length) == str);
|
||||
};
|
||||
|
||||
/**
|
||||
* 一些公用方法
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
|
||||
function serialize(value) {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function deserialize(value) {
|
||||
if (typeof value !== 'string' || isEmpty(value)) {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
try {
|
||||
return eval('(' + value + ')');// 处理变态的单双引号共存字符串
|
||||
} catch (e) {
|
||||
return value || undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateResult(result) {
|
||||
if (result.errCode == 200) {
|
||||
return true;
|
||||
} else if (result.errCode == 400) {
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
window.location = "static/manage/login.html?redirect=" + href;
|
||||
} else {
|
||||
Toast.error(result.errMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回不为空的字符串,为空返回def
|
||||
*/
|
||||
function getNotEmptyStr(str, def){
|
||||
if(isEmpty(str)) {
|
||||
return isEmpty(def)?"":def;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空对象
|
||||
* @param obj
|
||||
* @returns
|
||||
*/
|
||||
function isEmptyObject(obj){
|
||||
return $.isEmptyObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isEmpty(str){
|
||||
return (str == "" || str == null || str == undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是空
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isNull(str){
|
||||
return (str == null || str == undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否不是空字符串
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function isNotEmpty(str){
|
||||
return !isEmpty(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转字符串,使用空格分隔
|
||||
* @param array
|
||||
* @returns
|
||||
*/
|
||||
function arrToString(array){
|
||||
var temStr = "";
|
||||
if(isEmpty(array)){
|
||||
return temStr;
|
||||
}
|
||||
array.forEach(function(e){
|
||||
if(isNotEmpty(temStr)) {
|
||||
temStr += " ";
|
||||
}
|
||||
temStr += e;
|
||||
});
|
||||
return temStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组array中是否包含str字符串
|
||||
* @param array
|
||||
* @param str
|
||||
* @returns
|
||||
*/
|
||||
function haveString(array, str){
|
||||
if(isEmpty(array)) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
if(array[i] == str) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回对象的第一个属性
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttribute(data) {
|
||||
for ( var key in data) {
|
||||
return data[key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果对象只有一个属性则返回第一个属性,否则返回null
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
function getObjectFirstAttributeIfOnly(data) {
|
||||
var len = 0, value = "";
|
||||
for ( var key in data) {
|
||||
if (++len > 1) {
|
||||
return null;
|
||||
}
|
||||
value = data[key];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function postService(url, param, success=function(){}, complete=function(){}){
|
||||
ajaxTemp(url, "POST", "JSON", param, function(result){
|
||||
if (result.errCode == 400) {
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
window.location = "static/manage/login.html?redirect=" + href;
|
||||
} else if (result.errCode != "200") {
|
||||
Toast.warn(result.errMsg);
|
||||
} else {
|
||||
success(result);
|
||||
}
|
||||
},function(){
|
||||
Toast.warn("请求数据失败");
|
||||
}, function(result){
|
||||
complete(result);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax处理事件模板
|
||||
*
|
||||
* @url 后台处理的url,即action
|
||||
* @dataSentType 数据发送的方式,有post,get方式
|
||||
* @dataReceiveType 数据接收格式,有html json text等
|
||||
* @paramsStr 传入后台的参数
|
||||
* @successFunction ajax成功后执行的函数名 ajaxTemp("", "GET", "html", {}, function(){},
|
||||
* function(){}, "");
|
||||
*/
|
||||
function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||
$.ajax({
|
||||
url : url, // 后台处理程序
|
||||
sync : false,
|
||||
type : dataSentType, // 数据发送方式
|
||||
dataType : dataReceiveType, // 接受数据格式
|
||||
data : eval(paramsStr),
|
||||
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
success : function(msg) {
|
||||
if (msg.errCode == 400) {
|
||||
var href = encodeURIComponent(window.location.href);
|
||||
window.location = "static/manage/login.html?redirect=" + href;
|
||||
} else {
|
||||
if (typeof successFunction == "function") {
|
||||
successFunction(msg, id);
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeSend : function() {
|
||||
|
||||
},
|
||||
complete : function(msg) {
|
||||
if (msg.responseText.startWith("<!doctype html>")) {
|
||||
if (msg.responseText.indexOf("THIS_IS_LOGIN_PAGE_FLAG") > 0) {
|
||||
Toast.error('操作失败,登录已失效,请登陆后重试', 3000);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(typeof completeFunction == "function") {
|
||||
completeFunction(msg,id);
|
||||
}
|
||||
},
|
||||
error : function(msg) {
|
||||
if(typeof errorFunction == "function") {
|
||||
errorFunction(msg,id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cookie
|
||||
* @param name
|
||||
* @returns
|
||||
*/
|
||||
function getCookie(name) {
|
||||
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
|
||||
if(arr=document.cookie.match(reg)){
|
||||
return unescape(arr[2]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串格式化
|
||||
*/
|
||||
String.prototype.format = function(args) {
|
||||
if (arguments.length > 0) {
|
||||
var result = this;
|
||||
if (arguments.length == 1 && typeof (args) == "object") {
|
||||
for ( var key in args) {
|
||||
var reg = new RegExp("({" + key + "})", "g");
|
||||
result = result.replace(reg, args[key]);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i] == undefined) {
|
||||
return "";
|
||||
} else {
|
||||
var reg = new RegExp("({[" + i + "]})", "g");
|
||||
result = result.replace(reg, arguments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
String.prototype.endWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substring(this.length - str.length) == str);
|
||||
};
|
||||
|
||||
String.prototype.startWith = function(str) {
|
||||
if (str == null || str == "" || this.length == 0 || str.length > this.length) {
|
||||
return false;
|
||||
}
|
||||
return (this.substr(0, str.length) == str);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,115 +1,115 @@
|
||||
|
||||
/**
|
||||
* 将对象处理成json格式化和着色的html
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var Formatjson = {
|
||||
tabStr: " ",
|
||||
isArray: function(obj) {
|
||||
return obj && typeof obj === 'object' && typeof obj.length === 'number'
|
||||
&& !(obj.propertyIsEnumerable('length'));
|
||||
},
|
||||
processObjectToHtmlPre: function(obj, indent, addComma, isArray, isPropertyContent) {
|
||||
var htmlStr = this.processObject(obj, indent, addComma, isArray, isPropertyContent);
|
||||
htmlStr = '<pre class="json">' + htmlStr + '</pre>';
|
||||
return htmlStr;
|
||||
},
|
||||
processObject: function(obj, indent, addComma, isArray, isPropertyContent) {
|
||||
var html = "";
|
||||
var comma = (addComma) ? "<span class='comma'>,</span> " : "";
|
||||
var type = typeof obj;
|
||||
var clpsHtml ="";
|
||||
if (this.isArray(obj)) {
|
||||
if (obj.length == 0) {
|
||||
html += this.getRow(indent, "<span class='arrayBrace'>[ ]</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
clpsHtml = '<span><img class="option-img" src="webjars/mg-ui/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
html += this.getRow(indent, "<span class='arrayBrace'>[</span>"+clpsHtml, isPropertyContent);
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
html += this.processObject(obj[i], indent + 1, i < (obj.length - 1), true, false);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='arrayBrace'>]</span>" + comma);
|
||||
}
|
||||
} else if (type == 'object' && obj == null) {
|
||||
html += this.formatLiteral("null", "", comma, indent, isArray, "null");
|
||||
} else if (type == 'object') {
|
||||
var numProps = 0;
|
||||
for ( var prop in obj) {
|
||||
numProps++;
|
||||
}
|
||||
if (numProps == 0) {
|
||||
html += this.getRow(indent, "<span class='objectBrace'>{ }</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
clpsHtml = '<span><img class="option-img" src="webjars/mg-ui/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
html += this.getRow(indent, "<span class='objectBrace'>{</span>"+clpsHtml, isPropertyContent);
|
||||
var j = 0;
|
||||
for ( var prop in obj) {
|
||||
var processStr = '<span class="propertyName">"' + prop + '"</span>: ' + this.processObject(obj[prop], indent + 1, ++j < numProps, false, true);
|
||||
html += this.getRow(indent + 1, processStr);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='objectBrace'>}</span>" + comma);
|
||||
}
|
||||
} else if (type == 'number') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "number");
|
||||
} else if (type == 'boolean') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "boolean");
|
||||
} else if (type == 'function') {
|
||||
obj = this.formatFunction(indent, obj);
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "function");
|
||||
} else if (type == 'undefined') {
|
||||
html += this.formatLiteral("undefined", "", comma, indent, isArray, "null");
|
||||
} else {
|
||||
html += this.formatLiteral(obj, "\"", comma, indent, isArray, "string");
|
||||
}
|
||||
return html;
|
||||
},
|
||||
expImgClicked: function(img){
|
||||
var container = img.parentNode.nextSibling;
|
||||
if(!container) return;
|
||||
var disp = "none";
|
||||
var src = "webjars/mg-ui/img/collapsed.png";
|
||||
if(container.style.display == "none"){
|
||||
disp = "inline";
|
||||
src = "webjars/mg-ui/img/expanded.png";
|
||||
}
|
||||
container.style.display = disp;
|
||||
img.src = src;
|
||||
},
|
||||
formatLiteral: function(literal, quote, comma, indent, isArray, style) {
|
||||
if (typeof literal == 'string') {
|
||||
literal = literal.split("<").join("<").split(">").join(">");
|
||||
}
|
||||
var str = "<span class='" + style + "'>" + quote + literal + quote + comma + "</span>";
|
||||
if (isArray) {
|
||||
str = this.getRow(indent, str);
|
||||
}
|
||||
return str;
|
||||
},
|
||||
formatFunction: function(indent, obj) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
var funcStrArray = obj.toString().split("\n");
|
||||
var str = "";
|
||||
for (var i = 0; i < funcStrArray.length; i++) {
|
||||
str += ((i == 0) ? "" : tabs) + funcStrArray[i] + "\n";
|
||||
}
|
||||
return str;
|
||||
},
|
||||
getRow: function(indent, data, isPropertyContent) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent && !isPropertyContent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
if (data != null && data.length > 0 && data.charAt(data.length - 1) != "\n") {
|
||||
data = data + "\n";
|
||||
}
|
||||
return tabs + data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将对象处理成json格式化和着色的html
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var Formatjson = {
|
||||
tabStr: " ",
|
||||
isArray: function(obj) {
|
||||
return obj && typeof obj === 'object' && typeof obj.length === 'number'
|
||||
&& !(obj.propertyIsEnumerable('length'));
|
||||
},
|
||||
processObjectToHtmlPre: function(obj, indent, addComma, isArray, isPropertyContent) {
|
||||
var htmlStr = this.processObject(obj, indent, addComma, isArray, isPropertyContent);
|
||||
htmlStr = '<pre class="json">' + htmlStr + '</pre>';
|
||||
return htmlStr;
|
||||
},
|
||||
processObject: function(obj, indent, addComma, isArray, isPropertyContent) {
|
||||
var html = "";
|
||||
var comma = (addComma) ? "<span class='comma'>,</span> " : "";
|
||||
var type = typeof obj;
|
||||
var clpsHtml ="";
|
||||
if (this.isArray(obj)) {
|
||||
if (obj.length == 0) {
|
||||
html += this.getRow(indent, "<span class='arrayBrace'>[ ]</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
clpsHtml = '<span><img class="option-img" src="webjars/mg-ui/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
html += this.getRow(indent, "<span class='arrayBrace'>[</span>"+clpsHtml, isPropertyContent);
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
html += this.processObject(obj[i], indent + 1, i < (obj.length - 1), true, false);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='arrayBrace'>]</span>" + comma);
|
||||
}
|
||||
} else if (type == 'object' && obj == null) {
|
||||
html += this.formatLiteral("null", "", comma, indent, isArray, "null");
|
||||
} else if (type == 'object') {
|
||||
var numProps = 0;
|
||||
for ( var prop in obj) {
|
||||
numProps++;
|
||||
}
|
||||
if (numProps == 0) {
|
||||
html += this.getRow(indent, "<span class='objectBrace'>{ }</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
clpsHtml = '<span><img class="option-img" src="webjars/mg-ui/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||
html += this.getRow(indent, "<span class='objectBrace'>{</span>"+clpsHtml, isPropertyContent);
|
||||
var j = 0;
|
||||
for ( var prop in obj) {
|
||||
var processStr = '<span class="propertyName">"' + prop + '"</span>: ' + this.processObject(obj[prop], indent + 1, ++j < numProps, false, true);
|
||||
html += this.getRow(indent + 1, processStr);
|
||||
}
|
||||
clpsHtml = "</span>";
|
||||
html += this.getRow(indent, clpsHtml + "<span class='objectBrace'>}</span>" + comma);
|
||||
}
|
||||
} else if (type == 'number') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "number");
|
||||
} else if (type == 'boolean') {
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "boolean");
|
||||
} else if (type == 'function') {
|
||||
obj = this.formatFunction(indent, obj);
|
||||
html += this.formatLiteral(obj, "", comma, indent, isArray, "function");
|
||||
} else if (type == 'undefined') {
|
||||
html += this.formatLiteral("undefined", "", comma, indent, isArray, "null");
|
||||
} else {
|
||||
html += this.formatLiteral(obj, "\"", comma, indent, isArray, "string");
|
||||
}
|
||||
return html;
|
||||
},
|
||||
expImgClicked: function(img){
|
||||
var container = img.parentNode.nextSibling;
|
||||
if(!container) return;
|
||||
var disp = "none";
|
||||
var src = "webjars/mg-ui/img/collapsed.png";
|
||||
if(container.style.display == "none"){
|
||||
disp = "inline";
|
||||
src = "webjars/mg-ui/img/expanded.png";
|
||||
}
|
||||
container.style.display = disp;
|
||||
img.src = src;
|
||||
},
|
||||
formatLiteral: function(literal, quote, comma, indent, isArray, style) {
|
||||
if (typeof literal == 'string') {
|
||||
literal = literal.split("<").join("<").split(">").join(">");
|
||||
}
|
||||
var str = "<span class='" + style + "'>" + quote + literal + quote + comma + "</span>";
|
||||
if (isArray) {
|
||||
str = this.getRow(indent, str);
|
||||
}
|
||||
return str;
|
||||
},
|
||||
formatFunction: function(indent, obj) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
var funcStrArray = obj.toString().split("\n");
|
||||
var str = "";
|
||||
for (var i = 0; i < funcStrArray.length; i++) {
|
||||
str += ((i == 0) ? "" : tabs) + funcStrArray[i] + "\n";
|
||||
}
|
||||
return str;
|
||||
},
|
||||
getRow: function(indent, data, isPropertyContent) {
|
||||
var tabs = "";
|
||||
for (var i = 0; i < indent && !isPropertyContent; i++) {
|
||||
tabs += this.tabStr;
|
||||
}
|
||||
if (data != null && data.length > 0 && data.charAt(data.length - 1) != "\n") {
|
||||
data = data + "\n";
|
||||
}
|
||||
return tabs + data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
var tableRelationData = {
|
||||
// "name": "user_info",
|
||||
// "children": [
|
||||
// {
|
||||
// "name": "user_auth",
|
||||
// "children": []
|
||||
// },{
|
||||
// "name": "group_info",
|
||||
// "children": []
|
||||
// }]
|
||||
}
|
||||
|
||||
var tableRelationOption = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
triggerOn: 'mousemove'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'tree',
|
||||
/*orient: 'vertical',*/
|
||||
data: [tableRelationData],
|
||||
top: '1%',
|
||||
left: '7%',
|
||||
bottom: '1%',
|
||||
right: '20%',
|
||||
symbolSize: 7,
|
||||
label: {
|
||||
normal: {
|
||||
position: 'left',
|
||||
verticalAlign: 'middle',
|
||||
align: 'right',
|
||||
fontSize: 14
|
||||
}
|
||||
},
|
||||
leaves: {
|
||||
label: {
|
||||
normal: {
|
||||
position: 'right',
|
||||
verticalAlign: 'middle',
|
||||
align: 'left'
|
||||
}
|
||||
}
|
||||
},
|
||||
expandAndCollapse: true,
|
||||
animationDuration: 550,
|
||||
animationDurationUpdate: 750
|
||||
}
|
||||
]
|
||||
var tableRelationData = {
|
||||
// "name": "user_info",
|
||||
// "children": [
|
||||
// {
|
||||
// "name": "user_auth",
|
||||
// "children": []
|
||||
// },{
|
||||
// "name": "group_info",
|
||||
// "children": []
|
||||
// }]
|
||||
}
|
||||
|
||||
var tableRelationOption = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
triggerOn: 'mousemove'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'tree',
|
||||
/*orient: 'vertical',*/
|
||||
data: [tableRelationData],
|
||||
top: '1%',
|
||||
left: '7%',
|
||||
bottom: '1%',
|
||||
right: '20%',
|
||||
symbolSize: 7,
|
||||
label: {
|
||||
normal: {
|
||||
position: 'left',
|
||||
verticalAlign: 'middle',
|
||||
align: 'right',
|
||||
fontSize: 14
|
||||
}
|
||||
},
|
||||
leaves: {
|
||||
label: {
|
||||
normal: {
|
||||
position: 'right',
|
||||
verticalAlign: 'middle',
|
||||
align: 'left'
|
||||
}
|
||||
}
|
||||
},
|
||||
expandAndCollapse: true,
|
||||
animationDuration: 550,
|
||||
animationDurationUpdate: 750
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
/**
|
||||
* 提示工具类
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var Toast = {
|
||||
notOpen:function(){
|
||||
var data = {
|
||||
message:"该功能暂未开放,敬请期待!",
|
||||
icon: 'exclamation-sign', type:"warning",
|
||||
};
|
||||
this.show(data);
|
||||
},
|
||||
warn:function(msg, time){
|
||||
var data = {
|
||||
message:msg,time:time,
|
||||
icon: 'exclamation-sign', type:'warning',
|
||||
};
|
||||
this.show(data);
|
||||
},
|
||||
error:function(msg, time){
|
||||
var data = {
|
||||
message:msg,time:time,
|
||||
icon: 'exclamation-sign', type:'danger',
|
||||
};
|
||||
this.show(data);
|
||||
},
|
||||
show:function(data){
|
||||
data.time = isEmpty(data.time)?2000:data.time;
|
||||
data.placement = isEmpty(data.placement)?'top':data.placement;
|
||||
new $.zui.Messager(data.message, data).show();
|
||||
}
|
||||
/**
|
||||
* 提示工具类
|
||||
* @author 暮光:城中城
|
||||
* @since 2017年5月7日
|
||||
*/
|
||||
var Toast = {
|
||||
notOpen:function(){
|
||||
var data = {
|
||||
message:"该功能暂未开放,敬请期待!",
|
||||
icon: 'exclamation-sign', type:"warning",
|
||||
};
|
||||
this.show(data);
|
||||
},
|
||||
warn:function(msg, time){
|
||||
var data = {
|
||||
message:msg,time:time,
|
||||
icon: 'exclamation-sign', type:'warning',
|
||||
};
|
||||
this.show(data);
|
||||
},
|
||||
error:function(msg, time){
|
||||
var data = {
|
||||
message:msg,time:time,
|
||||
icon: 'exclamation-sign', type:'danger',
|
||||
};
|
||||
this.show(data);
|
||||
},
|
||||
show:function(data){
|
||||
data.time = isEmpty(data.time)?2000:data.time;
|
||||
data.placement = isEmpty(data.placement)?'top':data.placement;
|
||||
new $.zui.Messager(data.message, data).show();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user